blob: 3118774a076c46b98152975fba389dd838e0ee1f [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
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700933void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -0700934{
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 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700941 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 }
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 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700977 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 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
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001610 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 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 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 }
1687#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1689 pMac->scan.fValidateList = pParam->fValidateList;
1690 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1691 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001692 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001694 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1695 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1696 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1697 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1698 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1699 * single session
1700 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001701 //Remove this code once SLM_Sessionization is supported
1702 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001703 pMac->roam.configParam.doBMPSWorkaround = 0;
1704
Jeff Johnsone7245742012-09-05 17:12:55 -07001705#ifdef WLAN_FEATURE_11AC
1706 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001707 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001708 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001709 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001710#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001711 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001712
1713 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001714 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
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 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001838 }
1839#endif
1840
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001841 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001842
krunal soni5afa96c2013-09-06 22:19:02 -07001843 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001844 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001845
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 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303149 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 }
3151 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303152
3153 if (NULL != pIes)
3154 {
3155 vos_mem_free(pIes);
3156 }
3157
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 return status;
3159}
3160
Jeff Johnson295189b2012-06-20 16:38:30 -07003161void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3162{
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3164 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3165 // See !!Note: below in this function...
3166 tANI_U32 PrivacyEnabled = 0;
3167 tANI_U32 RsnEnabled = 0;
3168 tANI_U32 WepDefaultKeyId = 0;
3169 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3170 tANI_U32 Key0Length = 0;
3171 tANI_U32 Key1Length = 0;
3172 tANI_U32 Key2Length = 0;
3173 tANI_U32 Key3Length = 0;
3174
3175 // Reserve for the biggest key
3176 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3177 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3178 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3179 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3180
3181 switch ( pProfile->negotiatedUCEncryptionType )
3182 {
3183 case eCSR_ENCRYPT_TYPE_NONE:
3184
3185 // for NO encryption, turn off Privacy and Rsn.
3186 PrivacyEnabled = 0;
3187 RsnEnabled = 0;
3188
3189 // WEP key length and Wep Default Key ID don't matter in this case....
3190
3191 // clear out the WEP keys that may be hanging around.
3192 Key0Length = 0;
3193 Key1Length = 0;
3194 Key2Length = 0;
3195 Key3Length = 0;
3196
3197 break;
3198
3199 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303200 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003201
3202 // Privacy is ON. NO RSN for Wep40 static key.
3203 PrivacyEnabled = 1;
3204 RsnEnabled = 0;
3205
3206 // Set the Wep default key ID.
3207 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 // Wep key size if 5 bytes (40 bits).
3209 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3210
3211 // set encryption keys in the CFG database or clear those that are not present in this profile.
3212 if ( pProfile->Keys.KeyLength[0] )
3213 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303214 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3215 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3217 }
3218 else
3219 {
3220 Key0Length = 0;
3221 }
3222
3223 if ( pProfile->Keys.KeyLength[1] )
3224 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303225 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3226 WNI_CFG_WEP_KEY_LENGTH_5);
3227 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 }
3229 else
3230 {
3231 Key1Length = 0;
3232 }
3233
3234 if ( pProfile->Keys.KeyLength[2] )
3235 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303236 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3237 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3239 }
3240 else
3241 {
3242 Key2Length = 0;
3243 }
3244
3245 if ( pProfile->Keys.KeyLength[3] )
3246 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303247 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3248 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3250 }
3251 else
3252 {
3253 Key3Length = 0;
3254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 break;
3256
3257 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303258 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003259
3260 // Privacy is ON. NO RSN for Wep40 static key.
3261 PrivacyEnabled = 1;
3262 RsnEnabled = 0;
3263
3264 // Set the Wep default key ID.
3265 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3266
3267 // Wep key size if 13 bytes (104 bits).
3268 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3269
3270 // set encryption keys in the CFG database or clear those that are not present in this profile.
3271 if ( pProfile->Keys.KeyLength[0] )
3272 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303273 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3274 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3276 }
3277 else
3278 {
3279 Key0Length = 0;
3280 }
3281
3282 if ( pProfile->Keys.KeyLength[1] )
3283 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303284 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3285 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3287 }
3288 else
3289 {
3290 Key1Length = 0;
3291 }
3292
3293 if ( pProfile->Keys.KeyLength[2] )
3294 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303295 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3296 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3298 }
3299 else
3300 {
3301 Key2Length = 0;
3302 }
3303
3304 if ( pProfile->Keys.KeyLength[3] )
3305 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303306 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3307 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3309 }
3310 else
3311 {
3312 Key3Length = 0;
3313 }
3314
3315 break;
3316
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 case eCSR_ENCRYPT_TYPE_TKIP:
3318 case eCSR_ENCRYPT_TYPE_AES:
3319#ifdef FEATURE_WLAN_WAPI
3320 case eCSR_ENCRYPT_TYPE_WPI:
3321#endif /* FEATURE_WLAN_WAPI */
3322 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3323 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3324 PrivacyEnabled = (0 != fPrivacy);
3325
3326 // turn on RSN enabled for WPA associations
3327 RsnEnabled = 1;
3328
3329 // WEP key length and Wep Default Key ID don't matter in this case....
3330
3331 // clear out the static WEP keys that may be hanging around.
3332 Key0Length = 0;
3333 Key1Length = 0;
3334 Key2Length = 0;
3335 Key3Length = 0;
3336
3337 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 default:
3339 PrivacyEnabled = 0;
3340 RsnEnabled = 0;
3341 break;
3342 }
3343
3344 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3345 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3346 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3347 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3348 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3349 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3350 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3351 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3352}
3353
Jeff Johnson295189b2012-06-20 16:38:30 -07003354static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3355{
3356 tANI_U32 len = 0;
3357 if(pSSID->length <= WNI_CFG_SSID_LEN)
3358 {
3359 len = pSSID->length;
3360 }
3361 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3362}
3363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3365{
3366 eHalStatus status = eHAL_STATUS_SUCCESS;
3367 tANI_U32 QoSEnabled;
3368 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 // set the CFG enable/disable variables based on the qosType being configured...
3370 switch( qosType )
3371 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3373 QoSEnabled = FALSE;
3374 WmeEnabled = TRUE;
3375 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3377 QoSEnabled = FALSE;
3378 WmeEnabled = TRUE;
3379 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3381 QoSEnabled = FALSE;
3382 WmeEnabled = TRUE;
3383 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3385 QoSEnabled = TRUE;
3386 WmeEnabled = FALSE;
3387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 case eCSR_MEDIUM_ACCESS_11e_HCF:
3389 QoSEnabled = TRUE;
3390 WmeEnabled = FALSE;
3391 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 default:
3393 case eCSR_MEDIUM_ACCESS_DCF:
3394 QoSEnabled = FALSE;
3395 WmeEnabled = FALSE;
3396 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 }
3398 //save the WMM setting for later use
3399 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3401 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 return (status);
3403}
Jeff Johnson295189b2012-06-20 16:38:30 -07003404static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3405 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3406{
3407 eHalStatus status = eHAL_STATUS_FAILURE;
3408 int i;
3409 eCsrCfgDot11Mode cfgDot11Mode;
3410 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303411 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3412 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003414
3415 if( NULL != pIes )
3416 {
3417 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 // Originally, we thought that for 11a networks, the 11a rates are always
3419 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3420 // appear in the Operational Rate set. Consequently, in either case, we
3421 // would blindly put the rates we support into our Operational Rate set
3422 // (including the basic rates, which we have already verified are
3423 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 // However, it turns out that this is not always the case. Some AP's
3425 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3426 // too. Now, we're a little more careful:
3427 pDstRate = pOpRateSet->rate;
3428 if(pIes->SuppRates.present)
3429 {
3430 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3431 {
3432 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3433 {
3434 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003435 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 }
3437 }
3438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3440 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3441 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3442 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3443 {
3444 // If there are Extended Rates in the beacon, we will reflect those
3445 // extended rates that we support in out Extended Operational Rate
3446 // set:
3447 pDstRate = pExRateSet->rate;
3448 if(pIes->ExtSuppRates.present)
3449 {
3450 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3451 {
3452 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3453 {
3454 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3455 pExRateSet->numRates++;
3456 }
3457 }
3458 }
3459 }
3460 }//Parsing BSSDesc
3461 else
3462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003463 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 }
3465 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3466 return status;
3467}
3468
3469static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3470 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3471{
3472 int i;
3473 tANI_U8 *pDstRate;
3474 eCsrCfgDot11Mode cfgDot11Mode;
3475 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3476 tANI_U32 OperationalRatesLength = 0;
3477 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3478 tANI_U32 ExtendedOperationalRatesLength = 0;
3479 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3480 tANI_U32 ProprietaryOperationalRatesLength = 0;
3481 tANI_U32 PropRatesEnable = 0;
3482 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3483 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 if( NULL != pIes )
3486 {
3487 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 // Originally, we thought that for 11a networks, the 11a rates are always
3489 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3490 // appear in the Operational Rate set. Consequently, in either case, we
3491 // would blindly put the rates we support into our Operational Rate set
3492 // (including the basic rates, which we have already verified are
3493 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 // However, it turns out that this is not always the case. Some AP's
3495 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3496 // too. Now, we're a little more careful:
3497 pDstRate = OperationalRates;
3498 if(pIes->SuppRates.present)
3499 {
3500 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3501 {
3502 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3503 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3504 {
3505 *pDstRate++ = pIes->SuppRates.rates[ i ];
3506 OperationalRatesLength++;
3507 }
3508 }
3509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3511 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3512 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3513 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3514 {
3515 // If there are Extended Rates in the beacon, we will reflect those
3516 // extended rates that we support in out Extended Operational Rate
3517 // set:
3518 pDstRate = ExtendedOperationalRates;
3519 if(pIes->ExtSuppRates.present)
3520 {
3521 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3522 {
3523 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3524 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3525 {
3526 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3527 ExtendedOperationalRatesLength++;
3528 }
3529 }
3530 }
3531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 // Enable proprietary MAC features if peer node is Airgo node and STA
3533 // user wants to use them
3534 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3535 {
3536 PropRatesEnable = 1;
3537 }
3538 else
3539 {
3540 PropRatesEnable = 0;
3541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 // For ANI network companions, we need to populate the proprietary rate
3543 // set with any proprietary rates we found in the beacon, only if user
3544 // allows them...
3545 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3546 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3547 {
3548 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3549 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3550 {
3551 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3552 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303553 vos_mem_copy(ProprietaryOperationalRates,
3554 pIes->Airgo.PropSuppRates.rates,
3555 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 }
3557 else {
3558 // No proprietary modes...
3559 ProprietaryOperationalRatesLength = 0;
3560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 /* Get MCS Rate */
3562 pDstRate = MCSRateIdxSet;
3563 if ( pIes->HTCaps.present )
3564 {
3565 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3566 {
3567 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3568 {
3569 MCSRateLength++;
3570 *pDstRate++ = i;
3571 }
3572 }
3573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 // Set the operational rate set CFG variables...
3575 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3576 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3577 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3578 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3579 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3580 ProprietaryOperationalRates,
3581 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3582 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3583 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3584 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3585 }//Parsing BSSDesc
3586 else
3587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003588 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 }
3590}
3591
Jeff Johnson295189b2012-06-20 16:38:30 -07003592static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3593 tCsrRoamProfile *pProfile )
3594{
3595 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3596 { 8,
3597 { SIR_MAC_RATE_6,
3598 SIR_MAC_RATE_9,
3599 SIR_MAC_RATE_12,
3600 SIR_MAC_RATE_18,
3601 SIR_MAC_RATE_24,
3602 SIR_MAC_RATE_36,
3603 SIR_MAC_RATE_48,
3604 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3606 { 4,
3607 { SIR_MAC_RATE_1,
3608 SIR_MAC_RATE_2,
3609 SIR_MAC_RATE_5_5,
3610 SIR_MAC_RATE_11 } } };
3611
3612
3613 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3614 { SIR_MAC_RATE_72,
3615 SIR_MAC_RATE_96,
3616 SIR_MAC_RATE_108 } };
3617 eCsrCfgDot11Mode cfgDot11Mode;
3618 eCsrBand eBand;
3619 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3620 tANI_U32 OperationalRatesLength = 0;
3621 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3622 tANI_U32 ExtendedOperationalRatesLength = 0;
3623 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3624 tANI_U32 ProprietaryOperationalRatesLength = 0;
3625 tANI_U32 PropRatesEnable = 0;
3626 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 if(pProfile->ChannelInfo.ChannelList)
3628 {
3629 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3633 // networks, the 11b rates appear in the Operational Rate set. In either case,
3634 // we can blindly put the rates we support into our Operational Rate set
3635 // (including the basic rates, which we have already verified are supported
3636 // earlier in the roaming decision).
3637 if ( eCSR_BAND_5G == eBand )
3638 {
3639 // 11a rates into the Operational Rate Set.
3640 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3641 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303642 vos_mem_copy(OperationalRates,
3643 DefaultSupportedRates11a.supportedRateSet.rate,
3644 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003645
3646 // Nothing in the Extended rate set.
3647 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 // populate proprietary rates if user allows them
3649 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3650 {
3651 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3652 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303653 vos_mem_copy(ProprietaryOperationalRates,
3654 DefaultSupportedPropRates.propRate,
3655 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 }
3657 else
3658 {
3659 // No proprietary modes
3660 ProprietaryOperationalRatesLength = 0;
3661 }
3662 }
3663 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3664 {
3665 // 11b rates into the Operational Rate Set.
3666 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3667 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303668 vos_mem_copy(OperationalRates,
3669 DefaultSupportedRates11b.supportedRateSet.rate,
3670 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 // Nothing in the Extended rate set.
3672 ExtendedOperationalRatesLength = 0;
3673 // No proprietary modes
3674 ProprietaryOperationalRatesLength = 0;
3675 }
3676 else
3677 {
3678 // 11G
3679
3680 // 11b rates into the Operational Rate Set.
3681 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3682 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303683 vos_mem_copy(OperationalRates,
3684 DefaultSupportedRates11b.supportedRateSet.rate,
3685 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003686
3687 // 11a rates go in the Extended rate set.
3688 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3689 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303690 vos_mem_copy(ExtendedOperationalRates,
3691 DefaultSupportedRates11a.supportedRateSet.rate,
3692 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003693
3694 // populate proprietary rates if user allows them
3695 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3696 {
3697 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3698 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303699 vos_mem_copy(ProprietaryOperationalRates,
3700 DefaultSupportedPropRates.propRate,
3701 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 }
3703 else
3704 {
3705 // No proprietary modes
3706 ProprietaryOperationalRatesLength = 0;
3707 }
3708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3710 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3711 {
3712 PropRatesEnable = 1;
3713 }
3714 else
3715 {
3716 PropRatesEnable = 0;
3717 }
3718
3719 // Set the operational rate set CFG variables...
3720 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3721 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3722 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3723 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3724 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3725 ProprietaryOperationalRates,
3726 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3727 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003728}
Jeff Johnson295189b2012-06-20 16:38:30 -07003729void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3730{
3731 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003732
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3734 tANI_U32 sessionId;
3735 tSmeCmd *pCommand = NULL;
3736
3737 if(NULL == pEntry)
3738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003739 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 return;
3741 }
3742 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3743 sessionId = pCommand->sessionId;
3744
3745 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3746 {
3747 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3748 }
3749}
3750
Jeff Johnson295189b2012-06-20 16:38:30 -07003751//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3752tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3753{
3754 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3755 {
3756 return (WNI_CFG_PHY_MODE_11B);
3757 }
3758 else
3759 {
3760 if(eCSR_BAND_24 == band)
3761 return (WNI_CFG_PHY_MODE_11G);
3762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 return (WNI_CFG_PHY_MODE_11A);
3764}
Jeff Johnson295189b2012-06-20 16:38:30 -07003765
Jeff Johnsone7245742012-09-05 17:12:55 -07003766
3767#ifdef WLAN_FEATURE_11AC
3768ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3769{
3770 switch ( aniCBMode )
3771 {
3772 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3773 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3774 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3775 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3776 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3777 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3778 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3779 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3780 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003781 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003782 return PHY_SINGLE_CHANNEL_CENTERED;
3783 }
3784}
3785#endif
3786
Jeff Johnson295189b2012-06-20 16:38:30 -07003787//pIes may be NULL
3788eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3789 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303790 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003791{
3792 eHalStatus status = eHAL_STATUS_SUCCESS;
3793 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3794 tANI_U8 channel = 0;
3795 //Make sure we have the domain info for the BSS we try to connect to.
3796 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303797 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303799 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 {
3801 //Make sure the 11d info from this BSSDesc can be applied
3802 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303803 if (VOS_TRUE == resetCountry)
3804 {
3805 csrApplyCountryInformation(pMac, FALSE);
3806 }
3807 else
3808 {
3809 csrApplyCountryInformation(pMac, TRUE);
3810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 }
Kiran4a17ebe2013-01-31 10:43:43 -08003812 if ((csrIs11dSupported (pMac)) && pIes)
3813 {
3814 if (!pIes->Country.present)
3815 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 //Qos
3819 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3820 //SSID
3821 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3822 //fragment threshold
3823 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3824 //RTS threshold
3825 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3826
3827 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3828
3829 //Auth type
3830 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3831 //encryption type
3832 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3833 //short slot time
3834 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 //11d
3836 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3837 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3838 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 /*//11h
3840 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3841 */
3842 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3843 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003844
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003845 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 {
3847 channel = pProfile->operationChannel;
3848 }
3849 else
3850 {
3851 if(pBssDesc)
3852 {
3853 channel = pBssDesc->channelId;
3854 }
3855 }
3856 if(0 != channel)
3857 {
3858 if(CSR_IS_CHANNEL_24GHZ(channel))
3859 {//for now if we are on 2.4 Ghz, CB will be always disabled
3860 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3861 }
3862 else
3863 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003864 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 }
3866 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003867#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003868 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3869 // in function csrConvertCBIniValueToPhyCBState()
3870 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3871 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003872 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003873 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003874 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003875 }
3876 else
3877 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003878 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003879 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003880 }
3881 else
3882#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3884 //Rate
3885 //Fixed Rate
3886 if(pBssDesc)
3887 {
3888 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3889 }
3890 else
3891 {
3892 csrSetCfgRateSetFromProfile(pMac, pProfile);
3893 }
3894 //Make this the last CFG to set. The callback will trigger a join_req
3895 //Join time out
3896 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3897
3898 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 return (status);
3900}
3901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3903 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3904{
3905 eHalStatus status;
3906 tBssConfigParam *pBssConfig;
3907 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003908
3909 if(!pSession)
3910 {
3911 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3912 return eHAL_STATUS_FAILURE;
3913 }
3914
Kiet Lam64c1b492013-07-12 13:56:44 +05303915 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3916 if ( NULL == pBssConfig )
3917 status = eHAL_STATUS_FAILURE;
3918 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303920 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3922 if(HAL_STATUS_SUCCESS(status))
3923 {
3924 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003925 /* This will allow to pass cbMode during join req */
3926 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 //For IBSS, we need to prepare some more information
3928 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 )
3931 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003932 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 }
3934 // If we are in an IBSS, then stop the IBSS...
3935 ////Not worry about WDS connection for now
3936 if ( csrIsConnStateIbss( pMac, sessionId ) )
3937 {
3938 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3939 }
3940 else
3941 {
3942 // if we are in an Infrastructure association....
3943 if ( csrIsConnStateInfra( pMac, sessionId ) )
3944 {
3945 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3946 // across SSIDs (roaming to a new SSID)... //
3947 //Not worry about WDS connection for now
3948 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303949 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 {
3951 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303952 status = csrRoamIssueDisassociate( pMac, sessionId,
3953 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303955 else
3956 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3958 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303959 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303961 // Set parameters for this Bss.
3962 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3963 pBssDesc, pBssConfig,
3964 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303968 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 {
3970 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3971 // Nothing to stop.
3972 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303974 )
3975 {
3976 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3977 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3978 // Set parameters for this Bss.
3979 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3980 pBssDesc, pBssConfig,
3981 pIes, is11rRoamingFlag);
3982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984 }
3985 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303986 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 return (status);
3989}
3990
Jeff Johnson295189b2012-06-20 16:38:30 -07003991eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3992 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3993{
3994 eCsrJoinState eRoamState = eCsrContinueRoaming;
3995 eHalStatus status;
3996 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3997 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3998 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003999
4000 if(!pSession)
4001 {
4002 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4003 return (eCsrStopRoaming);
4004 }
4005
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 if( CSR_IS_WDS_STA( pProfile ) )
4007 {
4008 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4009 if( !HAL_STATUS_SUCCESS( status ) )
4010 {
4011 eRoamState = eCsrStopRoaming;
4012 }
4013 }
4014 else
4015 {
4016 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4017 {
4018 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4019 return (eCsrStopRoaming);
4020 }
4021 if ( csrIsInfraBssDesc( pBssDesc ) )
4022 {
4023 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4024 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4025 // have changed and handle the changes (without disturbing the current association).
4026
4027 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4028 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4029 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4030 )
4031 {
4032 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4033 // with Authenticating first. To force this, stop the current association (Disassociate) and
4034 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4035 // a new Association.
4036 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4037 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004038 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4040 {
4041 eRoamState = eCsrReassocToSelfNoCapChange;
4042 }
4043 else
4044 {
4045 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304047 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4049 if(HAL_STATUS_SUCCESS(status))
4050 {
4051 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004052 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304054 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4055 pBssDesc, &bssConfig,
4056 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 if(!HAL_STATUS_SUCCESS(status))
4058 {
4059 eRoamState = eCsrStopRoaming;
4060 }
4061 }
4062 else
4063 {
4064 eRoamState = eCsrStopRoaming;
4065 }
4066 }//same profile
4067 }
4068 else
4069 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304070 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004073 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304077 }
4078 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 {
4080 // 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 +05304081 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 // work much better.
4083 //
4084 //
4085 // stop the existing network before attempting to join the new network...
4086 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4087 {
4088 eRoamState = eCsrStopRoaming;
4089 }
4090 }
4091 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304092 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 {
4094 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4095 {
4096 eRoamState = eCsrStopRoaming;
4097 }
4098 }
4099 if( pIesLocal && !pScanResult->pvIes )
4100 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304101 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 }
4103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 return( eRoamState );
4105}
4106
Jeff Johnson295189b2012-06-20 16:38:30 -07004107eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4108 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4109{
4110 eHalStatus status = eHAL_STATUS_SUCCESS;
4111 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304112 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 roamInfo.pBssDesc = pBssDesc;
4114 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4115 return (status);
4116}
Jeff Johnson295189b2012-06-20 16:38:30 -07004117//In case no matching BSS is found, use whatever default we can find
4118static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4119{
4120 //Need to get all negotiated types in place first
4121 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004122 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 {
4124 default:
4125 case eCSR_AUTH_TYPE_WPA:
4126 case eCSR_AUTH_TYPE_WPA_PSK:
4127 case eCSR_AUTH_TYPE_WPA_NONE:
4128 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4129 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4130 break;
4131
4132 case eCSR_AUTH_TYPE_SHARED_KEY:
4133 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4134 break;
4135
4136 case eCSR_AUTH_TYPE_AUTOSWITCH:
4137 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4138 break;
4139 }
4140 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4141 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4142 //In this case, the multicast encryption needs to follow the uncast ones.
4143 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4144 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4145}
4146
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004147
4148static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4149{
4150 switch(pCommand->u.roamCmd.roamReason)
4151 {
4152 case eCsrLostLink1:
4153 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4154 break;
4155 case eCsrLostLink2:
4156 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4157 break;
4158 case eCsrLostLink3:
4159 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4160 break;
4161 default:
4162 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4163 pCommand->u.roamCmd.roamReason);
4164 break;
4165 }
4166}
4167
Jeff Johnson295189b2012-06-20 16:38:30 -07004168static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4169{
4170 eHalStatus status;
4171 tCsrScanResult *pScanResult = NULL;
4172 eCsrJoinState eRoamState = eCsrStopRoaming;
4173 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4174 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4175 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4176#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4177 v_U8_t acm_mask = 0;
4178#endif
4179 tANI_U32 sessionId = pCommand->sessionId;
4180 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4181 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4182 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004183
4184 if(!pSession)
4185 {
4186 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4187 return (eCsrStopRoaming);
4188 }
4189
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 do
4191 {
4192 // Check for Cardbus eject condition, before trying to Roam to any BSS
4193 //***if( !balIsCardPresent(pAdapter) ) break;
4194
Kiet Lam64c1b492013-07-12 13:56:44 +05304195 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004196 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 if(NULL != pBSSList)
4198 {
4199 // When handling AP's capability change, continue to associate to
4200 // same BSS and make sure pRoamBssEntry is not Null.
4201 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4202 {
4203 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4204 {
4205 //Try the first BSS
4206 pCommand->u.roamCmd.pLastRoamBss = NULL;
4207 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4208 }
4209 else
4210 {
4211 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4212 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4213 {
4214 //Done with all the BSSs
4215 //In this case, will tell HDD the completion
4216 break;
4217 }
4218 else
4219 {
4220 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304221 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4223 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4224 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4225 pRoamInfo = &roamInfo;
4226 }
4227 }
4228 while(pCommand->u.roamCmd.pRoamBssEntry)
4229 {
4230 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 /*If concurrency enabled take the concurrent connected channel first. */
4232 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004233 if (vos_concurrent_sessions_running() &&
4234 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 {
4236 concurrentChannel =
4237 csrGetConcurrentOperationChannel(pMac);
4238 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004239 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 if ((concurrentChannel) &&
4241 (concurrentChannel ==
4242 pScanResult->Result.BssDescriptor.channelId))
4243 {
4244 //make this 0 because we do not want the
4245 //below check to pass as we don't want to
4246 //connect on other channel
4247 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4248 FL("Concurrent channel match =%d"),
4249 concurrentChannel);
4250 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 }
4252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004253
4254 if (!concurrentChannel)
4255 {
4256
4257 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4258 sessionId, &pScanResult->Result.BssDescriptor,
4259 pCommand->u.roamCmd.roamId)))
4260 {
4261 //Ok to roam this
4262 break;
4263 }
4264 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004265 else
4266 {
4267 eRoamState = eCsrStopRoamingDueToConcurrency;
4268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4270 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4271 {
4272 //Done with all the BSSs
4273 fDone = eANI_BOOLEAN_TRUE;
4274 break;
4275 }
4276 }
4277 if(fDone)
4278 {
4279 break;
4280 }
4281 }
4282 }
4283 //We have something to roam, tell HDD when it is infra.
4284 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4285 //For WDS, the indication is eCSR_ROAM_WDS_IND
4286 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4287 {
4288 if(pRoamInfo)
4289 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004290 if(pSession->bRefAssocStartCnt)
4291 {
4292 pSession->bRefAssocStartCnt--;
4293 //Complete the last association attemp because a new one is about to be tried
4294 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4295 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004297 }
4298 }
4299 /* If the roaming has stopped, not to continue the roaming command*/
4300 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4301 {
4302 //No need to complete roaming here as it already completes
4303 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4304 pCommand->u.roamCmd.roamReason);
4305 eRoamState = eCsrStopRoaming;
4306 csrSetAbortRoamingCommand(pMac, pCommand);
4307 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304309 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 if(pScanResult)
4311 {
4312 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004315 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 fDone = eANI_BOOLEAN_TRUE;
4317 eRoamState = eCsrStopRoaming;
4318 break;
4319 }
4320 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4321 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4322 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4323 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4324 CSR_IS_QOS_BSS(pIesLocal) &&
4325 CSR_IS_UAPSD_BSS(pIesLocal) )
4326 {
4327#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4329 pIesLocal);
4330 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4331#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 }
4333 else
4334 {
4335 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4336 }
4337 if( pIesLocal && !pScanResult->Result.pvIes)
4338 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304339 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 }
4341 }
4342 else
4343 {
4344 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4345 }
4346 roamInfo.pProfile = pProfile;
4347 pSession->bRefAssocStartCnt++;
4348 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4349 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4352 {
4353 // If this is a start IBSS profile, then we need to start the IBSS.
4354 if ( CSR_IS_START_IBSS(pProfile) )
4355 {
4356 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 // Attempt to start this IBSS...
4358 csrRoamAssignDefaultParam( pMac, pCommand );
4359 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4360 if(HAL_STATUS_SUCCESS(status))
4361 {
4362 if ( fSameIbss )
4363 {
4364 eRoamState = eCsrStartIbssSameIbss;
4365 }
4366 else
4367 {
4368 eRoamState = eCsrContinueRoaming;
4369 }
4370 }
4371 else
4372 {
4373 //it somehow fail need to stop
4374 eRoamState = eCsrStopRoaming;
4375 }
4376 break;
4377 }
4378 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 )
4381 {
4382 // Attempt to start this WDS...
4383 csrRoamAssignDefaultParam( pMac, pCommand );
4384 /* For AP WDS, we dont have any BSSDescription */
4385 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4386 if(HAL_STATUS_SUCCESS(status))
4387 {
4388 eRoamState = eCsrContinueRoaming;
4389 }
4390 else
4391 {
4392 //it somehow fail need to stop
4393 eRoamState = eCsrStopRoaming;
4394 }
4395 }
4396 else
4397 {
4398 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004399 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 eRoamState = eCsrStopRoaming;
4401 break;
4402 }
4403 }
4404 else //We have BSS
4405 {
4406 //Need to assign these value because they are used in csrIsSameProfile
4407 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4408 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4409 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4410 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4411 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4412 {
4413 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4414 {
4415 eRoamState = eCsrStartIbssSameIbss;
4416 break;
4417 }
4418 }
4419 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4420 {
4421 //trying to connect to the one already connected
4422 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4423 eRoamState = eCsrReassocToSelfNoCapChange;
4424 break;
4425 }
4426 // Attempt to Join this Bss...
4427 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4428 break;
4429 }
4430
4431 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4433 {
4434 //Need to indicate association_completion if association_start has been done
4435 if(pSession->bRefAssocStartCnt > 0)
4436 {
4437 pSession->bRefAssocStartCnt--;
4438 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004439 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4441 eCSR_ROAM_ASSOCIATION_COMPLETION,
4442 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4443 }
4444 }
4445
4446 return( eRoamState );
4447}
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4450{
4451 eHalStatus status = eHAL_STATUS_SUCCESS;
4452 eCsrJoinState RoamState;
4453 tANI_U32 sessionId = pCommand->sessionId;
4454
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 //***if( hddIsRadioStateOn( pAdapter ) )
4456 {
4457 // Attept to join a Bss...
4458 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004461 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 {
4463 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 // and if connected in Infrastructure mode...
4465 if ( csrIsConnStateInfra(pMac, sessionId) )
4466 {
4467 //... then we need to issue a disassociation
4468 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4469 if(!HAL_STATUS_SUCCESS(status))
4470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004471 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 //roam command is completed by caller in the failed case
4473 fComplete = eANI_BOOLEAN_TRUE;
4474 }
4475 }
4476 else if( csrIsConnStateIbss(pMac, sessionId) )
4477 {
4478 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4479 if(!HAL_STATUS_SUCCESS(status))
4480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004481 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 //roam command is completed by caller in the failed case
4483 fComplete = eANI_BOOLEAN_TRUE;
4484 }
4485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4487 {
4488 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4489 if(!HAL_STATUS_SUCCESS(status))
4490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004491 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 //roam command is completed by caller in the failed case
4493 fComplete = eANI_BOOLEAN_TRUE;
4494 }
4495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 else
4497 {
4498 fComplete = eANI_BOOLEAN_TRUE;
4499 }
4500 if(fComplete)
4501 {
4502 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004503 if(eCsrStopRoamingDueToConcurrency == RoamState)
4504 {
4505 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4506 }
4507 else
4508 {
4509 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512 }
4513 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4514 {
4515 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4516 }
4517 else if ( eCsrStartIbssSameIbss == RoamState )
4518 {
4519 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4520 }
4521 }//hddIsRadioStateOn
4522
4523 return status;
4524}
Jeff Johnson295189b2012-06-20 16:38:30 -07004525eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4526{
4527 tANI_U32 sessionId;
4528 tCsrRoamSession *pSession;
4529 tCsrScanResult *pScanResult = NULL;
4530 tSirBssDescription *pBssDesc = NULL;
4531 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 sessionId = pCommand->sessionId;
4533 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004534
4535 if(!pSession)
4536 {
4537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4538 return eHAL_STATUS_FAILURE;
4539 }
4540
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4542 {
4543 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004544 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4546 return eHAL_STATUS_FAILURE;
4547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 if (pCommand->u.roamCmd.pRoamBssEntry)
4549 {
4550 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4551 pBssDesc = &pScanResult->Result.BssDescriptor;
4552 }
4553 else
4554 {
4555 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004556 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4558 return eHAL_STATUS_FAILURE;
4559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4561 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4562 return status;
4563}
4564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4566{
4567 eHalStatus status = eHAL_STATUS_SUCCESS;
4568 tCsrRoamInfo roamInfo;
4569 tANI_U32 sessionId = pCommand->sessionId;
4570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004571
4572 if(!pSession)
4573 {
4574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4575 return eHAL_STATUS_FAILURE;
4576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004577
4578 switch ( pCommand->u.roamCmd.roamReason )
4579 {
4580 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004582 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 case eCsrSmeIssuedDisassocForHandoff:
4585 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4586#if 0 // TODO : Confirm this change
4587 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4588#else
4589 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4590#endif
4591
4592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004595 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004599 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 case eCsrHddIssuedReassocToSameAP:
4602 case eCsrSmeIssuedReassocToSameAP:
4603 {
4604 tDot11fBeaconIEs *pIes = NULL;
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 if( pSession->pConnectBssDesc )
4607 {
4608 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4609 if(!HAL_STATUS_SUCCESS(status) )
4610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004611 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 }
4613 else
4614 {
4615 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4616 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4617 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4619 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4620 pSession->bRefAssocStartCnt++;
4621 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4622 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4623
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004624 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004625 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4626 &pCommand->u.roamCmd.roamProfile );
4627 if(!HAL_STATUS_SUCCESS(status))
4628 {
4629 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004630 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004631 }
4632
Kiet Lam64c1b492013-07-12 13:56:44 +05304633 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 pIes = NULL;
4635 }
4636 }
4637 break;
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004640 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4642 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004645 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4647 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 case eCsrStopBss:
4650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4651 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4652 break;
4653
4654 case eCsrForcedDisassocSta:
4655 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4656 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4657 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4658 pCommand->u.roamCmd.reason);
4659 break;
4660
4661 case eCsrForcedDeauthSta:
4662 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4663 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4664 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4665 pCommand->u.roamCmd.reason);
4666 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004667
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004668 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004669 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004670 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4671 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004673
4674 default:
4675 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4676
4677 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4678 {
4679 //Remember the roaming profile
4680 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304681 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4682 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304684 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4686 }
4687 }
4688
4689 //At this point, original uapsd_mask is saved in pCurRoamProfile
4690 //uapsd_mask in the pCommand may change from this point on.
4691
4692 // Attempt to roam with the new scan results (if we need to..)
4693 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004694 if(!HAL_STATUS_SUCCESS(status))
4695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004696 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 break;
4699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 return (status);
4701}
4702
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004703void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4704{
4705 pCommand->u.roamCmd.pLastRoamBss = NULL;
4706 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4707 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304708 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004709}
4710
Jeff Johnson295189b2012-06-20 16:38:30 -07004711void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4712{
4713 if(pCommand->u.roamCmd.fReleaseBssList)
4714 {
4715 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4716 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4717 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4718 }
4719 if(pCommand->u.roamCmd.fReleaseProfile)
4720 {
4721 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4722 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4723 }
4724 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4725 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304726 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727}
4728
Jeff Johnson295189b2012-06-20 16:38:30 -07004729void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4730{
Kiet Lam64c1b492013-07-12 13:56:44 +05304731 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004732}
Jeff Johnson295189b2012-06-20 16:38:30 -07004733void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4734{
4735 tListElem *pEntry;
4736 tSmeCmd *pCommand;
4737 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004738 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4740 if ( pEntry )
4741 {
4742 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 // If the head of the queue is Active and it is a ROAM command, remove
4744 // and put this on the Free queue.
4745 if ( eSmeCommandRoam == pCommand->command )
4746 {
4747 //we need to process the result first before removing it from active list because state changes
4748 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4749 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4750 if( fReleaseCommand )
4751 {
4752 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4753 {
4754 csrReleaseCommandRoam( pMac, pCommand );
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, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004765 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 }
4767 }
4768 else
4769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004770 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772 }
4773 else
4774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004775 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 if( fReleaseCommand )
4778 {
4779 smeProcessPendingQueue( pMac );
4780 }
4781}
4782
Jeff Johnson295189b2012-06-20 16:38:30 -07004783void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4784{
4785 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004786 if(!pSession)
4787 {
4788 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4789 return;
4790 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304791 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4792 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 pSession->NumPmkidCandidate = 0;
4794}
Jeff Johnson295189b2012-06-20 16:38:30 -07004795#ifdef FEATURE_WLAN_WAPI
4796void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4797{
4798 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004799 if(!pSession)
4800 {
4801 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4802 return;
4803 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304804 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4805 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 pSession->NumBkidCandidate = 0;
4807}
4808#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004809extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4812 tSirBssDescription *pSirBssDesc,
4813 tDot11fBeaconIEs *pIes)
4814{
4815 eHalStatus status = eHAL_STATUS_SUCCESS;
4816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4817 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004818
4819 if(!pSession)
4820 {
4821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4822 return eHAL_STATUS_FAILURE;
4823 }
4824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 if((eCSR_AUTH_TYPE_WPA == authType) ||
4826 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4827 (eCSR_AUTH_TYPE_RSN == authType) ||
4828 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4829#if defined WLAN_FEATURE_VOWIFI_11R
4830 ||
4831 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4832 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4833#endif /* FEATURE_WLAN_WAPI */
4834#ifdef FEATURE_WLAN_WAPI
4835 ||
4836 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4837 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4838#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004839#ifdef WLAN_FEATURE_11W
4840 ||
4841 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4842#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 )
4844 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004847 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
4849 if( pIesLocal )
4850 {
4851 tANI_U32 nIeLen;
4852 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 if((eCSR_AUTH_TYPE_RSN == authType) ||
4854#if defined WLAN_FEATURE_VOWIFI_11R
4855 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4856 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4857#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004858#if defined WLAN_FEATURE_11W
4859 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4862 {
4863 if(pIesLocal->RSN.present)
4864 {
4865 //Calculate the actual length
4866 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4867 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4868 + 2 //akm_suite_count
4869 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4870 + 2; //reserved
4871 if( pIesLocal->RSN.pmkid_count )
4872 {
4873 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4874 }
4875 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304876 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4877 if (NULL == pSession->pWpaRsnRspIE)
4878 status = eHAL_STATUS_FAILURE;
4879 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304881 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4883 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4884 //copy upto akm_suites
4885 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4887 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004888 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304889 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4890 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004891 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304892 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4893 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004894 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 if( pIesLocal->RSN.pwise_cipher_suite_count )
4896 {
4897 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304898 vos_mem_copy(pIeBuf,
4899 pIesLocal->RSN.pwise_cipher_suites,
4900 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4902 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304903 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 pIeBuf += 2;
4905 if( pIesLocal->RSN.akm_suite_count )
4906 {
4907 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304908 vos_mem_copy(pIeBuf,
4909 pIesLocal->RSN.akm_suites,
4910 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4912 }
4913 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304914 vos_mem_copy(pIeBuf,
4915 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4916 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4918 }
4919 }
4920 }
4921 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4922 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4923 {
4924 if(pIesLocal->WPA.present)
4925 {
4926 //Calculate the actual length
4927 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4928 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4929 + 2 //auth_suite_count
4930 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4931 // The WPA capabilities follows the Auth Suite (two octects)--
4932 // this field is optional, and we always "send" zero, so just
4933 // remove it. This is consistent with our assumptions in the
4934 // frames compiler; c.f. bug 15234:
4935 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304936
4937 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4938 if ( NULL == pSession->pWpaRsnRspIE )
4939 status = eHAL_STATUS_FAILURE;
4940 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 {
4942 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4943 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4944 pIeBuf = pSession->pWpaRsnRspIE + 2;
4945 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304946 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304948 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4949 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304951 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4952 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4954 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4955 }
4956 }
4957 }
4958#ifdef FEATURE_WLAN_WAPI
4959 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4960 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4961 {
4962 if(pIesLocal->WAPI.present)
4963 {
4964 //Calculate the actual length
4965 nIeLen = 4 //version + akm_suite_count
4966 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4967 + 2 //pwise_cipher_suite_count
4968 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4969 + 6; //gp_cipher_suite + preauth + reserved
4970 if( pIesLocal->WAPI.bkid_count )
4971 {
4972 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4973 }
4974
4975 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4977 if ( NULL == pSession->pWapiRspIE )
4978 status = eHAL_STATUS_FAILURE;
4979 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 {
4981 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4982 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4983 pIeBuf = pSession->pWapiRspIE + 2;
4984 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304985 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 pIeBuf += 4;
4987 if( pIesLocal->WAPI.akm_suite_count )
4988 {
4989 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4991 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304993 }
4994 vos_mem_copy(pIeBuf,
4995 &pIesLocal->WAPI.unicast_cipher_suite_count,
4996 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4999 {
5000 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305001 vos_mem_copy( pIeBuf,
5002 pIesLocal->WAPI.unicast_cipher_suites,
5003 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5005 }
lukez3c809222013-05-03 10:23:02 -07005006 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305007 vos_mem_copy(pIeBuf,
5008 pIesLocal->WAPI.multicast_cipher_suite,
5009 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005010 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305011 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305012 vos_mem_copy(pIeBuf,
5013 pIesLocal->WAPI.multicast_cipher_suite + 4,
5014 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005015 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305016 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305017 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5018
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005019 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 if( pIesLocal->WAPI.bkid_count )
5021 {
5022 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305023 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5024 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5026 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305027 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 }
5030 }
5031#endif /* FEATURE_WLAN_WAPI */
5032 if( !pIes )
5033 {
5034 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305035 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 }
5037 }
5038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 return (status);
5040}
5041
Jeff Johnson295189b2012-06-20 16:38:30 -07005042static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5043{
5044 v_U8_t bACWeights[WLANTL_MAX_AC];
5045 v_U8_t paramBk, paramBe, paramVi, paramVo;
5046 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5048 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5049 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5050 //This doesn't address the case where the lower AC needs a real higher weight
5051 if( pIEs->WMMParams.present )
5052 {
5053 //no change to the lowest ones
5054 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5055 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5056 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5057 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5058 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5059 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5060 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5061 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5062 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5063 {
5064 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5065 fWeightChange = VOS_TRUE;
5066 }
5067 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5068 {
5069 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5070 fWeightChange = VOS_TRUE;
5071 }
5072 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5073 {
5074 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5075 fWeightChange = VOS_TRUE;
5076 }
5077 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5078 {
5079 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5080 fWeightChange = VOS_TRUE;
5081 }
5082 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5083 {
5084 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5085 fWeightChange = VOS_TRUE;
5086 }
5087 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5088 {
5089 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5090 fWeightChange = VOS_TRUE;
5091 }
5092 if(fWeightChange)
5093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005094 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 bACWeights[2], bACWeights[3]);
5096 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5097 }
5098 }
5099}
Jeff Johnson295189b2012-06-20 16:38:30 -07005100#ifdef WLAN_FEATURE_VOWIFI_11R
5101//Returns whether the current association is a 11r assoc or not
5102tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5103{
5104#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5105 return csrNeighborRoamIs11rAssoc(pMac);
5106#else
5107 return eANI_BOOLEAN_FALSE;
5108#endif
5109}
5110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005111#ifdef FEATURE_WLAN_CCX
5112//Returns whether the current association is a CCX assoc or not
5113tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5114{
5115#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5116 return csrNeighborRoamIsCCXAssoc(pMac);
5117#else
5118 return eANI_BOOLEAN_FALSE;
5119#endif
5120}
5121#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005122#ifdef FEATURE_WLAN_LFR
5123//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305124tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005125{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305126 tCsrRoamSession *pSession = NULL;
5127
5128 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5129 {
5130 pSession = CSR_GET_SESSION( pMac, sessionId );
5131 if (NULL != pSession->pCurRoamProfile)
5132 {
5133 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5134 {
5135 return eANI_BOOLEAN_FALSE;
5136 }
5137 }
5138 }
5139
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005140#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5141 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5142 {
5143 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5144 }
5145 else
5146#endif
5147 {
5148 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005149 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005150 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005151}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005152
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005153#ifdef FEATURE_WLAN_CCX
5154/* ---------------------------------------------------------------------------
5155
5156 \fn csrNeighborRoamIsCCXAssoc
5157
5158 \brief This function returns whether the current association is a CCX assoc or not
5159
5160 \param pMac - The handle returned by macOpen.
5161
5162 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5163
5164---------------------------------------------------------------------------*/
5165tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5166{
5167 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5168}
5169#endif /* FEATURE_WLAN_CCX */
5170
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005171#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5172//Returns whether "FW based BG scan" is currently enabled...or not
5173tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5174{
5175 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5176}
5177#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005178#endif
5179
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005180#if defined(FEATURE_WLAN_CCX)
5181tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5182{
5183 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5184}
5185#endif /*FEATURE_WLAN_CCX*/
5186
Jeff Johnson295189b2012-06-20 16:38:30 -07005187//Return true means the command can be release, else not
5188static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5189 eCsrRoamCompleteResult Result, void *Context )
5190{
5191 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5192 tSirBssDescription *pSirBssDesc = NULL;
5193 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5194 tCsrScanResult *pScanResult = NULL;
5195 tCsrRoamInfo roamInfo;
5196 sme_QosAssocInfo assocInfo;
5197 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5198 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5199 tDot11fBeaconIEs *pIes = NULL;
5200 tANI_U32 sessionId = pCommand->sessionId;
5201 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5202 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5203 eRoamCmdStatus roamStatus;
5204 eCsrRoamResult roamResult;
5205 eHalStatus status;
5206 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005208
Jeff Johnson32d95a32012-09-10 13:15:23 -07005209 if(!pSession)
5210 {
5211 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5212 return eANI_BOOLEAN_FALSE;
5213 }
5214
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005215 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 switch( Result )
5217 {
5218 case eCsrJoinSuccess:
5219 // reset the IDLE timer
5220 // !!
5221 // !! fall through to the next CASE statement here is intentional !!
5222 // !!
5223 case eCsrReassocSuccess:
5224 if(eCsrReassocSuccess == Result)
5225 {
5226 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5227 }
5228 else
5229 {
5230 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5231 }
5232 // Success Join Response from LIM. Tell NDIS we are connected and save the
5233 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005234 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305235 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 //always free the memory here
5237 if(pSession->pWpaRsnRspIE)
5238 {
5239 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305240 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 pSession->pWpaRsnRspIE = NULL;
5242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005243#ifdef FEATURE_WLAN_WAPI
5244 if(pSession->pWapiRspIE)
5245 {
5246 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305247 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 pSession->pWapiRspIE = NULL;
5249 }
5250#endif /* FEATURE_WLAN_WAPI */
5251#ifdef FEATURE_WLAN_BTAMP_UT_RF
5252 //Reset counter so no join retry is needed.
5253 pSession->maxRetryCount = 0;
5254 csrRoamStopJoinRetryTimer(pMac, sessionId);
5255#endif
5256 /* This creates problem since we have not saved the connected profile.
5257 So moving this after saving the profile
5258 */
5259 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5260 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5261 {
5262 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5263 }
5264 else
5265 {
5266 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 //Use the last connected bssdesc for reassoc-ing to the same AP.
5269 //NOTE: What to do when reassoc to a different AP???
5270 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5271 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5272 {
5273 pSirBssDesc = pSession->pConnectBssDesc;
5274 if(pSirBssDesc)
5275 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305276 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5277 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 }
5279 }
5280 else
5281 {
5282
5283 if(pCommand->u.roamCmd.pRoamBssEntry)
5284 {
5285 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5286 if(pScanResult != NULL)
5287 {
5288 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5289 //this can be NULL
5290 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305291 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5292 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 }
5294 }
5295 }
5296 if( pSirBssDesc )
5297 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5300 //Save WPA/RSN IE
5301 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5302#ifdef FEATURE_WLAN_CCX
5303 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5304#endif
5305
5306 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5307 // substate change.
5308 // Moving even save profile above so that below mentioned conditon is also met.
5309 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5310 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5312 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5313 // will be dropped for the security context may not be set properly.
5314 //
5315 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5316 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5317 //
5318 // this reordering was done on titan_prod_usb branch and is being replicated here.
5319 //
5320
5321 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5322 !pProfile->bWPSAssociation)
5323 {
5324 // Issue the set Context request to LIM to establish the Unicast STA context
5325 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5326 pProfile->negotiatedUCEncryptionType,
5327 pSirBssDesc, &(pSirBssDesc->bssId),
5328 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005330 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5332 }
5333 // Issue the set Context request to LIM to establish the Broadcast STA context
5334 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5335 pSirBssDesc, &BroadcastMac,
5336 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5337 }
5338 else
5339 {
5340 //Need to wait for supplicant authtication
5341 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 //Set the subestate to WaitForKey in case authentiation is needed
5343 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5344
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 if(pProfile->bWPSAssociation)
5346 {
5347 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5348 }
5349 else
5350 {
5351 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5352 }
5353
5354 //Save sessionId in case of timeout
5355 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5356 //This time should be long enough for the rest of the process plus setting key
5357 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5358 {
5359 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005360 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5362 }
5363 }
5364
5365 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5366 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 if(Context)
5368 {
5369 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5370 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5372 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5373#ifdef WLAN_FEATURE_VOWIFI_11R
5374 len += pJoinRsp->parsedRicRspLen;
5375#endif /* WLAN_FEATURE_VOWIFI_11R */
5376#ifdef FEATURE_WLAN_CCX
5377 len += pJoinRsp->tspecIeLen;
5378#endif
5379 if(len)
5380 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305381 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5382 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305384 vos_mem_copy(pSession->connectedInfo.pbFrames,
5385 pJoinRsp->frames, len);
5386 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5387 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5388 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005389#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305390 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005391#endif /* WLAN_FEATURE_VOWIFI_11R */
5392#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305393 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005394#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305395 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5396 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5397 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5398 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 }
5400 }
5401 if(pCommand->u.roamCmd.fReassoc)
5402 {
5403 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5404 }
5405 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5406 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5407 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5408 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5409 }
5410 else
5411 {
5412 if(pCommand->u.roamCmd.fReassoc)
5413 {
5414 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5415 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5416 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5417 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5418 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5419 }
5420 }
5421#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5422 // Indicate SME-QOS with reassoc success event, only after
5423 // copying the frames
5424 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5425#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 roamInfo.pBssDesc = pSirBssDesc;
5427 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5428 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5429#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5430 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5431#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5432 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5434 //It may be better to let QoS do this????
5435 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005437 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5439 pmcStartUapsd( pMac, NULL, NULL );
5440 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305441 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5443 if( pSession->bRefAssocStartCnt > 0 )
5444 {
5445 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005446 //Remove this code once SLM_Sessionization is supported
5447 //BMPS_WORKAROUND_NOT_NEEDED
5448 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005449 {
5450 pMac->roam.configParam.doBMPSWorkaround = 1;
5451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5453 }
5454
5455 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 // reset the PMKID candidate list
5457 csrResetPMKIDCandidateList( pMac, sessionId );
5458 //Update TL's AC weight base on the current EDCA parameters
5459 //These parameters may change in the course of the connection, that sictuation
5460 //is not taken care here. This change is mainly to address a WIFI WMM test where
5461 //BE has a equal or higher TX priority than VI.
5462 //We only do this for infra link
5463 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5464 {
5465 csrCheckAndUpdateACWeight(pMac, pIes);
5466 }
5467#ifdef FEATURE_WLAN_WAPI
5468 // reset the BKID candidate list
5469 csrResetBKIDCandidateList( pMac, sessionId );
5470#endif /* FEATURE_WLAN_WAPI */
5471 }
5472 else
5473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005474 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 csrScanCancelIdleScan(pMac);
5477 //Not to signal link up because keys are yet to be set.
5478 //The linkup function will overwrite the sub-state that we need to keep at this point.
5479 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5480 {
5481 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5484 //enough to let security and DHCP handshake succeed before entry into BMPS
5485 if (pmcShouldBmpsTimerRun(pMac))
5486 {
5487 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5488 != eHAL_STATUS_SUCCESS)
5489 {
5490 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5491 }
5492 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 break;
5495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 case eCsrStartBssSuccess:
5497 // on the StartBss Response, LIM is returning the Bss Description that we
5498 // are beaconing. Add this Bss Description to our scan results and
5499 // chain the Profile to this Bss Description. On a Start BSS, there was no
5500 // detected Bss description (no partner) so we issued the Start Bss to
5501 // start the Ibss without any Bss description. Lim was kind enough to return
5502 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005503 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305506 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 if( CSR_IS_IBSS( pProfile ) )
5508 {
5509 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 else if (CSR_IS_INFRA_AP(pProfile))
5512 {
5513 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 else
5516 {
5517 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5518 }
5519 if( !CSR_IS_WDS_STA( pProfile ) )
5520 {
5521 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005525 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 roamInfo.pBssDesc = pSirBssDesc;
5527 //We need to associate_complete it first, becasue Associate_start already indicated.
5528 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5529 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5530 break;
5531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005534 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005535 }
5536 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5537 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5538 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5539 if(pSirBssDesc)
5540 {
5541 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305542 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5543 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 }
5545 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305546 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005547#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5548 {
5549 vos_log_ibss_pkt_type *pIbssLog;
5550 tANI_U32 bi;
5551
5552 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5553 if(pIbssLog)
5554 {
5555 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5556 {
5557 //We start the IBSS (didn't find any matched IBSS out there)
5558 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5559 }
5560 else
5561 {
5562 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5563 }
5564 if(pSirBssDesc)
5565 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305566 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5568 }
5569 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5570 {
5571 //***U8 is not enough for beacon interval
5572 pIbssLog->beaconInterval = (v_U8_t)bi;
5573 }
5574 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5575 }
5576 }
5577#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5578 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5579 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5581 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5583 csrRoamIssueSetContextReq( pMac, sessionId,
5584 pProfile->negotiatedMCEncryptionType,
5585 pSirBssDesc, &BroadcastMac,
5586 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5587 }
5588 }
5589 else
5590 {
5591 //Keep the state to eCSR_ROAMING_STATE_JOINING
5592 //Need to send join_req.
5593 if(pCommand->u.roamCmd.pRoamBssEntry)
5594 {
5595 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5596 {
5597 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5598 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5599 // Set the roaming substate to 'join attempt'...
5600 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005601 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 }
5603 }
5604 else
5605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005606 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 VOS_ASSERT( 0 );
5608 }
5609 }
5610 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5611 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5612 //trigger the connection start indication in Vista
5613 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5614 {
5615 roamStatus = eCSR_ROAM_IBSS_IND;
5616 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5617 if( CSR_IS_WDS( pProfile ) )
5618 {
5619 roamStatus = eCSR_ROAM_WDS_IND;
5620 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 if( CSR_IS_INFRA_AP( pProfile ) )
5623 {
5624 roamStatus = eCSR_ROAM_INFRA_IND;
5625 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005627
5628 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5629 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5630 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305631 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5633 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005634 //We start the IBSS (didn't find any matched IBSS out there)
5635 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305637 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5638 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005639 //Remove this code once SLM_Sessionization is supported
5640 //BMPS_WORKAROUND_NOT_NEEDED
5641 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005642 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005643 {
5644 pMac->roam.configParam.doBMPSWorkaround = 1;
5645 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005646
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5648 }
5649
5650 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005651
5652 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 {
5654 //need to send stop BSS because we fail to send join_req
5655 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5656 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5657 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 case eCsrStartBssFailure:
5661#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5662 {
5663 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5665 if(pIbssLog)
5666 {
5667 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5668 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5669 }
5670 }
5671#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 roamStatus = eCSR_ROAM_IBSS_IND;
5673 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5674 if( CSR_IS_WDS( pProfile ) )
5675 {
5676 roamStatus = eCSR_ROAM_WDS_IND;
5677 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 if( CSR_IS_INFRA_AP( pProfile ) )
5680 {
5681 roamStatus = eCSR_ROAM_INFRA_IND;
5682 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 if(Context)
5685 {
5686 pSirBssDesc = (tSirBssDescription *)Context;
5687 }
5688 else
5689 {
5690 pSirBssDesc = NULL;
5691 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305692 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 roamInfo.pBssDesc = pSirBssDesc;
5694 //We need to associate_complete it first, becasue Associate_start already indicated.
5695 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5696 csrSetDefaultDot11Mode( pMac );
5697 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 case eCsrSilentlyStopRoaming:
5699 // We are here because we try to start the same IBSS
5700 //No message to PE
5701 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005702 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5704 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305705 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5707 if( roamInfo.pBssDesc )
5708 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305709 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5710 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 }
5712 //Since there is no change in the current state, simply pass back no result otherwise
5713 //HDD may be mistakenly mark to disconnected state.
5714 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5715 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 case eCsrSilentlyStopRoamingSaveState:
5718 //We are here because we try to connect to the same AP
5719 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005720 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305721 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005722
5723 //to aviod resetting the substate to NONE
5724 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5725 //No need to change substate to wai_for_key because there is no state change
5726 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5727 if( roamInfo.pBssDesc )
5728 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305729 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5730 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5733 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5734 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5735 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5736 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5737 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5738 roamInfo.staId = pSession->connectedInfo.staId;
5739 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 pSession->bRefAssocStartCnt--;
5742 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5743 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5744 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 case eCsrReassocFailure:
5747#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5748 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5749#endif
5750 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005751 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 csrFreeConnectBssDesc(pMac, sessionId);
5753 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5754 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305755 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5757 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5758 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5759 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5760 eCSR_ROAM_WDS_IND,
5761 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5762 //Need to issue stop_bss
5763 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 case eCsrJoinFailure:
5765 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005766 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 default:
5768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005769 smsLog(pMac, LOGW, FL("receives no association indication"));
5770 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005771 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5773 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5774 {
5775 //do not free for the other profiles as we need to send down stop BSS later
5776 csrFreeConnectBssDesc(pMac, sessionId);
5777 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5778 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5779 csrSetDefaultDot11Mode( pMac );
5780 }
5781
5782 switch( pCommand->u.roamCmd.roamReason )
5783 {
5784 // If this transition is because of an 802.11 OID, then we transition
5785 // back to INIT state so we sit waiting for more OIDs to be issued and
5786 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005787 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 case eCsrSmeIssuedAssocToSimilarAP:
5789 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005790 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305792 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5794 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5795 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305796 vos_mem_copy(&roamInfo.bssid,
5797 &pSession->joinFailStatusCode.bssId,
5798 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005799
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 /* Defeaturize this later if needed */
5801#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5802 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5803 if (csrRoamIsHandoffInProgress(pMac))
5804 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 /* Should indicate neighbor roam algorithm about the connect failure here */
5806 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005808#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 if(pSession->bRefAssocStartCnt > 0)
5810 {
5811 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005812 if(eCsrJoinFailureDueToConcurrency == Result)
5813 {
5814 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5815 eCSR_ROAM_ASSOCIATION_COMPLETION,
5816 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5817 }
5818 else
5819 {
5820 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 eCSR_ROAM_ASSOCIATION_COMPLETION,
5822 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005825 else
5826 {
5827 /* bRefAssocStartCnt is not incremented when
5828 * eRoamState == eCsrStopRoamingDueToConcurrency
5829 * in csrRoamJoinNextBss API. so handle this in
5830 * else case by sending assoc failure
5831 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005832 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005833 pCommand->u.scanCmd.roamId,
5834 eCSR_ROAM_ASSOCIATION_FAILURE,
5835 eCSR_ROAM_RESULT_FAILURE);
5836 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005837 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005838#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5839 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5840#endif
5841 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5842 csrScanStartIdleScan(pMac);
5843#ifdef FEATURE_WLAN_BTAMP_UT_RF
5844 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5845 //BT activity and not able to recevie WLAN traffic. Retry the join
5846 if( CSR_IS_WDS_STA(pProfile) )
5847 {
5848 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5849 }
5850#endif
5851 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 case eCsrHddIssuedReassocToSameAP:
5853 case eCsrSmeIssuedReassocToSameAP:
5854 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5855
5856 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5857#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5858 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5859#endif
5860 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5861 csrScanStartIdleScan(pMac);
5862 break;
5863 case eCsrForcedDisassoc:
5864 case eCsrForcedDeauth:
5865 case eCsrSmeIssuedIbssJoinFailure:
5866 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5867
5868 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5869 {
5870 // Notify HDD that IBSS join failed
5871 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5872 }
5873 else
5874 {
5875 csrRoamCallCallback(pMac, sessionId, NULL,
5876 pCommand->u.roamCmd.roamId,
5877 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5878 }
5879#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5880 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5881#endif
5882 csrRoamLinkDown(pMac, sessionId);
5883 csrScanStartIdleScan(pMac);
5884 break;
5885 case eCsrForcedIbssLeave:
5886 csrRoamCallCallback(pMac, sessionId, NULL,
5887 pCommand->u.roamCmd.roamId,
5888 eCSR_ROAM_IBSS_LEAVE,
5889 eCSR_ROAM_RESULT_IBSS_STOP);
5890 break;
5891 case eCsrForcedDisassocMICFailure:
5892 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5893
5894 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5895#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5896 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5897#endif
5898 csrScanStartIdleScan(pMac);
5899 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 case eCsrStopBss:
5901 csrRoamCallCallback(pMac, sessionId, NULL,
5902 pCommand->u.roamCmd.roamId,
5903 eCSR_ROAM_INFRA_IND,
5904 eCSR_ROAM_RESULT_INFRA_STOPPED);
5905 break;
5906 case eCsrForcedDisassocSta:
5907 case eCsrForcedDeauthSta:
5908 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5909 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5910 {
5911 pSession = CSR_GET_SESSION(pMac, sessionId);
5912 if (!pSession)
5913 break;
5914
5915 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5916 {
5917 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305918 vos_mem_copy(roamInfo.peerMac,
5919 pCommand->u.roamCmd.peerMac,
5920 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5922 roamInfo.statusCode = eSIR_SME_SUCCESS;
5923 status = csrRoamCallCallback(pMac, sessionId,
5924 &roamInfo, pCommand->u.roamCmd.roamId,
5925 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5926 }
5927 }
5928 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 case eCsrLostLink1:
5930 // if lost link roam1 failed, then issue lost link Scan2 ...
5931 csrScanRequestLostLink2(pMac, sessionId);
5932 break;
5933 case eCsrLostLink2:
5934 // if lost link roam2 failed, then issue lost link scan3 ...
5935 csrScanRequestLostLink3(pMac, sessionId);
5936 break;
5937 case eCsrLostLink3:
5938 default:
5939 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5940
5941 //We are done with one round of lostlink roaming here
5942 csrScanHandleFailedLostlink3(pMac, sessionId);
5943 break;
5944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 break;
5946 }
5947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 return ( fReleaseCommand );
5949}
5950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5952{
5953 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 return (status);
5955}
5956
Jeff Johnson295189b2012-06-20 16:38:30 -07005957eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5958{
5959 eHalStatus status = eHAL_STATUS_SUCCESS;
5960 tANI_U32 size = 0;
5961
5962 do
5963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305964 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5966 {
5967 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305968 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5969 if ( NULL == pDstProfile->BSSIDs.bssid )
5970 status = eHAL_STATUS_FAILURE;
5971 else
5972 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 if(!HAL_STATUS_SUCCESS(status))
5974 {
5975 break;
5976 }
5977 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305978 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5979 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
5981 if(pSrcProfile->SSIDs.numOfSSIDs)
5982 {
5983 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305984 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5985 if ( NULL == pDstProfile->SSIDs.SSIDList )
5986 status = eHAL_STATUS_FAILURE;
5987 else
5988 status = eHAL_STATUS_SUCCESS;
5989 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 {
5991 break;
5992 }
5993 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305994 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5995 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 }
5997 if(pSrcProfile->nWPAReqIELength)
5998 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305999 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6000 if ( NULL == pDstProfile->pWPAReqIE )
6001 status = eHAL_STATUS_FAILURE;
6002 else
6003 status = eHAL_STATUS_SUCCESS;
6004
6005 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 {
6007 break;
6008 }
6009 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306010 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6011 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 }
6013 if(pSrcProfile->nRSNReqIELength)
6014 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306015 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6016 if ( NULL == pDstProfile->pRSNReqIE )
6017 status = eHAL_STATUS_FAILURE;
6018 else
6019 status = eHAL_STATUS_SUCCESS;
6020
6021 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 {
6023 break;
6024 }
6025 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306026 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6027 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 }
6029#ifdef FEATURE_WLAN_WAPI
6030 if(pSrcProfile->nWAPIReqIELength)
6031 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306032 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6033 if ( NULL == pDstProfile->pWAPIReqIE )
6034 status = eHAL_STATUS_FAILURE;
6035 else
6036 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 if(!HAL_STATUS_SUCCESS(status))
6038 {
6039 break;
6040 }
6041 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306042 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6043 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 }
6045#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 if(pSrcProfile->nAddIEScanLength)
6047 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306048 pDstProfile->pAddIEScan = vos_mem_malloc(pSrcProfile->nAddIEScanLength);
6049 if ( NULL == pDstProfile->pAddIEScan )
6050 status = eHAL_STATUS_FAILURE;
6051 else
6052 status = eHAL_STATUS_SUCCESS;
6053
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 if(!HAL_STATUS_SUCCESS(status))
6055 {
6056 break;
6057 }
6058 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306059 vos_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
6060 pSrcProfile->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 if(pSrcProfile->nAddIEAssocLength)
6063 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306064 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6065 if ( NULL == pDstProfile->pAddIEAssoc )
6066 status = eHAL_STATUS_FAILURE;
6067 else
6068 status = eHAL_STATUS_SUCCESS;
6069
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 if(!HAL_STATUS_SUCCESS(status))
6071 {
6072 break;
6073 }
6074 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306075 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6076 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 if(pSrcProfile->ChannelInfo.ChannelList)
6079 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6081 pSrcProfile->ChannelInfo.numOfChannels);
6082 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6083 status = eHAL_STATUS_FAILURE;
6084 else
6085 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 if(!HAL_STATUS_SUCCESS(status))
6087 {
6088 break;
6089 }
6090 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306091 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6092 pSrcProfile->ChannelInfo.ChannelList,
6093 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 pDstProfile->AuthType = pSrcProfile->AuthType;
6096 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6097 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6098 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6099 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6100 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006101#ifdef WLAN_FEATURE_11W
6102 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6103 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6104 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6105#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 pDstProfile->BSSType = pSrcProfile->BSSType;
6107 pDstProfile->phyMode = pSrcProfile->phyMode;
6108 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6109
6110#ifdef FEATURE_WLAN_WAPI
6111 if(csrIsProfileWapi(pSrcProfile))
6112 {
6113 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6114 {
6115 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6116 }
6117 }
6118#endif /* FEATURE_WLAN_WAPI */
6119 pDstProfile->CBMode = pSrcProfile->CBMode;
6120 /*Save the WPS info*/
6121 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6122 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 pDstProfile->privacy = pSrcProfile->privacy;
6125 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6126 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6127 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6128 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6129 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6130 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6131 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6132 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6133 pDstProfile->wps_state = pSrcProfile->wps_state;
6134 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306135 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6136 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006137#ifdef WLAN_FEATURE_VOWIFI_11R
6138 if (pSrcProfile->MDID.mdiePresent)
6139 {
6140 pDstProfile->MDID.mdiePresent = 1;
6141 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6142 }
6143#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 }while(0);
6145
6146 if(!HAL_STATUS_SUCCESS(status))
6147 {
6148 csrReleaseProfile(pMac, pDstProfile);
6149 pDstProfile = NULL;
6150 }
6151
6152 return (status);
6153}
Jeff Johnson295189b2012-06-20 16:38:30 -07006154eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6155{
6156 eHalStatus status = eHAL_STATUS_SUCCESS;
6157 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6158 do
6159 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306160 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 if(pSrcProfile->bssid)
6162 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306163 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6164 if ( NULL == pDstProfile->BSSIDs.bssid )
6165 status = eHAL_STATUS_FAILURE;
6166 else
6167 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 if(!HAL_STATUS_SUCCESS(status))
6169 {
6170 break;
6171 }
6172 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306173 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6174 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 }
6176 if(pSrcProfile->SSID.ssId)
6177 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306178 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6179 if ( NULL == pDstProfile->SSIDs.SSIDList )
6180 status = eHAL_STATUS_FAILURE;
6181 else
6182 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 if(!HAL_STATUS_SUCCESS(status))
6184 {
6185 break;
6186 }
6187 pDstProfile->SSIDs.numOfSSIDs = 1;
6188 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6189 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306190 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6191 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006193 if(pSrcProfile->nAddIEAssocLength)
6194 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306195 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6196 if ( NULL == pDstProfile->pAddIEAssoc)
6197 status = eHAL_STATUS_FAILURE;
6198 else
6199 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006200 if(!HAL_STATUS_SUCCESS(status))
6201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006202 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006203 break;
6204 }
6205 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306206 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6207 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006208 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306209 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6210 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6211 status = eHAL_STATUS_FAILURE;
6212 else
6213 status = eHAL_STATUS_SUCCESS;
6214
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 if(!HAL_STATUS_SUCCESS(status))
6216 {
6217 break;
6218 }
6219 pDstProfile->ChannelInfo.numOfChannels = 1;
6220 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 pDstProfile->AuthType.numEntries = 1;
6222 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6223 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6224 pDstProfile->EncryptionType.numEntries = 1;
6225 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6226 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6227 pDstProfile->mcEncryptionType.numEntries = 1;
6228 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6229 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6230 pDstProfile->BSSType = pSrcProfile->BSSType;
6231 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306232 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6233 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006234#ifdef WLAN_FEATURE_VOWIFI_11R
6235 if (pSrcProfile->MDID.mdiePresent)
6236 {
6237 pDstProfile->MDID.mdiePresent = 1;
6238 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6239 }
6240#endif
6241
6242 }while(0);
6243
6244 if(!HAL_STATUS_SUCCESS(status))
6245 {
6246 csrReleaseProfile(pMac, pDstProfile);
6247 pDstProfile = NULL;
6248 }
6249
6250 return (status);
6251}
6252
Jeff Johnson295189b2012-06-20 16:38:30 -07006253eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6254 tScanResultHandle hBSSList,
6255 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6256 tANI_BOOLEAN fClearScan)
6257{
6258 eHalStatus status = eHAL_STATUS_SUCCESS;
6259 tSmeCmd *pCommand;
6260
6261 pCommand = csrGetCommandBuffer(pMac);
6262 if(NULL == pCommand)
6263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006264 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 status = eHAL_STATUS_RESOURCES;
6266 }
6267 else
6268 {
6269 if( fClearScan )
6270 {
6271 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306272 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 }
6274 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6275 if(NULL == pProfile)
6276 {
6277 //We can roam now
6278 //Since pProfile is NULL, we need to build our own profile, set everything to default
6279 //We can only support open and no encryption
6280 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6281 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6282 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6283 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6284 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6285 }
6286 else
6287 {
6288 //make a copy of the profile
6289 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6290 if(HAL_STATUS_SUCCESS(status))
6291 {
6292 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6293 }
6294 }
6295 pCommand->command = eSmeCommandRoam;
6296 pCommand->sessionId = (tANI_U8)sessionId;
6297 pCommand->u.roamCmd.hBSSList = hBSSList;
6298 pCommand->u.roamCmd.roamId = roamId;
6299 pCommand->u.roamCmd.roamReason = reason;
6300 //We need to free the BssList when the command is done
6301 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6302 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6304 FL("CSR PERSONA=%d"),
6305 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6307 if( !HAL_STATUS_SUCCESS( status ) )
6308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006309 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 csrReleaseCommandRoam( pMac, pCommand );
6311 }
6312 }
6313
6314 return (status);
6315}
Jeff Johnson295189b2012-06-20 16:38:30 -07006316eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6317 tCsrRoamModifyProfileFields *pMmodProfileFields,
6318 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6319{
6320 eHalStatus status = eHAL_STATUS_SUCCESS;
6321 tSmeCmd *pCommand;
6322
6323 pCommand = csrGetCommandBuffer(pMac);
6324 if(NULL == pCommand)
6325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006326 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 status = eHAL_STATUS_RESOURCES;
6328 }
6329 else
6330 {
6331 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306332 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 if(pProfile)
6334 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 //This is likely trying to reassoc to different profile
6336 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6337 //make a copy of the profile
6338 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6339 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 }
6341 else
6342 {
6343 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6344 //how to update WPA/WPA2 info in roamProfile??
6345 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 if(HAL_STATUS_SUCCESS(status))
6348 {
6349 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6350 }
6351 pCommand->command = eSmeCommandRoam;
6352 pCommand->sessionId = (tANI_U8)sessionId;
6353 pCommand->u.roamCmd.roamId = roamId;
6354 pCommand->u.roamCmd.roamReason = reason;
6355 //We need to free the BssList when the command is done
6356 //For reassoc there is no BSS list, so the boolean set to false
6357 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6358 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6359 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6361 if( !HAL_STATUS_SUCCESS( status ) )
6362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006363 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6365 csrReleaseCommandRoam( pMac, pCommand );
6366 }
6367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 return (status);
6369}
6370
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006371eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6372 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306373// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006374{
6375 eHalStatus status = eHAL_STATUS_SUCCESS;
6376 tSmeCmd *pCommand;
6377
6378 pCommand = csrGetCommandBuffer(pMac);
6379 if(NULL == pCommand)
6380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006381 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006382 status = eHAL_STATUS_RESOURCES;
6383 }
6384 else
6385 {
6386 if(pBssDescription)
6387 {
6388 //copy over the parameters we need later
6389 pCommand->command = eSmeCommandRoam;
6390 pCommand->sessionId = (tANI_U8)sessionId;
6391 pCommand->u.roamCmd.roamReason = reason;
6392 //this is the important parameter
6393 //in this case we are using this field for the "next" BSS
6394 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6395 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6396 if( !HAL_STATUS_SUCCESS( status ) )
6397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006398 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006399 csrReleaseCommandPreauth( pMac, pCommand );
6400 }
6401 }
6402 else
6403 {
6404 //Return failure
6405 status = eHAL_STATUS_RESOURCES;
6406 }
6407 }
6408 return (status);
6409}
6410
6411eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6412{
6413 tListElem *pEntry;
6414 tSmeCmd *pCommand;
6415 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6416 if ( pEntry )
6417 {
6418 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6419 if ( (eSmeCommandRoam == pCommand->command) &&
6420 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6421 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006422 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006423 pCommand->command, pCommand->u.roamCmd.roamReason);
6424 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6425 csrReleaseCommandPreauth( pMac, pCommand );
6426 }
6427 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006428 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006429 pCommand->command, pCommand->u.roamCmd.roamReason);
6430 }
6431 }
6432 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006433 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006434 }
6435 smeProcessPendingQueue( pMac );
6436 return eHAL_STATUS_SUCCESS;
6437}
6438
Jeff Johnson295189b2012-06-20 16:38:30 -07006439eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6440 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6441{
6442 eHalStatus status = eHAL_STATUS_FAILURE;
6443 tScanResultHandle hBSSList;
6444 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6446 if(HAL_STATUS_SUCCESS(status))
6447 {
6448 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6449 if(pRoamId)
6450 {
6451 *pRoamId = roamId;
6452 }
6453 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6454 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6455 if(!HAL_STATUS_SUCCESS(status))
6456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006457 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 csrScanResultPurge(pMac, hBSSList);
6459 }
6460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 return (status);
6462}
6463
Jeff Johnson295189b2012-06-20 16:38:30 -07006464eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6465 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6466{
6467 eHalStatus status = eHAL_STATUS_SUCCESS;
6468 tScanResultHandle hBSSList;
6469 tCsrScanResultFilter *pScanFilter;
6470 tANI_U32 roamId = 0;
6471 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6472 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 if (NULL == pProfile)
6474 {
6475 smsLog(pMac, LOGP, FL("No profile specified"));
6476 return eHAL_STATUS_FAILURE;
6477 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006478 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 if( CSR_IS_WDS( pProfile ) &&
6481 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006483 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006484 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 return status;
6486 }
6487 csrRoamCancelRoaming(pMac, sessionId);
6488 csrScanRemoveFreshScanCommand(pMac, sessionId);
6489 csrScanCancelIdleScan(pMac);
6490 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306491 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6493 {
6494 csrScanDisable(pMac);
6495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6497 //Check whether ssid changes
6498 if(csrIsConnStateConnected(pMac, sessionId))
6499 {
6500 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6501 {
6502 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6503 }
6504 }
6505#ifdef FEATURE_WLAN_BTAMP_UT_RF
6506 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6507#endif
6508 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006510 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6512 if(pRoamId)
6513 {
6514 roamId = *pRoamId;
6515 }
6516 if(!HAL_STATUS_SUCCESS(status))
6517 {
6518 fCallCallback = eANI_BOOLEAN_TRUE;
6519 }
6520 }
6521 else
6522 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306523 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6524 if ( NULL == pScanFilter )
6525 status = eHAL_STATUS_FAILURE;
6526 else
6527 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 if(HAL_STATUS_SUCCESS(status))
6529 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306530 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 //Try to connect to any BSS
6532 if(NULL == pProfile)
6533 {
6534 //No encryption
6535 pScanFilter->EncryptionType.numEntries = 1;
6536 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6537 }//we don't have a profile
6538 else
6539 {
6540 //Here is the profile we need to connect to
6541 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6542 }//We have a profile
6543 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6544 if(pRoamId)
6545 {
6546 *pRoamId = roamId;
6547 }
6548
6549 if(HAL_STATUS_SUCCESS(status))
6550 {
6551 /*Save the WPS info*/
6552 if(NULL != pProfile)
6553 {
6554 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6555 }
6556 else
6557 {
6558 pScanFilter->bWPSAssociation = 0;
6559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 do
6561 {
6562 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006563 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 )
6565 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006566 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6568 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6569 if(!HAL_STATUS_SUCCESS(status))
6570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006571 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 fCallCallback = eANI_BOOLEAN_TRUE;
6573 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006574 else
6575 {
6576 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 break;
6579 }
6580 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006581 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 if(HAL_STATUS_SUCCESS(status))
6583 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6585 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6586 if(!HAL_STATUS_SUCCESS(status))
6587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006588 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 csrScanResultPurge(pMac, hBSSList);
6590 fCallCallback = eANI_BOOLEAN_TRUE;
6591 }
6592 }//Have scan result
6593 else if(NULL != pProfile)
6594 {
6595 //Check whether it is for start ibss
6596 if(CSR_IS_START_IBSS(pProfile))
6597 {
6598 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6599 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6600 if(!HAL_STATUS_SUCCESS(status))
6601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006602 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 fCallCallback = eANI_BOOLEAN_TRUE;
6604 }
6605 }
6606 else
6607 {
6608 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006609 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 if(!HAL_STATUS_SUCCESS(status))
6611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006612 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 fCallCallback = eANI_BOOLEAN_TRUE;
6614 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006615 else
6616 {
6617 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 }
6620 }
6621 else
6622 {
6623 fCallCallback = eANI_BOOLEAN_TRUE;
6624 }
6625 } while (0);
6626 if(NULL != pProfile)
6627 {
6628 //we need to free memory for filter if profile exists
6629 csrFreeScanFilter(pMac, pScanFilter);
6630 }
6631 }//Got the scan filter from profile
6632
Kiet Lam64c1b492013-07-12 13:56:44 +05306633 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 }//allocated memory for pScanFilter
6635 }//No Bsslist coming in
6636 //tell the caller if we fail to trigger a join request
6637 if( fCallCallback )
6638 {
6639 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6640 }
6641
6642 return (status);
6643}
Jeff Johnson295189b2012-06-20 16:38:30 -07006644eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6645 tCsrRoamModifyProfileFields modProfileFields,
6646 tANI_U32 *pRoamId)
6647{
6648 eHalStatus status = eHAL_STATUS_SUCCESS;
6649 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6650 tANI_U32 roamId = 0;
6651 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 if (NULL == pProfile)
6653 {
6654 smsLog(pMac, LOGP, FL("No profile specified"));
6655 return eHAL_STATUS_FAILURE;
6656 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006657 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 -07006658 csrRoamCancelRoaming(pMac, sessionId);
6659 csrScanRemoveFreshScanCommand(pMac, sessionId);
6660 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306661 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 if(csrIsConnStateConnected(pMac, sessionId))
6664 {
6665 if(pProfile)
6666 {
6667 if(pProfile->SSIDs.numOfSSIDs &&
6668 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6669 {
6670 fCallCallback = eANI_BOOLEAN_FALSE;
6671 }
6672 else
6673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006674 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 }
6676 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306677 else if (!vos_mem_compare(&modProfileFields,
6678 &pSession->connectedProfile.modifyProfileFields,
6679 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 {
6681 fCallCallback = eANI_BOOLEAN_FALSE;
6682 }
6683 else
6684 {
6685 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006686 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 }
6688 }
6689 else
6690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006691 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 if(!fCallCallback)
6694 {
6695 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6696 if(pRoamId)
6697 {
6698 *pRoamId = roamId;
6699 }
6700
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6702 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 }
6704 else
6705 {
6706 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6707 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 return status;
6710}
Jeff Johnson295189b2012-06-20 16:38:30 -07006711eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6712{
6713 eHalStatus status = eHAL_STATUS_FAILURE;
6714 tScanResultHandle hBSSList = NULL;
6715 tCsrScanResultFilter *pScanFilter = NULL;
6716 tANI_U32 roamId;
6717 tCsrRoamProfile *pProfile = NULL;
6718 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006719
6720 if(!pSession)
6721 {
6722 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6723 return eHAL_STATUS_FAILURE;
6724 }
6725
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 do
6727 {
6728 if(pSession->pCurRoamProfile)
6729 {
6730 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306731 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306733 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6734 if ( NULL == pProfile )
6735 status = eHAL_STATUS_FAILURE;
6736 else
6737 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 if(!HAL_STATUS_SUCCESS(status))
6739 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306740 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306742 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306744 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6745 if ( NULL == pScanFilter )
6746 status = eHAL_STATUS_FAILURE;
6747 else
6748 status = eHAL_STATUS_SUCCESS;
6749
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 if(!HAL_STATUS_SUCCESS(status))
6751 {
6752 break;
6753 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306754 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6756 if(!HAL_STATUS_SUCCESS(status))
6757 {
6758 break;
6759 }
6760 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6761 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6762 if(HAL_STATUS_SUCCESS(status))
6763 {
6764 //we want to put the last connected BSS to the very beginning, if possible
6765 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6766 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6767 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6768 if(!HAL_STATUS_SUCCESS(status))
6769 {
6770 csrScanResultPurge(pMac, hBSSList);
6771 break;
6772 }
6773 }
6774 else
6775 {
6776 //Do a scan on this profile
6777 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006778 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 if(!HAL_STATUS_SUCCESS(status))
6780 {
6781 break;
6782 }
6783 }
6784 }//We have a profile
6785 else
6786 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006787 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 break;
6789 }
6790 }while(0);
6791 if(pScanFilter)
6792 {
6793 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306794 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006795 }
6796 if(NULL != pProfile)
6797 {
6798 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306799 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 return (status);
6802}
Jeff Johnson295189b2012-06-20 16:38:30 -07006803eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6804{
6805 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 if(csrIsConnStateConnected(pMac, sessionId))
6807 {
6808 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6809 if(HAL_STATUS_SUCCESS(status))
6810 {
6811 status = csrRoamJoinLastProfile(pMac, sessionId);
6812 }
6813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 return (status);
6815}
6816
Jeff Johnson295189b2012-06-20 16:38:30 -07006817eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6818{
6819 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006820 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 csrRoamCancelRoaming(pMac, sessionId);
6822 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6823 if(csrIsConnStateDisconnected(pMac, sessionId))
6824 {
6825 status = csrRoamJoinLastProfile(pMac, sessionId);
6826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 return (status);
6828}
6829
Jeff Johnson295189b2012-06-20 16:38:30 -07006830eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6831{
6832 eHalStatus status = eHAL_STATUS_SUCCESS;
6833 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6834 eCsrRoamSubState NewSubstate;
6835 tANI_U32 sessionId = pCommand->sessionId;
6836
6837 // change state to 'Roaming'...
6838 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6839
6840 if ( csrIsConnStateIbss( pMac, sessionId ) )
6841 {
6842 // If we are in an IBSS, then stop the IBSS...
6843 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6844 fComplete = (!HAL_STATUS_SUCCESS(status));
6845 }
6846 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006848 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 -07006849 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6850 //Restore AC weight in case we change it
6851 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6852 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6853 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6854 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6855 {
6856 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6857 }
6858 if( fDisassoc )
6859 {
6860 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6861 }
6862 else
6863 {
6864 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6865 }
6866 fComplete = (!HAL_STATUS_SUCCESS(status));
6867 }
6868 else if ( csrIsConnStateWds( pMac, sessionId ) )
6869 {
6870 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6871 {
6872 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6873 fComplete = (!HAL_STATUS_SUCCESS(status));
6874 }
6875 //This has to be WDS station
6876 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6877 {
6878
6879 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6880 if( fDisassoc )
6881 {
6882 status = csrRoamIssueDisassociate( pMac, sessionId,
6883 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6884 fComplete = (!HAL_STATUS_SUCCESS(status));
6885 }
6886 }
6887 } else {
6888 // we got a dis-assoc request while not connected to any peer
6889 // just complete the command
6890 fComplete = eANI_BOOLEAN_TRUE;
6891 status = eHAL_STATUS_FAILURE;
6892 }
6893 if(fComplete)
6894 {
6895 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6896 }
6897
6898 if(HAL_STATUS_SUCCESS(status))
6899 {
6900 if ( csrIsConnStateInfra( pMac, sessionId ) )
6901 {
6902 //Set the state to disconnect here
6903 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6904 }
6905 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006906 else
6907 {
6908 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 return (status);
6911}
6912
Jeff Johnson295189b2012-06-20 16:38:30 -07006913/* This is been removed from latest code base */
6914/*
6915static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6916{
6917 eHalStatus status;
6918 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6920 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 return ( status );
6922}
6923*/
6924
Jeff Johnson295189b2012-06-20 16:38:30 -07006925eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6926{
6927 eHalStatus status = eHAL_STATUS_SUCCESS;
6928 tSmeCmd *pCommand;
6929 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 do
6931 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006932 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 pCommand = csrGetCommandBuffer( pMac );
6934 if ( !pCommand )
6935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006936 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 status = eHAL_STATUS_RESOURCES;
6938 break;
6939 }
6940 //Change the substate in case it is wait-for-key
6941 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6942 {
6943 csrRoamStopWaitForKeyTimer( pMac );
6944 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6945 }
6946 pCommand->command = eSmeCommandRoam;
6947 pCommand->sessionId = (tANI_U8)sessionId;
6948 switch ( reason )
6949 {
6950 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6951 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6952 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 case eCSR_DISCONNECT_REASON_DEAUTH:
6954 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 case eCSR_DISCONNECT_REASON_HANDOFF:
6957 fHighPriority = eANI_BOOLEAN_TRUE;
6958 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6959 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6961 case eCSR_DISCONNECT_REASON_DISASSOC:
6962 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6965 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6966 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6968 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6969 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 default:
6971 break;
6972 }
6973 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6974 if( !HAL_STATUS_SUCCESS( status ) )
6975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006976 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 csrReleaseCommandRoam( pMac, pCommand );
6978 }
6979 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 return( status );
6981}
6982
Jeff Johnson295189b2012-06-20 16:38:30 -07006983eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6984{
6985 eHalStatus status = eHAL_STATUS_SUCCESS;
6986 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 pCommand = csrGetCommandBuffer( pMac );
6988 if ( NULL != pCommand )
6989 {
6990 //Change the substate in case it is wait-for-key
6991 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6992 {
6993 csrRoamStopWaitForKeyTimer( pMac );
6994 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6995 }
6996 pCommand->command = eSmeCommandRoam;
6997 pCommand->sessionId = (tANI_U8)sessionId;
6998 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6999 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7000 if( !HAL_STATUS_SUCCESS( status ) )
7001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007002 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 csrReleaseCommandRoam( pMac, pCommand );
7004 }
7005 }
7006 else
7007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007008 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 status = eHAL_STATUS_RESOURCES;
7010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 return ( status );
7012}
7013
Jeff Johnson295189b2012-06-20 16:38:30 -07007014eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7015{
7016 eHalStatus status = eHAL_STATUS_SUCCESS;
7017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007018
7019 if(!pSession)
7020 {
7021 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7022 return eHAL_STATUS_FAILURE;
7023 }
7024
Jeff Johnson295189b2012-06-20 16:38:30 -07007025#ifdef FEATURE_WLAN_BTAMP_UT_RF
7026 //Stop te retry
7027 pSession->maxRetryCount = 0;
7028 csrRoamStopJoinRetryTimer(pMac, sessionId);
7029#endif
7030 //Not to call cancel roaming here
7031 //Only issue disconnect when necessary
7032 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7033 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7034 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7035
7036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007037 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 return (status);
7041}
7042
Jeff Johnson295189b2012-06-20 16:38:30 -07007043eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7044{
7045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007046
7047 if(!pSession)
7048 {
7049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7050 return eHAL_STATUS_FAILURE;
7051 }
7052
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7055
7056 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7057}
7058
Jeff Johnson295189b2012-06-20 16:38:30 -07007059eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7060 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7061{
7062 eHalStatus status = eHAL_STATUS_SUCCESS;
7063 tDot11fBeaconIEs *pIesTemp = pIes;
7064 tANI_U8 index;
7065 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7066 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007067
7068 if(!pSession)
7069 {
7070 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7071 return eHAL_STATUS_FAILURE;
7072 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007073 if(pConnectProfile->pAddIEAssoc)
7074 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307075 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007076 pConnectProfile->pAddIEAssoc = NULL;
7077 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307078 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7080 pConnectProfile->AuthInfo = pProfile->AuthType;
7081 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7082 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7083 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7084 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7085 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7086 pConnectProfile->BSSType = pProfile->BSSType;
7087 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7088 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007089 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7090
Kiet Lam64c1b492013-07-12 13:56:44 +05307091 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007092 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7093 if(pProfile->nAddIEAssocLength)
7094 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307095 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7096 if ( NULL == pConnectProfile->pAddIEAssoc )
7097 status = eHAL_STATUS_FAILURE;
7098 else
7099 status = eHAL_STATUS_SUCCESS;
7100 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007101 {
7102 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7103 return eHAL_STATUS_FAILURE;
7104 }
7105 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307106 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7107 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007108 }
7109
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 //Save bssid
7111 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7112#ifdef WLAN_FEATURE_VOWIFI_11R
7113 if (pSirBssDesc->mdiePresent)
7114 {
7115 pConnectProfile->MDID.mdiePresent = 1;
7116 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7117 }
7118#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007119 if( NULL == pIesTemp )
7120 {
7121 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007123#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007124 if ((csrIsProfileCCX(pProfile) ||
7125 ((pIesTemp->CCXVersion.present)
7126 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7127 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7128 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7129 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007130#ifdef WLAN_FEATURE_11W
7131 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7132#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307133 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007134 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 {
7136 pConnectProfile->isCCXAssoc = 1;
7137 }
7138#endif
7139 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 if(HAL_STATUS_SUCCESS(status))
7141 {
7142 if(pIesTemp->SSID.present)
7143 {
7144 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307145 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7146 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 }
7148
7149 //Save the bss desc
7150 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307151
7152 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307154 //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 -07007155 pConnectProfile->qap = TRUE;
7156 }
7157 else
7158 {
7159 pConnectProfile->qap = FALSE;
7160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007161 if ( NULL == pIes )
7162 {
7163 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307164 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 }
7166 }
7167 //Save Qos connection
7168 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7169
7170 if(!HAL_STATUS_SUCCESS(status))
7171 {
7172 csrFreeConnectBssDesc(pMac, sessionId);
7173 }
7174 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7175 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307176 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7177 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7178 pConnectProfile->SSID.ssId,
7179 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 {
7181 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7182 break;
7183 }
7184 pConnectProfile->handoffPermitted = FALSE;
7185 }
7186
7187 return (status);
7188}
7189
Jeff Johnson295189b2012-06-20 16:38:30 -07007190static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7191{
7192 tListElem *pEntry = NULL;
7193 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 //The head of the active list is the request we sent
7195 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7196 if(pEntry)
7197 {
7198 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7201 {
7202 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7203 {
7204#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7205 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7206#endif
7207 }
7208 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7209 }
7210 else
7211 {
7212 tANI_U32 roamId = 0;
7213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007214 if(!pSession)
7215 {
7216 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7217 return;
7218 }
7219
Jeff Johnson295189b2012-06-20 16:38:30 -07007220
7221 //The head of the active list is the request we sent
7222 //Try to get back the same profile and roam again
7223 if(pCommand)
7224 {
7225 roamId = pCommand->u.roamCmd.roamId;
7226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7228 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007229 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007230#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7231 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7232 if (csrRoamIsHandoffInProgress(pMac))
7233 {
7234 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7235 /* Should indicate neighbor roam algorithm about the connect failure here */
7236 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7237 }
7238#endif
7239 if (pCommand)
7240 {
7241 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7242 {
7243 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7244 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7245 csrRoamReissueRoamCommand(pMac);
7246 }
7247 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7248 {
7249 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7250 }
7251 else
7252 {
7253 csrRoam(pMac, pCommand);
7254 }
7255 }
7256 else
7257 {
7258 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7259 }
7260 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7261}
7262
Jeff Johnson295189b2012-06-20 16:38:30 -07007263eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7264 tDot11fBeaconIEs *pIes,
7265 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7266{
7267 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007268 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
7270 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
7271
7272 // Set the roaming substate to 'join attempt'...
7273 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007275 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 return (status);
7277}
7278
Jeff Johnson295189b2012-06-20 16:38:30 -07007279static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7280 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7281{
7282 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 // Set the roaming substate to 'join attempt'...
7284 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7285
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007286 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007287
7288 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007289 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007290}
7291
Jeff Johnson295189b2012-06-20 16:38:30 -07007292void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7293{
7294 tListElem *pEntry;
7295 tSmeCmd *pCommand;
7296 tCsrRoamInfo roamInfo;
7297 tANI_U32 sessionId;
7298 tCsrRoamSession *pSession;
7299
7300 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7301 if(pEntry)
7302 {
7303 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7304 if ( eSmeCommandRoam == pCommand->command )
7305 {
7306 sessionId = pCommand->sessionId;
7307 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007308
7309 if(!pSession)
7310 {
7311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7312 return;
7313 }
7314
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 if( pCommand->u.roamCmd.fStopWds )
7316 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307317 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7319 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7320 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7323 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7324 eCSR_ROAM_WDS_IND,
7325 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7327 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7328 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7329 eCSR_ROAM_INFRA_IND,
7330 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7331 }
7332
Jeff Johnson295189b2012-06-20 16:38:30 -07007333
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007336 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7338 }
7339 }
7340 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007342 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7344 }
7345 }
7346 else
7347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007348 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 }
7350 }
7351 else
7352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007353 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 }
7355}
7356
Jeff Johnson295189b2012-06-20 16:38:30 -07007357tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7358{
7359 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7360 tListElem *pEntry;
7361 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 //alwasy lock active list before locking pending list
7363 csrLLLock( &pMac->sme.smeCmdActiveList );
7364 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7365 if(pEntry)
7366 {
7367 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7368 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7369 {
7370 fRet = eANI_BOOLEAN_TRUE;
7371 }
7372 }
7373 if(eANI_BOOLEAN_FALSE == fRet)
7374 {
7375 csrLLLock(&pMac->sme.smeCmdPendingList);
7376 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7377 while(pEntry)
7378 {
7379 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7380 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7381 {
7382 fRet = eANI_BOOLEAN_TRUE;
7383 break;
7384 }
7385 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7386 }
7387 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7388 }
7389 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 return (fRet);
7391}
7392
Jeff Johnson295189b2012-06-20 16:38:30 -07007393tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7394{
7395 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7396 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7398 {
7399 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7400 {
7401 break;
7402 }
7403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 return ( fRet );
7405}
7406
Jeff Johnson295189b2012-06-20 16:38:30 -07007407tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7408{
7409 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 //alwasy lock active list before locking pending list
7411 csrLLLock( &pMac->sme.smeCmdActiveList );
7412 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7413 if(eANI_BOOLEAN_FALSE == fRet)
7414 {
7415 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7416 }
7417 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 return (fRet);
7419}
7420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7422{
7423 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7424 tListElem *pEntry;
7425 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 //alwasy lock active list before locking pending list
7427 csrLLLock( &pMac->sme.smeCmdActiveList );
7428 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7429 if( pEntry )
7430 {
7431 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7432 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7433 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7434 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7435 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7436 {
7437 fRet = eANI_BOOLEAN_TRUE;
7438 }
7439 }
7440 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007441 return (fRet);
7442}
Jeff Johnson295189b2012-06-20 16:38:30 -07007443eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7444{
7445 eHalStatus status = eHAL_STATUS_SUCCESS;
7446 tSmeCmd *pCommand = NULL;
7447 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7448 tANI_BOOLEAN fRemoveCmd = FALSE;
7449 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 // Delete the old assoc command. All is setup for reassoc to be serialized
7451 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7452 if ( pEntry )
7453 {
7454 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7455 if ( !pCommand )
7456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007457 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007458 return eHAL_STATUS_RESOURCES;
7459 }
7460 if ( eSmeCommandRoam == pCommand->command )
7461 {
7462 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7463 {
7464 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7465 }
7466 else
7467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007468 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007469 }
7470 if (fRemoveCmd == FALSE)
7471 {
7472 // Implies we did not get the serialized assoc command we
7473 // were expecting
7474 pCommand = NULL;
7475 }
7476 }
7477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 if(NULL == pCommand)
7479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007480 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 return eHAL_STATUS_RESOURCES;
7482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 do
7484 {
7485 //Change the substate in case it is wait-for-key
7486 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7487 {
7488 csrRoamStopWaitForKeyTimer( pMac );
7489 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7490 }
7491 pCommand->command = eSmeCommandRoam;
7492 pCommand->sessionId = (tANI_U8)sessionId;
7493 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7495 if( !HAL_STATUS_SUCCESS( status ) )
7496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007497 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 csrReleaseCommandRoam( pMac, pCommand );
7499 }
7500 } while( 0 );
7501
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 return( status );
7503}
7504static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7505{
7506 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7507 tCsrScanResult *pScanResult = NULL;
7508 tSirBssDescription *pBssDesc = NULL;
7509 tSmeCmd *pCommand = NULL;
7510 tANI_U32 sessionId;
7511 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 if(NULL == pEntry)
7513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007514 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 return;
7516 }
7517 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7518 sessionId = pCommand->sessionId;
7519 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007520
7521 if(!pSession)
7522 {
7523 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7524 return;
7525 }
7526
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7528 {
7529 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007530 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7532 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007533 /* If the roaming has stopped, not to continue the roaming command*/
7534 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7535 {
7536 //No need to complete roaming here as it already completes
7537 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7538 pCommand->u.roamCmd.roamReason);
7539 csrSetAbortRoamingCommand( pMac, pCommand );
7540 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 else
7543 {
7544 if ( CCM_IS_RESULT_SUCCESS(result) )
7545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007546 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 // Successfully set the configuration parameters for the new Bss. Attempt to
7548 // join the roaming Bss.
7549 if(pCommand->u.roamCmd.pRoamBssEntry)
7550 {
7551 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7552 pBssDesc = &pScanResult->Result.BssDescriptor;
7553 }
7554 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7555 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 )
7558 {
7559 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7560 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7561 pBssDesc, pCommand->u.roamCmd.roamId )))
7562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007563 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 //We need to complete the command
7565 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7566 }
7567 }
7568 else
7569 {
7570 if (!pCommand->u.roamCmd.pRoamBssEntry)
7571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007572 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 //We need to complete the command
7574 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7575 return;
7576 }
7577 // If we are roaming TO an Infrastructure BSS...
7578 VOS_ASSERT(pScanResult != NULL);
7579 if ( csrIsInfraBssDesc( pBssDesc ) )
7580 {
7581 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7583 {
7584 // ..and currently in an Infrastructure connection....
7585 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7586 {
7587 // ...and the SSIDs are equal, then we Reassoc.
7588 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7589 pIesLocal ) )
7590 // ..and currently in an infrastructure connection
7591 {
7592 // then issue a Reassoc.
7593 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7594 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7595 &pCommand->u.roamCmd.roamProfile );
7596 }
7597 else
7598 {
7599
7600 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7601 // previously associated AP.
7602 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7603 pIesLocal,
7604 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7605 {
7606 //try something else
7607 csrRoam( pMac, pCommand );
7608 }
7609 }
7610 }
7611 else
7612 {
7613 eHalStatus status = eHAL_STATUS_SUCCESS;
7614
7615 /* We need to come with other way to figure out that this is because of HO in BMP
7616 The below API will be only available for Android as it uses a different HO algorithm */
7617 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7618 * use join request */
7619#ifdef WLAN_FEATURE_VOWIFI_11R
7620 if (csrRoamIsHandoffInProgress(pMac) &&
7621 csrRoamIs11rAssoc(pMac))
7622 {
7623 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7624 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7625 }
7626 else
7627#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007628#ifdef FEATURE_WLAN_CCX
7629 if (csrRoamIsHandoffInProgress(pMac) &&
7630 csrRoamIsCCXAssoc(pMac))
7631 {
7632 // Now serialize the reassoc command.
7633 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7634 }
7635 else
7636#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007637#ifdef FEATURE_WLAN_LFR
7638 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307639 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007640 {
7641 // Now serialize the reassoc command.
7642 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7643 }
7644 else
7645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 // else we are not connected and attempting to Join. Issue the
7647 // Join request.
7648 {
7649 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7650 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7651 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7652 }
7653 if(!HAL_STATUS_SUCCESS(status))
7654 {
7655 //try something else
7656 csrRoam( pMac, pCommand );
7657 }
7658 }
7659 if( !pScanResult->Result.pvIes )
7660 {
7661 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307662 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 }
7664 }
7665 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7666 else
7667 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007668 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 }
7670 }//else
7671 }//if ( WNI_CFG_SUCCESS == result )
7672 else
7673 {
7674 // In the event the configuration failed, for infra let the roam processor
7675 //attempt to join something else...
7676 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7677 {
7678 csrRoam(pMac, pCommand);
7679 }
7680 else
7681 {
7682 //We need to complete the command
7683 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7684 {
7685 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7686 }
7687 else
7688 {
7689 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7690 }
7691 }
7692 }
7693 }//we have active entry
7694}
7695
Jeff Johnson295189b2012-06-20 16:38:30 -07007696static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7697{
7698 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007699 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007702 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7704 // join the new one...
7705 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7707 }
7708 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007709 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007710 /***profHandleLostLinkAfterReset(pAdapter);
7711 // In the event the authenticate fails, let the roam processor attempt to join something else...
7712 roamRoam( pAdapter );***/
7713 }
7714}
7715
Jeff Johnson295189b2012-06-20 16:38:30 -07007716static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7717{
7718 eCsrRoamCompleteResult result;
7719 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7720 tCsrRoamInfo roamInfo;
7721 tANI_U32 roamId = 0;
7722
7723 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007725 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 /* Defeaturize this part later if needed */
7728#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7729 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7730 * we need the response contents while processing the result in csrRoamProcessResults() */
7731 if (csrRoamIsHandoffInProgress(pMac))
7732 {
7733 /* Need to dig more on indicating events to SME QoS module */
7734 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7735 csrRoamComplete( pMac, result, pSmeJoinRsp);
7736 }
7737 else
7738#endif
7739 {
7740 csrRoamComplete( pMac, result, NULL );
7741 }
7742 }
7743 /* Should we handle this similar to handling the join failure? Is it ok
7744 * to call csrRoamComplete() with state as CsrJoinFailure */
7745 else
7746 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007747 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007748 result = eCsrReassocFailure;
7749#ifdef WLAN_FEATURE_VOWIFI_11R
7750 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7751 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7752 {
7753 // Inform HDD to turn off FT flag in HDD
7754 if (pNeighborRoamInfo)
7755 {
7756 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7757 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7758 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007759 /*
7760 * Since the above callback sends a disconnect
7761 * to HDD, we should clean-up our state
7762 * machine as well to be in sync with the upper
7763 * layers. There is no need to send a disassoc
7764 * since: 1) we will never reassoc to the current
7765 * AP in LFR, and 2) there is no need to issue a
7766 * disassoc to the AP with which we were trying
7767 * to reassoc.
7768 */
7769 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7770 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007771 }
7772 }
7773#endif
7774 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7775 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7776 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7777 //The disassoc rsp message will remove the command from active list
7778 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7779 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7780 {
7781 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7782 }
7783 }
7784}
7785
Jeff Johnson295189b2012-06-20 16:38:30 -07007786static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7787{
Jeff Johnson295189b2012-06-20 16:38:30 -07007788#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7789 {
7790 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7792 if(pIbssLog)
7793 {
7794 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7795 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7796 {
7797 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7798 }
7799 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7800 }
7801 }
7802#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7804 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7805 {
7806 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7807 }
7808 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7809 {
7810 csrRoamReissueRoamCommand(pMac);
7811 }
7812}
7813
Jeff Johnson295189b2012-06-20 16:38:30 -07007814void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7815{
7816 tSirResultCodes statusCode;
7817#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7818 tScanResultHandle hBSSList;
7819 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7820 eHalStatus status;
7821 tCsrRoamInfo roamInfo;
7822 tCsrScanResultFilter *pScanFilter = NULL;
7823 tANI_U32 roamId = 0;
7824 tCsrRoamProfile *pCurRoamProfile = NULL;
7825 tListElem *pEntry = NULL;
7826 tSmeCmd *pCommand = NULL;
7827#endif
7828 tANI_U32 sessionId;
7829 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007830
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 tSirSmeDisassocRsp SmeDisassocRsp;
7832
7833 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7834 sessionId = SmeDisassocRsp.sessionId;
7835 statusCode = SmeDisassocRsp.statusCode;
7836
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007837 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007838
7839 if ( csrIsConnStateInfra( pMac, sessionId ) )
7840 {
7841 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007844
7845 if(!pSession)
7846 {
7847 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7848 return;
7849 }
7850
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7852 {
7853 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7854 }
7855 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7856 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7857 {
7858 if ( eSIR_SME_SUCCESS == statusCode )
7859 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007860 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007861 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7862 }
7863 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007867 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007868#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007869 /*
7870 * First ensure if the roam profile is in the scan cache.
7871 * If not, post a reassoc failure and disconnect.
7872 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307873 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7874 if ( NULL == pScanFilter )
7875 status = eHAL_STATUS_FAILURE;
7876 else
7877 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007878 if(HAL_STATUS_SUCCESS(status))
7879 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307880 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007881 status = csrRoamPrepareFilterFromProfile(pMac,
7882 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7883 if(!HAL_STATUS_SUCCESS(status))
7884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007885 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007886 __func__, status);
7887 goto POST_ROAM_FAILURE;
7888 }
7889 else
7890 {
7891 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7892 if (!HAL_STATUS_SUCCESS(status))
7893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007894 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007895 __func__, status);
7896 goto POST_ROAM_FAILURE;
7897 }
7898 }
7899 }
7900 else
7901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007902 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007903 __func__, status);
7904 goto POST_ROAM_FAILURE;
7905 }
7906
7907 /*
7908 * After ensuring that the roam profile is in the scan result list,
7909 * dequeue the command from the active list.
7910 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7912 if ( pEntry )
7913 {
7914 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007915 /* If the head of the queue is Active and it is a ROAM command, remove
7916 * and put this on the Free queue.
7917 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 if ( eSmeCommandRoam == pCommand->command )
7919 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007920
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007921 /*
7922 * we need to process the result first before removing it from active list
7923 * because state changes still happening insides roamQProcessRoamResults so
7924 * no other roam command should be issued.
7925 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7927 if(pCommand->u.roamCmd.fReleaseProfile)
7928 {
7929 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7930 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 else
7935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007936 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007937 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 }
7939 }
7940 else
7941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007942 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 }
7944 }
7945 else
7946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007947 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007949
7950 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7952
Kiet Lam64c1b492013-07-12 13:56:44 +05307953 vos_mem_copy(roamInfo.bssid,
7954 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7955 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007956
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007957 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7958 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007959
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007960 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307961 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7962 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307964 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007965 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7966 //make sure to put it at the head of the cmd queue
7967 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7968 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7969 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7970
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 if(!HAL_STATUS_SUCCESS(status))
7972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007973 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007974 __func__, status);
7975 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976 }
7977
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007978 /* Notify sub-modules like QoS etc. that handoff happening */
7979 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007980 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307981 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307983 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007984 return;
7985 }
7986
7987POST_ROAM_FAILURE:
7988 if (pScanFilter)
7989 {
7990 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307991 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007992 }
7993 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05307994 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007995
7996 /* Inform the upper layers that the reassoc failed */
7997 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7998 csrRoamCallCallback(pMac, sessionId,
7999 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8000
8001 /*
8002 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8003 * Upon success, we would re-enter this routine after receiving the disassoc
8004 * response and will fall into the reassoc fail sub-state. And, eventually
8005 * call csrRoamComplete which would remove the roam command from SME active
8006 * queue.
8007 */
8008 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8009 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008011 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008012 __func__, status);
8013 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008015#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008016
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8018 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8019 {
8020 // Disassoc due to Reassoc failure falls into this codepath....
8021 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8022 }
8023 else
8024 {
8025 if ( eSIR_SME_SUCCESS == statusCode )
8026 {
8027 // Successfully disassociated from the 'old' Bss...
8028 //
8029 // We get Disassociate response in three conditions.
8030 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8031 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8032 // Infrastructure network.
8033 // - Third is where we are doing an Infra to Infra roam between networks with different
8034 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8035
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008036 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 }
8038 else
8039 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008040 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 //We are not done yet. Get the data and continue roaming
8043 csrRoamReissueRoamCommand(pMac);
8044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008045}
8046
Jeff Johnson295189b2012-06-20 16:38:30 -07008047static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8048{
8049 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008051 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
8053 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8054 {
8055 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8056 }
8057 else
8058 {
8059 if ( eSIR_SME_SUCCESS == statusCode )
8060 {
8061 // Successfully deauth from the 'old' Bss...
8062 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008063 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 }
8065 else
8066 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008067 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 }
8069 //We are not done yet. Get the data and continue roaming
8070 csrRoamReissueRoamCommand(pMac);
8071 }
8072}
8073
Jeff Johnson295189b2012-06-20 16:38:30 -07008074static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8075{
8076 eCsrRoamCompleteResult result;
8077
8078 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008080 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 result = eCsrStartBssSuccess;
8082 }
8083 else
8084 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008085 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 //Let csrRoamComplete decide what to do
8087 result = eCsrStartBssFailure;
8088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008090}
8091
Jeff Johnson295189b2012-06-20 16:38:30 -07008092/*
8093 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8094 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8095 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8096 For the messages where sender allocates memory for specific structures, then it can be
8097 cast accordingly.
8098*/
8099void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8100{
8101 tSirSmeRsp *pSmeRsp;
8102 tSmeIbssPeerInd *pIbssPeerInd;
8103 tCsrRoamInfo roamInfo;
8104 // TODO Session Id need to be acquired in this function
8105 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008107 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008108 pSmeRsp->messageType, pSmeRsp->messageType,
8109 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 pSmeRsp->messageType = (pSmeRsp->messageType);
8111 pSmeRsp->length = (pSmeRsp->length);
8112 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 switch (pSmeRsp->messageType)
8114 {
8115
8116 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8117 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8118 {
8119 //We sent a JOIN_REQ
8120 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8121 }
8122 break;
8123
8124 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8125 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8126 {
8127 //We sent a AUTH_REQ
8128 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8129 }
8130 break;
8131
8132 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8133 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8134 {
8135 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8136 }
8137 break;
8138
8139 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8140 {
8141 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8142 }
8143 break;
8144
8145 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8146 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8147 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8148 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8149 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8150 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8151//HO
8152 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008154 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8156 }
8157 break;
8158
8159 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8160 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8161 {
8162 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8163 }
8164 break;
8165
8166 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8167 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8168 {
8169 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8170 }
8171 break;
8172
8173 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8174 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8175 {
8176 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8180 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8181 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008182 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308183 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8184 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8186 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308187 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8188 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8190 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8191 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8192 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008194 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 pSmeRsp->messageType, pSmeRsp->messageType,
8196 pMac->roam.curSubState[pSmeRsp->sessionId] );
8197
8198 //If we are connected, check the link status change
8199 if(!csrIsConnStateDisconnected(pMac, sessionId))
8200 {
8201 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8202 }
8203 break;
8204 }
8205}
8206
Jeff Johnson295189b2012-06-20 16:38:30 -07008207void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8208{
8209 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 switch (pSirMsg->messageType)
8211 {
8212 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008213 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 csrRoamStatsRspProcessor( pMac, pSirMsg );
8215 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8217 {
8218 tCsrRoamSession *pSession;
8219 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8220 tCsrRoamInfo roamInfo;
8221 tCsrRoamInfo *pRoamInfo = NULL;
8222 tANI_U32 sessionId;
8223 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008224 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308225 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8228 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8229 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008230
8231 if(!pSession)
8232 {
8233 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8234 return;
8235 }
8236
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8238 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8240 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8241 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8243 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308244 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8245 sizeof(tSirMacAddr));
8246 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8247 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8250 {
8251 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8252 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8253 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8254 }
8255 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8256 {
8257 vos_sleep( 100 );
8258 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8259 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8260 }
8261
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 }
8263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008264 default:
8265 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8266 break;
8267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008268}
8269
Jeff Johnson295189b2012-06-20 16:38:30 -07008270eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8271 tSirBssDescription *pBssDescription,
8272 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8273 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8274 tANI_U8 keyId, tANI_U16 keyLength,
8275 tANI_U8 *pKey, tANI_U8 paeRole )
8276{
8277 eHalStatus status = eHAL_STATUS_SUCCESS;
8278 tAniEdType edType;
8279
8280 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8281 {
8282 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8283 }
8284
8285 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8286
8287 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8288 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8289 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8290 addKey )
8291 {
8292 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 setKey.encType = EncryptType;
8294 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308295 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 setKey.paeRole = paeRole; //0 for supplicant
8297 setKey.keyId = keyId; // Kye index
8298 setKey.keyLength = keyLength;
8299 if( keyLength )
8300 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308301 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 }
8303 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 return (status);
8306}
8307
Jeff Johnson295189b2012-06-20 16:38:30 -07008308static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8309 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8310{
8311 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8312 tSmeCmd *pCommand = NULL;
8313#ifdef FEATURE_WLAN_CCX
8314 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8315#endif /* FEATURE_WLAN_CCX */
8316
8317 do
8318 {
8319 pCommand = csrGetCommandBuffer(pMac);
8320 if(NULL == pCommand)
8321 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008322 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 status = eHAL_STATUS_RESOURCES;
8324 break;
8325 }
8326 pCommand->command = eSmeCommandSetKey;
8327 pCommand->sessionId = (tANI_U8)sessionId;
8328 // validate the key length, Adjust if too long...
8329 // for static WEP the keys are not set thru' SetContextReq
8330 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8331 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8332 {
8333 //KeyLength maybe 0 for static WEP
8334 if( pSetKey->keyLength )
8335 {
8336 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008338 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 break;
8340 }
8341
8342 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308343 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8344 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 }
8346 }
8347 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8348 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8349 {
8350 //KeyLength maybe 0 for static WEP
8351 if( pSetKey->keyLength )
8352 {
8353 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008355 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 break;
8357 }
8358
8359 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308360 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8361 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 }
8363 }
8364 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8365 {
8366 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008368 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 break;
8370 }
8371 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308372 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8373 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 }
8375 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8376 {
8377 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008379 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 break;
8381 }
8382 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308383 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8384 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 }
8386#ifdef FEATURE_WLAN_WAPI
8387 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8388 {
8389 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008391 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008392 break;
8393 }
8394 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308395 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8396 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 }
8398#endif /* FEATURE_WLAN_WAPI */
8399#ifdef FEATURE_WLAN_CCX
8400 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8401 {
8402 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008404 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 break;
8406 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308407 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8408 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 pSession->ccxCckmInfo.reassoc_req_num=1;
8410 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8411 status = eHAL_STATUS_SUCCESS;
8412 break;
8413 }
8414#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008415
Jeff Johnson295189b2012-06-20 16:38:30 -07008416#ifdef WLAN_FEATURE_11W
8417 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008418 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008420 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008422 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 break;
8424 }
8425 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308426 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 }
8428#endif
8429 status = eHAL_STATUS_SUCCESS;
8430 pCommand->u.setKeyCmd.roamId = roamId;
8431 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8432 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308433 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8434 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8436 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308437 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 //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
8439
8440 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8441 if( !HAL_STATUS_SUCCESS( status ) )
8442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008443 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 }
8445 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 // Free the command if there has been a failure, or it is a
8447 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008448 if ( ( NULL != pCommand ) &&
8449 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008450#ifdef FEATURE_WLAN_CCX
8451 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8452#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008453 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 {
8455 csrReleaseCommandSetKey( pMac, pCommand );
8456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 return( status );
8458}
8459
Jeff Johnson295189b2012-06-20 16:38:30 -07008460eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8461 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8462{
8463 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8464 tSmeCmd *pCommand = NULL;
8465 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 do
8467 {
8468 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008470 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 status = eHAL_STATUS_CSR_WRONG_STATE;
8472 break;
8473 }
8474 pCommand = csrGetCommandBuffer(pMac);
8475 if(NULL == pCommand)
8476 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008477 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 status = eHAL_STATUS_RESOURCES;
8479 break;
8480 }
8481 pCommand->command = eSmeCommandRemoveKey;
8482 pCommand->sessionId = (tANI_U8)sessionId;
8483 pCommand->u.removeKeyCmd.roamId = roamId;
8484 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308485 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8486 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8488 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8489 {
8490 //in this case, put it to the end of the Q incase there is a set key pending.
8491 fImediate = eANI_BOOLEAN_FALSE;
8492 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008493 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008494 pRemoveKey->encType, pRemoveKey->keyId,
8495 pCommand->u.removeKeyCmd.peerMac[0],
8496 pCommand->u.removeKeyCmd.peerMac[1],
8497 pCommand->u.removeKeyCmd.peerMac[2],
8498 pCommand->u.removeKeyCmd.peerMac[3],
8499 pCommand->u.removeKeyCmd.peerMac[4],
8500 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8502 if( !HAL_STATUS_SUCCESS( status ) )
8503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008504 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 break;
8506 }
8507 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8509 {
8510 csrReleaseCommandRemoveKey( pMac, pCommand );
8511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 return (status );
8513}
8514
Jeff Johnson295189b2012-06-20 16:38:30 -07008515eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8516{
8517 eHalStatus status;
8518 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8519 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8520 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8521 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008522#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8523 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8524 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008525 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308527 vos_mem_set(&setKeyEvent,
8528 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8530 {
8531 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8532 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8533 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8534 }
8535 else
8536 {
8537 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8538 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8539 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8540 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308541 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008542 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 {
8544 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 //It has to be static WEP here
8546 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8547 {
8548 setKeyEvent.keyId = (v_U8_t)defKeyId;
8549 }
8550 }
8551 else
8552 {
8553 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8554 }
8555 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8556 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8557 }
8558#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 if( csrIsSetKeyAllowed(pMac, sessionId) )
8560 {
8561 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8562 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8563 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8564 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8565 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8566 pCommand->u.setKeyCmd.keyRsc);
8567 }
8568 else
8569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008570 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 //Set this status so the error handling take care of the case.
8572 status = eHAL_STATUS_CSR_WRONG_STATE;
8573 }
8574 if( !HAL_STATUS_SUCCESS(status) )
8575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008576 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008578#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008579 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 {
8581 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8582 {
8583 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8584 }
8585 else
8586 {
8587 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8588 }
8589 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8590 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8591 }
8592#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 return ( status );
8595}
8596
Jeff Johnson295189b2012-06-20 16:38:30 -07008597eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8598{
8599 eHalStatus status;
8600 tpSirSmeRemoveKeyReq pMsg = NULL;
8601 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8602 tANI_U8 *p;
8603 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008604#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8605 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8606 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308607 vos_mem_set(&removeKeyEvent,
8608 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8610 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8611 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308612 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8614 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8615 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8616#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 if( csrIsSetKeyAllowed(pMac, sessionId) )
8618 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308619 pMsg = vos_mem_malloc(wMsgLen);
8620 if ( NULL == pMsg )
8621 status = eHAL_STATUS_FAILURE;
8622 else
8623 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008624 }
8625 else
8626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008627 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 //Set the error status so error handling kicks in below
8629 status = eHAL_STATUS_CSR_WRONG_STATE;
8630 }
8631 if( HAL_STATUS_SUCCESS( status ) )
8632 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308633 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8635 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 pMsg->sessionId = (tANI_U8)sessionId;
8637 pMsg->transactionId = 0;
8638 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8639 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8640 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308641 vos_mem_copy(p,
8642 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8643 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 p += sizeof(tSirMacAddr);
8645 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308646 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 p += sizeof(tSirMacAddr);
8648 // edType
8649 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8650 p++;
8651 // weptype
8652 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8653 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8654 {
8655 *p = (tANI_U8)eSIR_WEP_STATIC;
8656 }
8657 else
8658 {
8659 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8660 }
8661 p++;
8662 //keyid
8663 *p = pCommand->u.removeKeyCmd.keyId;
8664 p++;
8665 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 status = palSendMBMessage(pMac->hHdd, pMsg);
8667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 if( !HAL_STATUS_SUCCESS( status ) )
8669 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008670 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008671#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8672 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008673 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8675#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 return ( status );
8679}
8680
Jeff Johnson295189b2012-06-20 16:38:30 -07008681eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8682{
8683 eHalStatus status;
8684
8685 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8686 {
8687 status = eHAL_STATUS_CSR_WRONG_STATE;
8688 }
8689 else
8690 {
8691 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 return ( status );
8694}
8695
Jeff Johnson295189b2012-06-20 16:38:30 -07008696/*
8697 Prepare a filter base on a profile for parsing the scan results.
8698 Upon successful return, caller MUST call csrFreeScanFilter on
8699 pScanFilter when it is done with the filter.
8700*/
8701eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8702 tCsrScanResultFilter *pScanFilter)
8703{
8704 eHalStatus status = eHAL_STATUS_SUCCESS;
8705 tANI_U32 size = 0;
8706 tANI_U8 index = 0;
8707
8708 do
8709 {
8710 if(pProfile->BSSIDs.numOfBSSIDs)
8711 {
8712 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308713 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8714 if ( NULL == pScanFilter->BSSIDs.bssid )
8715 status = eHAL_STATUS_FAILURE;
8716 else
8717 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 if(!HAL_STATUS_SUCCESS(status))
8719 {
8720 break;
8721 }
8722 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308723 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 }
8725 if(pProfile->SSIDs.numOfSSIDs)
8726 {
8727 if( !CSR_IS_WDS_STA( pProfile ) )
8728 {
8729 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8730 }
8731 else
8732 {
8733 //For WDS station
8734 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8735 pScanFilter->SSIDs.numOfSSIDs = 1;
8736 }
8737 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308738 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8739 if ( NULL == pScanFilter->SSIDs.SSIDList )
8740 status = eHAL_STATUS_FAILURE;
8741 else
8742 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 if(!HAL_STATUS_SUCCESS(status))
8744 {
8745 break;
8746 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308747 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8748 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 }
8750 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8751 {
8752 pScanFilter->ChannelInfo.numOfChannels = 0;
8753 pScanFilter->ChannelInfo.ChannelList = NULL;
8754 }
8755 else if(pProfile->ChannelInfo.numOfChannels)
8756 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308757 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8758 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8759 pProfile->ChannelInfo.numOfChannels);
8760 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8761 status = eHAL_STATUS_FAILURE;
8762 else
8763 status = eHAL_STATUS_SUCCESS;
8764
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 pScanFilter->ChannelInfo.numOfChannels = 0;
8766 if(HAL_STATUS_SUCCESS(status))
8767 {
8768 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8769 {
8770 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8771 {
8772 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8773 = pProfile->ChannelInfo.ChannelList[index];
8774 pScanFilter->ChannelInfo.numOfChannels++;
8775 }
8776 else
8777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008778 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 }
8781 }
8782 else
8783 {
8784 break;
8785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 }
8787 else
8788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008789 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 status = eHAL_STATUS_FAILURE;
8791 break;
8792 }
8793 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8794 pScanFilter->authType = pProfile->AuthType;
8795 pScanFilter->EncryptionType = pProfile->EncryptionType;
8796 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8797 pScanFilter->BSSType = pProfile->BSSType;
8798 pScanFilter->phyMode = pProfile->phyMode;
8799#ifdef FEATURE_WLAN_WAPI
8800 //check if user asked for WAPI with 11n or auto mode, in that case modify
8801 //the phymode to 11g
8802 if(csrIsProfileWapi(pProfile))
8803 {
8804 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8805 {
8806 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8807 }
8808 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8809 {
8810 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8811 }
8812 if(!pScanFilter->phyMode)
8813 {
8814 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8815 }
8816 }
8817#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 /*Save the WPS info*/
8819 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 if( pProfile->countryCode[0] )
8821 {
8822 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308823 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8824 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 }
8826#ifdef WLAN_FEATURE_VOWIFI_11R
8827 if (pProfile->MDID.mdiePresent)
8828 {
8829 pScanFilter->MDID.mdiePresent = 1;
8830 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8831 }
8832#endif
8833
8834 }while(0);
8835
8836 if(!HAL_STATUS_SUCCESS(status))
8837 {
8838 csrFreeScanFilter(pMac, pScanFilter);
8839 }
8840
8841 return(status);
8842}
8843
Jeff Johnson295189b2012-06-20 16:38:30 -07008844tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8845 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8846{
8847 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8848 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 do
8850 {
8851 // Validate the type is ok...
8852 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8853 pCommand = csrGetCommandBuffer( pMac );
8854 if ( !pCommand )
8855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008856 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 break;
8858 }
8859 //Change the substate in case it is waiting for key
8860 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8861 {
8862 csrRoamStopWaitForKeyTimer( pMac );
8863 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8864 }
8865 pCommand->command = eSmeCommandWmStatusChange;
8866 pCommand->sessionId = (tANI_U8)sessionId;
8867 pCommand->u.wmStatusChangeCmd.Type = Type;
8868 if ( eCsrDisassociated == Type )
8869 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308870 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8871 pSmeRsp,
8872 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 }
8874 else
8875 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308876 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8877 pSmeRsp,
8878 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 }
8880 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8881 {
8882 fCommandQueued = eANI_BOOLEAN_TRUE;
8883 }
8884 else
8885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008886 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 csrReleaseCommandWmStatusChange( pMac, pCommand );
8888 }
8889
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8891 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 return( fCommandQueued );
8894}
8895
Jeff Johnson295189b2012-06-20 16:38:30 -07008896static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8897{
8898 v_S7_t rssi = 0;
8899 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8900 if(pGetRssiReq)
8901 {
8902 if(NULL != pGetRssiReq->pVosContext)
8903 {
8904 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8905 }
8906 else
8907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008908 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 return;
8910 }
8911
8912 if(NULL != pGetRssiReq->rssiCallback)
8913 {
8914 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8915 }
8916 else
8917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008918 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 return;
8920 }
8921 }
8922 else
8923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008924 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 }
8926 return;
8927}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308928
8929static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8930{
8931 tANI_S8 snr = 0;
8932 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8933
8934 if (pGetSnrReq)
8935 {
8936 if (VOS_STATUS_SUCCESS !=
8937 WDA_GetSnr(pGetSnrReq->staId, &snr))
8938 {
8939 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8940 return;
8941 }
8942
8943 if (pGetSnrReq->snrCallback)
8944 {
8945 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8946 pGetSnrReq->pDevContext);
8947 }
8948 else
8949 {
8950 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8951 return;
8952 }
8953 }
8954 else
8955 {
8956 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8957 }
8958 return;
8959}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008960#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8961void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8962{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008963 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8964
Jeff Johnson36d483b2013-04-08 11:08:53 -07008965 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008966 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008967 /* Get roam Rssi request is backed up and passed back to the response,
8968 Extract the request message to fetch callback */
8969 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8970 v_S7_t rssi = pRoamRssiRsp->rssi;
8971
8972 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008973 {
8974 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8975 reqBkp->rssiCallback = NULL;
8976 vos_mem_free(reqBkp);
8977 }
8978 else
8979 {
8980 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8981 if (NULL != reqBkp)
8982 {
8983 vos_mem_free(reqBkp);
8984 }
8985 }
8986 }
8987 else
8988 {
8989 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8990 }
8991 return;
8992}
8993#endif
8994
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008995
8996#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8997void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8998{
8999 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9000
9001 if (NULL != pTsmStatsRsp)
9002 {
9003 /* Get roam Rssi request is backed up and passed back to the response,
9004 Extract the request message to fetch callback */
9005 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9006
9007 if (NULL != reqBkp)
9008 {
9009 if (NULL != reqBkp->tsmStatsCallback)
9010 {
9011 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9012 pTsmStatsRsp->staId, reqBkp->pDevContext);
9013 reqBkp->tsmStatsCallback = NULL;
9014 }
9015 vos_mem_free(reqBkp);
9016 }
9017 else
9018 {
9019 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9020 if (NULL != reqBkp)
9021 {
9022 vos_mem_free(reqBkp);
9023 }
9024 }
9025 }
9026 else
9027 {
9028 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9029 }
9030 return;
9031}
9032
9033void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
9034{
9035 tANI_U32 roamTS2 = 0;
9036 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009037 tpPESession pSessionEntry = NULL;
9038 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009039
9040 if (NULL == pSession)
9041 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009042 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009043 return;
9044 }
9045
9046 roamTS2 = vos_timer_get_system_time();
9047 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009048 smsLog(pMac, LOG1, "Bssid(%02X:%02X:%02X:%02X:%02X:%02X) Roaming Delay(%u ms)",
9049 pSession->connectedProfile.bssid[0], pSession->connectedProfile.bssid[1],
9050 pSession->connectedProfile.bssid[2], pSession->connectedProfile.bssid[3],
9051 pSession->connectedProfile.bssid[4], pSession->connectedProfile.bssid[5],
9052 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009053
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009054 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9055 if (NULL == pSessionEntry)
9056 {
9057 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9058 return;
9059 }
9060 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009061 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
9062 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
9063}
9064#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
9065
Jeff Johnsone7245742012-09-05 17:12:55 -07009066static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9067{
9068 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9069 if(pTlRssiInd)
9070 {
9071 if(NULL != pTlRssiInd->tlCallback)
9072 {
9073 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009074 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009075 }
9076 else
9077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009078 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009079 }
9080 }
9081 else
9082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009083 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009084 }
9085 return;
9086}
Jeff Johnson295189b2012-06-20 16:38:30 -07009087
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309088eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9089{
9090 tpSirResetAPCapsChange pMsg;
9091 tANI_U16 len;
9092 eHalStatus status = eHAL_STATUS_SUCCESS;
9093
9094 /* Create the message and send to lim */
9095 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309096 pMsg = vos_mem_malloc(len);
9097 if ( NULL == pMsg )
9098 status = eHAL_STATUS_FAILURE;
9099 else
9100 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309101 if (HAL_STATUS_SUCCESS(status))
9102 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309103 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309104 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9105 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309106 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309107 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
9108 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
9109 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
9110 status = palSendMBMessage(pMac->hHdd, pMsg);
9111 }
9112 else
9113 {
9114 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9115 }
9116 return status;
9117}
9118
Jeff Johnson295189b2012-06-20 16:38:30 -07009119void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9120{
9121 tSirSmeAssocInd *pAssocInd;
9122 tSirSmeDisassocInd *pDisassocInd;
9123 tSirSmeDeauthInd *pDeauthInd;
9124 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9125 tSirSmeNewBssInfo *pNewBss;
9126 tSmeIbssPeerInd *pIbssPeerInd;
9127 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9128 tSirSmeApNewCaps *pApNewCaps;
9129 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9130 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9131 tCsrRoamInfo *pRoamInfo = NULL;
9132 tCsrRoamInfo roamInfo;
9133 eHalStatus status;
9134 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9135 tCsrRoamSession *pSession = NULL;
9136 tpSirSmeSwitchChannelInd pSwitchChnInd;
9137 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009138 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 pSirMsg->messageType = (pSirMsg->messageType);
9140 pSirMsg->length = (pSirMsg->length);
9141 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309142 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 switch( pSirMsg->messageType )
9144 {
9145 case eWNI_SME_ASSOC_IND:
9146 {
9147 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009148 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9150 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9151 if( HAL_STATUS_SUCCESS( status ) )
9152 {
9153 pSession = CSR_GET_SESSION(pMac, sessionId);
9154
Jeff Johnson32d95a32012-09-10 13:15:23 -07009155 if(!pSession)
9156 {
9157 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9158 return;
9159 }
9160
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 pRoamInfo = &roamInfo;
9162
9163 // Required for indicating the frames to upper layer
9164 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9165 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9166
9167 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9168 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9169 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9170 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9171
9172 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9173 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9174 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9175
9176 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9177 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309178 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9179 sizeof(tSirMacAddr));
9180 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9181 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9183 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9186 {
9187 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9188 {
9189 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9190 pSession->pConnectBssDesc,
9191 &(pRoamInfo->peerMac),
9192 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9193 pRoamInfo->fAuthRequired = FALSE;
9194 }
9195 else
9196 {
9197 pRoamInfo->fAuthRequired = TRUE;
9198 }
9199 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9200 if (!HAL_STATUS_SUCCESS(status))
9201 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009203 /* Send Association completion message to PE */
9204 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9205
9206 /* send a message to CSR itself just to avoid the EAPOL frames going
9207 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009208 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9209 {
9210 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9213 {
9214 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9215 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9216 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 }
9219 }
9220 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009222 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 // Check if AP dis-associated us because of MIC failure. If so,
9224 // then we need to take action immediately and not wait till the
9225 // the WmStatusChange requests is pushed and processed
9226 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9227 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9228 if( HAL_STATUS_SUCCESS( status ) )
9229 {
9230 // If we are in neighbor preauth done state then on receiving
9231 // disassoc or deauth we dont roam instead we just disassoc
9232 // from current ap and then go to disconnected state
9233 // This happens for CCX and 11r FT connections ONLY.
9234#ifdef WLAN_FEATURE_VOWIFI_11R
9235 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9236 {
9237 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9238 }
9239#endif
9240#ifdef FEATURE_WLAN_CCX
9241 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9242 {
9243 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9244 }
9245#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009246#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309247 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009248 {
9249 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9250 }
9251#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 pSession = CSR_GET_SESSION( pMac, sessionId );
9253
Jeff Johnson32d95a32012-09-10 13:15:23 -07009254 if(!pSession)
9255 {
9256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9257 return;
9258 }
9259
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 if ( csrIsConnStateInfra( pMac, sessionId ) )
9261 {
9262 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009264#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9265 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9266#endif
9267 csrRoamLinkDown(pMac, sessionId);
9268 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9270 {
9271
9272 pRoamInfo = &roamInfo;
9273
9274 pRoamInfo->statusCode = pDisassocInd->statusCode;
9275 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9276
9277 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
9278
Kiet Lam64c1b492013-07-12 13:56:44 +05309279 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9280 sizeof(tSirMacAddr));
9281 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9282 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009283
9284 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009285
9286 /*
9287 * STA/P2P client got disassociated so remove any pending deauth
9288 * commands in sme pending list
9289 */
9290 pCommand.command = eSmeCommandRoam;
9291 pCommand.sessionId = (tANI_U8)sessionId;
9292 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Kiet Lam64c1b492013-07-12 13:56:44 +05309293 vos_mem_copy(pCommand.u.roamCmd.peerMac,
9294 pDisassocInd->peerMacAddr,
9295 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009296 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 }
9299 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009301 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9303 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9304 if( HAL_STATUS_SUCCESS( status ) )
9305 {
9306 // If we are in neighbor preauth done state then on receiving
9307 // disassoc or deauth we dont roam instead we just disassoc
9308 // from current ap and then go to disconnected state
9309 // This happens for CCX and 11r FT connections ONLY.
9310#ifdef WLAN_FEATURE_VOWIFI_11R
9311 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9312 {
9313 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9314 }
9315#endif
9316#ifdef FEATURE_WLAN_CCX
9317 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9318 {
9319 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9320 }
9321#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009322#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309323 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009324 {
9325 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9326 }
9327#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 pSession = CSR_GET_SESSION( pMac, sessionId );
9329
Jeff Johnson32d95a32012-09-10 13:15:23 -07009330 if(!pSession)
9331 {
9332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9333 return;
9334 }
9335
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 if ( csrIsConnStateInfra( pMac, sessionId ) )
9337 {
9338 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009340#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9341 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9342#endif
9343 csrRoamLinkDown(pMac, sessionId);
9344 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9346 {
9347
9348 pRoamInfo = &roamInfo;
9349
9350 pRoamInfo->statusCode = pDeauthInd->statusCode;
9351 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9352
9353 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9354
Kiet Lam64c1b492013-07-12 13:56:44 +05309355 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9356 sizeof(tSirMacAddr));
9357 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9358 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009359
9360 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 }
9363 break;
9364
9365 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 -08009366 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9368 //Update with the new channel id.
9369 //The channel id is hidden in the statusCode.
9370 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9371 if( HAL_STATUS_SUCCESS( status ) )
9372 {
9373 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009374 if(!pSession)
9375 {
9376 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9377 return;
9378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9380 if(pSession->pConnectBssDesc)
9381 {
9382 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9383 }
9384 }
9385 break;
9386
9387 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009388 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 {
9390 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9391 sessionId = pDeauthRsp->sessionId;
9392 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9393 {
9394 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009395 if(!pSession)
9396 {
9397 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9398 return;
9399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9401 {
9402 pRoamInfo = &roamInfo;
9403 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309404 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9405 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9407 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9408 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9409 }
9410 }
9411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 break;
9413
9414 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009415 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009416 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 {
9418 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9419 sessionId = pDisassocRsp->sessionId;
9420 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9421 {
9422 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009423 if(!pSession)
9424 {
9425 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9426 return;
9427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9429 {
9430 pRoamInfo = &roamInfo;
9431 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309432 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9433 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9435 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9436 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9437 }
9438 }
9439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 case eWNI_SME_MIC_FAILURE_IND:
9442 {
9443 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9444 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9445 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009446
9447 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9448 if( HAL_STATUS_SUCCESS( status ) )
9449 {
9450 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9451 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9452 pRoamInfo = &roamInfo;
9453 if(pMicInd->info.multicast)
9454 {
9455 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9456 }
9457 else
9458 {
9459 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9460 }
9461 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9462 }
9463
Jeff Johnson295189b2012-06-20 16:38:30 -07009464#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9465 {
lukez3c809222013-05-03 10:23:02 -07009466 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009468 if(!pSession)
9469 {
9470 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9471 return;
9472 }
lukez3c809222013-05-03 10:23:02 -07009473
Kiet Lam64c1b492013-07-12 13:56:44 +05309474 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9476 secEvent.encryptionModeMulticast =
9477 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9478 secEvent.encryptionModeUnicast =
9479 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9480 secEvent.authMode =
9481 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309482 vos_mem_copy(secEvent.bssid,
9483 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9485 }
9486#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 }
9488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9490 {
9491 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9492 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009493 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009494
9495 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9496 if( HAL_STATUS_SUCCESS( status ) )
9497 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309498 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9500 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9501 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9502 }
9503 }
9504 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009505
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9507 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9508 switch( pStatusChangeMsg->statusChangeCode )
9509 {
9510 case eSIR_SME_IBSS_ACTIVE:
9511 sessionId = csrFindIbssSession( pMac );
9512 if( CSR_SESSION_ID_INVALID != sessionId )
9513 {
9514 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009515 if(!pSession)
9516 {
9517 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9518 return;
9519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9521 if(pSession->pConnectBssDesc)
9522 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309523 vos_mem_copy(&roamInfo.bssid,
9524 pSession->pConnectBssDesc->bssId,
9525 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9527 pRoamInfo = &roamInfo;
9528 }
9529 else
9530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009531 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 }
9533 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9534 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9535 }
9536 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 case eSIR_SME_IBSS_INACTIVE:
9538 sessionId = csrFindIbssSession( pMac );
9539 if( CSR_SESSION_ID_INVALID != sessionId )
9540 {
9541 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009542 if(!pSession)
9543 {
9544 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9545 return;
9546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9548 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9549 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9550 }
9551 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9553 sessionId = csrFindIbssSession( pMac );
9554 if( CSR_SESSION_ID_INVALID != sessionId )
9555 {
9556 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009557 if(!pSession)
9558 {
9559 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9560 return;
9561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 // update the connection state information
9563 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009564#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9565 {
9566 vos_log_ibss_pkt_type *pIbssLog;
9567 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9569 if(pIbssLog)
9570 {
9571 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9572 if(pNewBss)
9573 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309574 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 if(pNewBss->ssId.length)
9576 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309577 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9578 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 }
9580 pIbssLog->operatingChannel = pNewBss->channelNumber;
9581 }
9582 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9583 {
9584 //***U8 is not enough for beacon interval
9585 pIbssLog->beaconInterval = (v_U8_t)bi;
9586 }
9587 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9588 }
9589 }
9590#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009592
9593 if ((eCSR_ENCRYPT_TYPE_NONE ==
9594 pSession->connectedProfile.EncryptionType ))
9595 {
9596 csrRoamIssueSetContextReq( pMac, sessionId,
9597 pSession->connectedProfile.EncryptionType,
9598 pSession->pConnectBssDesc,
9599 &Broadcastaddr,
9600 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9603 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309604 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9605 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 pRoamInfo = &roamInfo;
9607 //This BSSID is th ereal BSSID, let's save it
9608 if(pSession->pConnectBssDesc)
9609 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309610 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9611 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009614 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 // detection by LIM that the capabilities of the associated AP have changed.
9617 case eSIR_SME_AP_CAPS_CHANGED:
9618 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009619 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9621 if( HAL_STATUS_SUCCESS( status ) )
9622 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009623 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9624 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309625 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009626 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9627 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9628 )
9629 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309630 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9631 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009632 }
9633 else
9634 {
9635 smsLog(pMac, LOGW,
9636 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009637 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009638 pMac->roam.curState[sessionId],
9639 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309640 /* We ignore the caps change event if CSR is not in full connected state.
9641 * Send one event to PE to reset limSentCapsChangeNtf
9642 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9643 * otherwise lim cannot send any CAPS change events to SME */
9644 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 }
9647 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 default:
9650 roamStatus = eCSR_ROAM_FAILED;
9651 result = eCSR_ROAM_RESULT_NONE;
9652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 } // end switch on statusChangeCode
9654 if(eCSR_ROAM_RESULT_NONE != result)
9655 {
9656 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9657 }
9658 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 case eWNI_SME_IBSS_NEW_PEER_IND:
9660 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009661#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9662 {
9663 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009664 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9665 if(pIbssLog)
9666 {
9667 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309668 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9670 }
9671 }
9672#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 sessionId = csrFindIbssSession( pMac );
9674 if( CSR_SESSION_ID_INVALID != sessionId )
9675 {
9676 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009677
9678 if(!pSession)
9679 {
9680 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9681 return;
9682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9684 if(pSession->pConnectBssDesc)
9685 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309686 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9687 sizeof(tCsrBssid));
9688 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9689 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309692 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9693 - sizeof(tSmeIbssPeerInd)));
9694 if ( NULL == roamInfo.pbFrames )
9695 status = eHAL_STATUS_FAILURE;
9696 else
9697 status = eHAL_STATUS_SUCCESS;
9698 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 {
9700 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309701 vos_mem_copy(roamInfo.pbFrames,
9702 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9703 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 }
9705 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9706 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9707 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309708 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9709 if ( NULL == roamInfo.pBssDesc )
9710 status = eHAL_STATUS_FAILURE;
9711 else
9712 status = eHAL_STATUS_SUCCESS;
9713 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309715 vos_mem_copy(roamInfo.pBssDesc,
9716 pSession->pConnectBssDesc,
9717 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 }
9719 if(HAL_STATUS_SUCCESS(status))
9720 {
9721 pRoamInfo = &roamInfo;
9722 }
9723 else
9724 {
9725 if(roamInfo.pbFrames)
9726 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309727 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 }
9729 if(roamInfo.pBssDesc)
9730 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309731 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 }
9733 }
9734 }
9735 else
9736 {
9737 pRoamInfo = &roamInfo;
9738 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009739 if ((eCSR_ENCRYPT_TYPE_NONE ==
9740 pSession->connectedProfile.EncryptionType ))
9741 {
9742 csrRoamIssueSetContextReq( pMac, sessionId,
9743 pSession->connectedProfile.EncryptionType,
9744 pSession->pConnectBssDesc,
9745 &(pIbssPeerInd->peerAddr),
9746 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 }
9749 else
9750 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009751 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 }
9753 //send up the sec type for the new peer
9754 if (pRoamInfo)
9755 {
9756 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9757 }
9758 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9759 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9760 if(pRoamInfo)
9761 {
9762 if(roamInfo.pbFrames)
9763 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309764 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 }
9766 if(roamInfo.pBssDesc)
9767 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309768 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 }
9770 }
9771 }
9772 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009773 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9774 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9775 sessionId = csrFindIbssSession( pMac );
9776 if( CSR_SESSION_ID_INVALID != sessionId )
9777 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009778#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9779 {
9780 vos_log_ibss_pkt_type *pIbssLog;
9781
9782 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9783 if(pIbssLog)
9784 {
9785 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9786 if(pIbssPeerInd)
9787 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309788 vos_mem_copy(pIbssLog->peerMacAddr,
9789 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 }
9791 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9792 }
9793 }
9794#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009795 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9797 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9798 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309799 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9800 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9802 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9803 }
9804 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 case eWNI_SME_SETCONTEXT_RSP:
9806 {
9807 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9808 tListElem *pEntry;
9809 tSmeCmd *pCommand;
9810
9811 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9812 if ( pEntry )
9813 {
9814 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9815 if ( eSmeCommandSetKey == pCommand->command )
9816 {
9817 sessionId = pCommand->sessionId;
9818 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009819
9820 if(!pSession)
9821 {
9822 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9823 return;
9824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009825
9826#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9827 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9828 {
9829 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309830 vos_mem_set(&setKeyEvent,
9831 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 if( pRsp->peerMacAddr[0] & 0x01 )
9833 {
9834 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9835 }
9836 else
9837 {
9838 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9839 }
9840 setKeyEvent.encryptionModeMulticast =
9841 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9842 setKeyEvent.encryptionModeUnicast =
9843 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309844 vos_mem_copy(setKeyEvent.bssid,
9845 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 setKeyEvent.authMode =
9847 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009848 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 {
9850 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9851 }
9852 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9853 }
9854#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9855 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9856 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009857 csrRoamStopWaitForKeyTimer( pMac );
9858
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 //We are done with authentication, whethere succeed or not
9860 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 //We do it here because this linkup function is not called after association
9862 //when a key needs to be set.
9863 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9864 {
9865 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9866 }
9867 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009868 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309870 vos_mem_copy(&roamInfo.peerMac,
9871 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009872 //Make sure we install the GTK before indicating to HDD as authenticated
9873 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309874 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9875 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009876 {
Yathish9f22e662012-12-10 14:21:35 -08009877#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9878 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9879 {
9880 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309881 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009882 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9883 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9884 pMsg->seesionId = sessionId;
9885 status = palSendMBMessage(pMac->hHdd, pMsg );
9886 }
9887#endif
9888 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009889 }
9890 else
9891 {
9892 result = eCSR_ROAM_RESULT_NONE;
9893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009894 pRoamInfo = &roamInfo;
9895 }
9896 else
9897 {
9898 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009899 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9901 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9902 }
9903 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9904 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9906 // can go ahead and initiate the TSPEC if any are pending
9907 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009908#ifdef FEATURE_WLAN_CCX
9909 //Send Adjacent AP repot to new AP.
9910 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9911 pSession->isPrevApInfoValid &&
9912 pSession->connectedProfile.isCCXAssoc)
9913 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009914#ifdef FEATURE_WLAN_CCX_UPLOAD
9915 csrSendCcxAdjacentApRepInd(pMac, pSession);
9916#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009917 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9918#endif
9919 pSession->isPrevApInfoValid = FALSE;
9920 }
9921#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009922 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9923 {
9924 csrReleaseCommandSetKey( pMac, pCommand );
9925 }
9926 }
9927 else
9928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009929 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 }
9931 }
9932 else
9933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009934 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 smeProcessPendingQueue( pMac );
9937 }
9938 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 case eWNI_SME_REMOVEKEY_RSP:
9940 {
9941 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9942 tListElem *pEntry;
9943 tSmeCmd *pCommand;
9944
9945 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9946 if ( pEntry )
9947 {
9948 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9949 if ( eSmeCommandRemoveKey == pCommand->command )
9950 {
9951 sessionId = pCommand->sessionId;
9952 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009953
9954 if(!pSession)
9955 {
9956 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9957 return;
9958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009959#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9960 {
9961 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309962 vos_mem_set(&removeKeyEvent,
9963 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9965 removeKeyEvent.encryptionModeMulticast =
9966 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9967 removeKeyEvent.encryptionModeUnicast =
9968 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309969 vos_mem_copy( removeKeyEvent.bssid,
9970 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009971 removeKeyEvent.authMode =
9972 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009973 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 {
9975 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9976 }
9977 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9978 }
9979#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009980 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309982 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9983 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009984 result = eCSR_ROAM_RESULT_NONE;
9985 pRoamInfo = &roamInfo;
9986 }
9987 else
9988 {
9989 result = eCSR_ROAM_RESULT_FAILURE;
9990 }
9991 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9992 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9993 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9994 {
9995 csrReleaseCommandRemoveKey( pMac, pCommand );
9996 }
9997 }
9998 else
9999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010000 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 }
10002 }
10003 else
10004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010005 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 smeProcessPendingQueue( pMac );
10008 }
10009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010011 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010012 csrRoamStatsRspProcessor( pMac, pSirMsg );
10013 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010014#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
10015 case eWNI_SME_GET_ROAM_RSSI_RSP:
10016 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10017 csrRoamRssiRspProcessor( pMac, pSirMsg );
10018 break;
10019#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010020#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
10021 case eWNI_SME_GET_TSM_STATS_RSP:
10022 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10023 csrTsmStatsRspProcessor( pMac, pSirMsg );
10024 break;
10025#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010027 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 csrUpdateRssi( pMac, pSirMsg );
10029 break;
10030
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010031 case eWNI_SME_GET_SNR_REQ:
10032 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10033 csrUpdateSnr(pMac, pSirMsg);
10034 break;
10035
Jeff Johnson295189b2012-06-20 16:38:30 -070010036#ifdef WLAN_FEATURE_VOWIFI_11R
10037 case eWNI_SME_FT_PRE_AUTH_RSP:
10038 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10039 break;
10040#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10042 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010043 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 -070010044 sessionId = pSmeMaxAssocInd->sessionId;
10045 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010046 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10047 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10049 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10050 break;
10051
10052 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010053 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 btampEstablishLogLinkHdlr( pSirMsg );
10055 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010056 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010057 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010058 csrRoamRssiIndHdlr( pMac, pSirMsg );
10059 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010060#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10061 case eWNI_SME_CANDIDATE_FOUND_IND:
10062 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10063 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10064 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010065 case eWNI_SME_HANDOFF_REQ:
10066 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10067 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10068 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010069#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010070
10071 default:
10072 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010073 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010074}
10075
Jeff Johnson295189b2012-06-20 16:38:30 -070010076void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10077 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10078{
10079 if(pSession)
10080 {
10081 if(pSession->bRefAssocStartCnt)
10082 {
10083 pSession->bRefAssocStartCnt--;
10084 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10085 //Need to call association_completion because there is an assoc_start pending.
10086 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10087 eCSR_ROAM_ASSOCIATION_COMPLETION,
10088 eCSR_ROAM_RESULT_FAILURE);
10089 }
10090 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10091 }
10092 else
10093 {
10094 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10095 }
10096}
10097
10098
10099eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10100{
10101 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10103 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10104 {
10105 status = csrScanRequestLostLink1( pMac, sessionId );
10106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 return(status);
10108}
10109
Jeff Johnson295189b2012-06-20 16:38:30 -070010110//return a boolean to indicate whether roaming completed or continue.
10111tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10112 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10113{
10114 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10115 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10116 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10117 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010118 if(!pSession)
10119 {
10120 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10121 return eANI_BOOLEAN_FALSE;
10122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 //Check whether time is up
10124 if(pSession->fCancelRoaming || fForce ||
10125 ((curTime - pSession->roamingStartTime) > roamTime) ||
10126 eCsrReassocRoaming == pSession->roamingReason ||
10127 eCsrDynamicRoaming == pSession->roamingReason)
10128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010129 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10131 {
10132 //roaming is cancelled, tell HDD to indicate disconnect
10133 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10134 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10135 //to be eSIR_BEACON_MISSED
10136 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10137 {
10138 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10139 }
10140 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10141 {
10142 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10143 }
10144 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10145 {
10146 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10147 }
10148 else
10149 {
10150 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10151 }
10152 }
10153 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10154 pSession->roamingReason = eCsrNotRoaming;
10155 }
10156 else
10157 {
10158 pSession->roamResult = roamResult;
10159 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10160 {
10161 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10162 pSession->roamingReason = eCsrNotRoaming;
10163 }
10164 else
10165 {
10166 fCompleted = eANI_BOOLEAN_FALSE;
10167 }
10168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 return(fCompleted);
10170}
10171
Jeff Johnson295189b2012-06-20 16:38:30 -070010172void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10173{
10174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010175
10176 if(!pSession)
10177 {
10178 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10179 return;
10180 }
10181
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 if(CSR_IS_ROAMING(pSession))
10183 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010184 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10186 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10187 {
10188 //No need to do anything in here because the handler takes care of it
10189 }
10190 else
10191 {
10192 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10193 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10194 //Roaming is stopped after here
10195 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10196 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010197 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 csrRoamStopRoamingTimer(pMac, sessionId);
10199 }
10200 }
10201}
10202
Jeff Johnson295189b2012-06-20 16:38:30 -070010203void csrRoamRoamingTimerHandler(void *pv)
10204{
10205 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10206 tpAniSirGlobal pMac = pInfo->pMac;
10207 tANI_U32 sessionId = pInfo->sessionId;
10208 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010209
10210 if(!pSession)
10211 {
10212 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10213 return;
10214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010215
10216 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10217 {
10218 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10219 {
10220 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10221 pSession->roamingReason = eCsrNotRoaming;
10222 }
10223 }
10224}
10225
Jeff Johnson295189b2012-06-20 16:38:30 -070010226eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10227{
10228 eHalStatus status;
10229 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010230
10231 if(!pSession)
10232 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010233 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010234 return eHAL_STATUS_FAILURE;
10235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010236
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010237 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010239 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010240
10241 return (status);
10242}
10243
Jeff Johnson295189b2012-06-20 16:38:30 -070010244eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10245{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010246 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010247}
10248
Jeff Johnson295189b2012-06-20 16:38:30 -070010249void csrRoamWaitForKeyTimeOutHandler(void *pv)
10250{
10251 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10252 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010253 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
10254
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010255 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010256 pMac->roam.neighborRoamInfo.neighborRoamState,
10257 pMac->roam.curSubState[pInfo->sessionId]);
10258
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10260 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010261#ifdef FEATURE_WLAN_LFR
10262 if (csrNeighborRoamIsHandoffInProgress(pMac))
10263 {
10264 /*
10265 * Enable heartbeat timer when hand-off is in progress
10266 * and Key Wait timer expired.
10267 */
10268 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010269 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010270 pMac->roam.configParam.HeartbeatThresh24);
10271 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10272 pMac->roam.configParam.HeartbeatThresh24,
10273 NULL, eANI_BOOLEAN_FALSE);
10274 }
10275#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010276 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010277
Jeff Johnson295189b2012-06-20 16:38:30 -070010278 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010279 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10280 {
10281 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10282 pInfo->sessionId);
10283 }
10284
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010285 if (pSession)
10286 {
10287 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10288 {
10289 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10290 smeProcessPendingQueue(pMac);
10291 }
10292 else
10293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010294 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010295 __func__);
10296 }
10297 }
10298 else
10299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010300 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 }
10303
10304}
10305
Jeff Johnson295189b2012-06-20 16:38:30 -070010306eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10307{
10308 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010309#ifdef FEATURE_WLAN_LFR
10310 if (csrNeighborRoamIsHandoffInProgress(pMac))
10311 {
10312 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010313 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010314 __func__,
10315 pMac->roam.neighborRoamInfo.neighborRoamState,
10316 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10317 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10318 }
10319#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010320 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010321 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010322
10323 return (status);
10324}
10325
Jeff Johnson295189b2012-06-20 16:38:30 -070010326eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10327{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010328 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010329 pMac->roam.neighborRoamInfo.neighborRoamState,
10330 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10331#ifdef FEATURE_WLAN_LFR
10332 if (csrNeighborRoamIsHandoffInProgress(pMac))
10333 {
10334 /*
10335 * Enable heartbeat timer when hand-off is in progress
10336 * and Key Wait timer got stopped for some reason
10337 */
10338 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010339 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010340 pMac->roam.configParam.HeartbeatThresh24);
10341 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10342 pMac->roam.configParam.HeartbeatThresh24,
10343 NULL, eANI_BOOLEAN_FALSE);
10344 }
10345#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010346 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010347}
10348
Jeff Johnson295189b2012-06-20 16:38:30 -070010349void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10350 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10351{
10352 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10353 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010354 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10355 /* To silence the KW tool Null chaeck is added */
10356 if(!pSession)
10357 {
10358 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10359 return;
10360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010361
10362 if(pCommand)
10363 {
10364 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10368 {
10369 //if success, force roaming completion
10370 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10371 }
10372 else
10373 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010374 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010375 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10377 }
10378}
10379
Jeff Johnson295189b2012-06-20 16:38:30 -070010380eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10381{
10382 eHalStatus status = eHAL_STATUS_SUCCESS;
10383 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10384 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10385 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10386 tCsrRoamInfo *pRoamInfo = NULL;
10387 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010388 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010389 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010390 /* To silence the KW tool Null chaeck is added */
10391 if(!pSession)
10392 {
10393 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10394 return eHAL_STATUS_FAILURE;
10395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010397 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10399 if ( eWNI_SME_DISASSOC_IND == type )
10400 {
10401 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10402 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10403 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010404 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 }
10406 else if ( eWNI_SME_DEAUTH_IND == type )
10407 {
10408 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10409 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10410 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010411 /* Convert into proper reason code */
10412 pSession->joinFailStatusCode.reasonCode =
10413 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010414 0 : pDeauthIndMsg->reasonCode;
10415 /* cfg layer expects 0 as reason code if
10416 the driver dosent know the reason code
10417 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 }
10419 else
10420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010421 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010422 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010423 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 }
10425
10426 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 {
10429 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10430 }
10431
10432 if ( eWNI_SME_DISASSOC_IND == type )
10433 {
10434 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10435 }
10436 else if ( eWNI_SME_DEAUTH_IND == type )
10437 {
10438 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 if(!HAL_STATUS_SUCCESS(status))
10441 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010442 //If fail to send confirmation to PE, not to trigger roaming
10443 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010444 }
10445
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010446 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010447 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010448 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10449 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010450 if( eWNI_SME_DISASSOC_IND == type)
10451 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010452 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010453 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10454 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010455 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 else if( eWNI_SME_DEAUTH_IND == type )
10458 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010459 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010460 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10461 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010462 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10463 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010464 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010465
10466 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10467 that we are roaming. But if we cannot possibly roam, or if we are unable to
10468 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 if(fToRoam)
10470 {
10471 //Only remove the connected BSS in infrastructure mode
10472 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10473 //Not to do anying for lostlink with WDS
10474 if( pMac->roam.configParam.nRoamingTime )
10475 {
10476 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10477 ( eWNI_SME_DEAUTH_IND == type ) ?
10478 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10479 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010480 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 //For IBSS, we need to give some more info to HDD
10482 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10483 {
10484 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10485 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10486 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10487 }
10488 else
10489 {
10490 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10491 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010492 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010493 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10494 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10495 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10496 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10497 }
10498 else
10499 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010500 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010501 fToRoam = eANI_BOOLEAN_FALSE;
10502 }
10503 }
10504 else
10505 {
10506 //We are told not to roam, indicate lostlink
10507 fToRoam = eANI_BOOLEAN_FALSE;
10508 }
10509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 if(!fToRoam)
10511 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010512 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010513 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010514 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010515 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10516 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10517 * csrRoamCheckForLinkStatusChange API.
10518 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010519 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10520 }
10521
10522 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 Still enable idle scan for polling in case concurrent sessions are running */
10524 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10525 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010526 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010527 }
10528 }
10529
10530 return (status);
10531}
10532
Jeff Johnson295189b2012-06-20 16:38:30 -070010533eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10534{
10535 eHalStatus status = eHAL_STATUS_SUCCESS;
10536 tListElem *pEntry = NULL;
10537 tSmeCmd *pCommand = NULL;
10538 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010539
10540 if(!pSession)
10541 {
10542 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10543 return eHAL_STATUS_FAILURE;
10544 }
10545
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 //Only remove the connected BSS in infrastructure mode
10548 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10549 if(pMac->roam.configParam.nRoamingTime)
10550 {
10551 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10552 {
10553 //before starting the lost link logic release the roam command for handoff
10554 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10555 if(pEntry)
10556 {
10557 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10558 }
10559 if(pCommand)
10560 {
10561 if (( eSmeCommandRoam == pCommand->command ) &&
10562 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10563 {
10564 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10565 {
10566 csrReleaseCommandRoam( pMac, pCommand );
10567 }
10568 }
10569 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010570 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 }
10572 }
10573 else
10574 {
10575 //We are told not to roam, indicate lostlink
10576 status = eHAL_STATUS_FAILURE;
10577 }
10578
10579 return (status);
10580}
Jeff Johnson295189b2012-06-20 16:38:30 -070010581void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10582{
10583 tListElem *pEntry;
10584 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10586 if ( pEntry )
10587 {
10588 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10589 if ( eSmeCommandWmStatusChange == pCommand->command )
10590 {
10591 // Nothing to process in a Lost Link completion.... It just kicks off a
10592 // roaming sequence.
10593 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10594 {
10595 csrReleaseCommandWmStatusChange( pMac, pCommand );
10596 }
10597 else
10598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010599 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 }
10601
10602 }
10603 else
10604 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010605 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 }
10607 }
10608 else
10609 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010610 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010612 smeProcessPendingQueue( pMac );
10613}
10614
Jeff Johnson295189b2012-06-20 16:38:30 -070010615void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10616{
10617 eHalStatus status = eHAL_STATUS_FAILURE;
10618 tSirSmeRsp *pSirSmeMsg;
10619 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010620
10621 if(!pSession)
10622 {
10623 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10624 return;
10625 }
10626
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 switch ( pCommand->u.wmStatusChangeCmd.Type )
10628 {
10629 case eCsrDisassociated:
10630 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10631 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10632 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010633 case eCsrDeauthenticated:
10634 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10635 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010638 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 break;
10640 }
10641 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10642 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10643 {
10644 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10645 {
10646 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010647 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010648 }
10649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10651 // command here since there is nothing else to do.
10652 csrRoamWmStatusChangeComplete( pMac );
10653}
10654
Jeff Johnson295189b2012-06-20 16:38:30 -070010655//This function returns band and mode information.
10656//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10657//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010658static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10659 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010660{
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10662 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10663 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010664 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010665
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 //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 -070010667 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10668 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10669 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10670 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010671 {
10672 switch( pMac->roam.configParam.uCfgDot11Mode )
10673 {
10674 case eCSR_CFG_DOT11_MODE_11A:
10675 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10676 eBand = eCSR_BAND_5G;
10677 break;
10678 case eCSR_CFG_DOT11_MODE_11B:
10679 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10680 eBand = eCSR_BAND_24;
10681 break;
10682 case eCSR_CFG_DOT11_MODE_11G:
10683 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10684 eBand = eCSR_BAND_24;
10685 break;
10686 case eCSR_CFG_DOT11_MODE_11N:
10687 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010688 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10689 break;
10690#ifdef WLAN_FEATURE_11AC
10691 case eCSR_CFG_DOT11_MODE_11AC:
10692 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10693 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010694 /* If the operating channel is in 2.4 GHz band, check for
10695 * INI item to disable VHT operation in 2.4 GHz band
10696 */
10697 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10698 !pMac->roam.configParam.enableVhtFor24GHz)
10699 {
10700 /* Disable 11AC operation */
10701 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10702 }
10703 else
10704 {
10705 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10706 }
10707 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010708 }
10709 else
10710 {
10711 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10712 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10713 }
10714 break;
10715 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10716 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10717 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010718 /* If the operating channel is in 2.4 GHz band, check for
10719 * INI item to disable VHT operation in 2.4 GHz band
10720 */
10721 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10722 !pMac->roam.configParam.enableVhtFor24GHz)
10723 {
10724 /* Disable 11AC operation */
10725 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10726 }
10727 else
10728 {
10729 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10730 }
10731 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010732 }
10733 else
10734 {
10735 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10736 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10737 }
10738 break;
10739#endif
10740 case eCSR_CFG_DOT11_MODE_AUTO:
10741 eBand = pMac->roam.configParam.eBand;
10742 if (eCSR_BAND_24 == eBand)
10743 {
10744 // WiFi tests require IBSS networks to start in 11b mode
10745 // without any change to the default parameter settings
10746 // on the adapter. We use ACU to start an IBSS through
10747 // creation of a startIBSS profile. This startIBSS profile
10748 // has Auto MACProtocol and the adapter property setting
10749 // for dot11Mode is also AUTO. So in this case, let's
10750 // start the IBSS network in 11b mode instead of 11g mode.
10751 // So this is for Auto=profile->MacProtocol && Auto=Global.
10752 // dot11Mode && profile->channel is < 14, then start the IBSS
10753 // in b mode.
10754 //
10755 // Note: we used to have this start as an 11g IBSS for best
10756 // performance... now to specify that the user will have to
10757 // set the do11Mode in the property page to 11g to force it.
10758 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10759 }
10760 else
10761 {
10762#ifdef WLAN_FEATURE_11AC
10763 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10764 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010765 /* If the operating channel is in 2.4 GHz band, check for
10766 * INI item to disable VHT operation in 2.4 GHz band
10767 */
10768 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10769 !pMac->roam.configParam.enableVhtFor24GHz)
10770 {
10771 /* Disable 11AC operation */
10772 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10773 }
10774 else
10775 {
10776 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10777 }
10778 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010779 }
10780 else
10781 {
10782 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10783 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10784 }
10785#else
10786 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10787 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10788#endif
10789 }
10790 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 default:
10792 // Global dot11 Mode setting is 11a/b/g.
10793 // use the channel number to determine the Mode setting.
10794 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10795 {
10796 eBand = pMac->roam.configParam.eBand;
10797 if(eCSR_BAND_24 == eBand)
10798 {
10799 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10800 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10801 }
10802 else
10803 {
10804 //prefer 5GHz
10805 eBand = eCSR_BAND_5G;
10806 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10807 }
10808 }
10809 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10810 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010811 // WiFi tests require IBSS networks to start in 11b mode
10812 // without any change to the default parameter settings
10813 // on the adapter. We use ACU to start an IBSS through
10814 // creation of a startIBSS profile. This startIBSS profile
10815 // has Auto MACProtocol and the adapter property setting
10816 // for dot11Mode is also AUTO. So in this case, let's
10817 // start the IBSS network in 11b mode instead of 11g mode.
10818 // So this is for Auto=profile->MacProtocol && Auto=Global.
10819 // dot11Mode && profile->channel is < 14, then start the IBSS
10820 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010822 // Note: we used to have this start as an 11g IBSS for best
10823 // performance... now to specify that the user will have to
10824 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10826 eBand = eCSR_BAND_24;
10827 }
10828 else
10829 {
10830 // else, it's a 5.0GHz channel. Set mode to 11a.
10831 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10832 eBand = eCSR_BAND_5G;
10833 }
10834 break;
10835 }//switch
10836 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10837 else
10838 {
10839 //dot11 mode is set, lets pick the band
10840 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10841 {
10842 // channel is Auto also.
10843 eBand = pMac->roam.configParam.eBand;
10844 if(eCSR_BAND_ALL == eBand)
10845 {
10846 //prefer 5GHz
10847 eBand = eCSR_BAND_5G;
10848 }
10849 }
10850 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10851 {
10852 eBand = eCSR_BAND_24;
10853 }
10854 else
10855 {
10856 eBand = eCSR_BAND_5G;
10857 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 if(pBand)
10860 {
10861 *pBand = eBand;
10862 }
10863
10864 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010865 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10867 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010868
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010869 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10870 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 -070010871 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010872#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010873 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010874#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010875 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10876 {
10877 //We cannot do 11n here
10878 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10879 {
10880 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10881 }
10882 else
10883 {
10884 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10885 }
10886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 return( cfgDot11Mode );
10888}
10889
Jeff Johnson295189b2012-06-20 16:38:30 -070010890eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10891{
10892 eHalStatus status;
10893 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010894
10895 if(!pSession)
10896 {
10897 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10898 return eHAL_STATUS_FAILURE;
10899 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010900
10901#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10902 {
10903 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10905 if(pIbssLog)
10906 {
10907 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10908 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10909 }
10910 }
10911#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010912 // Set the roaming substate to 'stop Bss request'...
10913 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10914
10915 // attempt to stop the Bss (reason code is ignored...)
10916 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010917 if(!HAL_STATUS_SUCCESS(status))
10918 {
10919 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 return (status);
10922}
10923
Jeff Johnson295189b2012-06-20 16:38:30 -070010924//pNumChan is a caller allocated space with the sizeof pChannels
10925eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10926{
10927
10928 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10929 (tANI_U8 *)pChannels,
10930 pNumChan));
10931}
10932
Kiran4a17ebe2013-01-31 10:43:43 -080010933tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10934{
10935 tANI_U32 cfgLength = 0;
10936 tANI_U16 cfgId = 0;
10937 tPowerdBm maxTxPwr = 0;
10938 tANI_U8 *pCountryInfo = NULL;
10939 eHalStatus status;
10940 tANI_U8 count = 0;
10941 tANI_U8 firstChannel;
10942 tANI_U8 maxChannels;
10943
10944 if (CSR_IS_CHANNEL_5GHZ(channel))
10945 {
10946 cfgId = WNI_CFG_MAX_TX_POWER_5;
10947 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10948 }
10949 else if (CSR_IS_CHANNEL_24GHZ(channel))
10950 {
10951 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10952 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10953 }
10954 else
10955 return maxTxPwr;
10956
Kiet Lam64c1b492013-07-12 13:56:44 +053010957 pCountryInfo = vos_mem_malloc(cfgLength);
10958 if ( NULL == pCountryInfo )
10959 status = eHAL_STATUS_FAILURE;
10960 else
10961 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010962 if (status != eHAL_STATUS_SUCCESS)
10963 {
10964 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010965 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010966 __FUNCTION__, status);
10967 goto error;
10968 }
10969 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10970 if (status != eHAL_STATUS_SUCCESS)
10971 {
10972 goto error;
10973 }
10974 /* Identify the channel and maxtxpower */
10975 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10976 {
10977 firstChannel = pCountryInfo[count++];
10978 maxChannels = pCountryInfo[count++];
10979 maxTxPwr = pCountryInfo[count++];
10980
10981 if ((channel >= firstChannel) &&
10982 (channel < (firstChannel + maxChannels)))
10983 {
10984 break;
10985 }
10986 }
10987
10988error:
10989 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010990 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010991
10992 return maxTxPwr;
10993}
10994
10995
Jeff Johnson295189b2012-06-20 16:38:30 -070010996tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10997{
10998 tANI_BOOLEAN fValid = FALSE;
10999 tANI_U32 idxValidChannels;
11000 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11001
11002 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11003 {
11004 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11005 {
11006 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11007 {
11008 fValid = TRUE;
11009 break;
11010 }
11011 }
11012 }
11013 pMac->roam.numValidChannels = len;
11014 return fValid;
11015}
11016
Jeff Johnson295189b2012-06-20 16:38:30 -070011017tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11018{
11019 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11020 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11022 {
11023 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11024 {
11025 fValid = eANI_BOOLEAN_TRUE;
11026 break;
11027 }
11028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 return (fValid);
11030}
11031
Jeff Johnson295189b2012-06-20 16:38:30 -070011032//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011033 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011034{
Jeff Johnsone7245742012-09-05 17:12:55 -070011035 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 tANI_U8 centerChn;
11037 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11039 {
11040 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11041 }
11042 else
11043 {
11044 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11045 }
11046 //Figure what the other side's CB mode
11047 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11048 {
11049 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11050 {
11051 if(pIes->HTInfo.present)
11052 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011053 /* This is called during INFRA STA/CLIENT and should use the merged value of
11054 * supported channel width and recommended tx width as per standard
11055 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011056 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011057 pIes->HTCaps.supportedChannelWidthSet,
11058 pIes->HTInfo.recommendedTxWidthSet,
11059 pIes->HTInfo.secondaryChannelOffset);
11060
11061 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11062 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011064 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11065 switch (eRet) {
11066 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11067 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11068 break;
11069 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11070 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11071 break;
11072 case PHY_SINGLE_CHANNEL_CENTERED:
11073 default:
11074 centerChn = primaryChn;
11075 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011077 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011079 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011080 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 }
11082 }
11083 }
11084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011085 return eRet;
11086}
Jeff Johnson295189b2012-06-20 16:38:30 -070011087tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11088{
11089 tANI_BOOLEAN fFound = FALSE;
11090 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11092 {
11093 if( pCipherList->encryptionType[idx] == encryptionType )
11094 {
11095 fFound = TRUE;
11096 break;
11097 }
11098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 return fFound;
11100}
Jeff Johnson295189b2012-06-20 16:38:30 -070011101tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11102{
11103 tANI_BOOLEAN fFound = FALSE;
11104 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11106 {
11107 if( pAuthList->authType[idx] == authType )
11108 {
11109 fFound = TRUE;
11110 break;
11111 }
11112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 return fFound;
11114}
Jeff Johnson295189b2012-06-20 16:38:30 -070011115tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11116{
11117 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11118 tCsrScanResultFilter *pScanFilter = NULL;
11119 eHalStatus status = eHAL_STATUS_SUCCESS;
11120
11121 if(pProfile1 && pProfile2)
11122 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011123 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11124 if ( NULL == pScanFilter )
11125 status = eHAL_STATUS_FAILURE;
11126 else
11127 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 if(HAL_STATUS_SUCCESS(status))
11129 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011130 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11132 if(HAL_STATUS_SUCCESS(status))
11133 {
11134 fCheck = eANI_BOOLEAN_FALSE;
11135 do
11136 {
11137 tANI_U32 i;
11138 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11139 {
11140 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11141 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11142 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11143 if ( fCheck ) break;
11144 }
11145 if(!fCheck)
11146 {
11147 break;
11148 }
11149 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11150 || pProfile2->BSSType != pProfile1->BSSType
11151 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11152 )
11153 {
11154 fCheck = eANI_BOOLEAN_FALSE;
11155 break;
11156 }
11157#ifdef WLAN_FEATURE_VOWIFI_11R
11158 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11159 {
11160 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11161 {
11162 fCheck = eANI_BOOLEAN_FALSE;
11163 break;
11164 }
11165 }
11166#endif
11167 //Match found
11168 fCheck = eANI_BOOLEAN_TRUE;
11169 }while(0);
11170 csrFreeScanFilter(pMac, pScanFilter);
11171 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011172 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011173 }
11174 }
11175
11176 return (fCheck);
11177}
11178
Jeff Johnson295189b2012-06-20 16:38:30 -070011179tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11180{
11181 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11182 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 do
11184 {
11185 //Only check for static WEP
11186 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11187 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11188 {
11189 fCheck = eANI_BOOLEAN_TRUE;
11190 break;
11191 }
11192 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11193 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11194 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11195 {
11196 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011197 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11198 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 {
11200 break;
11201 }
11202 }
11203 if( i == CSR_MAX_NUM_KEY)
11204 {
11205 fCheck = eANI_BOOLEAN_TRUE;
11206 }
11207 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 return (fCheck);
11209}
11210
Jeff Johnson295189b2012-06-20 16:38:30 -070011211//IBSS
11212
Jeff Johnson295189b2012-06-20 16:38:30 -070011213tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11214{
11215 tANI_U8 channel = 0;
11216 tANI_U32 idx;
11217 tANI_U32 idxValidChannels;
11218 tANI_BOOLEAN fFound = FALSE;
11219 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11220
11221 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11222 {
11223 channel = pMac->roam.configParam.AdHocChannel5G;
11224 if(!csrRoamIsChannelValid(pMac, channel))
11225 {
11226 channel = 0;
11227 }
11228 }
11229 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11230 {
11231 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11232 {
11233 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11234 {
11235 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11236 {
11237 fFound = TRUE;
11238 channel = csrStartIbssChannels50[ idx ];
11239 }
11240 }
11241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11243 if (!fFound)
11244 {
11245 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11246 {
11247 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11248 {
11249 channel = csrStartIbssChannels50[ idx ];
11250 break;
11251 }
11252 }
11253 }
11254 }//if
11255
11256 return( channel );
11257}
11258
Jeff Johnson295189b2012-06-20 16:38:30 -070011259tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11260{
11261 tANI_U8 channel = 1;
11262 tANI_U32 idx;
11263 tANI_U32 idxValidChannels;
11264 tANI_BOOLEAN fFound = FALSE;
11265 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11266
11267 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11268 {
11269 channel = pMac->roam.configParam.AdHocChannel24;
11270 if(!csrRoamIsChannelValid(pMac, channel))
11271 {
11272 channel = 0;
11273 }
11274 }
11275
11276 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11277 {
11278 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11279 {
11280 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11281 {
11282 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11283 {
11284 fFound = TRUE;
11285 channel = csrStartIbssChannels24[ idx ];
11286 }
11287 }
11288 }
11289 }
11290
11291 return( channel );
11292}
11293
Jeff Johnson295189b2012-06-20 16:38:30 -070011294static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11295 tCsrRoamStartBssParams *pParam )
11296{
11297 eCsrCfgDot11Mode cfgDot11Mode;
11298 eCsrBand eBand;
11299 tANI_U8 channel = 0;
11300 tSirNwType nwType;
11301 tANI_U8 operationChannel = 0;
11302
11303 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11304 {
11305 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11306 }
11307
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011309
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11311 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11312 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11313 )
11314 {
11315 /* This should never happen */
11316 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011317 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 pProfile->csrPersona);
11319 VOS_ASSERT(0);
11320 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011321 switch( cfgDot11Mode )
11322 {
11323 case eCSR_CFG_DOT11_MODE_11G:
11324 nwType = eSIR_11G_NW_TYPE;
11325 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011326 case eCSR_CFG_DOT11_MODE_11B:
11327 nwType = eSIR_11B_NW_TYPE;
11328 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011329 case eCSR_CFG_DOT11_MODE_11A:
11330 nwType = eSIR_11A_NW_TYPE;
11331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 default:
11333 case eCSR_CFG_DOT11_MODE_11N:
11334 case eCSR_CFG_DOT11_MODE_TAURUS:
11335 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11336 if(eCSR_BAND_24 == eBand)
11337 {
11338 nwType = eSIR_11G_NW_TYPE;
11339 }
11340 else
11341 {
11342 nwType = eSIR_11A_NW_TYPE;
11343 }
11344 break;
11345 }
11346
11347 pParam->extendedRateSet.numRates = 0;
11348
11349 switch ( nwType )
11350 {
11351 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011352 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 case eSIR_11A_NW_TYPE:
11354
11355 pParam->operationalRateSet.numRates = 8;
11356
11357 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11358 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11359 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11360 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11361 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11362 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11363 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11364 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11365
11366 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11367 {
11368 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11369 if( 0 == channel &&
11370 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11371 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11372 )
11373 {
11374 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11375 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11376 nwType = eSIR_11B_NW_TYPE;
11377 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11378 pParam->operationalRateSet.numRates = 4;
11379 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11380 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11381 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11382 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11383 }
11384 }
11385 else
11386 {
11387 channel = operationChannel;
11388 }
11389 break;
11390
11391 case eSIR_11B_NW_TYPE:
11392 pParam->operationalRateSet.numRates = 4;
11393 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11394 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11395 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11396 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11398 {
11399 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11400 }
11401 else
11402 {
11403 channel = operationChannel;
11404 }
11405
11406 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 /* For P2P Client and P2P GO, disable 11b rates */
11409 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11410 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11411 )
11412 {
11413 pParam->operationalRateSet.numRates = 8;
11414
11415 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11416 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11417 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11418 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11419 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11420 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11421 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11422 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11423 }
11424 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 {
11426 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011427 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11428 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11429 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11430 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11431
11432 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11434 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11435 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11436 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11437 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11438 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11439 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11440 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11441 }
11442
11443 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11444 {
11445 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11446 }
11447 else
11448 {
11449 channel = operationChannel;
11450 }
11451
11452 break;
11453 }
11454 pParam->operationChn = channel;
11455 pParam->sirNwType = nwType;
11456}
11457
Jeff Johnson295189b2012-06-20 16:38:30 -070011458static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11459 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11460{
11461
11462 if( pParam )
11463 {
11464 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011465 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011467 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011468
11469 if( pIes )
11470 {
11471 if(pIes->SuppRates.present)
11472 {
11473 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11474 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011476 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 -070011477 pIes->SuppRates.num_rates);
11478 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11479 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011480 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11481 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 }
11483 if( pIes->SSID.present )
11484 {
11485 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011486 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11487 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011488 }
11489 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 }
11491 else
11492 {
11493 pParam->ssId.length = 0;
11494 pParam->operationalRateSet.numRates = 0;
11495 }
11496 }
11497}
11498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11500{
11501 tANI_U8 MaxRate = 0;
11502 tANI_U32 i;
11503 tANI_U8 *pRate;
11504
11505 pRate = pSirRateSet->rate;
11506 for ( i = 0; i < pSirRateSet->numRates; i++ )
11507 {
11508 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11509 }
11510
11511 // Save the max rate in the connected state information...
11512
11513 // modify LastRates variable as well
11514
11515 return;
11516}
11517
Jeff Johnson295189b2012-06-20 16:38:30 -070011518eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11519 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11520{
11521 eHalStatus status = eHAL_STATUS_SUCCESS;
11522 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 // Set the roaming substate to 'Start BSS attempt'...
11524 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011525#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11526 //Need to figure out whether we need to log WDS???
11527 if( CSR_IS_IBSS( pProfile ) )
11528 {
11529 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11531 if(pIbssLog)
11532 {
11533 if(pBssDesc)
11534 {
11535 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011536 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 }
11538 else
11539 {
11540 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11541 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011542 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 if(pProfile->ChannelInfo.numOfChannels == 0)
11544 {
11545 pIbssLog->channelSetting = AUTO_PICK;
11546 }
11547 else
11548 {
11549 pIbssLog->channelSetting = SPECIFIED;
11550 }
11551 pIbssLog->operatingChannel = pParam->operationChn;
11552 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11553 }
11554 }
11555#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11556 //Put RSN information in for Starting BSS
11557 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11558 pParam->pRSNIE = pProfile->pRSNReqIE;
11559
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 pParam->privacy = pProfile->privacy;
11561 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11562 pParam->authType = pProfile->csr80211AuthType;
11563 pParam->beaconInterval = pProfile->beaconInterval;
11564 pParam->dtimPeriod = pProfile->dtimPeriod;
11565 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11566 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11567 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11568 {
11569 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11570 {
11571 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11572 }
11573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 pParam->protEnabled = pProfile->protEnabled;
11575 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11576 pParam->ht_protection = pProfile->cfg_protection;
11577 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011578
Jeff Johnson295189b2012-06-20 16:38:30 -070011579 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11580 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 pParam->bssPersona = pProfile->csrPersona;
11582 // When starting an IBSS, start on the channel from the Profile.
11583 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 return (status);
11585}
11586
Jeff Johnson295189b2012-06-20 16:38:30 -070011587static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011588 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011589{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011590 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011591 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011593
11594 if(!pSession)
11595 {
11596 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11597 return;
11598 }
11599
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 if( pBssDesc )
11601 {
11602 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11603 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11604 //The following code has to be do after that.
11605 //For WDS station, use selfMac as the self BSSID
11606 if( CSR_IS_WDS_STA( pProfile ) )
11607 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011608 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11609 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 }
11611 }
11612 else
11613 {
11614 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 //Use the first SSID
11616 if(pProfile->SSIDs.numOfSSIDs)
11617 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011618 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11619 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 }
11621 //For WDS station, use selfMac as the self BSSID
11622 if( CSR_IS_WDS_STA( pProfile ) )
11623 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011624 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11625 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011626 }
11627 //Use the first BSSID
11628 else if( pProfile->BSSIDs.numOfBSSIDs )
11629 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011630 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11631 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 }
11633 else
11634 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011635 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 }
11637 }
11638 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 //Set operating channel in pProfile which will be used
11640 //in csrRoamSetBssConfigCfg() to determine channel bonding
11641 //mode and will be configured in CFG later
11642 pProfile->operationChannel = Channel;
11643
11644 if(Channel == 0)
11645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011646 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011647 }
11648 else
11649 {
11650
11651 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011652 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011653 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011654 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011655 {
11656 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11657 }
11658 else
11659 {
11660 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11661 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011662 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011663 pBssConfig->cbMode = cbMode;
11664 pSession->bssParams.cbMode = cbMode;
11665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011666 }
11667}
11668
Jeff Johnson295189b2012-06-20 16:38:30 -070011669static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11670 tANI_BOOLEAN *pfSameIbss )
11671{
11672 eHalStatus status = eHAL_STATUS_SUCCESS;
11673 tANI_BOOLEAN fSameIbss = FALSE;
11674
11675 if ( csrIsConnStateIbss( pMac, sessionId ) )
11676 {
11677 // Check if any profile parameter has changed ? If any profile parameter
11678 // has changed then stop old BSS and start a new one with new parameters
11679 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11680 {
11681 fSameIbss = TRUE;
11682 }
11683 else
11684 {
11685 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11686 }
11687 }
11688 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11689 {
11690 // Disassociate from the connected Infrastructure network...
11691 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11692 }
11693 else
11694 {
11695 tBssConfigParam *pBssConfig;
11696
Kiet Lam64c1b492013-07-12 13:56:44 +053011697 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11698 if ( NULL == pBssConfig )
11699 status = eHAL_STATUS_FAILURE;
11700 else
11701 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 if(HAL_STATUS_SUCCESS(status))
11703 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011704 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 // there is no Bss description before we start an IBSS so we need to adopt
11706 // all Bss configuration parameters from the Profile.
11707 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11708 if(HAL_STATUS_SUCCESS(status))
11709 {
11710 //save dotMode
11711 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11712 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011713 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011714 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11715 NULL, pBssConfig,
11716 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011718
11719 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 }//Allocate memory
11721 }
11722
11723 if(pfSameIbss)
11724 {
11725 *pfSameIbss = fSameIbss;
11726 }
11727 return( status );
11728}
11729
Jeff Johnson295189b2012-06-20 16:38:30 -070011730static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11731 tSirSmeNewBssInfo *pNewBss )
11732{
11733 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011734
11735 if(!pSession)
11736 {
11737 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11738 return;
11739 }
11740
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 if( pNewBss )
11742 {
11743 // Set the operating channel.
11744 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11745 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011746 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11747 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 return;
11750}
11751
Jeff Johnson295189b2012-06-20 16:38:30 -070011752#ifdef FEATURE_WLAN_WAPI
11753eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11754 tANI_U32 numItems )
11755{
11756 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11757 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011760 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011761 return status;
11762 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011763 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 pSession = CSR_GET_SESSION( pMac, sessionId );
11765 if(numItems <= CSR_MAX_BKID_ALLOWED)
11766 {
11767 status = eHAL_STATUS_SUCCESS;
11768 //numItems may be 0 to clear the cache
11769 pSession->NumBkidCache = (tANI_U16)numItems;
11770 if(numItems && pBKIDCache)
11771 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011772 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11773 sizeof(tBkidCacheInfo) * numItems);
11774 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 }
11776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 return (status);
11778}
Jeff Johnson295189b2012-06-20 16:38:30 -070011779eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11780 tBkidCacheInfo *pBkidCache)
11781{
11782 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11783 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011786 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 return status;
11788 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 pSession = CSR_GET_SESSION( pMac, sessionId );
11790 if(pNum && pBkidCache)
11791 {
11792 if(pSession->NumBkidCache == 0)
11793 {
11794 *pNum = 0;
11795 status = eHAL_STATUS_SUCCESS;
11796 }
11797 else if(*pNum >= pSession->NumBkidCache)
11798 {
11799 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011801 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 -070011802 pSession->NumBkidCache);
11803 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11804 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011805 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11806 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 *pNum = pSession->NumBkidCache;
11808 status = eHAL_STATUS_SUCCESS;
11809 }
11810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011812}
Jeff Johnson295189b2012-06-20 16:38:30 -070011813tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11814{
11815 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011816}
11817#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011818eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11819 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11820{
11821 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11822 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011823
11824 if(!pSession)
11825 {
11826 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11827 return eHAL_STATUS_FAILURE;
11828 }
11829
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011830 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11832 {
11833#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11834 {
11835 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011836 vos_mem_set(&secEvent,
11837 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11839 secEvent.encryptionModeMulticast =
11840 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11841 secEvent.encryptionModeUnicast =
11842 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011843 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 secEvent.authMode =
11845 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11846 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11847 }
11848#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 status = eHAL_STATUS_SUCCESS;
11850 //numItems may be 0 to clear the cache
11851 pSession->NumPmkidCache = (tANI_U16)numItems;
11852 if(numItems && pPMKIDCache)
11853 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011854 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11855 sizeof(tPmkidCacheInfo) * numItems);
11856 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 }
11858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 return (status);
11860}
11861
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011862eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11863 tANI_U8 *pBSSId )
11864{
11865 eHalStatus status = eHAL_STATUS_FAILURE;
11866 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11867 tANI_BOOLEAN fMatchFound = FALSE;
11868 tANI_U32 Index;
11869 if(!pSession)
11870 {
11871 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11872 return eHAL_STATUS_FAILURE;
11873 }
11874 do
11875 {
11876 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11877 {
11878 smsLog(pMac, LOGW, "Delete PMKID for %02X-%02X-%02X-%02X-%02X-%02X ",
11879 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
11880 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
11881 {
11882 fMatchFound = TRUE;
11883 break;
11884 }
11885 }
11886 if( !fMatchFound ) break;
11887 palZeroMemory( pMac->hHdd, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo));
11888 status = eHAL_STATUS_SUCCESS;
11889 }
11890 while( 0 );
11891 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11892 fMatchFound, status);
11893 return status;
11894}
Jeff Johnson295189b2012-06-20 16:38:30 -070011895tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11896{
11897 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11898}
11899
Jeff Johnson295189b2012-06-20 16:38:30 -070011900eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11901{
11902 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11903 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011904
11905 if(!pSession)
11906 {
11907 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11908 return eHAL_STATUS_FAILURE;
11909 }
11910
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 if(pNum && pPmkidCache)
11912 {
11913 if(pSession->NumPmkidCache == 0)
11914 {
11915 *pNum = 0;
11916 status = eHAL_STATUS_SUCCESS;
11917 }
11918 else if(*pNum >= pSession->NumPmkidCache)
11919 {
11920 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011922 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 -070011923 pSession->NumPmkidCache);
11924 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11925 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011926 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11927 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 *pNum = pSession->NumPmkidCache;
11929 status = eHAL_STATUS_SUCCESS;
11930 }
11931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 return (status);
11933}
11934
Jeff Johnson295189b2012-06-20 16:38:30 -070011935eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11936{
11937 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11938 tANI_U32 len;
11939 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011940
11941 if(!pSession)
11942 {
11943 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11944 return eHAL_STATUS_FAILURE;
11945 }
11946
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 if(pLen)
11948 {
11949 len = *pLen;
11950 *pLen = pSession->nWpaRsnReqIeLength;
11951 if(pBuf)
11952 {
11953 if(len >= pSession->nWpaRsnReqIeLength)
11954 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011955 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11956 pSession->nWpaRsnReqIeLength);
11957 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 }
11959 }
11960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 return (status);
11962}
11963
Jeff Johnson295189b2012-06-20 16:38:30 -070011964eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11965{
11966 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11967 tANI_U32 len;
11968 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011969
11970 if(!pSession)
11971 {
11972 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11973 return eHAL_STATUS_FAILURE;
11974 }
11975
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 if(pLen)
11977 {
11978 len = *pLen;
11979 *pLen = pSession->nWpaRsnRspIeLength;
11980 if(pBuf)
11981 {
11982 if(len >= pSession->nWpaRsnRspIeLength)
11983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011984 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11985 pSession->nWpaRsnRspIeLength);
11986 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 }
11988 }
11989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 return (status);
11991}
Jeff Johnson295189b2012-06-20 16:38:30 -070011992#ifdef FEATURE_WLAN_WAPI
11993eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11994{
11995 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11996 tANI_U32 len;
11997 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011998
11999 if(!pSession)
12000 {
12001 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12002 return eHAL_STATUS_FAILURE;
12003 }
12004
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 if(pLen)
12006 {
12007 len = *pLen;
12008 *pLen = pSession->nWapiReqIeLength;
12009 if(pBuf)
12010 {
12011 if(len >= pSession->nWapiReqIeLength)
12012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012013 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12014 pSession->nWapiReqIeLength);
12015 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012016 }
12017 }
12018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 return (status);
12020}
Jeff Johnson295189b2012-06-20 16:38:30 -070012021eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12022{
12023 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12024 tANI_U32 len;
12025 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012026
12027 if(!pSession)
12028 {
12029 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12030 return eHAL_STATUS_FAILURE;
12031 }
12032
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 if(pLen)
12034 {
12035 len = *pLen;
12036 *pLen = pSession->nWapiRspIeLength;
12037 if(pBuf)
12038 {
12039 if(len >= pSession->nWapiRspIeLength)
12040 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012041 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12042 pSession->nWapiRspIeLength);
12043 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 }
12045 }
12046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 return (status);
12048}
12049#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012050eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12051{
12052 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12053 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012054
12055 if(!pSession)
12056 {
12057 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12058 return (retStatus);
12059 }
12060
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 if(CSR_IS_ROAMING(pSession))
12062 {
12063 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12064 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 return (retStatus);
12067}
12068
Jeff Johnson295189b2012-06-20 16:38:30 -070012069//This function remove the connected BSS from te cached scan result
12070eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12071 tCsrRoamConnectedProfile *pConnProfile)
12072{
12073 eHalStatus status = eHAL_STATUS_FAILURE;
12074 tCsrScanResultFilter *pScanFilter = NULL;
12075 tListElem *pEntry;
12076 tCsrScanResult *pResult;
12077 tDot11fBeaconIEs *pIes;
12078 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12080 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12081 {
12082 do
12083 {
12084 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012085 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12086 if ( NULL == pScanFilter )
12087 status = eHAL_STATUS_FAILURE;
12088 else
12089 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012091 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12092 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12093 if ( NULL == pScanFilter->BSSIDs.bssid )
12094 status = eHAL_STATUS_FAILURE;
12095 else
12096 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012098 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12099 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12101 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12102 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012103 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12104 if ( NULL == pScanFilter->SSIDs.SSIDList )
12105 status = eHAL_STATUS_FAILURE;
12106 else
12107 status = eHAL_STATUS_SUCCESS;
12108 if (!HAL_STATUS_SUCCESS(status)) break;
12109 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12110 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 }
12112 pScanFilter->authType.numEntries = 1;
12113 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12114 pScanFilter->BSSType = pConnProfile->BSSType;
12115 pScanFilter->EncryptionType.numEntries = 1;
12116 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12117 pScanFilter->mcEncryptionType.numEntries = 1;
12118 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12119 //We ignore the channel for now, BSSID should be enough
12120 pScanFilter->ChannelInfo.numOfChannels = 0;
12121 //Also ignore the following fields
12122 pScanFilter->uapsd_mask = 0;
12123 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12124 pScanFilter->countryCode[0] = 0;
12125 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 csrLLLock(&pMac->scan.scanResultList);
12127 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12128 while( pEntry )
12129 {
12130 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12131 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12132 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12133 pScanFilter, NULL, NULL, NULL, &pIes);
12134 //Release the IEs allocated by csrMatchBSS is needed
12135 if( !pResult->Result.pvIes )
12136 {
12137 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012138 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012139 }
12140 if(fMatch)
12141 {
12142 //We found the one
12143 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12144 {
12145 //Free the memory
12146 csrFreeScanResultEntry( pMac, pResult );
12147 }
12148 break;
12149 }
12150 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12151 }//while
12152 csrLLUnlock(&pMac->scan.scanResultList);
12153 }while(0);
12154 if(pScanFilter)
12155 {
12156 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012157 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 }
12159 }
12160 return (status);
12161}
12162
Jeff Johnson295189b2012-06-20 16:38:30 -070012163//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012164eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12165{
12166 eHalStatus status = eHAL_STATUS_SUCCESS;
12167 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12169 {
12170 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12171 {
12172 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12173 {
12174 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012175 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 status = eHAL_STATUS_CSR_WRONG_STATE;
12177 break;
12178 }
12179 if( csrIsConnStateInfra( pMac, sessionId ) )
12180 {
12181 if( chnId &&
12182 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12183 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012184 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12186 status = eHAL_STATUS_CSR_WRONG_STATE;
12187 break;
12188 }
12189 }
12190 }
12191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 return ( status );
12193}
12194
Jeff Johnson295189b2012-06-20 16:38:30 -070012195static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12196{
12197 eHalStatus status = eHAL_STATUS_SUCCESS;
12198 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12199 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012200
12201 if(!pSession)
12202 {
12203 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12204 return eHAL_STATUS_FAILURE;
12205 }
12206
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 if ( csrIsConnStateIbss( pMac, sessionId ) )
12208 {
12209 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12210 }
12211 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12212 {
12213 // Disassociate from the connected Infrastructure network...
12214 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12215 }
12216 else
12217 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12219 //Otherwise we need to add code to handle the
12220 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12221 //send stop_bss to PE, before we can continue.
12222 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012223 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012225 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12226 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 // there is no Bss description before we start an WDS so we need
12228 // to adopt all Bss configuration parameters from the Profile.
12229 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12230 if(HAL_STATUS_SUCCESS(status))
12231 {
12232 //Save profile for late use
12233 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012234 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12235 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012236 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012237 vos_mem_set(pSession->pCurRoamProfile,
12238 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012242 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012243 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12244 NULL, &bssConfig,
12245 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 }
12247 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012248
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 return( status );
12250}
12251
Jeff Johnson295189b2012-06-20 16:38:30 -070012252////////////////////Mail box
12253
Jeff Johnson295189b2012-06-20 16:38:30 -070012254//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12255//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012256static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12257 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12259{
12260 tCsrChannelSet channelGroup;
12261 tSirMacCapabilityInfo *pAP_capabilityInfo;
12262 tAniBool fTmp;
12263 tANI_BOOLEAN found = FALSE;
12264 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012265 tANI_S8 pwrLimit = 0;
12266 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12268 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12269 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12270 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 // 802.11h
12272 //We can do this because it is in HOST CPU order for now.
12273 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012274 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12275 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12276 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 fTmp = (tAniBool)pal_cpu_to_be32(1);
12278 }
12279 else
12280 fTmp = (tAniBool)0;
12281
12282 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012283 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 pBuf += sizeof(tAniBool);
12285 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012286 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 // This is required for 11k test VoWiFi Ent: Test 2.
12288 // We need the power capabilities for Assoc Req.
12289 // This macro is provided by the halPhyCfg.h. We pick our
12290 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012291 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12292 if (0 != pwrLimit)
12293 {
12294 *pBuf++ = pwrLimit;
12295 }
12296 else
12297 {
12298 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 size = sizeof(pMac->roam.validChannelList);
12301 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12302 {
12303 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12304 for ( i = 0; i < size; i++)
12305 {
12306 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12307
12308 }
12309 }
12310 else
12311 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012312 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 *pBuf++ = 0; //tSirSupChnl->numChnl
12314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 //Check whether it is ok to enter UAPSD
12316#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12317 if( btcIsReadyForUapsd(pMac) )
12318#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12319 {
12320 *pBuf++ = uapsdMask;
12321 }
12322#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12323 else
12324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012325 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 *pBuf++ = 0;
12327 }
12328#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12329
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012331 vos_mem_copy(pBuf, pBssDescription,
12332 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012333 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12334}
12335
Jeff Johnson295189b2012-06-20 16:38:30 -070012336/*
12337 * The communication between HDD and LIM is thru mailbox (MB).
12338 * Both sides will access the data structure "tSirSmeJoinReq".
12339 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12340 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12341 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12342 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12343 */
12344eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012345 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012346{
12347 eHalStatus status = eHAL_STATUS_SUCCESS;
12348 tSirSmeJoinReq *pMsg;
12349 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012350 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012351 tANI_U16 msgLen, wTmp, ieLen;
12352 tSirMacRateSet OpRateSet;
12353 tSirMacRateSet ExRateSet;
12354 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12355 tANI_U32 dwTmp;
12356 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012357 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012358
12359 if(!pSession)
12360 {
12361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12362 return eHAL_STATUS_FAILURE;
12363 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012364 /* To satisfy klockworks */
12365 if (NULL == pBssDescription)
12366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012367 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012368 return eHAL_STATUS_FAILURE;
12369 }
12370
Jeff Johnson295189b2012-06-20 16:38:30 -070012371 do {
12372 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12373 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012374 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12376 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12377 // IE fields, but the length field in the bssDescription needs to be interpreted to
12378 // determine length of the IE fields.
12379 //
12380 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12381 // add in the length from the bssDescription (then add the size of the 'length' field
12382 // itself because that is NOT included in the length field).
12383 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12384 pBssDescription->length + sizeof( pBssDescription->length ) +
12385 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 +053012386 pMsg = vos_mem_malloc(msgLen);
12387 if (NULL == pMsg)
12388 status = eHAL_STATUS_FAILURE;
12389 else
12390 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012392 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012393 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 pMsg->length = pal_cpu_to_be16(msgLen);
12395 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 // sessionId
12397 *pBuf = (tANI_U8)sessionId;
12398 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 // transactionId
12400 *pBuf = 0;
12401 *( pBuf + 1 ) = 0;
12402 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 // ssId
12404 if( pIes->SSID.present && pIes->SSID.num_ssid )
12405 {
12406 // ssId len
12407 *pBuf = pIes->SSID.num_ssid;
12408 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012409 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 pBuf += pIes->SSID.num_ssid;
12411 }
12412 else
12413 {
12414 *pBuf = 0;
12415 pBuf++;
12416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012418 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12419 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012420 pBuf += sizeof(tSirMacAddr);
12421 // bsstype
12422 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12423 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012424 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012425 pBuf += sizeof(tSirBssType);
12426 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012427 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12428 if (pBssDescription->channelId <= 14 &&
12429 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12430 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12431 {
12432 //Need to disable VHT operation in 2.4 GHz band
12433 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12434 }
12435 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 //Persona
12438 *pBuf = (tANI_U8)pProfile->csrPersona;
12439 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012440 //CBMode
12441 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12442 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012443
12444 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012445 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12446
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 // uapsdPerAcBitmask
12448 *pBuf = pProfile->uapsd_mask;
12449 pBuf++;
12450
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012451
12452
Jeff Johnson295189b2012-06-20 16:38:30 -070012453 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012454 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 {
12456 // OperationalRateSet
12457 if (OpRateSet.numRates) {
12458 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012459 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 pBuf += OpRateSet.numRates;
12461 } else *pBuf++ = 0;
12462 // ExtendedRateSet
12463 if (ExRateSet.numRates) {
12464 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012465 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 pBuf += ExRateSet.numRates;
12467 } else *pBuf++ = 0;
12468 }
12469 else
12470 {
12471 *pBuf++ = 0;
12472 *pBuf++ = 0;
12473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012474 // rsnIE
12475 if ( csrIsProfileWpa( pProfile ) )
12476 {
12477 // Insert the Wpa IE into the join request
12478 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12479 (tCsrWpaIe *)( wpaRsnIE ) );
12480 }
12481 else if( csrIsProfileRSN( pProfile ) )
12482 {
12483 // Insert the RSN IE into the join request
12484 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12485 (tCsrRSNIe *)( wpaRsnIE ) );
12486 }
12487#ifdef FEATURE_WLAN_WAPI
12488 else if( csrIsProfileWapi( pProfile ) )
12489 {
12490 // Insert the WAPI IE into the join request
12491 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12492 (tCsrWapiIe *)( wpaRsnIE ) );
12493 }
12494#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012495 else
12496 {
12497 ieLen = 0;
12498 }
12499 //remember the IE for future use
12500 if( ieLen )
12501 {
12502 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012504 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 -070012505 ieLen = DOT11F_IE_RSN_MAX_LEN;
12506 }
12507#ifdef FEATURE_WLAN_WAPI
12508 if( csrIsProfileWapi( pProfile ) )
12509 {
12510 //Check whether we need to allocate more memory
12511 if(ieLen > pSession->nWapiReqIeLength)
12512 {
12513 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12514 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012515 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012517 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12518 if (NULL == pSession->pWapiReqIE)
12519 status = eHAL_STATUS_FAILURE;
12520 else
12521 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 if(!HAL_STATUS_SUCCESS(status)) break;
12523 }
12524 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012525 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012527 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012529 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 pBuf += ieLen;
12531 }
12532 else//should be WPA/WPA2 otherwise
12533#endif /* FEATURE_WLAN_WAPI */
12534 {
12535 //Check whether we need to allocate more memory
12536 if(ieLen > pSession->nWpaRsnReqIeLength)
12537 {
12538 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12539 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012540 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012542 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12543 if (NULL == pSession->pWpaRsnReqIE)
12544 status = eHAL_STATUS_FAILURE;
12545 else
12546 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 if(!HAL_STATUS_SUCCESS(status)) break;
12548 }
12549 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012550 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012552 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012554 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 pBuf += ieLen;
12556 }
12557 }
12558 else
12559 {
12560 //free whatever old info
12561 pSession->nWpaRsnReqIeLength = 0;
12562 if(pSession->pWpaRsnReqIE)
12563 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012564 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 pSession->pWpaRsnReqIE = NULL;
12566 }
12567#ifdef FEATURE_WLAN_WAPI
12568 pSession->nWapiReqIeLength = 0;
12569 if(pSession->pWapiReqIE)
12570 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012571 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 pSession->pWapiReqIE = NULL;
12573 }
12574#endif /* FEATURE_WLAN_WAPI */
12575 //length is two bytes
12576 *pBuf = 0;
12577 *(pBuf + 1) = 0;
12578 pBuf += 2;
12579 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012580#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012581 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012583 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 //length is two bytes
12585 *pBuf = 0;
12586 *(pBuf + 1) = 0;
12587 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012588 }
12589 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012591 // cckmIE
12592 if( csrIsProfileCCX( pProfile ) )
12593 {
12594 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012595#ifdef FEATURE_WLAN_CCX_UPLOAD
12596 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12597 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12598 pSession->suppCckmIeInfo.cckmIe, ieLen);
12599#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012600 ieLen = csrConstructCcxCckmIe( pMac,
12601 pSession,
12602 pProfile,
12603 pBssDescription,
12604 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 pSession->nWpaRsnReqIeLength,
12606 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012607#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012608 }
12609 else
12610 {
12611 ieLen = 0;
12612 }
12613 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12614 if( ieLen )
12615 {
12616 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12617 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012618 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012619 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012620 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012621 pBuf += ieLen;
12622 }
12623 else
12624 {
12625 //Indicate you have no CCKM IE
12626 //length is two bytes
12627 *pBuf = 0;
12628 *(pBuf + 1) = 0;
12629 pBuf += 2;
12630 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 }
12632#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 // addIEScan
12634 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12635 {
12636 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 if(ieLen > pSession->nAddIEScanLength)
12638 {
12639 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12640 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012641 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012643 pSession->pAddIEScan = vos_mem_malloc(ieLen);
12644 if (NULL == pSession->pAddIEScan)
12645 status = eHAL_STATUS_FAILURE;
12646 else
12647 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 if(!HAL_STATUS_SUCCESS(status)) break;
12649 }
12650 pSession->nAddIEScanLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012651 vos_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012653 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012655 vos_mem_copy(pBuf, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 pBuf += ieLen;
12657 }
12658 else
12659 {
12660 pSession->nAddIEScanLength = 0;
12661 if(pSession->pAddIEScan)
12662 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012663 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 pSession->pAddIEScan = NULL;
12665 }
12666 *pBuf = 0;
12667 *(pBuf + 1) = 0;
12668 pBuf += 2;
12669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 // addIEAssoc
12671 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12672 {
12673 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 if(ieLen > pSession->nAddIEAssocLength)
12675 {
12676 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012677 {
12678 vos_mem_free(pSession->pAddIEAssoc);
12679 }
12680 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12681 if (NULL == pSession->pAddIEAssoc)
12682 status = eHAL_STATUS_FAILURE;
12683 else
12684 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012687 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012688 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012690 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012692 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012693 pBuf += ieLen;
12694 }
12695 else
12696 {
12697 pSession->nAddIEAssocLength = 0;
12698 if(pSession->pAddIEAssoc)
12699 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012700 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 pSession->pAddIEAssoc = NULL;
12702 }
12703 *pBuf = 0;
12704 *(pBuf + 1) = 0;
12705 pBuf += 2;
12706 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012707
12708 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012709 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012710 //Unmask any AC in reassoc that is ACM-set
12711 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12712 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012714 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12715 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012716#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012717 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012718#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012719 uapsd_mask &= ~(acm_mask);
12720 }
12721 else
12722 {
12723 uapsd_mask = 0;
12724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 }
12726 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012727
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012729 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012730 pBuf += sizeof(tANI_U32);
12731
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012733 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012734 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012735#ifdef WLAN_FEATURE_11W
12736 //MgmtEncryption
12737 if (pProfile->MFPEnabled)
12738 {
12739 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12740 }
12741 else
12742 {
12743 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12744 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012745 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012746 pBuf += sizeof(tANI_U32);
12747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012748#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012749 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012750 if (csrIsProfile11r( pProfile )
12751#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012752 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12753 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012754#endif
12755 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012756 {
12757 // is11Rconnection;
12758 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012759 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012760 pBuf += sizeof(tAniBool);
12761 }
12762 else
12763 {
12764 // is11Rconnection;
12765 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012766 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012767 pBuf += sizeof(tAniBool);
12768 }
12769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012770#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012771
12772 // isCCXFeatureIniEnabled
12773 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12774 {
12775 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012776 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012777 pBuf += sizeof(tAniBool);
12778 }
12779 else
12780 {
12781 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012782 vos_mem_copy(pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012783 pBuf += sizeof(tAniBool);
12784 }
12785
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012786 /* A profile can not be both CCX and 11R. But an 802.11R AP
12787 * may be advertising support for CCX as well. So if we are
12788 * associating Open or explicitly CCX then we will get CCX.
12789 * If we are associating explictly 11R only then we will get
12790 * 11R.
12791 */
12792 if ((csrIsProfileCCX(pProfile) ||
12793 ((pIes->CCXVersion.present)
12794 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012795 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12796 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12797 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012798#ifdef WLAN_FEATURE_11W
12799 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12800#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012801 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012802 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12803 {
12804 // isCCXconnection;
12805 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012806 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012807 pBuf += sizeof(tAniBool);
12808 }
12809 else
12810 {
12811 //isCCXconnection;
12812 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012813 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012814 pBuf += sizeof(tAniBool);
12815 }
12816
12817 if (eWNI_SME_JOIN_REQ == messageType)
12818 {
12819 tCCXTspecInfo ccxTspec;
12820 // CCX-Tspec IEs in the ASSOC request is presently not supported
12821 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012822 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12823 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012824 pBuf += sizeof(tCCXTspecInfo);
12825 }
12826 else if (eWNI_SME_REASSOC_REQ == messageType)
12827 {
12828 if ((csrIsProfileCCX(pProfile) ||
12829 ((pIes->CCXVersion.present)
12830 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012831 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12832 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12833 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012834#ifdef WLAN_FEATURE_11W
12835 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12836#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012837 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012838 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 {
12840 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012842 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12844 *pBuf = ccxTspec.numTspecs;
12845 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 // Copy the TSPEC information only if present
12847 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012848 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12849 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 }
12851 pBuf += sizeof(ccxTspec.tspec);
12852 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012853 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 tCCXTspecInfo ccxTspec;
12856 // CCX-Tspec IEs in the ASSOC request is presently not supported
12857 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012858 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12859 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 pBuf += sizeof(tCCXTspecInfo);
12861 }
12862 }
12863#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012864#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012866 if (pMac->roam.configParam.isFastTransitionEnabled
12867#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012868 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012869#endif
12870 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012872 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012873 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012874 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 }
12876 else
12877 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012878 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012879 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012880 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 }
12882#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012883#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012884 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012885 {
12886 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012887 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012888 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012889 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012890 }
12891 else
12892 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012893 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012894 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012895 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012896 }
12897#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012898
12899 // txLdpcIniFeatureEnabled
12900 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12901 pBuf++;
12902
Kiran4a17ebe2013-01-31 10:43:43 -080012903 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12904 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12905 {
12906 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12907 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12908 csrApplyPower2Current(pMac);
12909 }
12910
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012911#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012912 // txBFIniFeatureEnabled
12913 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12914 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012915
12916 // txBFCsnValue
12917 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12918 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012919#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012920 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12921 pBuf++;
12922
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012923 //BssDesc
12924 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12925 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012926
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012927 status = palSendMBMessage(pMac->hHdd, pMsg );
12928 if(!HAL_STATUS_SUCCESS(status))
12929 {
12930 break;
12931 }
12932 else
12933 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012934#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012935 if (eWNI_SME_JOIN_REQ == messageType)
12936 {
12937 //Tush-QoS: notify QoS module that join happening
12938 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12939 }
12940 else if (eWNI_SME_REASSOC_REQ == messageType)
12941 {
12942 //Tush-QoS: notify QoS module that reassoc happening
12943 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012945#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012949}
12950
Jeff Johnson295189b2012-06-20 16:38:30 -070012951//
12952eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12953{
12954 eHalStatus status = eHAL_STATUS_SUCCESS;
12955 tSirSmeDisassocReq *pMsg;
12956 tANI_U8 *pBuf;
12957 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12959 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12960 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012962 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12963 if (NULL == pMsg)
12964 status = eHAL_STATUS_FAILURE;
12965 else
12966 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012968 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12970 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 pBuf = &pMsg->sessionId;
12972 // sessionId
12973 *pBuf++ = (tANI_U8)sessionId;
12974 // transactionId
12975 *pBuf = 0;
12976 *( pBuf + 1 ) = 0;
12977 pBuf += sizeof(tANI_U16);
12978
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012979 if ( (pSession->pCurRoamProfile != NULL) &&
12980 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12981 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 {
12983 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012984 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12985 sizeof( tSirMacAddr ));
12986 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 pBuf = pBuf + sizeof ( tSirMacAddr );
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 //perMacAddr is passed as bssId for softAP
12991 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 pBuf = pBuf + sizeof ( tSirMacAddr );
12993 }
12994 else
12995 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012997 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12998 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013000 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13001 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013002 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 if(!HAL_STATUS_SUCCESS(status))
13005 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013006 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013007 break;
13008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 // reasonCode
13010 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013011 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13012 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 if(!HAL_STATUS_SUCCESS(status))
13014 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013015 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 break;
13017 }
13018 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13020 Here we should not send the disassoc over the air to the AP */
13021 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13022#ifdef WLAN_FEATURE_VOWIFI_11R
13023 && csrRoamIs11rAssoc(pMac)
13024#endif
13025 )
13026 {
13027 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13028 }
13029 pBuf += sizeof(tANI_U8);
13030 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013032 return( status );
13033}
Jeff Johnson295189b2012-06-20 16:38:30 -070013034eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13035{
13036 eHalStatus status = eHAL_STATUS_SUCCESS;
13037 tSirSmeTkipCntrMeasReq *pMsg;
13038 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 do
13040 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013041 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13042 if ( NULL == pMsg )
13043 status = eHAL_STATUS_FAILURE;
13044 else
13045 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013047 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13049 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 pBuf = &pMsg->sessionId;
13051 // sessionId
13052 *pBuf++ = (tANI_U8)sessionId;
13053 // transactionId
13054 *pBuf = 0;
13055 *( pBuf + 1 ) = 0;
13056 pBuf += sizeof(tANI_U16);
13057 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013058 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13059 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 pBuf = pBuf + sizeof ( tSirMacAddr );
13061 // bEnable
13062 *pBuf = (tANI_BOOLEAN)bEnable;
13063 if(!HAL_STATUS_SUCCESS(status))
13064 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013065 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 break;
13067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 return( status );
13071}
Jeff Johnson295189b2012-06-20 16:38:30 -070013072eHalStatus
13073csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13074 VOS_MODULE_ID modId, tSirMacAddr bssId,
13075 void *pUsrContext, void *pfnSapEventCallback,
13076 tANI_U8 *pAssocStasBuf )
13077{
13078 eHalStatus status = eHAL_STATUS_SUCCESS;
13079 tSirSmeGetAssocSTAsReq *pMsg;
13080 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13081 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 do
13083 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013084 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13085 if ( NULL == pMsg )
13086 status = eHAL_STATUS_FAILURE;
13087 else
13088 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013090 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 pBuf = (tANI_U8 *)&pMsg->bssId;
13093 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013095 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 // modId
13098 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013099 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 // pUsrContext
13102 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
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 // pfnSapEventCallback
13106 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013107 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 // pAssocStasBuf
13110 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013111 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 status = palSendMBMessage( pMac->hHdd, pMsg );
13115 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 return( status );
13117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013118eHalStatus
13119csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13120 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13121 {
13122 eHalStatus status = eHAL_STATUS_SUCCESS;
13123 tSirSmeGetWPSPBCSessionsReq *pMsg;
13124 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13125 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 do
13127 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013128 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13129 if ( NULL == pMsg )
13130 status = eHAL_STATUS_FAILURE;
13131 else
13132 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013134 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013137 VOS_ASSERT(pBuf);
13138
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 // pUsrContext
13141 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013142 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 // pSapEventCallback
13145 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013146 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013149 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013152 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013157 return( status );
13158}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013159
13160eHalStatus
13161csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13162{
13163 tpSirChangeBIParams pMsg;
13164 tANI_U16 len = 0;
13165 eHalStatus status = eHAL_STATUS_SUCCESS;
13166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13167
13168 if(!pSession)
13169 {
13170 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13171 return eHAL_STATUS_FAILURE;
13172 }
13173
13174 //NO need to update the Beacon Params if update beacon parameter flag is not set
13175 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13176 return eHAL_STATUS_SUCCESS;
13177
13178 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13179
13180 /* Create the message and send to lim */
13181 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013182 pMsg = vos_mem_malloc(len);
13183 if ( NULL == pMsg )
13184 status = eHAL_STATUS_FAILURE;
13185 else
13186 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013187 if(HAL_STATUS_SUCCESS(status))
13188 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013190 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13191 pMsg->length = len;
13192
13193 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013194 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13195 sizeof(tSirMacAddr));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013196 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 -080013197 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
13198 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
13199 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013200 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013201 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13202 status = palSendMBMessage(pMac->hHdd, pMsg);
13203 }
13204 return status;
13205}
13206
Jeff Johnson295189b2012-06-20 16:38:30 -070013207eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13208{
13209 eHalStatus status = eHAL_STATUS_SUCCESS;
13210 tSirSmeDeauthReq *pMsg;
13211 tANI_U8 *pBuf;
13212 tANI_U16 wTmp;
13213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13214 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13215 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013217 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13218 if ( NULL == pMsg )
13219 status = eHAL_STATUS_FAILURE;
13220 else
13221 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013223 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13225 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13226 //sessionId
13227 pBuf = &pMsg->sessionId;
13228 *pBuf++ = (tANI_U8)sessionId;
13229
13230 //tansactionId
13231 *pBuf = 0;
13232 *(pBuf + 1 ) = 0;
13233 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13237 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013238 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13239 sizeof( pMsg->peerMacAddr ) );
13240 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 pBuf = pBuf + sizeof(tSirMacAddr);
13242 }
13243 else
13244 {
13245 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013246 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13247 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 }
13250 if(!HAL_STATUS_SUCCESS(status))
13251 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013252 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 break;
13254 }
13255 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013256 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13257 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 pBuf = pBuf + sizeof(tSirMacAddr);
13259 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 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013265 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13266 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 if(!HAL_STATUS_SUCCESS(status))
13268 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013269 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 break;
13271 }
13272 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 return( status );
13275}
13276
Jeff Johnson295189b2012-06-20 16:38:30 -070013277eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13278{
13279 eHalStatus status = eHAL_STATUS_SUCCESS;
13280 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013282 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13283 if ( NULL == pMsg )
13284 status = eHAL_STATUS_FAILURE;
13285 else
13286 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013288 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13290 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13291 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013292 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13293 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
Kiet Lam64c1b492013-07-12 13:56:44 +053013301 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13302 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 if(!HAL_STATUS_SUCCESS(status))
13304 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013305 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 break;
13307 }
13308//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 return( status );
13312}
13313
Jeff Johnson295189b2012-06-20 16:38:30 -070013314eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13315{
13316 eHalStatus status = eHAL_STATUS_SUCCESS;
13317 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013319 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13320 if ( NULL == pMsg )
13321 status = eHAL_STATUS_FAILURE;
13322 else
13323 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13327 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13328 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013329 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
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 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013336 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13337 sizeof(pMsg->peerMacAddr));
13338 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 if(!HAL_STATUS_SUCCESS(status))
13340 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013341 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 break;
13343 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 return( status );
13347}
Jeff Johnson295189b2012-06-20 16:38:30 -070013348eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13349{
13350 eHalStatus status = eHAL_STATUS_SUCCESS;
13351 tSirSmeAssocCnf *pMsg;
13352 tANI_U8 *pBuf;
13353 tSirResultCodes statusCode;
13354 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013356 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13357 if ( NULL == pMsg )
13358 status = eHAL_STATUS_FAILURE;
13359 else
13360 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013362 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13364 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 pBuf = (tANI_U8 *)&pMsg->statusCode;
13366 if(HAL_STATUS_SUCCESS(Halstatus))
13367 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13368 else
13369 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013370 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 pBuf += sizeof(tSirResultCodes);
13372 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013373 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13374 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 pBuf += sizeof (tSirMacAddr);
13376 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013377 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13378 sizeof(tSirMacAddr));
13379 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 pBuf += sizeof (tSirMacAddr);
13381 // aid
13382 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013383 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 pBuf += sizeof (tANI_U16);
13385 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013386 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13387 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 pBuf += sizeof (tSirMacAddr);
13389 // alternateChannelId
13390 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 status = palSendMBMessage( pMac->hHdd, pMsg );
13392 if(!HAL_STATUS_SUCCESS(status))
13393 {
13394 //pMsg is freed by palSendMBMessage
13395 break;
13396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 return( status );
13399}
Jeff Johnson295189b2012-06-20 16:38:30 -070013400eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13401 tpSirSmeAssocInd pAssocInd,
13402 eHalStatus Halstatus,
13403 tANI_U8 sessionId)
13404{
13405 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13407 tANI_U8 *pBuf;
13408 tSirResultCodes statusCode;
13409 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13412 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13413 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013414
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13416 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13417
13418 pMsg->sessionId = sessionId;
13419
13420 pBuf = (tANI_U8 *)&pMsg->statusCode;
13421 if(HAL_STATUS_SUCCESS(Halstatus))
13422 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13423 else
13424 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013425 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 pBuf += sizeof(tSirResultCodes);
13427 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013428 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 pBuf += sizeof (tSirMacAddr);
13430 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013431 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13432 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 pBuf += sizeof (tSirMacAddr);
13434 // StaId
13435 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013436 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 pBuf += sizeof (tANI_U16);
13438 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013439 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 pBuf += sizeof (tSirMacAddr);
13441 // alternateChannelId
13442 *pBuf = 11;
13443 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013444 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 //Wmm
13446 *pBuf = pAssocInd->wmmEnabledSta;
13447 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013449 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013452 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 //reassocReq
13455 *pBuf = pAssocInd->reassocReq;
13456 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13458 msgQ.bodyptr = pMsg;
13459 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013462 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013463}
Jeff Johnson295189b2012-06-20 16:38:30 -070013464
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013465eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13467 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13468 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13469 tANI_U8 *pKeyRsc )
13470{
13471 tSirSmeSetContextReq *pMsg;
13472 tANI_U16 msgLen;
13473 eHalStatus status = eHAL_STATUS_FAILURE;
13474 tAniEdType tmpEdType;
13475 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013476 tANI_U8 *pBuf = NULL;
13477 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13482 // key set. Since we only support upto one key, we always allocate memory for 1 key
13483 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13484 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13485 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13486 ( sizeof( pMsg->keyMaterial.key ) );
13487
Kiet Lam64c1b492013-07-12 13:56:44 +053013488 pMsg = vos_mem_malloc(msgLen);
13489 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13490 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13492 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 //sessionId
13494 pBuf = &pMsg->sessionId;
13495 *pBuf = (tANI_U8)sessionId;
13496 pBuf++;
13497 // transactionId
13498 *pBuf = 0;
13499 *(pBuf + 1) = 0;
13500 pBuf += sizeof(tANI_U16);
13501 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013502 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013503
13504 pBuf += sizeof(tSirMacAddr);
13505
13506 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013507 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13508 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013509
13510 pBuf += sizeof(tSirMacAddr);
13511
13512 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13514 // in the tSirKeyMaterial keyMaterial; field).
13515 //
13516 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13517 // shorter than this max size. Is LIM interpreting this ok ?
13518 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 -070013519 // set pMsg->keyMaterial.edType
13520 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013521 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 // set the pMsg->keyMaterial.numKeys field
13524 *p = numKeys;
13525 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 // set pSirKey->keyId = keyId;
13527 *p = keyId;
13528 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 // set pSirKey->unicast = (tANI_U8)fUnicast;
13530 *p = (tANI_U8)fUnicast;
13531 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 // set pSirKey->keyDirection = aniKeyDirection;
13533 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013534 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 p += sizeof(tAniKeyDirection);
13536 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013537 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 // set pSirKey->paeRole
13540 *p = paeRole; // 0 is Supplicant
13541 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 // set pSirKey->keyLength = keyLength;
13543 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 if ( keyLength && pKey )
13545 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013546 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 if(keyLength == 16)
13548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013549 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 -070013550 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13551 pKey[5], pKey[6], pKey[7], pKey[8],
13552 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13553 }
13554 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 return( status );
13558}
13559
Jeff Johnson295189b2012-06-20 16:38:30 -070013560eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13561 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13562{
13563 eHalStatus status;
13564 tSirSmeStartBssReq *pMsg;
13565 tANI_U8 *pBuf = NULL;
13566 tANI_U8 *wTmpBuf = NULL;
13567 tANI_U16 msgLen, wTmp;
13568 tANI_U32 dwTmp;
13569 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013570 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013573
13574 if(!pSession)
13575 {
13576 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13577 return eHAL_STATUS_FAILURE;
13578 }
13579
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 do {
13581 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13582 pSession->joinFailStatusCode.reasonCode = 0;
13583 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013584 pMsg = vos_mem_malloc(msgLen);
13585 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13586 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 //sessionId
13591 *pBuf = (tANI_U8)sessionId;
13592 pBuf++;
13593 // transactionId
13594 *pBuf = 0;
13595 *(pBuf + 1) = 0;
13596 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013598 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 pBuf += sizeof(tSirMacAddr);
13600 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013601 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 pBuf += sizeof(tSirMacAddr);
13603 // beaconInterval
13604 if( pBssDesc && pBssDesc->beaconInterval )
13605 {
13606 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 else if(pParam->beaconInterval)
13609 {
13610 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 else
13613 {
13614 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13615 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013616 if(csrIsconcurrentsessionValid (pMac, sessionId,
13617 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013618 == eHAL_STATUS_SUCCESS )
13619 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013620 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013621 pParam->bssPersona);
13622 //Update the beacon Interval
13623 pParam->beaconInterval = wTmp;
13624 }
13625 else
13626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013627 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013628 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013629 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013630 return status;
13631 }
13632
Kiet Lam64c1b492013-07-12 13:56:44 +053013633 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 pBuf += sizeof(tANI_U16);
13635 // dot11mode
13636 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13637 pBuf += 1;
13638 // bssType
13639 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013640 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 pBuf += sizeof(tSirBssType);
13642 // ssId
13643 if( pParam->ssId.length )
13644 {
13645 // ssId len
13646 *pBuf = pParam->ssId.length;
13647 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013648 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 pBuf += pParam->ssId.length;
13650 }
13651 else
13652 {
13653 *pBuf = 0;
13654 pBuf++;
13655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 // set the channel Id
13657 *pBuf = pParam->operationChn;
13658 pBuf++;
13659 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013660 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013661 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013662 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013663
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 // Set privacy
13665 *pBuf = pParam->privacy;
13666 pBuf++;
13667
13668 //Set Uapsd
13669 *pBuf = pParam->ApUapsdEnable;
13670 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 //Set SSID hidden
13672 *pBuf = pParam->ssidHidden;
13673 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13675 pBuf++;
13676
13677 //Ht protection Enable/Disable
13678 *pBuf = (tANI_U8)pParam->protEnabled;
13679 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 //Enable Beacons to Receive for OBSS protection Enable/Disable
13681 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13682 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 //set cfg related to protection
13684 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013685 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 // Set Auth type
13688 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013689 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 // Set DTIM
13692 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013693 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 // Set wps_state
13696 *pBuf = pParam->wps_state;
13697 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013698 //Persona
13699 *pBuf = (tANI_U8)pParam->bssPersona;
13700 pBuf++;
13701
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013702 //txLdpcIniFeatureEnabled
13703 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13704 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013705
krunal soni4f087d22013-07-29 16:32:26 -070013706 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13708 {
13709 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013710 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013711 break;
13712 }
13713 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013714 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 pBuf += sizeof(tANI_U16);
13716 if( wTmp )
13717 {
13718 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 pBuf += wTmp;
13721 }
13722 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013723 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13726 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013727 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13728 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 pBuf += pParam->operationalRateSet.numRates ;
13730 *pBuf++ = pParam->extendedRateSet.numRates;
13731 if(0 != pParam->extendedRateSet.numRates)
13732 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013733 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13734 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 pBuf += pParam->extendedRateSet.numRates;
13736 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13738 pMsg->length = pal_cpu_to_be16(msgLen);
13739
13740 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 return( status );
13743}
13744
Jeff Johnson295189b2012-06-20 16:38:30 -070013745eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13746{
13747 eHalStatus status = eHAL_STATUS_FAILURE;
13748 tSirSmeStopBssReq *pMsg;
13749 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13750 tANI_U8 *pBuf;
13751 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013752
13753 if(!pSession)
13754 {
13755 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13756 return eHAL_STATUS_FAILURE;
13757 }
13758
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013760 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13761 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13762 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13764 pBuf = &pMsg->sessionId;
13765 //sessionId
13766 *pBuf = (tANI_U8)sessionId;
13767 pBuf++;
13768 // transactionId
13769 *pBuf = 0;
13770 pBuf += sizeof(tANI_U16);
13771 //reason code
13772 *pBuf = 0;
13773 pBuf += sizeof(tSirResultCodes);
13774 // bssid
13775 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13776 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13777 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13779 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 }
13781 else
13782 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013783 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13784 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 }
13786 pBuf += sizeof(tSirMacAddr);
13787 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13788 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 status = palSendMBMessage( pMac->hHdd, pMsg );
13790#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013791 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13792 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13793 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13795 pMsg->reasonCode = 0;
13796 // bssid
13797 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13798 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13799 {
13800 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13801 }
13802 else
13803 {
13804 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13805 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013806 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 pMsg->transactionId = 0;
13808 pMsg->sessionId = (tANI_U8)sessionId;
13809 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13810 status = palSendMBMessage( pMac->hHdd, pMsg );
13811#endif
13812 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 return( status );
13814}
13815
Jeff Johnson295189b2012-06-20 16:38:30 -070013816eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13817 tCsrRoamModifyProfileFields *pModProfileFields,
13818 tANI_U32 *pRoamId, v_BOOL_t fForce)
13819{
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 eHalStatus status = eHAL_STATUS_FAILURE;
13821 tANI_U32 roamId = 0;
13822 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013824 (fForce || (!vos_mem_compare( &pModProfileFields,
13825 &pSession->connectedProfile.modifyProfileFields,
13826 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 {
13828 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13829 if(pRoamId)
13830 {
13831 *pRoamId = roamId;
13832 }
13833
Jeff Johnson295189b2012-06-20 16:38:30 -070013834 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13835 eCsrSmeIssuedReassocToSameAP, roamId,
13836 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 return status;
13839}
Jeff Johnson295189b2012-06-20 16:38:30 -070013840static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13841{
13842 eHalStatus status = eHAL_STATUS_SUCCESS;
13843 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013844 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13846 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13847 return (status);
13848}
Jeff Johnson295189b2012-06-20 16:38:30 -070013849eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13850{
13851 eHalStatus status = eHAL_STATUS_SUCCESS;
13852 tListElem *pEntry = NULL;
13853 tSmeCmd *pCommand = NULL;
13854 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 do
13856 {
13857 if(pMsg == NULL)
13858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013859 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013860 status = eHAL_STATUS_FAILURE;
13861 break;
13862 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13864 if(pEntry)
13865 {
13866 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13867 if(eSmeCommandAddStaSession == pCommand->command)
13868 {
13869 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013870 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 //Remove this command out of the active list
13874 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13875 {
13876 //Now put this command back on the avilable command list
13877 csrReleaseCommand(pMac, pCommand);
13878 }
13879 smeProcessPendingQueue( pMac );
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 Add sta session command 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 }
13889 else
13890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013891 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 -070013892 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 status = eHAL_STATUS_FAILURE;
13894 break;
13895 }
13896 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013898}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013899eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13900 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013901{
13902 tSirSmeAddStaSelfReq *pMsg;
13903 tANI_U16 msgLen;
13904 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013906 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013907 pMsg = vos_mem_malloc(msgLen);
13908 if ( NULL == pMsg ) break;
13909 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13911 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013914 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13915
13916 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13917
13918 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 pMsg->selfMacAddr[0],
13920 pMsg->selfMacAddr[1],
13921 pMsg->selfMacAddr[2],
13922 pMsg->selfMacAddr[3],
13923 pMsg->selfMacAddr[4],
13924 pMsg->selfMacAddr[5]);
13925 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 return( status );
13928}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013929eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13930 tANI_U32 sessionId,
13931 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013932{
13933 eHalStatus status = eHAL_STATUS_SUCCESS;
13934 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 pCommand = csrGetCommandBuffer(pMac);
13936 if(NULL == pCommand)
13937 {
13938 status = eHAL_STATUS_RESOURCES;
13939 }
13940 else
13941 {
13942 pCommand->command = eSmeCommandAddStaSession;
13943 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013944 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13945 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013946 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13948 if( !HAL_STATUS_SUCCESS( status ) )
13949 {
13950 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013951 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 }
13953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 return (status);
13955}
Jeff Johnson295189b2012-06-20 16:38:30 -070013956eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13957{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013958 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013959}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013960eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13961 csrRoamCompleteCallback callback,
13962 void *pContext, tANI_U8 *pSelfMacAddr,
13963 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013964{
13965 eHalStatus status = eHAL_STATUS_SUCCESS;
13966 tANI_U32 i;
13967 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 *pbSessionId = CSR_SESSION_ID_INVALID;
13969 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13970 {
13971 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13972 {
13973 pSession = CSR_GET_SESSION( pMac, i );
13974 status = eHAL_STATUS_SUCCESS;
13975 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13976 pSession->sessionId = (tANI_U8)i;
13977 pSession->callback = callback;
13978 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013979 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013981 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13982 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013984 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013986 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 break;
13988 }
13989#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013990 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13991 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013993 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013995 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 break;
13997 }
13998#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013999 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 break;
14001 }
14002 }
14003 if( CSR_ROAM_SESSION_MAX == i )
14004 {
14005 //No session is available
14006 status = eHAL_STATUS_RESOURCES;
14007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 return ( status );
14009}
Jeff Johnson295189b2012-06-20 16:38:30 -070014010eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14011{
14012 eHalStatus status = eHAL_STATUS_SUCCESS;
14013 tListElem *pEntry = NULL;
14014 tSmeCmd *pCommand = NULL;
14015 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 do
14017 {
14018 if(pMsg == NULL)
14019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014020 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 status = eHAL_STATUS_FAILURE;
14022 break;
14023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14025 if(pEntry)
14026 {
14027 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14028 if(eSmeCommandDelStaSession == pCommand->command)
14029 {
14030 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014032 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 //This session is done.
14034 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 if(pCommand->u.delStaSessionCmd.callback)
14036 {
14037
14038 status = sme_ReleaseGlobalLock( &pMac->sme );
14039 if ( HAL_STATUS_SUCCESS( status ) )
14040 {
14041 pCommand->u.delStaSessionCmd.callback(
14042 pCommand->u.delStaSessionCmd.pContext);
14043 status = sme_AcquireGlobalLock( &pMac->sme );
14044 if (! HAL_STATUS_SUCCESS( status ) )
14045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014046 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 return status;
14048 }
14049 }
14050 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014051 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 }
14053 }
14054
14055 //Remove this command out of the active list
14056 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14057 {
14058 //Now put this command back on the avilable command list
14059 csrReleaseCommand(pMac, pCommand);
14060 }
14061 smeProcessPendingQueue( pMac );
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 Del sta session command 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 }
14071 else
14072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014073 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 -070014074 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 status = eHAL_STATUS_FAILURE;
14076 break;
14077 }
14078 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014080}
Jeff Johnson295189b2012-06-20 16:38:30 -070014081eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14082{
14083 tSirSmeDelStaSelfReq *pMsg;
14084 tANI_U16 msgLen;
14085 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14088 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014089 pMsg = vos_mem_malloc(msgLen);
14090 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14091 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14093 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014095 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14096 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014098 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 return( status );
14100}
Jeff Johnson295189b2012-06-20 16:38:30 -070014101eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14102 tSirMacAddr sessionMacAddr,
14103 csrRoamSessionCloseCallback callback,
14104 void *pContext)
14105{
14106 eHalStatus status = eHAL_STATUS_SUCCESS;
14107 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 pCommand = csrGetCommandBuffer(pMac);
14109 if(NULL == pCommand)
14110 {
14111 status = eHAL_STATUS_RESOURCES;
14112 }
14113 else
14114 {
14115 pCommand->command = eSmeCommandDelStaSession;
14116 pCommand->sessionId = (tANI_U8)sessionId;
14117 pCommand->u.delStaSessionCmd.callback = callback;
14118 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014119 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14120 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14122 if( !HAL_STATUS_SUCCESS( status ) )
14123 {
14124 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014125 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 }
14127 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 return (status);
14129}
Jeff Johnson295189b2012-06-20 16:38:30 -070014130eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14131{
14132 return csrSendMBDelSelfStaReqMsg( pMac,
14133 pCommand->u.delStaSessionCmd.selfMacAddr );
14134}
Jeff Johnson295189b2012-06-20 16:38:30 -070014135static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14136{
14137 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14138 tListElem *pEntry, *pNext;
14139 tSmeCmd *pCommand;
14140 tDblLinkList localList;
14141
14142 vos_mem_zero(&localList, sizeof(tDblLinkList));
14143 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14144 {
14145 smsLog(pMac, LOGE, FL(" failed to open list"));
14146 return;
14147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 csrLLLock(pList);
14149 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14150 while(pEntry != NULL)
14151 {
14152 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14153 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14154 if(pCommand->sessionId == sessionId)
14155 {
14156 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14157 {
14158 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14159 }
14160 }
14161 pEntry = pNext;
14162 }
14163 csrLLUnlock(pList);
14164
14165 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14166 {
14167 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14168 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14169 }
14170 csrLLClose(&localList);
14171}
14172
Jeff Johnson295189b2012-06-20 16:38:30 -070014173void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14174{
14175 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14176 {
14177 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014178 csrRoamStop(pMac, sessionId);
14179 csrFreeConnectBssDesc(pMac, sessionId);
14180 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14181 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014182 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014183#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014184 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014185#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014186 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14187 if (pMac->fScanOffload)
14188 {
14189 purgeSmeSessionCmdList(pMac, sessionId,
14190 &pMac->sme.smeScanCmdPendingList);
14191 }
14192
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 purgeCsrSessionCmdList(pMac, sessionId);
14194 csrInitSession(pMac, sessionId);
14195 }
14196}
14197
Jeff Johnson295189b2012-06-20 16:38:30 -070014198eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14199 tANI_BOOLEAN fSync,
14200 csrRoamSessionCloseCallback callback,
14201 void *pContext )
14202{
14203 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14205 {
14206 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14207 if(fSync)
14208 {
14209 csrCleanupSession(pMac, sessionId);
14210 }
14211 else
14212 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014213 purgeSmeSessionCmdList(pMac, sessionId,
14214 &pMac->sme.smeCmdPendingList);
14215 if (pMac->fScanOffload)
14216 {
14217 purgeSmeSessionCmdList(pMac, sessionId,
14218 &pMac->sme.smeScanCmdPendingList);
14219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 purgeCsrSessionCmdList(pMac, sessionId);
14221 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14222 pSession->selfMacAddr, callback, pContext);
14223 }
14224 }
14225 else
14226 {
14227 status = eHAL_STATUS_INVALID_PARAMETER;
14228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 return ( status );
14230}
14231
Jeff Johnson295189b2012-06-20 16:38:30 -070014232static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14233{
14234 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014235
14236 if(!pSession)
14237 {
14238 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14239 return;
14240 }
14241
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14243 pSession->sessionId = CSR_SESSION_ID_INVALID;
14244 pSession->callback = NULL;
14245 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14247 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14248 csrFreeRoamProfile( pMac, sessionId );
14249 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14250 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14251 csrFreeConnectBssDesc(pMac, sessionId);
14252 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014253 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14254 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014256 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 pSession->pWpaRsnReqIE = NULL;
14258 }
14259 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014260 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014262 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 pSession->pWpaRsnRspIE = NULL;
14264 }
14265 pSession->nWpaRsnRspIeLength = 0;
14266#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014267 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014269 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 pSession->pWapiReqIE = NULL;
14271 }
14272 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014273 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014275 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 pSession->pWapiRspIE = NULL;
14277 }
14278 pSession->nWapiRspIeLength = 0;
14279#endif /* FEATURE_WLAN_WAPI */
Kiet Lam64c1b492013-07-12 13:56:44 +053014280 if (pSession->pAddIEScan)
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014282 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 pSession->pAddIEScan = NULL;
14284 }
14285 pSession->nAddIEScanLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014286 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014288 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014292}
14293
Jeff Johnson295189b2012-06-20 16:38:30 -070014294eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14295{
14296 eHalStatus status = eHAL_STATUS_FAILURE;
14297 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14299 {
14300 if( CSR_IS_SESSION_VALID( pMac, i ) )
14301 {
14302 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14303 {
14304 //Found it
14305 status = eHAL_STATUS_SUCCESS;
14306 *pSessionId = i;
14307 break;
14308 }
14309 }
14310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 return( status );
14312}
14313
Jeff Johnson295189b2012-06-20 16:38:30 -070014314//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14315//session because for IBSS, the bssid changes.
14316static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14317{
14318 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14319 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14321 {
14322 if( CSR_IS_SESSION_VALID( pMac, i ) )
14323 {
14324 pSession = CSR_GET_SESSION( pMac, i );
14325 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14326 {
14327 //Found it
14328 nRet = i;
14329 break;
14330 }
14331 }
14332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 return (nRet);
14334}
Jeff Johnson295189b2012-06-20 16:38:30 -070014335static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14336{
14337 /* Update the current BSS info in ho control block based on connected
14338 profile info from pmac global structure */
14339
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014340 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
14342 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 /* Check for user misconfig of RSSI trigger threshold */
14344 pMac->roam.configParam.vccRssiThreshold =
14345 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14346 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14347 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014348 /* Check for user misconfig of UL MAC Loss trigger threshold */
14349 pMac->roam.configParam.vccUlMacLossThreshold =
14350 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14351 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014352#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14353 {
14354 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 /* Indicate the neighbor roal algorithm about the connect indication */
14356 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14357 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14358 }
14359#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014360}
14361
Jeff Johnson295189b2012-06-20 16:38:30 -070014362static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14363{
14364 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014365
14366 if(!pSession)
14367 {
14368 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14369 return;
14370 }
14371
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 //Only to handle the case for Handover on infra link
14373 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14374 {
14375 return;
14376 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14378 csrRoamDeregStatisticsReq(pMac);
14379 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14380#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14381 /* Indicate the neighbor roal algorithm about the disconnect indication */
14382 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14383#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014384
14385 //Remove this code once SLM_Sessionization is supported
14386 //BMPS_WORKAROUND_NOT_NEEDED
14387 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014388 csrIsInfraApStarted( pMac ) &&
14389 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014390 {
14391 pMac->roam.configParam.doBMPSWorkaround = 0;
14392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014393}
14394
Jeff Johnson295189b2012-06-20 16:38:30 -070014395void csrRoamTlStatsTimerHandler(void *pv)
14396{
14397 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14398 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14400
Jeff Johnsone7245742012-09-05 17:12:55 -070014401 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14402
Jeff Johnson295189b2012-06-20 16:38:30 -070014403#if 0
14404 // TODO Persession .???
14405 //req TL for stats
14406 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014408 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 }
14410 else
14411 {
14412 //save in SME
14413 csrRoamSaveStatsFromTl(pMac, tlStats);
14414 }
14415#endif
14416 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14417 {
14418 if(pMac->roam.tlStatsReqInfo.periodicity)
14419 {
14420 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014421 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14422 pMac->roam.tlStatsReqInfo.periodicity);
14423 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014424 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014425 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 return;
14427 }
14428 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14429 }
14430 }
14431}
Jeff Johnson295189b2012-06-20 16:38:30 -070014432void csrRoamPeStatsTimerHandler(void *pv)
14433{
14434 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14435 eHalStatus status;
14436 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14437 VOS_STATUS vosStatus;
14438 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014439 pPeStatsReqListEntry->timerRunning = FALSE;
14440 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14441 {
14442 // If we entered here, meaning the timer could not be successfully
14443 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14444
14445 /* Destroy the timer */
14446 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14447 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014449 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014450 }
14451
14452 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014453 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 pPeStatsReqListEntry = NULL;
14455 }
14456 else
14457 {
14458 if(!pPeStatsReqListEntry->rspPending)
14459 {
14460 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14461 pPeStatsReqListEntry->staId);
14462 if(!HAL_STATUS_SUCCESS(status))
14463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014464 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 }
14466 else
14467 {
14468 pPeStatsReqListEntry->rspPending = TRUE;
14469 }
14470 }
14471
14472 //send down a req
14473 if(pPeStatsReqListEntry->periodicity &&
14474 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14475 {
14476 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14477 if(ePMC_FULL_POWER == powerState)
14478 {
14479 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14480 {
14481 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14482 }
14483 }
14484 else
14485 {
14486 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14487 {
14488 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14489 }
14490 }
14491 //start timer
14492 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14493 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014495 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014496 return;
14497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 pPeStatsReqListEntry->timerRunning = TRUE;
14499
14500 }
14501
14502 }
14503}
Jeff Johnson295189b2012-06-20 16:38:30 -070014504void csrRoamStatsClientTimerHandler(void *pv)
14505{
14506 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14508 {
14509#if 0
14510 // TODO Stats fix for multisession
14511 //start the timer
14512 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14513
14514 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014516 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 }
14518#endif
14519 }
14520#if 0
14521 //send up the stats report
14522 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14523 pStaEntry->staId, pStaEntry->pContext);
14524#endif
14525}
14526
14527
14528
Jeff Johnson295189b2012-06-20 16:38:30 -070014529eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14530{
14531 tAniGetPEStatsReq *pMsg;
14532 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014533 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14534 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014536 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014537 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 }
14539 // need to initiate a stats request to PE
14540 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14541 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14542 pMsg->staId = staId;
14543 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 if(!HAL_STATUS_SUCCESS(status))
14546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014547 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 return status;
14550}
Jeff Johnson295189b2012-06-20 16:38:30 -070014551void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14552{
14553 tAniGetPEStatsRsp *pSmeStatsRsp;
14554 eHalStatus status = eHAL_STATUS_FAILURE;
14555 tListElem *pEntry = NULL;
14556 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14557 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14558 tANI_U32 tempMask = 0;
14559 tANI_U8 counter = 0;
14560 tANI_U8 *pStats = NULL;
14561 tANI_U32 length = 0;
14562 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014563 v_S7_t rssi = 0, snr = 0;
14564 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014565 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14567 if(pSmeStatsRsp->rc)
14568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014569 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014570 goto post_update;
14571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 tempMask = pSmeStatsRsp->statsMask;
14573 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 /* subtract all statistics from this length, and after processing the entire
14575 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14576 * in this 'stats' message.
14577 */
14578 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 //new stats info from PE, fill up the stats strucutres in PMAC
14580 while(tempMask)
14581 {
14582 if(tempMask & 1)
14583 {
14584 switch(counter)
14585 {
14586 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014587 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014588 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14589 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014590 pStats += sizeof(tCsrSummaryStatsInfo);
14591 length -= sizeof(tCsrSummaryStatsInfo);
14592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014593 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014594 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014595 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14596 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14598 length -= sizeof(tCsrGlobalClassAStatsInfo);
14599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014601 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014602 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14603 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014604 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14605 length -= sizeof(tCsrGlobalClassBStatsInfo);
14606 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014607 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014608 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014609 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14610 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014611 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14612 length -= sizeof(tCsrGlobalClassCStatsInfo);
14613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014614 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014615 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014616 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14617 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014618 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14619 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014620 }
14621 else
14622 {
14623 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014624 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 VOS_ASSERT( 0 );
14626 }
14627 if(!HAL_STATUS_SUCCESS(status))
14628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014629 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014630 }
14631 pStats += sizeof(tCsrPerStaStatsInfo);
14632 length -= sizeof(tCsrPerStaStatsInfo);
14633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014634 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014635 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014637 }
14638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 tempMask >>=1;
14640 counter++;
14641 }
14642 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14643 if (length != 0)
14644 {
14645 pRssi = (tANI_U32*)pStats;
14646 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014647 pStats += sizeof(tANI_U32);
14648 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014649 }
14650 else
14651 {
14652 /* If riva is not sending rssi, continue to use the hack */
14653 rssi = RSSI_HACK_BMPS;
14654 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014655
Jeff Johnson295189b2012-06-20 16:38:30 -070014656 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014657
14658 if (length != 0)
14659 {
14660 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014661 pStats += sizeof(tANI_U32);
14662 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014663 }
14664 else
14665 {
14666 linkCapacity = 0;
14667 }
14668
14669 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014670
14671 if (length != 0)
14672 {
14673 pSnr = (tANI_U32*)pStats;
14674 snr = (v_S7_t)*pSnr;
14675 }
14676 else
14677 {
14678 snr = SNR_HACK_BMPS;
14679 }
14680
14681 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014682post_update:
14683 //make sure to update the pe stats req list
14684 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14685 if(pEntry)
14686 {
14687 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14688 pPeStaEntry->rspPending = FALSE;
14689
14690 }
14691 //check the one timer cases
14692 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14693 if(pEntry)
14694 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014695 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 if(pTempStaEntry->timerExpired)
14697 {
14698 //send up the stats report
14699 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14700 pTempStaEntry->staId, pTempStaEntry->pContext);
14701 //also remove from the client list
14702 csrRoamRemoveStatListEntry(pMac, pEntry);
14703 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014704 }
14705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014706}
Jeff Johnson295189b2012-06-20 16:38:30 -070014707tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14708{
14709 tListElem *pEntry = NULL;
14710 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 if(!pEntry)
14713 {
14714 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014715 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 return NULL;
14717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014718 while( pEntry )
14719 {
14720 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 if(pTempStaEntry->statsMask == statsMask)
14722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014723 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014724 break;
14725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 return pEntry;
14729}
14730
Jeff Johnson295189b2012-06-20 16:38:30 -070014731tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14732 tANI_BOOLEAN update)
14733{
14734 tListElem *pEntry;
14735 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014737 if(!pEntry)
14738 {
14739 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014740 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014741 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 return NULL;
14743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 while( pEntry )
14745 {
14746 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14748 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014750 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 if(update)
14752 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014753 pTempStaEntry->periodicity = pStaEntry->periodicity;
14754 pTempStaEntry->callback = pStaEntry->callback;
14755 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 }
14757 break;
14758 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014759 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 return pEntry;
14762}
Jeff Johnson295189b2012-06-20 16:38:30 -070014763tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14764{
14765 tListElem *pEntry;
14766 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 if(!pEntry)
14769 {
14770 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014771 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014772 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 return NULL;
14774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 while( pEntry )
14776 {
14777 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014780 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014781 break;
14782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14784 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014785 return pEntry;
14786}
Jeff Johnson295189b2012-06-20 16:38:30 -070014787eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14788 csrRoamLinkQualityIndCallback callback,
14789 void *pContext)
14790{
14791 pMac->roam.linkQualityIndInfo.callback = callback;
14792 pMac->roam.linkQualityIndInfo.context = pContext;
14793 if( NULL == callback )
14794 {
14795 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14796 }
14797 else
14798 {
14799 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 /* do we need to invoke the callback to notify client of initial value ?? */
14801 }
14802 return eHAL_STATUS_SUCCESS;
14803}
Jeff Johnson295189b2012-06-20 16:38:30 -070014804void csrRoamVccTrigger(tpAniSirGlobal pMac)
14805{
14806 eCsrRoamLinkQualityInd newVccLinkQuality;
14807 tANI_U32 ul_mac_loss = 0;
14808 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14810 /*-------------------------------------------------------------------------
14811 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014812 Check for a change in link quality and notify client if necessary
14813 -------------------------------------------------------------------------*/
14814 ul_mac_loss_trigger_threshold =
14815 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014817 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014821 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014822 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14823 }
14824 else
14825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014826 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14828 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14830 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014833 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014836 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 newVccLinkQuality );
14838
14839 /* we now invoke the callback once to notify client of initial value */
14840 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14841 pMac->roam.linkQualityIndInfo.context );
14842 //event: EVENT_WLAN_VCC
14843 }
14844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 pMac->roam.vccLinkQuality = newVccLinkQuality;
14846
Jeff Johnson295189b2012-06-20 16:38:30 -070014847}
Jeff Johnson295189b2012-06-20 16:38:30 -070014848VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14849 v_U8_t rssiNotification,
14850 void * context)
14851{
14852 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14853 eCsrRoamLinkQualityInd newVccLinkQuality;
14854 // TODO : Session info unavailable
14855 tANI_U32 sessionId = 0;
14856 VOS_STATUS status = VOS_STATUS_SUCCESS;
14857 /*-------------------------------------------------------------------------
14858 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 Check for a change in link quality and notify client if necessary
14860 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014861 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 pMac->roam.configParam.vccRssiThreshold);
14863 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14864 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014865 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 return VOS_STATUS_SUCCESS;
14867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014870 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14872 }
14873 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014875 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014876 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14877 }
14878 else
14879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014880 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 //Set to this so the code below won't do anything
14882 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 VOS_ASSERT(0);
14884 }
14885
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014888 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014891 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 /* we now invoke the callback once to notify client of initial value */
14894 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14895 pMac->roam.linkQualityIndInfo.context );
14896 //event: EVENT_WLAN_VCC
14897 }
14898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 return status;
14901}
Jeff Johnson295189b2012-06-20 16:38:30 -070014902tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14903 tDblLinkList *pStaList,
14904 tCsrStatsClientReqInfo *pStaEntry)
14905{
14906 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014907 //if same entity requested for same set of stats with different periodicity &
14908 // callback update it
14909 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14910 {
14911
Kiet Lam64c1b492013-07-12 13:56:44 +053014912 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14913 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 {
14915 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014916 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 return NULL;
14918 }
14919
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 pNewStaEntry->callback = pStaEntry->callback;
14921 pNewStaEntry->pContext = pStaEntry->pContext;
14922 pNewStaEntry->periodicity = pStaEntry->periodicity;
14923 pNewStaEntry->requesterId = pStaEntry->requesterId;
14924 pNewStaEntry->statsMask = pStaEntry->statsMask;
14925 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14926 pNewStaEntry->pMac = pStaEntry->pMac;
14927 pNewStaEntry->staId = pStaEntry->staId;
14928 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14929
14930 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14931 }
14932 return pNewStaEntry;
14933}
14934
Jeff Johnson295189b2012-06-20 16:38:30 -070014935tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14936 tDblLinkList *pStaList,
14937 tCsrPeStatsReqInfo *pStaEntry)
14938{
14939 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014940 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14941 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 {
14943 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014944 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 return NULL;
14946 }
14947
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14949 pNewStaEntry->numClient = pStaEntry->numClient;
14950 pNewStaEntry->periodicity = pStaEntry->periodicity;
14951 pNewStaEntry->statsMask = pStaEntry->statsMask;
14952 pNewStaEntry->pMac = pStaEntry->pMac;
14953 pNewStaEntry->staId = pStaEntry->staId;
14954 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14955 pNewStaEntry->rspPending = pStaEntry->rspPending;
14956
14957 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 return pNewStaEntry;
14959}
Jeff Johnson295189b2012-06-20 16:38:30 -070014960eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14961 tCsrRssiCallback callback,
14962 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14963{
14964 eHalStatus status = eHAL_STATUS_SUCCESS;
14965 vos_msg_t msg;
14966 tANI_U32 sessionId;
14967
14968 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014969 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014970 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14971 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014973 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014974 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14977
14978 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14979 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14980 pMsg->sessionId = sessionId;
14981 pMsg->staId = staId;
14982 pMsg->rssiCallback = callback;
14983 pMsg->pDevContext = pContext;
14984 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 msg.type = eWNI_SME_GET_RSSI_REQ;
14986 msg.bodyptr = pMsg;
14987 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014990 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014991 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 status = eHAL_STATUS_FAILURE;
14993 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014994 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 return status;
14996}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014997
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014998eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14999 tCsrSnrCallback callback,
15000 tANI_U8 staId, tCsrBssid bssId,
15001 void *pContext)
15002{
15003 eHalStatus status = eHAL_STATUS_SUCCESS;
15004 vos_msg_t msg;
15005 tANI_U32 sessionId;
15006
15007 tAniGetSnrReq *pMsg;
15008
15009 smsLog(pMac, LOG2, FL("called"));
15010
15011 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15012 if (NULL == pMsg )
15013 {
15014 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15015 return status;
15016 }
15017
15018 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15019
15020 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15021 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15022 pMsg->sessionId = sessionId;
15023 pMsg->staId = staId;
15024 pMsg->snrCallback = callback;
15025 pMsg->pDevContext = pContext;
15026 msg.type = eWNI_SME_GET_SNR_REQ;
15027 msg.bodyptr = pMsg;
15028 msg.reserved = 0;
15029
15030 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15031 {
15032 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15033 vos_mem_free((v_VOID_t *)pMsg);
15034 status = eHAL_STATUS_FAILURE;
15035 }
15036
15037 smsLog(pMac, LOG2, FL("returned"));
15038 return status;
15039}
15040
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015041#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15042eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15043 tCsrRssiCallback callback,
15044 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15045{
15046 eHalStatus status = eHAL_STATUS_SUCCESS;
15047 tAniGetRssiReq *pMsg;
15048
Kiet Lam64c1b492013-07-12 13:56:44 +053015049 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15050 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015051 {
15052 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053015053 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015054 }
15055 // need to initiate a stats request to PE
15056 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15057 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15058 pMsg->staId = staId;
15059 pMsg->rssiCallback = callback;
15060 pMsg->pDevContext = pContext;
15061 pMsg->pVosContext = pVosContext;
15062 status = palSendMBMessage(pMac->hHdd, pMsg );
15063 if(!HAL_STATUS_SUCCESS(status))
15064 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015065 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15066 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015067 status = eHAL_STATUS_FAILURE;
15068 }
15069 return status;
15070}
15071#endif
15072
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015073
15074
15075#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15076eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15077 tCsrTsmStatsCallback callback,
15078 tANI_U8 staId,
15079 tCsrBssid bssId,
15080 void *pContext,
15081 void* pVosContext,
15082 tANI_U8 tid)
15083{
15084 eHalStatus status = eHAL_STATUS_SUCCESS;
15085 tAniGetTsmStatsReq *pMsg = NULL;
15086
15087 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15088 if ( !HAL_STATUS_SUCCESS(status) )
15089 {
15090 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15091 return status;
15092 }
15093 // need to initiate a stats request to PE
15094 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15095 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15096 pMsg->staId = staId;
15097 pMsg->tid = tid;
15098 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15099 pMsg->tsmStatsCallback = callback;
15100 pMsg->pDevContext = pContext;
15101 pMsg->pVosContext = pVosContext;
15102 status = palSendMBMessage(pMac->hHdd, pMsg );
15103 if(!HAL_STATUS_SUCCESS(status))
15104 {
15105 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15106 //pMsg is freed by palSendMBMessage
15107 status = eHAL_STATUS_FAILURE;
15108 }
15109 return status;
15110}
15111#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15112
15113
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015114/* ---------------------------------------------------------------------------
15115 \fn csrGetTLSTAState
15116 \helper function to get teh TL STA State whenever the function is called.
15117
15118 \param staId - The staID to be passed to the TL
15119 to get the relevant TL STA State
15120 \return the state as tANI_U16
15121 ---------------------------------------------------------------------------*/
15122tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15123{
15124 WLANTL_STAStateType tlSTAState;
15125 tlSTAState = WLANTL_STA_INIT;
15126
15127 //request TL for STA State
15128 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15129 {
15130 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15131 }
15132
15133 return tlSTAState;
15134}
15135
Jeff Johnson295189b2012-06-20 16:38:30 -070015136eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15137 tANI_U32 statsMask,
15138 tCsrStatsCallback callback,
15139 tANI_U32 periodicity, tANI_BOOLEAN cache,
15140 tANI_U8 staId, void *pContext)
15141{
15142 tCsrStatsClientReqInfo staEntry;
15143 tCsrStatsClientReqInfo *pStaEntry = NULL;
15144 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15145 tListElem *pEntry = NULL;
15146 tANI_BOOLEAN found = FALSE;
15147 eHalStatus status = eHAL_STATUS_SUCCESS;
15148 tANI_BOOLEAN insertInClientList = FALSE;
15149 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015150 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015151
15152 if( csrIsAllSessionDisconnected(pMac) )
15153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015154 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 return eHAL_STATUS_FAILURE;
15156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 if((!statsMask) && (!callback))
15158 {
15159 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015160 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 return eHAL_STATUS_FAILURE;
15162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015163 //for the search list method for deregister
15164 staEntry.requesterId = requesterId;
15165 staEntry.statsMask = statsMask;
15166 //requester wants to deregister or just an error
15167 if((statsMask) && (!callback))
15168 {
15169 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15170 if(!pEntry)
15171 {
15172 //msg
15173 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015174 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 return eHAL_STATUS_FAILURE;
15176 }
15177 else
15178 {
15179 //clean up & return
15180 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015181 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015183 pStaEntry->pPeStaEntry->numClient--;
15184 //check if we need to delete the entry from peStatsReqList too
15185 if(!pStaEntry->pPeStaEntry->numClient)
15186 {
15187 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015189 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015190
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 //check if we need to stop the tl stats timer too
15192 pMac->roam.tlStatsReqInfo.numClient--;
15193 if(!pMac->roam.tlStatsReqInfo.numClient)
15194 {
15195 if(pMac->roam.tlStatsReqInfo.timerRunning)
15196 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015197 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15198 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015200 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 return eHAL_STATUS_FAILURE;
15202 }
15203 }
15204 pMac->roam.tlStatsReqInfo.periodicity = 0;
15205 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15206 }
15207 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 // Destroy the vos timer...
15209 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15210 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015212 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015214 csrRoamRemoveStatListEntry(pMac, pEntry);
15215 pStaEntry = NULL;
15216 return eHAL_STATUS_SUCCESS;
15217 }
15218 }
15219
15220 if(cache && !periodicity)
15221 {
15222 //return the cached stats
15223 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15224 }
15225 else
15226 {
15227 //add the request in the client req list
15228 staEntry.callback = callback;
15229 staEntry.pContext = pContext;
15230 staEntry.periodicity = periodicity;
15231 staEntry.pPeStaEntry = NULL;
15232 staEntry.staId = staId;
15233 staEntry.pMac = pMac;
15234 staEntry.timerExpired = FALSE;
15235
15236
Jeff Johnson295189b2012-06-20 16:38:30 -070015237 //if periodic report requested with non cached result from PE/TL
15238 if(periodicity)
15239 {
15240
15241 //if looking for stats from PE
15242 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15243 {
15244
15245 //check if same request made already & waiting for rsp
15246 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15247 periodicity, &found, staId);
15248 if(!pPeStaEntry)
15249 {
15250 //bail out, maxed out on number of req for PE
15251 return eHAL_STATUS_FAILURE;
15252 }
15253 else
15254 {
15255 staEntry.pPeStaEntry = pPeStaEntry;
15256 }
15257
15258 }
15259 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15260 if(statsMask & (1 << eCsrGlobalClassDStats))
15261 {
15262 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015264 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 }
15266 else
15267 {
15268
15269 //update periodicity
15270 if(pMac->roam.tlStatsReqInfo.periodicity)
15271 {
15272 pMac->roam.tlStatsReqInfo.periodicity =
15273 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15274 }
15275 else
15276 {
15277 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15278 }
15279 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15280 {
15281 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15282 }
15283
15284 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15285 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015286 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015287 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015289 //req TL for class D stats
15290 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015292 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015293 }
15294 else
15295 {
15296 //save in SME
15297 csrRoamSaveStatsFromTl(pMac, pTlStats);
15298 }
15299 vos_mem_free(pTlStats);
15300 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015301 }
15302 else
15303 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015304 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015306
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 if(pMac->roam.tlStatsReqInfo.periodicity)
15308 {
15309 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015310 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15311 pMac->roam.tlStatsReqInfo.periodicity);
15312 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015314 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 return eHAL_STATUS_FAILURE;
15316 }
15317 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15318 }
15319 }
15320 }
15321 pMac->roam.tlStatsReqInfo.numClient++;
15322 }
15323
15324 insertInClientList = TRUE;
15325 }
15326 //if one time report requested with non cached result from PE/TL
15327 else if(!cache && !periodicity)
15328 {
15329 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15330 {
15331 //send down a req
15332 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15333 if(!HAL_STATUS_SUCCESS(status))
15334 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015335 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015336 }
15337 //so that when the stats rsp comes back from PE we respond to upper layer
15338 //right away
15339 staEntry.timerExpired = TRUE;
15340 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 }
15342 if(statsMask & (1 << eCsrGlobalClassDStats))
15343 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015344 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015345 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015347 //req TL for class D stats
15348 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015350 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015351 }
15352 else
15353 {
15354 //save in SME
15355 csrRoamSaveStatsFromTl(pMac, pTlStats);
15356 }
15357 vos_mem_free(pTlStats);
15358 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 }
15360 else
15361 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015362 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015364
15365 }
15366 //if looking for stats from TL only
15367 if(!insertInClientList)
15368 {
15369 //return the stats
15370 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 if(insertInClientList)
15374 {
15375 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15376 if(!pStaEntry)
15377 {
15378 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015379 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 return eHAL_STATUS_FAILURE;
15381 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015382 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 //Init & start timer if needed
15384 if(periodicity)
15385 {
15386 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15387 csrRoamStatsClientTimerHandler, pStaEntry );
15388 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015390 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 return eHAL_STATUS_FAILURE;
15392 }
15393 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15394 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015396 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 return eHAL_STATUS_FAILURE;
15398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 }
15402 return eHAL_STATUS_SUCCESS;
15403}
15404
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015405#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15406
15407static tSirRetStatus
15408csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15409 tANI_U8* pBD,
15410 tANI_U8 type,
15411 tANI_U8 subType,
15412 tSirMacAddr peerAddr,
15413 tSirMacAddr selfMacAddr)
15414{
15415 tSirRetStatus statusCode = eSIR_SUCCESS;
15416 tpSirMacMgmtHdr pMacHdr;
15417
15418 /* Prepare MAC management header */
15419 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15420
15421 /* Prepare FC */
15422 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15423 pMacHdr->fc.type = type;
15424 pMacHdr->fc.subType = subType;
15425
15426 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015427 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15428 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015429
15430 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15431
15432 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015433 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15434 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015435 return statusCode;
15436} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15437
15438static tSirRetStatus
15439csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15440 tANI_U8 nChannelNum,
15441 tANI_U32 dot11mode,
15442 tSirMacAddr selfMacAddr,
15443 tANI_U8 *pFrame,
15444 tANI_U16 *pusLen)
15445{
15446 tDot11fProbeRequest pr;
15447 tANI_U32 nStatus, nBytes, nPayload;
15448 tSirRetStatus nSirStatus;
15449 /*Bcast tx*/
15450 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15451 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15452
15453
Kiet Lam64c1b492013-07-12 13:56:44 +053015454 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015455
15456 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15457
15458 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15459 {
15460 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15461 }
15462
15463
15464 if (IS_DOT11_MODE_HT(dot11mode))
15465 {
15466 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15467 }
15468
15469
15470 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15471 if ( DOT11F_FAILED( nStatus ) )
15472 {
15473 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15474 "Failed to calculate the packed size f"
15475 "or a Probe Request (0x%08x).\n", nStatus );
15476
15477
15478 nPayload = sizeof( tDot11fProbeRequest );
15479 }
15480 else if ( DOT11F_WARNED( nStatus ) )
15481 {
15482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15483 "There were warnings while calculating"
15484 "the packed size for a Probe Request ("
15485 "0x%08x).\n", nStatus );
15486 }
15487
15488 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15489
15490 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015491 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015492
15493
15494 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015495 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015496
15497 if ( eSIR_SUCCESS != nSirStatus )
15498 {
15499 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15500 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15501 nSirStatus );
15502 return nSirStatus;
15503 }
15504
15505
15506 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15507 sizeof( tSirMacMgmtHdr ),
15508 nPayload, &nPayload );
15509 if ( DOT11F_FAILED( nStatus ) )
15510 {
15511 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15512 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15513 return eSIR_FAILURE;
15514 }
15515 else if ( DOT11F_WARNED( nStatus ) )
15516 {
15517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015518 "There were warnings while packing a Probe Request (0x%08x).\n",
15519 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015520 }
15521
15522 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15523 return eSIR_SUCCESS;
15524}
15525
15526eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15527{
15528 vos_msg_t msg;
15529 tSirRoamOffloadScanReq *pRequestBuf;
15530 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15531 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015532 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015533 tANI_U8 *ChannelList = NULL;
15534 tANI_U32 sessionId;
15535 eHalStatus status = eHAL_STATUS_SUCCESS;
15536 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015537 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015538 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015539 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15540
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015541 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015542 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015543 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015544 return eHAL_STATUS_FAILURE;
15545 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015546
15547 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15548 {
15549 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15550 return eHAL_STATUS_FAILURE;
15551 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015552 status = csrRoamGetSessionIdFromBSSID(pMac,
15553 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15554 &sessionId);
15555 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15556 * It is important to ensure that the command is passed down to the FW only
15557 * if the Infra Station is in a connected state.A connected station could also be
15558 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15559 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15560 * irrespective of whichever state we are in.*/
15561 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15562 (command != ROAM_SCAN_OFFLOAD_STOP))
15563 {
15564 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15565 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15566 return eHAL_STATUS_FAILURE;
15567 }
15568
15569 if ( !HAL_STATUS_SUCCESS( status ) )
15570 {
15571 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15572 return eHAL_STATUS_FAILURE;
15573 }
15574 pSession = CSR_GET_SESSION( pMac, sessionId );
15575 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15576 if (NULL == pRequestBuf)
15577 {
15578 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15579 return eHAL_STATUS_FAILED_ALLOC;
15580 }
15581
Kiet Lam64c1b492013-07-12 13:56:44 +053015582 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015583 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15584 * host driver reloads, but Riva still up and running*/
15585 if(command == ROAM_SCAN_OFFLOAD_STOP)
15586 pRequestBuf->RoamScanOffloadEnabled = 0;
15587 else
15588 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015589 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15590 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015591 sizeof(tCsrBssid));
15592 pRequestBuf->ConnectedNetwork.ssId.length =
15593 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15594 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15595 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15596 pRequestBuf->ConnectedNetwork.ssId.length);
15597 pRequestBuf->ConnectedNetwork.authentication =
15598 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15599 pRequestBuf->ConnectedNetwork.encryption =
15600 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15601 pRequestBuf->ConnectedNetwork.mcencryption =
15602 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15603 pRequestBuf->LookupThreshold =
15604 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15605 pRequestBuf->RoamRssiDiff =
15606 pMac->roam.configParam.RoamRssiDiff;
15607 pRequestBuf->Command = command;
15608 pRequestBuf->StartScanReason = reason;
15609 pRequestBuf->NeighborScanTimerPeriod =
15610 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15611 pRequestBuf->NeighborRoamScanRefreshPeriod =
15612 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15613 pRequestBuf->NeighborScanChannelMinTime =
15614 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15615 pRequestBuf->NeighborScanChannelMaxTime =
15616 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15617 pRequestBuf->EmptyRefreshScanPeriod =
15618 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
15619#ifdef FEATURE_WLAN_CCX
15620 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15621#endif
15622 if (
15623#ifdef FEATURE_WLAN_CCX
15624 ((pNeighborRoamInfo->isCCXAssoc) &&
15625 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15626 eANI_BOOLEAN_FALSE)) ||
15627 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15628#endif // CCX
15629 currChannelListInfo->numOfChannels == 0)
15630 {
15631
15632 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
15633 * Give Preference to INI Channels.*/
15634 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15635 {
15636 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15637 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
15638 {
15639 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15640 {
15641 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15642 }
15643 ChannelList++;
15644 }
15645 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15646 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15647 }
15648 else{
15649 ChannelList = pMac->scan.occupiedChannels.channelList;
15650 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15651 {
15652 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15653 {
15654 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15655 }
15656 ChannelList++;
15657 }
15658 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15659 /* If the profile changes as to what it was earlier, inform the FW through
15660 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15661 * for the earlier profile and try to learn them afresh.*/
15662 if (reason == REASON_FLUSH_CHANNEL_LIST)
15663 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15664 else {
15665 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15666 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15667 else
15668 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15669 }
15670 }
15671 }
15672#ifdef FEATURE_WLAN_CCX
15673 else
15674 {
15675 /* If CCX is enabled, and a neighbor Report is received,then
15676 * Ignore the INI Channels or the Occupied Channel List. Consider
15677 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015678 if (currChannelListInfo->numOfChannels != 0)
15679 {
15680 ChannelList = currChannelListInfo->ChannelList;
15681 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015682 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015683 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15684 {
15685 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15686 }
15687 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015688 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015689 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15690 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15691 }
15692 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015693#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015694 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15695 {
15696 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15697 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15698 }
15699 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15700 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15701 pRequestBuf->ChannelCacheType,
15702 pRequestBuf->ConnectedNetwork.ChannelCount,
15703 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015704 num_channels = 0;
15705 ChannelList = NULL;
15706
15707 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015708 host_channels = sizeof(pMac->roam.validChannelList);
15709 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015710 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015711 ChannelList = pMac->roam.validChannelList;
15712 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015713 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015714 else
15715 {
15716 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15717 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015718 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015719 return eHAL_STATUS_FAILURE;
15720 }
15721 for(i=0; i<pMac->roam.numValidChannels; i++)
15722 {
15723 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15724 {
15725 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15726 }
15727 ChannelList++;
15728 }
15729 pRequestBuf->ValidChannelCount = num_channels;
15730
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015731 pRequestBuf->MDID.mdiePresent =
15732 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15733 pRequestBuf->MDID.mobilityDomain =
15734 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015735 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15736
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015737 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015738
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015739 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15740 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15741 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15742 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15743 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15744
15745 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15746 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015747 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015748 msg.reserved = 0;
15749 msg.bodyptr = pRequestBuf;
15750 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15751 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015752 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15753 vos_mem_free(pRequestBuf);
15754 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015755 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015756 else
15757 {
15758 if (ROAM_SCAN_OFFLOAD_START == command)
15759 bRoamScanOffloadStarted = VOS_TRUE;
15760 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15761 bRoamScanOffloadStarted = VOS_FALSE;
15762 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015763
15764 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15765 return status;
15766}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015767
15768eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15769{
15770 switch(reason)
15771 {
15772 case 0:
15773 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15774 break;
15775 case REASON_OS_REQUESTED_ROAMING_NOW:
15776 csrNeighborRoamProceedWithHandoffReq(pMac);
15777 break;
15778 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015779 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 -070015780 }
15781 return eHAL_STATUS_SUCCESS;
15782}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015783#endif
15784
Jeff Johnson295189b2012-06-20 16:38:30 -070015785tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15786 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15787{
15788 tANI_BOOLEAN found = FALSE;
15789 eHalStatus status = eHAL_STATUS_SUCCESS;
15790 tCsrPeStatsReqInfo staEntry;
15791 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15792 tListElem *pStaEntry = NULL;
15793 VOS_STATUS vosStatus;
15794 tPmcPowerState powerState;
15795 *pFound = FALSE;
15796
15797 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15798 if(pStaEntry)
15799 {
15800 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15801 if(pTempStaEntry->periodicity)
15802 {
15803 pTempStaEntry->periodicity =
15804 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15805 }
15806 else
15807 {
15808 pTempStaEntry->periodicity = periodicity;
15809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 pTempStaEntry->numClient++;
15811 found = TRUE;
15812 }
15813 else
15814 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015815 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 staEntry.numClient = 1;
15817 staEntry.periodicity = periodicity;
15818 staEntry.pMac = pMac;
15819 staEntry.rspPending = FALSE;
15820 staEntry.staId = staId;
15821 staEntry.statsMask = statsMask;
15822 staEntry.timerRunning = FALSE;
15823 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15824 if(!pTempStaEntry)
15825 {
15826 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015827 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015828 return NULL;
15829 }
15830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015831 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15832 if(ePMC_FULL_POWER == powerState)
15833 {
15834 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15835 {
15836 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15837 }
15838 }
15839 else
15840 {
15841 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15842 {
15843 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15844 }
15845 }
15846 if(!pTempStaEntry->timerRunning)
15847 {
15848 //send down a req in case of one time req, for periodic ones wait for timer to expire
15849 if(!pTempStaEntry->rspPending &&
15850 !pTempStaEntry->periodicity)
15851 {
15852 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15853 if(!HAL_STATUS_SUCCESS(status))
15854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015855 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 }
15857 else
15858 {
15859 pTempStaEntry->rspPending = TRUE;
15860 }
15861 }
15862 if(pTempStaEntry->periodicity)
15863 {
15864 if(!found)
15865 {
15866
15867 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15868 csrRoamPeStatsTimerHandler, pTempStaEntry );
15869 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015871 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015872 return NULL;
15873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015874 }
15875 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015876 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015877 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15878 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015880 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015881 return NULL;
15882 }
15883 pTempStaEntry->timerRunning = TRUE;
15884 }
15885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015886 *pFound = found;
15887 return pTempStaEntry;
15888}
15889
Jeff Johnson295189b2012-06-20 16:38:30 -070015890/*
15891 pStaEntry is no longer invalid upon the return of this function.
15892*/
15893static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15894{
15895 if(pEntry)
15896 {
15897 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15898 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015899 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 }
15902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015903
15904void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15905{
15906 tListElem *pEntry;
15907 tCsrPeStatsReqInfo *pTempStaEntry;
15908 VOS_STATUS vosStatus;
15909 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 if(!pEntry)
15911 {
15912 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015913 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015914 return;
15915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 while( pEntry )
15917 {
15918 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015921 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 if(pTempStaEntry->timerRunning)
15923 {
15924 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15925 /* If we are not able to stop the timer here, just remove
15926 * the entry from the linked list. Destroy the timer object
15927 * and free the memory in the timer CB
15928 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015929 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 {
15931 /* the timer is successfully stopped */
15932 pTempStaEntry->timerRunning = FALSE;
15933
15934 /* Destroy the timer */
15935 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15936 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015938 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 }
15940 }
15941 else
15942 {
15943 // the timer could not be stopped. Hence destroy and free the
15944 // memory for the PE stat entry in the timer CB.
15945 pTempStaEntry->timerStopFailed = TRUE;
15946 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015948
15949 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15950 {
15951 // Only free the memory if we could stop the timer successfully
15952 if(!pTempStaEntry->timerStopFailed)
15953 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015954 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015955 pTempStaEntry = NULL;
15956 }
15957 break;
15958 }
15959
15960 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15961 }
15962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015963 return;
15964}
15965
15966
Jeff Johnsone7245742012-09-05 17:12:55 -070015967void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015968{
15969
Jeff Johnsone7245742012-09-05 17:12:55 -070015970 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15971 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15972 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15973 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15974 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15975 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15976 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015978 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15979 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15980 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15981 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15982 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15983 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015984 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015985 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15986 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015987
15988}
15989
Jeff Johnson295189b2012-06-20 16:38:30 -070015990void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15991 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15992{
15993 tANI_U8 stats[500];
15994 tANI_U8 *pStats = NULL;
15995 tANI_U32 tempMask = 0;
15996 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 if(!callback)
15998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015999 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016000 return;
16001 }
16002 if(!statsMask)
16003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016004 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016005 return;
16006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016007 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016009 while(tempMask)
16010 {
16011 if(tempMask & 1)
16012 {
16013 //new stats info from PE, fill up the stats strucutres in PMAC
16014 switch(counter)
16015 {
16016 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016017 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016018 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16019 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 pStats += sizeof(tCsrSummaryStatsInfo);
16021 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016023 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016024 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16025 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016026 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016027 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016028 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016029 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016030 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16031 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016032 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016034 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016035 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016036 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16037 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016041 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016042 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16043 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016044 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016045 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016047 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016048 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16049 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016050 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016052 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016053 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016055 }
16056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016057 tempMask >>=1;
16058 counter++;
16059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016061}
16062
Jeff Johnson295189b2012-06-20 16:38:30 -070016063eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16064{
16065 tListElem *pEntry = NULL;
16066 tListElem *pPrevEntry = NULL;
16067 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16068 eHalStatus status = eHAL_STATUS_SUCCESS;
16069 VOS_STATUS vosStatus;
16070 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 if(!pEntry)
16072 {
16073 //list empty
16074 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016075 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016076 return status;
16077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016078 while( pEntry )
16079 {
16080 if(pPrevEntry)
16081 {
16082 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16083 //send up the stats report
16084 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16085 pTempStaEntry->staId, pTempStaEntry->pContext);
16086 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016088 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016089 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16090 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016091 pTempStaEntry->pPeStaEntry->numClient--;
16092 //check if we need to delete the entry from peStatsReqList too
16093 if(!pTempStaEntry->pPeStaEntry->numClient)
16094 {
16095 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 //check if we need to stop the tl stats timer too
16099 pMac->roam.tlStatsReqInfo.numClient--;
16100 if(!pMac->roam.tlStatsReqInfo.numClient)
16101 {
16102 if(pMac->roam.tlStatsReqInfo.timerRunning)
16103 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016104 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16105 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016107 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016108 //we will continue
16109 }
16110 }
16111 pMac->roam.tlStatsReqInfo.periodicity = 0;
16112 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016114 if (pTempStaEntry->periodicity)
16115 {
16116 //While creating StaEntry in csrGetStatistics,
16117 //Initializing and starting timer only when periodicity is set.
16118 //So Stop and Destroy timer only when periodicity is set.
16119
Jeff Johnsone7245742012-09-05 17:12:55 -070016120 vos_timer_stop( &pTempStaEntry->timer );
16121 // Destroy the vos timer...
16122 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16123 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016125 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016127 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016128
Jeff Johnson295189b2012-06-20 16:38:30 -070016129
16130 pPrevEntry = pEntry;
16131 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16132 }
16133 //the last one
16134 if(pPrevEntry)
16135 {
16136 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16137 //send up the stats report
16138 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16139 pTempStaEntry->staId, pTempStaEntry->pContext);
16140 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016142 return status;
16143
16144}
16145
Jeff Johnson295189b2012-06-20 16:38:30 -070016146eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16147 tRequestFullPowerReason *pReason,
16148 tANI_BOOLEAN *pfNeedPower )
16149{
16150 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16151 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16152 tPmcState pmcState;
16153 eHalStatus status = eHAL_STATUS_SUCCESS;
16154 // TODO : Session info unavailable
16155 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016156 if( pfNeedPower )
16157 {
16158 *pfNeedPower = eANI_BOOLEAN_FALSE;
16159 }
16160 //We only handle CSR commands
16161 if( !(eSmeCsrCommandMask & pCommand->command) )
16162 {
16163 return eHAL_STATUS_SUCCESS;
16164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 //Check PMC state first
16166 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016167 switch( pmcState )
16168 {
16169 case REQUEST_IMPS:
16170 case IMPS:
16171 if( eSmeCommandScan == pCommand->command )
16172 {
16173 switch( pCommand->u.scanCmd.reason )
16174 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016175#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16176 case eCsrScanGetLfrResult:
16177#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016178 case eCsrScanGetResult:
16179 case eCsrScanBGScanAbort:
16180 case eCsrScanBGScanEnable:
16181 case eCsrScanGetScanChnInfo:
16182 //Internal process, no need for full power
16183 fNeedFullPower = eANI_BOOLEAN_FALSE;
16184 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016185 default:
16186 //Other scans are real scan, ask for power
16187 fNeedFullPower = eANI_BOOLEAN_TRUE;
16188 break;
16189 } //switch
16190 }
16191 else
16192 {
16193 //ask for power for roam and status change
16194 fNeedFullPower = eANI_BOOLEAN_TRUE;
16195 }
16196 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016197 case REQUEST_BMPS:
16198 case BMPS:
16199 case REQUEST_START_UAPSD:
16200 case UAPSD:
16201 //We treat WOWL same as BMPS
16202 case REQUEST_ENTER_WOWL:
16203 case WOWL:
16204 if( eSmeCommandRoam == pCommand->command )
16205 {
16206 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16207 tCsrScanResult *pScanResult;
16208 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016209 switch ( pCommand->u.roamCmd.roamReason )
16210 {
16211 case eCsrForcedDisassoc:
16212 case eCsrForcedDisassocMICFailure:
16213 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16214 fNeedFullPower = eANI_BOOLEAN_TRUE;
16215 break;
16216 case eCsrSmeIssuedDisassocForHandoff:
16217 case eCsrForcedDeauth:
16218 case eCsrHddIssuedReassocToSameAP:
16219 case eCsrSmeIssuedReassocToSameAP:
16220 fNeedFullPower = eANI_BOOLEAN_TRUE;
16221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016222 case eCsrCapsChange:
16223 fNeedFullPower = eANI_BOOLEAN_TRUE;
16224 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016225 default:
16226 //Check whether the profile is already connected. If so, no need for full power
16227 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16228 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16229 {
16230 //Only need to check the first one
16231 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16232 if( pEntry )
16233 {
16234 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16235#if 0
16236 // TODO : Session Specific info pConnectBssDesc
16237 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16238 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16239 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16240 {
16241 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16242 // with Authenticating first. To force this, stop the current association (Disassociate) and
16243 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16244 // a new Association.
16245 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16246 {
16247 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16248 {
16249 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16250 //No need for full power
16251 //Set the flag so the code later can avoid to do the above
16252 //check again.
16253 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16254 break;
16255 }
16256 }
16257 }
16258#endif
16259 }
16260 }
16261 //If we are here, full power is needed
16262 fNeedFullPower = eANI_BOOLEAN_TRUE;
16263 break;
16264 }
16265 }
16266 else if( eSmeCommandWmStatusChange == pCommand->command )
16267 {
16268 //need full power for all
16269 fNeedFullPower = eANI_BOOLEAN_TRUE;
16270 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16271 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016272#ifdef FEATURE_WLAN_TDLS
16273 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16274 {
16275 //TDLS link is getting established. need full power
16276 fNeedFullPower = eANI_BOOLEAN_TRUE;
16277 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16278 }
16279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 case REQUEST_STOP_UAPSD:
16282 case REQUEST_EXIT_WOWL:
16283 if( eSmeCommandRoam == pCommand->command )
16284 {
16285 fNeedFullPower = eANI_BOOLEAN_TRUE;
16286 switch ( pCommand->u.roamCmd.roamReason )
16287 {
16288 case eCsrForcedDisassoc:
16289 case eCsrForcedDisassocMICFailure:
16290 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16291 break;
16292 default:
16293 break;
16294 }
16295 }
16296 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016297 case STOPPED:
16298 case REQUEST_STANDBY:
16299 case STANDBY:
16300 case LOW_POWER:
16301 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016302 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 status = eHAL_STATUS_FAILURE;
16304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016305 case FULL_POWER:
16306 case REQUEST_FULL_POWER:
16307 default:
16308 //No need to ask for full power. This has to be FULL_POWER state
16309 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016311 if( pReason )
16312 {
16313 *pReason = reason;
16314 }
16315 if( pfNeedPower )
16316 {
16317 *pfNeedPower = fNeedFullPower;
16318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016319 return ( status );
16320}
16321
Jeff Johnson295189b2012-06-20 16:38:30 -070016322static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16323{
16324 eHalStatus status = eHAL_STATUS_SUCCESS;
16325 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16326 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016328 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16329 {
16330 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016332 return ( status );
16333}
16334
Jeff Johnson295189b2012-06-20 16:38:30 -070016335tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16336{
16337 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 if( pCmd )
16339 {
16340 pMac->roam.sPendingCommands++;
16341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 return ( pCmd );
16343}
16344
Jeff Johnson295189b2012-06-20 16:38:30 -070016345void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16346{
16347 if (pMac->roam.sPendingCommands > 0)
16348 {
16349 //All command allocated through csrGetCommandBuffer need to
16350 //decrement the pending count when releasing.
16351 pMac->roam.sPendingCommands--;
16352 smeReleaseCommand( pMac, pCommand );
16353 }
16354 else
16355 {
16356 smsLog(pMac, LOGE, FL( "no pending commands"));
16357 VOS_ASSERT(0);
16358 }
16359}
16360
Jeff Johnson295189b2012-06-20 16:38:30 -070016361//Return SUCCESS is the command is queued, failed
16362eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16363{
16364 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16366 {
16367 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16368 pCommand->u.scanCmd.reason);
16369 return eHAL_STATUS_CSR_WRONG_STATE;
16370 }
16371
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016372 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16373 {
16374 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16375 &pCommand->Link, LL_ACCESS_LOCK);
16376 // process the command queue...
16377 smeProcessPendingQueue(pMac);
16378 status = eHAL_STATUS_SUCCESS;
16379 goto end;
16380 }
16381
Jeff Johnson295189b2012-06-20 16:38:30 -070016382 //We can call request full power first before putting the command into pending Q
16383 //because we are holding SME lock at this point.
16384 status = csrRequestFullPower( pMac, pCommand );
16385 if( HAL_STATUS_SUCCESS( status ) )
16386 {
16387 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016388 //make sure roamCmdPendingList is not empty first
16389 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16390 if( fNoCmdPending )
16391 {
16392 smePushCommand( pMac, pCommand, fHighPriority );
16393 }
16394 else
16395 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016396 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016397 //no list lock is needed since SME lock is held
16398 if( !fHighPriority )
16399 {
16400 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16401 }
16402 else {
16403 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16404 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 }
16407 else if( eHAL_STATUS_PMC_PENDING == status )
16408 {
16409 //no list lock is needed since SME lock is held
16410 if( !fHighPriority )
16411 {
16412 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16413 }
16414 else {
16415 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16416 }
16417 //Let caller know the command is queue
16418 status = eHAL_STATUS_SUCCESS;
16419 }
16420 else
16421 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016422 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016423 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016424 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016426end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016428}
Jeff Johnson295189b2012-06-20 16:38:30 -070016429eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16430{
16431 eHalStatus status = eHAL_STATUS_SUCCESS;
16432 tSirUpdateAPWPSIEsReq *pMsg;
16433 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16434
16435 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16436 if (NULL == pSession)
16437 {
16438 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16439 return eHAL_STATUS_FAILURE;
16440 }
16441
Jeff Johnson295189b2012-06-20 16:38:30 -070016442 do
16443 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016444 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16445 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16446 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016447 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16448
16449 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016450 VOS_ASSERT(pBuf);
16451
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 // transactionId
16454 *pBuf = 0;
16455 *( pBuf + 1 ) = 0;
16456 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016458 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16459 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016460 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 //sessionId
16462 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016464 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016466 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016467 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 return ( status );
16470}
Jeff Johnson295189b2012-06-20 16:38:30 -070016471eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16472{
16473 eHalStatus status = eHAL_STATUS_SUCCESS;
16474 tSirUpdateAPWPARSNIEsReq *pMsg;
16475 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016476 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16477 if (NULL == pSession)
16478 {
16479 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16480 return eHAL_STATUS_FAILURE;
16481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016482 do
16483 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016484 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16485 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16486 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 pBuf = (tANI_U8 *)&pMsg->transactionId;
16489 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 // transactionId
16491 *pBuf = 0;
16492 *( pBuf + 1 ) = 0;
16493 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016494 VOS_ASSERT(pBuf);
16495
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016497 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16498 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016500 // sessionId
16501 *pBuf++ = (tANI_U8)sessionId;
16502
16503 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016504 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016509 return ( status );
16510}
Jeff Johnson295189b2012-06-20 16:38:30 -070016511
16512#ifdef WLAN_FEATURE_VOWIFI_11R
16513//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16514eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16515{
16516 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16517 tpSirFTPreAuthReq pftPreAuthReq;
16518 tANI_U16 auth_req_len = 0;
16519 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 auth_req_len = sizeof(tSirFTPreAuthReq);
16521 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016522 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016523 {
16524 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16525 return eHAL_STATUS_RESOURCES;
16526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 // Save the SME Session ID here. We need it while processing the preauth response
16528 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016529 vos_mem_zero(pftPreAuthReq, auth_req_len);
16530
16531 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16532 sizeof(pBssDescription->length) + pBssDescription->length);
16533
16534 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16535
16536 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16537
Kiet Lam64c1b492013-07-12 13:56:44 +053016538 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16539 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16540 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16541 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016542
Jeff Johnson295189b2012-06-20 16:38:30 -070016543#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016544 if (csrRoamIs11rAssoc(pMac) &&
16545 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 {
16547 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016548 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16549 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016550 }
16551 else
16552#endif
16553 {
16554 pftPreAuthReq->ft_ies_length = 0;
16555 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016556 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16557 sizeof(pBssDescription->length) + pBssDescription->length);
16558 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016559 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16560}
Jeff Johnson295189b2012-06-20 16:38:30 -070016561/*--------------------------------------------------------------------------
16562 * This will receive and process the FT Pre Auth Rsp from the current
16563 * associated ap.
16564 *
16565 * This will invoke the hdd call back. This is so that hdd can now
16566 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16567 ------------------------------------------------------------------------*/
16568void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16569{
16570 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16571 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016572#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016573 tCsrRoamInfo roamInfo;
16574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016575
16576#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016577 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016578#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016579#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016580 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016581 if (status != eHAL_STATUS_SUCCESS) {
16582 /*
16583 * Bail out if pre-auth was not even processed.
16584 */
16585 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16586 return;
16587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016588#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016589 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16590 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16591 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016592 // Implies a success
16593 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016594 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16595 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016596 /* No need to notify qos module if this is a non 11r roam*/
16597 if (csrRoamIs11rAssoc(pMac))
16598 {
16599 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16600 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016601 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16602 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016603 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16604 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 if (eHAL_STATUS_SUCCESS != status)
16606 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016607 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016608 return;
16609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016610 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016611 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16612 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016613 if (csrRoamIs11rAssoc(pMac))
16614 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16615 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16616
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016617#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16618 if (csrRoamIsCCXAssoc(pMac))
16619 {
16620 /* read TSF */
16621 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16622
16623 // Save the bssid from the received response
16624 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16625 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16626 }
16627#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016628#ifdef FEATURE_WLAN_LFR
16629 // If Legacy Fast Roaming is enabled, signal the supplicant
16630 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016631 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016632 {
16633 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016634 vos_mem_copy((void *)&roamInfo.bssid,
16635 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016636 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16637 }
16638
16639#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016640
16641 // Done with it, init it.
16642 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16643}
16644#endif
16645#ifdef FEATURE_WLAN_BTAMP_UT_RF
16646void csrRoamJoinRetryTimerHandler(void *pv)
16647{
16648 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16649 tpAniSirGlobal pMac = pInfo->pMac;
16650 tANI_U32 sessionId = pInfo->sessionId;
16651 tCsrRoamSession *pSession;
16652
16653 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016655 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016656 pSession = CSR_GET_SESSION( pMac, sessionId );
16657 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16658 {
16659 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016661 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016662 }
16663 }
16664 }
16665}
Jeff Johnson295189b2012-06-20 16:38:30 -070016666eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16667{
16668 eHalStatus status = eHAL_STATUS_FAILURE;
16669 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16670
16671 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016673 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016674 pSession->maxRetryCount--;
16675 pSession->joinRetryTimerInfo.pMac = pMac;
16676 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016677 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16678 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016680 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016681 }
16682 }
16683 else
16684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016685 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016686 pSession->maxRetryCount);
16687 }
16688
16689 return (status);
16690}
Jeff Johnson295189b2012-06-20 16:38:30 -070016691eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16692{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016693 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016694 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16695 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016696 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 }
16698
16699 return eHAL_STATUS_SUCCESS;
16700}
16701#endif
16702
16703
16704/*
16705 pBuf points to the beginning of the message
16706 LIM packs disassoc rsp as below,
16707 messageType - 2 bytes
16708 messageLength - 2 bytes
16709 sessionId - 1 byte
16710 transactionId - 2 bytes (tANI_U16)
16711 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16712 peerMacAddr - 6 bytes
16713 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16714*/
16715static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16716{
16717 if(pBuf && pRsp)
16718 {
16719 pBuf += 4; //skip type and length
16720 pRsp->sessionId = *pBuf++;
16721 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16722 pBuf += 2;
16723 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16724 pBuf += 4;
16725 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16726 }
16727}
16728
Jeff Johnsond13512a2012-07-17 11:42:19 -070016729eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16730{
16731 static uNvTables nvTables;
16732 eHalStatus status = eHAL_STATUS_SUCCESS;
16733 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16734
16735 /* read the country code from NV and use it */
16736 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16737 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016738 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16739 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016740 return status;
16741 }
16742 else
16743 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016744 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016745 status = eHAL_STATUS_FAILURE;
16746 return status;
16747 }
16748}
16749
16750eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16751{
Kiet Lam64c1b492013-07-12 13:56:44 +053016752 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016753 return eHAL_STATUS_SUCCESS;
16754}
schang86c22c42013-03-13 18:41:24 -070016755
16756eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16757{
16758 tSirSetTxPowerReq *pMsg = NULL;
16759 eHalStatus status = eHAL_STATUS_SUCCESS;
16760 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16761
16762 if (!pSession)
16763 {
16764 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16765 return eHAL_STATUS_FAILURE;
16766 }
16767
Kiet Lam64c1b492013-07-12 13:56:44 +053016768 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16769 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16770 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16771 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16772 pMsg->length = sizeof(tSirSetTxPowerReq);
16773 pMsg->mwPower = mW;
16774 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16775 sizeof(tSirMacAddr));
16776 status = palSendMBMessage(pMac->hHdd, pMsg);
16777 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016778 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016779 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16780 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016781 }
16782 return status;
16783}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016784
16785/* Returns whether a session is in VOS_STA_MODE...or not */
16786tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16787{
16788 tCsrRoamSession *pSession = NULL;
16789 pSession = CSR_GET_SESSION ( pMac, sessionId );
16790 if(!pSession)
16791 {
16792 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16793 return eANI_BOOLEAN_FALSE;
16794 }
16795 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16796 {
16797 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16798 return eANI_BOOLEAN_FALSE;
16799 }
16800 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16801 {
16802 return eANI_BOOLEAN_FALSE;
16803 }
16804 /* There is a possibility that the above check may fail,because
16805 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16806 * when it is connected.So,we may sneak through the above check even
16807 * if we are not a STA mode INFRA station. So, if we sneak through
16808 * the above condition, we can use the following check if we are
16809 * really in STA Mode.*/
16810
16811 if ( NULL != pSession->pCurRoamProfile )
16812 {
16813 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16814 {
16815 return eANI_BOOLEAN_TRUE;
16816 } else {
16817 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16818 return eANI_BOOLEAN_FALSE;
16819 }
16820 }
16821
16822 return eANI_BOOLEAN_FALSE;
16823}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016824
16825#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16826eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16827 tCsrHandoffRequest *pHandoffInfo)
16828{
16829 eHalStatus status = eHAL_STATUS_SUCCESS;
16830 vos_msg_t msg;
16831
16832 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016833 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16834 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016835 {
16836 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016837 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016838 }
16839 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16840 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16841 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16842 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016843 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016844 pHandoffInfo->bssid,
16845 6);
16846 msg.type = eWNI_SME_HANDOFF_REQ;
16847 msg.bodyptr = pMsg;
16848 msg.reserved = 0;
16849 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16850 {
16851 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016852 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016853 status = eHAL_STATUS_FAILURE;
16854 }
16855 return status;
16856}
16857#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016858
16859#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16860/* ---------------------------------------------------------------------------
16861 \fn csrSetCCKMIe
16862 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16863 data structure and this IE will be packed inside reassociation request
16864 \param pMac - pMac global structure
16865 \param sessionId - Current session id
16866 \param pCckmIe - pointer to CCKM IE data
16867 \param ccKmIeLen - length of the CCKM IE
16868 \- return Success or failure
16869 -------------------------------------------------------------------------*/
16870VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16871 const tANI_U8 *pCckmIe,
16872 const tANI_U8 ccKmIeLen)
16873{
16874 eHalStatus status = eHAL_STATUS_SUCCESS;
16875 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16876
16877 if (!pSession)
16878 {
16879 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16880 return eHAL_STATUS_FAILURE;
16881 }
16882 palCopyMemory(pMac->hHdd, pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
16883 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16884 return status;
16885}
16886
16887/* ---------------------------------------------------------------------------
16888 \fn csrRoamReadTSF
16889 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16890 probe response reception from the hand off AP to arrive at the latest TSF value.
16891 \param pMac - pMac global structure
16892 \param pTimestamp - output TSF timestamp
16893 \- return Success or failure
16894 -------------------------------------------------------------------------*/
16895VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16896{
16897 eHalStatus status = eHAL_STATUS_SUCCESS;
16898 tCsrNeighborRoamBSSInfo handoffNode;
16899 tANI_U32 timer_diff = 0;
16900 tANI_U32 timeStamp[2];
16901 tpSirBssDescription pBssDescription = NULL;
16902
16903 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16904 pBssDescription = handoffNode.pBssDescription;
16905
16906 // Get the time diff in milli seconds
16907 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16908 // Convert msec to micro sec timer
16909 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16910
16911 timeStamp[0] = pBssDescription->timeStamp[0];
16912 timeStamp[1] = pBssDescription->timeStamp[1];
16913
16914 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16915
16916 palCopyMemory(pMac->hHdd, pTimestamp, (void *) &timeStamp[0],
16917 sizeof (tANI_U32) * 2);
16918 return status;
16919}
16920
16921#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16922