blob: 08caec10c83906edbd44ba52da6335877d13f394 [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 );
Kiet Lam6c583332013-10-14 05:37:09 +0530340
341 if (!('0' == pMac->scan.countryCodeDefault[0] &&
342 '0' == pMac->scan.countryCodeDefault[1]))
343 {
344 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
345 &regId, COUNTRY_NV);
346 }
347 else
348 {
349 regId = REGDOMAIN_WORLD;
350 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 WDA_SetRegDomain(pMac, regId);
352 pMac->scan.domainIdDefault = regId;
353 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530354 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
355 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 }while(0);
358
359 return (status);
360}
361
Jeff Johnson295189b2012-06-20 16:38:30 -0700362eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
363{
364 eHalStatus status = eHAL_STATUS_SUCCESS;
365 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
366 v_REGDOMAIN_t regId;
367 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 if(NULL == apCntryCode)
369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800370 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 return eHAL_STATUS_FAILURE;
372 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700373 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 /* To get correct Regulatory domain from NV table
375 * 2 character Country code should be used
376 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700377 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
378/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700380
381 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800383 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700384 return eHAL_STATUS_FAILURE;
385 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700386*/
Kiet Lam6c583332013-10-14 05:37:09 +0530387 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
388 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 if (status != eHAL_STATUS_SUCCESS)
390 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700391 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 return status;
393 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 status = WDA_SetRegDomain(hHal, regId);
395 if (status != eHAL_STATUS_SUCCESS)
396 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700397 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 return status;
399 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 pMac->scan.domainIdDefault = regId;
401 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530403 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
404
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530406 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
407
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 /* If 2 bytes country code, 3rd byte must be filled with space */
409 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
410 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530411 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530413 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
414 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 return status;
417}
Jeff Johnson295189b2012-06-20 16:38:30 -0700418eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
419{
420 eHalStatus status = eHAL_STATUS_SUCCESS;
421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
422 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530423 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
424 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
426 {
427 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
428 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
429 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
430 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
431 }
432 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
433
434 return status;
435}
Jeff Johnson295189b2012-06-20 16:38:30 -0700436eHalStatus csrClose(tpAniSirGlobal pMac)
437{
438 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 csrRoamClose(pMac);
441 csrScanClose(pMac);
442 csrLLClose(&pMac->roam.statsClientReqList);
443 csrLLClose(&pMac->roam.peStatsReqList);
444 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 /* DeInit Globals */
446 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 return (status);
448}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530449
450eHalStatus csrUpdateChannelList(tCsrScanStruct *pScan)
451{
452 tSirUpdateChanList *pChanList;
453 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
454 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
455 (sizeof(tSirUpdateChanParam) * (numChan - 1));
456 vos_msg_t msg;
457 tANI_U8 i;
458
459 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
460 if (!pChanList)
461 {
462 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
463 "Failed to allocate memory for tSirUpdateChanList");
464 return eHAL_STATUS_FAILED_ALLOC;
465 }
466
467 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
468 msg.reserved = 0;
469 msg.bodyptr = pChanList;
470 pChanList->numChan = numChan;
471 for (i = 0; i < pChanList->numChan; i++)
472 {
473 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
474 pChanList->chanParam[i].pwr = pScan->defaultPowerTable[i].pwr;
475 }
476
477 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
478 {
479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
480 "%s: Failed to post msg to WDA", __func__);
481 vos_mem_free(pChanList);
482 return eHAL_STATUS_FAILURE;
483 }
484
485 return eHAL_STATUS_SUCCESS;
486}
487
Jeff Johnson295189b2012-06-20 16:38:30 -0700488eHalStatus csrStart(tpAniSirGlobal pMac)
489{
490 eHalStatus status = eHAL_STATUS_SUCCESS;
491 tANI_U32 i;
492
493 do
494 {
495 //save the global vos context
496 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
497 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
498 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
499
500 status = csrRoamStart(pMac);
501 if(!HAL_STATUS_SUCCESS(status)) break;
502 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
503 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
504 if(!HAL_STATUS_SUCCESS(status)) break;
505 pMac->roam.sPendingCommands = 0;
506 csrScanEnable(pMac);
507#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
508 status = csrNeighborRoamInit(pMac);
509#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
510 pMac->roam.tlStatsReqInfo.numClient = 0;
511 pMac->roam.tlStatsReqInfo.periodicity = 0;
512 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
513 //init the link quality indication also
514 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
515 if(!HAL_STATUS_SUCCESS(status))
516 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800517 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 break;
519 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530520
521 if (pMac->fScanOffload)
522 {
523 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
524 "Scan offload is enabled, update default chan list");
525 status = csrUpdateChannelList(&pMac->scan);
526 }
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700529#if defined(ANI_LOGDUMP)
530 csrDumpInit(pMac);
531#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 return (status);
533}
534
Kiet Lama72a2322013-11-15 11:18:11 +0530535eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700536{
537 tANI_U32 sessionId;
538 tANI_U32 i;
539
540 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
541 {
542 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
543 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 csrScanDisable(pMac);
545 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
546 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
548
549#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
550 csrNeighborRoamClose(pMac);
551#endif
552 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 // deregister from PMC since we register during csrStart()
554 // (ignore status since there is nothing we can do if it fails)
555 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 //Reset the domain back to the deault
557 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800558 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700559
560 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
561 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530562 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
564 }
565
Kiet Lama72a2322013-11-15 11:18:11 +0530566#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
567 /* When HAL resets all the context information
568 * in HAL is lost, so we might need to send the
569 * scan offload request again when it comes
570 * out of reset for scan offload to be functional
571 */
572 if (HAL_STOP_TYPE_SYS_RESET == stopType)
573 {
574 bRoamScanOffloadStarted = VOS_FALSE;
575 }
576#endif
577
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 return (eHAL_STATUS_SUCCESS);
579}
580
Jeff Johnson295189b2012-06-20 16:38:30 -0700581eHalStatus csrReady(tpAniSirGlobal pMac)
582{
583 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 csrScanGetSupportedChannels( pMac );
585 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
586 //use it to init the background scan list
587 csrInitBGScanChannelList(pMac);
588 /* HDD issues the init scan */
589 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800590 /* If the gScanAgingTime is set to '0' then scan results aging timeout
591 based on timer feature is not enabled*/
592 if(0 != pMac->scan.scanResultCfgAgingTime )
593 {
594 csrScanStartResultCfgAgingTimer(pMac);
595 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 //Store the AC weights in TL for later use
597 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 status = csrInitChannelList( pMac );
599 if ( ! HAL_STATUS_SUCCESS( status ) )
600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800601 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 status );
603 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 return (status);
605}
Jeff Johnson295189b2012-06-20 16:38:30 -0700606void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
607{
608 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
610 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
611}
Jeff Johnson295189b2012-06-20 16:38:30 -0700612void csrSetGlobalCfgs( tpAniSirGlobal pMac )
613{
Jeff Johnsone7245742012-09-05 17:12:55 -0700614
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
616 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
617 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
618 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
619 NULL, eANI_BOOLEAN_FALSE);
620 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700621 /* 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
622 * Once session is established we will use the session related params stored in PE session for CB mode
623 */
624 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
626
627 //Update the operating mode to configured value during initialization,
628 //So that client can advertise full capabilities in Probe request frame.
629 csrSetDefaultDot11Mode( pMac );
630}
631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
633{
634 eHalStatus status = eHAL_STATUS_SUCCESS;
635 tANI_U32 i;
636 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 do
638 {
639 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
640 {
641 pSession = CSR_GET_SESSION( pMac, i );
642 pSession->roamingTimerInfo.pMac = pMac;
643 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
644 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
646 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530647 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
648 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530650 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800652 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 break;
654 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530655 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
656 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
657 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800659 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 return eHAL_STATUS_FAILURE;
661 }
662 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 return (status);
664}
665
Jeff Johnson295189b2012-06-20 16:38:30 -0700666eHalStatus csrRoamClose(tpAniSirGlobal pMac)
667{
668 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
670 {
671 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
672 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530673 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
674 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
675 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
676 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 return (eHAL_STATUS_SUCCESS);
678}
679
Jeff Johnson295189b2012-06-20 16:38:30 -0700680eHalStatus csrRoamStart(tpAniSirGlobal pMac)
681{
682 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 return (eHAL_STATUS_SUCCESS);
684}
685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
687{
688 csrRoamStopRoamingTimer(pMac, sessionId);
689 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
690 csrRoamDeregStatisticsReq(pMac);
691}
Jeff Johnson295189b2012-06-20 16:38:30 -0700692eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
693{
694 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800695 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 {
697 status = eHAL_STATUS_SUCCESS;
698 *pState = pMac->roam.roamSession[sessionId].connectState;
699 }
700 return (status);
701}
702
Jeff Johnson295189b2012-06-20 16:38:30 -0700703eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
704{
705 eHalStatus status = eHAL_STATUS_FAILURE;
706 tANI_U32 size = 0;
707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700708
709 if(!pSession)
710 {
711 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
712 return eHAL_STATUS_FAILURE;
713 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700714
715 if(pProfile)
716 {
717 if(pSession->pConnectBssDesc)
718 {
719 do
720 {
721 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
722 if(size)
723 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530724 pProfile->pBssDesc = vos_mem_malloc(size);
725 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530727 vos_mem_copy(pProfile->pBssDesc,
728 pSession->pConnectBssDesc, size);
729 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 }
731 else
732 break;
733 }
734 else
735 {
736 pProfile->pBssDesc = NULL;
737 }
738 pProfile->AuthType = pSession->connectedProfile.AuthType;
739 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
740 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
741 pProfile->BSSType = pSession->connectedProfile.BSSType;
742 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
743 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530744 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
745 sizeof(tCsrBssid));
746 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
747 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700748#ifdef WLAN_FEATURE_VOWIFI_11R
749 if (pSession->connectedProfile.MDID.mdiePresent)
750 {
751 pProfile->MDID.mdiePresent = 1;
752 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
753 }
754 else
755 {
756 pProfile->MDID.mdiePresent = 0;
757 pProfile->MDID.mobilityDomain = 0;
758 }
759#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700760#ifdef FEATURE_WLAN_CCX
761 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
763 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530764 vos_mem_copy (pProfile->ccxCckmInfo.krk,
765 pSession->connectedProfile.ccxCckmInfo.krk,
766 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 pProfile->ccxCckmInfo.reassoc_req_num=
768 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
769 pProfile->ccxCckmInfo.krk_plumbed =
770 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
771 }
772#endif
773 }while(0);
774 }
775 }
776
777 return (status);
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
781{
782 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700783
784 if((csrIsConnStateConnected(pMac, sessionId)) ||
785 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 {
787 if(pProfile)
788 {
789 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
790 }
791 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 return (status);
793}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700794
Jeff Johnson295189b2012-06-20 16:38:30 -0700795eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
796{
797 eHalStatus status = eHAL_STATUS_SUCCESS;
798
Kiet Lam64c1b492013-07-12 13:56:44 +0530799 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530801 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530803 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700804 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530805 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700806 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530807 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
810 return (status);
811}
812
Jeff Johnson295189b2012-06-20 16:38:30 -0700813static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
814{
815 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 if( pConnectedInfo->pbFrames )
817 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530818 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 pConnectedInfo->pbFrames = NULL;
820 }
821 pConnectedInfo->nBeaconLength = 0;
822 pConnectedInfo->nAssocReqLength = 0;
823 pConnectedInfo->nAssocRspLength = 0;
824 pConnectedInfo->staId = 0;
825#ifdef WLAN_FEATURE_VOWIFI_11R
826 pConnectedInfo->nRICRspLength = 0;
827#endif
828#ifdef FEATURE_WLAN_CCX
829 pConnectedInfo->nTspecIeLength = 0;
830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 return ( status );
832}
833
Jeff Johnson295189b2012-06-20 16:38:30 -0700834
835
Jeff Johnsone7245742012-09-05 17:12:55 -0700836
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700837void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
838{
839 csrReinitPreauthCmd(pMac, pCommand);
840 csrReleaseCommand( pMac, pCommand );
841}
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
844{
845 csrReinitRoamCmd(pMac, pCommand);
846 csrReleaseCommand( pMac, pCommand );
847}
848
Jeff Johnson295189b2012-06-20 16:38:30 -0700849void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
850{
851 csrReinitScanCmd(pMac, pCommand);
852 csrReleaseCommand( pMac, pCommand );
853}
854
Jeff Johnson295189b2012-06-20 16:38:30 -0700855void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
856{
857 csrReinitWmStatusChangeCmd(pMac, pCommand);
858 csrReleaseCommand( pMac, pCommand );
859}
860
Jeff Johnson295189b2012-06-20 16:38:30 -0700861void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
862{
Kiet Lam64c1b492013-07-12 13:56:44 +0530863 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700864}
865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
867{
Kiet Lam64c1b492013-07-12 13:56:44 +0530868 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869}
870
Jeff Johnson295189b2012-06-20 16:38:30 -0700871void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
872{
873 csrReinitSetKeyCmd(pMac, pCommand);
874 csrReleaseCommand( pMac, pCommand );
875}
Jeff Johnson295189b2012-06-20 16:38:30 -0700876void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
877{
878 csrReinitRemoveKeyCmd(pMac, pCommand);
879 csrReleaseCommand( pMac, pCommand );
880}
Jeff Johnson295189b2012-06-20 16:38:30 -0700881void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
882{
883
884 if( eSmeCsrCommandMask & pCommand->command )
885 {
886 switch (pCommand->command)
887 {
888 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800889 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800890 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
891 __func__, pCommand->u.scanCmd.reason,
892 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 if (NULL != pCommand->u.scanCmd.callback)
894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800895 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
897 }
898 csrReleaseCommandScan( pMac, pCommand );
899 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 case eSmeCommandRoam:
901 csrReleaseCommandRoam( pMac, pCommand );
902 break;
903
904 case eSmeCommandWmStatusChange:
905 csrReleaseCommandWmStatusChange( pMac, pCommand );
906 break;
907
908 case eSmeCommandSetKey:
909 csrReleaseCommandSetKey( pMac, pCommand );
910 break;
911
912 case eSmeCommandRemoveKey:
913 csrReleaseCommandRemoveKey( pMac, pCommand );
914 break;
915
916 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800917 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 csrReleaseCommand( pMac, pCommand );
919 break;
920 }
921 }
922}
923
Jeff Johnson295189b2012-06-20 16:38:30 -0700924void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
925{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800926 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 if(pMac->roam.curSubState[sessionId] == NewSubstate)
929 {
930 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700931 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 pMac->roam.curSubState[sessionId] = NewSubstate;
933}
934
Jeff Johnson295189b2012-06-20 16:38:30 -0700935eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
936{
937 eCsrRoamState PreviousState;
938
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530939 smsLog( pMac, LOG1, "CSR RoamState[%hu]: [ %d <== %d ]", sessionId,
940 NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700941
942 PreviousState = pMac->roam.curState[sessionId];
943
944 if ( NewRoamState != pMac->roam.curState[sessionId] )
945 {
946 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
947 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
948 {
949 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
950 }
951
952 pMac->roam.curState[sessionId] = NewRoamState;
953 }
954 return( PreviousState );
955}
956
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700957void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -0700958{
959 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 if(catOffset)
961 {
962 pMac->roam.configParam.bCatRssiOffset = catOffset;
963 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
964 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700965 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 -0700966 }
967 }
968}
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970static void initConfigParam(tpAniSirGlobal pMac)
971{
972 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
974 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
975 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700976
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
978 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
979 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
980 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
981 pMac->roam.configParam.HeartbeatThresh24 = 40;
982 pMac->roam.configParam.HeartbeatThresh50 = 40;
983 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
984 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
985 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700986 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 pMac->roam.configParam.RTSThreshold = 2346;
988 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
989 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
990 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
991 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
992 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
993 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
994 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
995 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
996 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
997 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
998 {
999 pMac->roam.configParam.BssPreferValue[i] = i;
1000 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001001 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1003 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1004 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1006 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1007 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1008 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1009 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1010 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001011 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1012 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001013 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001014#ifdef WLAN_AP_STA_CONCURRENCY
1015 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1016 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1017 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1018 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1019 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001020 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1021 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001022#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1024 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1025 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1026 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001027#ifdef WLAN_FEATURE_VOWIFI_11R
1028 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001030#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1031 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1032 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1033 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1034 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1035 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1036 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1037 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1038 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1039 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1040 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1041 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001042 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001043#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001044#ifdef WLAN_FEATURE_11AC
1045 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1046#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001047
1048 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1049 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001050
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001051 //Remove this code once SLM_Sessionization is supported
1052 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001053 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001054
Jeff Johnsone7245742012-09-05 17:12:55 -07001055}
Jeff Johnson295189b2012-06-20 16:38:30 -07001056eCsrBand csrGetCurrentBand(tHalHandle hHal)
1057{
1058 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1059 return pMac->roam.configParam.bandCapability;
1060}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001061
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001062
1063#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1064/*
1065 This function flushes the roam scan cache
1066*/
1067eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1068{
1069 eHalStatus status = eHAL_STATUS_SUCCESS;
1070 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1071
1072 /* Free up the memory first (if required) */
1073 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1074 {
1075 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1076 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1077 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1078 }
1079 return status;
1080}
1081#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1082
1083
Srinivas Girigowdade697412013-02-14 16:31:48 -08001084#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001085/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001086 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001087*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001088eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001089{
1090 eHalStatus status = eHAL_STATUS_SUCCESS;
1091 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1092
1093 /* Free up the memory first (if required) */
1094 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1095 {
1096 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1097 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001098 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001099 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001100 return status;
1101}
1102
1103
1104
1105/*
1106 This function flushes the roam scan cache and creates fresh cache
1107 based on the input channel list
1108*/
1109eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1110 const tANI_U8 *pChannelList,
1111 const tANI_U8 numChannels)
1112{
1113 eHalStatus status = eHAL_STATUS_SUCCESS;
1114 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1115
Srinivas Girigowdade697412013-02-14 16:31:48 -08001116 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1117
1118 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1119 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1120
1121 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1122 {
1123 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1124 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1125 return eHAL_STATUS_RESOURCES;
1126 }
1127
1128 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301129 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1130 pChannelList,
1131 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001132 return status;
1133}
1134
1135/* This function modifies the bgscan channel list set via config ini or
1136 runtime, whenever the band changes.
1137 if the band is auto, then no operation is performed on the channel list
1138 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1139 if the band is 5G, then make sure channel list contains only 5G valid channels
1140*/
1141eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1142 eCsrBand eBand)
1143{
1144 eHalStatus status = eHAL_STATUS_SUCCESS;
1145 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1146 tANI_U8 outNumChannels = 0;
1147 tANI_U8 inNumChannels = 0;
1148 tANI_U8 *inPtr = NULL;
1149 tANI_U8 i = 0;
1150 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1151
1152 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1153
1154 {
1155 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1156 "No update required for channel list "
1157 "either cfg.ini channel list is not set up or "
1158 "auto band (Band %d)", eBand);
1159 return status;
1160 }
1161
1162 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1163 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1164 if (eCSR_BAND_24 == eBand)
1165 {
1166 for (i = 0; i < inNumChannels; i++)
1167 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001168 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001169 {
1170 ChannelList[outNumChannels++] = inPtr[i];
1171 }
1172 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001173 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001174 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001175 }
1176 else if (eCSR_BAND_5G == eBand)
1177 {
1178 for (i = 0; i < inNumChannels; i++)
1179 {
1180 /* Add 5G Non-DFS channel */
1181 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001182 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001183 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1184 {
1185 ChannelList[outNumChannels++] = inPtr[i];
1186 }
1187 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001188 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001189 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001190 }
1191 else if (eCSR_BAND_ALL == eBand)
1192 {
1193 for (i = 0; i < inNumChannels; i++)
1194 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001195 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001196 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1197 {
1198 ChannelList[outNumChannels++] = inPtr[i];
1199 }
1200 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001201 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001202 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001203 }
1204 else
1205 {
1206 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1207 "Invalid band, No operation carried out (Band %d)", eBand);
1208 status = eHAL_STATUS_INVALID_PARAMETER;
1209 }
1210
1211 return status;
1212}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001213#endif
1214
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001215#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1216/* This function modifies the roam scan channel list as per AP neighbor
1217 report; AP neighbor report may be empty or may include only other AP
1218 channels; in any case, we merge the channel list with the learned occupied
1219 channels list.
1220 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1221 if the band is 5G, then make sure channel list contains only 5G valid channels
1222*/
1223eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1224 tANI_U8 *pChannelList,
1225 tANI_U8 numChannels,
1226 const eCsrBand eBand)
1227{
1228 eHalStatus status = eHAL_STATUS_SUCCESS;
1229 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1230 tANI_U8 outNumChannels = 0;
1231 tANI_U8 inNumChannels = numChannels;
1232 tANI_U8 *inPtr = pChannelList;
1233 tANI_U8 i = 0;
1234 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1235 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1236 tANI_U8 mergedOutputNumOfChannels = 0;
1237 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1238
1239 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1240 * report Channels. This increases the chances of the DUT to get a candidate AP while
1241 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1242 if (pMac->scan.occupiedChannels.numChannels)
1243 {
1244 csrNeighborRoamMergeChannelLists(pMac,
1245 &pMac->scan.occupiedChannels.channelList[0],
1246 pMac->scan.occupiedChannels.numChannels,
1247 inPtr,
1248 inNumChannels,
1249 &mergedOutputNumOfChannels);
1250 inNumChannels = mergedOutputNumOfChannels;
1251 }
1252
1253 if (eCSR_BAND_24 == eBand)
1254 {
1255 for (i = 0; i < inNumChannels; i++)
1256 {
1257 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1258 {
1259 ChannelList[outNumChannels++] = inPtr[i];
1260 }
1261 }
1262 }
1263 else if (eCSR_BAND_5G == eBand)
1264 {
1265 for (i = 0; i < inNumChannels; i++)
1266 {
1267 /* Add 5G Non-DFS channel */
1268 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1269 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1270 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1271 {
1272 ChannelList[outNumChannels++] = inPtr[i];
1273 }
1274 }
1275 }
1276 else if (eCSR_BAND_ALL == eBand)
1277 {
1278 for (i = 0; i < inNumChannels; i++)
1279 {
1280 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1281 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1282 {
1283 ChannelList[outNumChannels++] = inPtr[i];
1284 }
1285 }
1286 }
1287 else
1288 {
1289 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1290 "Invalid band, No operation carried out (Band %d)", eBand);
1291 return eHAL_STATUS_INVALID_PARAMETER;
1292 }
1293
1294 /* if roaming within band is enabled, then select only the
1295 in band channels .
1296 This is required only if the band capability is set to ALL,
1297 E.g., if band capability is only 2.4G then all the channels in the
1298 list are already filtered for 2.4G channels, hence ignore this check*/
1299
1300 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1301 {
1302 csrNeighborRoamChannelsFilterByCurrentBand(
1303 pMac,
1304 ChannelList,
1305 outNumChannels,
1306 tmpChannelList,
1307 &outNumChannels);
1308 palCopyMemory(pMac->hHdd, ChannelList,
1309 tmpChannelList, outNumChannels);
1310 }
1311
1312 /* Prepare final roam scan channel list */
1313 if(outNumChannels)
1314 {
1315 /* Clear the channel list first */
1316 if (NULL != currChannelListInfo->ChannelList)
1317 {
1318 vos_mem_free(currChannelListInfo->ChannelList);
1319 currChannelListInfo->ChannelList = NULL;
1320 currChannelListInfo->numOfChannels = 0;
1321 }
1322
1323 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1324 if (NULL == currChannelListInfo->ChannelList)
1325 {
1326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1327 "Failed to allocate memory for roam scan channel list");
1328 currChannelListInfo->numOfChannels = 0;
1329 return VOS_STATUS_E_RESOURCES;
1330 }
1331 palCopyMemory(pMac->hHdd, currChannelListInfo->ChannelList,
1332 ChannelList, outNumChannels);
1333 }
1334 return status;
1335}
1336#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1337
Jeff Johnson295189b2012-06-20 16:38:30 -07001338eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1339{
1340 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1341 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1343 (eBand == eCSR_BAND_24))
1344 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001345 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001347 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001348 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 pMac->roam.configParam.uCfgDot11Mode, eBand);
1350 return eHAL_STATUS_INVALID_PARAMETER;
1351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1353 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1354 (eBand == eCSR_BAND_5G))
1355 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001356 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001358 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001359 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 pMac->roam.configParam.uCfgDot11Mode, eBand);
1361 return eHAL_STATUS_INVALID_PARAMETER;
1362 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001363 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001364 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001365 pMac->roam.configParam.eBand = eBand;
1366 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001368#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1369 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1370#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 status = csrInitGetChannels( pMac );
1372 if (eHAL_STATUS_SUCCESS == status)
1373 csrInitChannelList( hHal );
1374 return status;
1375}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001376
1377
Jeff Johnsone7245742012-09-05 17:12:55 -07001378/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1379 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1380 * Ideally we should have kept the ini value and enum value same and representing the same
1381 * cb values as in 11n standard i.e.
1382 * Set to 1 (SCA) if the secondary channel is above the primary channel
1383 * Set to 3 (SCB) if the secondary channel is below the primary channel
1384 * Set to 0 (SCN) if no secondary channel is present
1385 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1386 * 0 - secondary none
1387 * 1 - secondary LOW
1388 * 2 - secondary HIGH
1389 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1390 * The enum values are as follows:
1391 * PHY_SINGLE_CHANNEL_CENTERED = 0
1392 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1393 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1394 */
1395ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1396{
1397
1398 ePhyChanBondState phyCbState;
1399 switch (cbIniValue) {
1400 // secondary none
1401 case 0:
1402 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1403 break;
1404 // secondary LOW
1405 case 1:
1406 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1407 break;
1408 // secondary HIGH
1409 case 2:
1410 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1411 break;
1412#ifdef WLAN_FEATURE_11AC
1413 case 3:
1414 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1415 break;
1416 case 4:
1417 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1418 break;
1419 case 5:
1420 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1421 break;
1422 case 6:
1423 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1424 break;
1425 case 7:
1426 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1427 break;
1428 case 8:
1429 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1430 break;
1431 case 9:
1432 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1433 break;
1434#endif
1435 default:
1436 // If an invalid value is passed, disable CHANNEL BONDING
1437 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1438 break;
1439 }
1440 return phyCbState;
1441}
1442
1443v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1444{
1445
1446 v_U32_t cbIniValue;
1447 switch (phyCbState) {
1448 // secondary none
1449 case PHY_SINGLE_CHANNEL_CENTERED:
1450 cbIniValue = 0;
1451 break;
1452 // secondary LOW
1453 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1454 cbIniValue = 1;
1455 break;
1456 // secondary HIGH
1457 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1458 cbIniValue = 2;
1459 break;
1460#ifdef WLAN_FEATURE_11AC
1461 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1462 cbIniValue = 3;
1463 break;
1464 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1465 cbIniValue = 4;
1466 break;
1467 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1468 cbIniValue = 5;
1469 break;
1470 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1471 cbIniValue = 6;
1472 break;
1473 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1474 cbIniValue = 7;
1475 break;
1476 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1477 cbIniValue = 8;
1478 break;
1479 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1480 cbIniValue = 9;
1481 break;
1482#endif
1483 default:
1484 // return some invalid value
1485 cbIniValue = 10;
1486 break;
1487 }
1488 return cbIniValue;
1489}
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
1491eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1492{
1493 eHalStatus status = eHAL_STATUS_SUCCESS;
1494
1495 if(pParam)
1496 {
1497 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1498 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1499 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1500 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1501 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1502 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1503
1504 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001505 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1506
Jeff Johnsone7245742012-09-05 17:12:55 -07001507 /* channelBondingMode5GHz plays a dual role right now
1508 * 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
1509 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1510 */
1511 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001513 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001514 }
1515 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1516 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001518 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001519 }
1520 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1522 pMac->roam.configParam.phyMode = pParam->phyMode;
1523 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1524 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1525 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1526 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1527 pMac->roam.configParam.TxRate = pParam->TxRate;
1528 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1529 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1530 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1531 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1532 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001533 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 //if HDD passed down non zero values then only update,
1535 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001536 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 {
1538 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1539 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001540 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 {
1542 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1543 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001544 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 {
1546 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1547 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001548 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 {
1550 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1551 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001552 if (pParam->nActiveMaxChnTimeBtc)
1553 {
1554 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1555 }
1556 if (pParam->nActiveMinChnTimeBtc)
1557 {
1558 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1559 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001560#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001561 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001562 {
1563 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1564 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001565 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001566 {
1567 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1568 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001569 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001570 {
1571 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1572 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001573 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001574 {
1575 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1576 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001577 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001578 {
1579 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1580 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001581 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001582 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001583 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1584 }
1585 if (pParam->nNumP2PChanCombinedConc)
1586 {
1587 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001588 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001591 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 {
1593 //Change the unit from second to microsecond
1594 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1596 {
1597 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1598 }
1599 else
1600 {
1601 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1602 }
1603 }
1604 else
1605 {
1606 pMac->roam.configParam.impsSleepTime = 0;
1607 }
1608 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1610 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 //if HDD passed down non zero values for age params, then only update,
1612 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001613 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 {
1615 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 if(pParam->scanAgeTimeNCNPS)
1618 {
1619 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 if(pParam->scanAgeTimeNCPS)
1622 {
1623 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 if(pParam->scanAgeTimeCNPS)
1626 {
1627 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1628 }
1629 if(pParam->scanAgeTimeCPS)
1630 {
1631 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1632 }
1633
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001634 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1636 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1637 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1638 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1639 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1641 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1643 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1644 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1645 //Assign this before calling CsrInit11dInfo
1646 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 if( csrIs11dSupported( pMac ) )
1648 {
1649 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1650 }
1651 else
1652 {
1653 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1654 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001655
1656 /* Initialize the power + channel information if 11h is enabled.
1657 If 11d is enabled this information has already been initialized */
1658 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1659 {
1660 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1661 }
1662
1663
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301664#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301665 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1666 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001667 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001668#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001669#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001671 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001672 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001673 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001674 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001675 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001676 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001677 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001678 pMac->roam.configParam.nProbes = pParam->nProbes;
1679 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001680#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001681#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1682 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001683 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001684#endif
1685#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001686 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001687 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001688#endif
1689
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301690#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1692#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001693#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301694 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1695 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001696 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1697 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1698 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1699 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1700 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1701 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1702 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1703 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 {
1705 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001706 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 -07001707 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1708 {
1709 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 }
1712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1714 pMac->scan.fValidateList = pParam->fValidateList;
1715 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1716 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001717 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001719 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1720 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1721 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1722 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1723 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1724 * single session
1725 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001726 //Remove this code once SLM_Sessionization is supported
1727 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001728 pMac->roam.configParam.doBMPSWorkaround = 0;
1729
Jeff Johnsone7245742012-09-05 17:12:55 -07001730#ifdef WLAN_FEATURE_11AC
1731 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001732 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001733 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001734 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001735#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001736 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001737
1738 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001739 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001740 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1741 pParam->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 }
1743
1744 return status;
1745}
1746
Jeff Johnson295189b2012-06-20 16:38:30 -07001747eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1748{
1749 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 if(pParam)
1751 {
1752 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1753 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1754 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1755 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1756 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1757 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001758 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1759 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1761 pParam->phyMode = pMac->roam.configParam.phyMode;
1762 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1763 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1764 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1765 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1766 pParam->TxRate = pMac->roam.configParam.TxRate;
1767 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1768 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1769 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1770 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1771 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1773 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1774 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1775 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001776 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1777 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1778 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001779#ifdef WLAN_AP_STA_CONCURRENCY
1780 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1781 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1782 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1783 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1784 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001785 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1786 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 //Change the unit from microsecond to second
1789 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1790 pParam->eBand = pMac->roam.configParam.eBand;
1791 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1792 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1793 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1794 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1795 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1796 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1797 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1798 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1799 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1800 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1801 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1802 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1803 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1805 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1806 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1807 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1809 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1810 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1811 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1812 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001813 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001814 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001815 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001816 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001817
1818#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301819 vos_mem_copy(&pParam->neighborRoamConfig,
1820 &pMac->roam.configParam.neighborRoamConfig,
1821 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001822#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001823#ifdef WLAN_FEATURE_11AC
1824 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001825 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001826 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001827 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001828#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001829#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301830 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1831 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001832#endif
1833#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1834 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1835 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1836 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1837 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1838 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001839 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001840 pParam->nProbes = pMac->roam.configParam.nProbes;
1841 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001842#endif
1843#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1844 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1845 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1846#endif
1847#ifdef FEATURE_WLAN_LFR
1848 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1849#endif
1850
1851#ifdef FEATURE_WLAN_CCX
1852 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1853#endif
1854#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301855 vos_mem_copy(&pParam->neighborRoamConfig,
1856 &pMac->roam.configParam.neighborRoamConfig,
1857 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001858 {
1859 int i;
1860 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1861 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1862 {
1863 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1864 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001865 }
1866#endif
1867
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001868 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001869
krunal soni5afa96c2013-09-06 22:19:02 -07001870 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001871 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001872
krunal sonie9002db2013-11-25 14:24:17 -08001873 pParam->isCoalesingInIBSSAllowed =
1874 pMac->roam.configParam.isCoalesingInIBSSAllowed;
1875
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 csrSetChannels(pMac, pParam);
1877
1878 status = eHAL_STATUS_SUCCESS;
1879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 return (status);
1881}
1882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1884{
1885 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1886 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1887 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1888 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 do
1890 {
1891 if(eCSR_BAND_24 == eBand)
1892 {
1893 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1894 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1895 }
1896 if(eCSR_BAND_5G == eBand)
1897 {
1898 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1899 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1900 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1901 )
1902 {
1903 break;
1904 }
1905 }
1906 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1907 {
1908 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1909 }
1910 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1911 {
1912 newPhyMode = eCSR_DOT11_MODE_AUTO;
1913 }
1914 else
1915 {
1916 //Check for dual band and higher capability first
1917 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1918 {
1919 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1920 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1921 }
1922 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1923 {
1924 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1925 if(eCSR_BAND_24 == eBand) break;
1926 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1927 eBand = eCSR_BAND_5G;
1928 }
1929 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1930 {
1931 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1932 if(eCSR_BAND_5G == eBand) break;
1933 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1934 eBand = eCSR_BAND_24;
1935 }
1936 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1937 {
1938 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1939 if(eCSR_BAND_5G == eBand) break;
1940 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1941 eBand = eCSR_BAND_24;
1942 }
1943 else if(eCSR_DOT11_MODE_11n & phyMode)
1944 {
1945 newPhyMode = eCSR_DOT11_MODE_11n;
1946 }
1947 else if(eCSR_DOT11_MODE_abg & phyMode)
1948 {
1949 newPhyMode = eCSR_DOT11_MODE_abg;
1950 }
1951 else if(eCSR_DOT11_MODE_11a & phyMode)
1952 {
1953 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1954 {
1955 if(eCSR_BAND_ALL == eBand)
1956 {
1957 newPhyMode = eCSR_DOT11_MODE_abg;
1958 }
1959 else
1960 {
1961 //bad setting
1962 break;
1963 }
1964 }
1965 else
1966 {
1967 newPhyMode = eCSR_DOT11_MODE_11a;
1968 eBand = eCSR_BAND_5G;
1969 }
1970 }
1971 else if(eCSR_DOT11_MODE_11g & phyMode)
1972 {
1973 newPhyMode = eCSR_DOT11_MODE_11g;
1974 eBand = eCSR_BAND_24;
1975 }
1976 else if(eCSR_DOT11_MODE_11b & phyMode)
1977 {
1978 newPhyMode = eCSR_DOT11_MODE_11b;
1979 eBand = eCSR_BAND_24;
1980 }
1981 else
1982 {
1983 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001984 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001985 newPhyMode = eCSR_DOT11_MODE_AUTO;
1986 }
1987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 //Done validating
1989 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001990 //Now we need to check whether a restart is needed.
1991 if(eBand != pMac->roam.configParam.eBand)
1992 {
1993 fRestartNeeded = eANI_BOOLEAN_TRUE;
1994 break;
1995 }
1996 if(newPhyMode != pMac->roam.configParam.phyMode)
1997 {
1998 fRestartNeeded = eANI_BOOLEAN_TRUE;
1999 break;
2000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 if(HAL_STATUS_SUCCESS(status))
2003 {
2004 pMac->roam.configParam.eBand = eBand;
2005 pMac->roam.configParam.phyMode = newPhyMode;
2006 if(pfRestartNeeded)
2007 {
2008 *pfRestartNeeded = fRestartNeeded;
2009 }
2010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 return (status);
2012}
2013
Jeff Johnson295189b2012-06-20 16:38:30 -07002014void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2015{
2016 tANI_U8 Index;
2017 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 // for dual band NICs, don't need to trim the channel list....
2019 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2020 {
2021 // 2.4 GHz band operation requires the channel list to be trimmed to
2022 // the 2.4 GHz channels only...
2023 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2024 {
2025 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2026 Index++ )
2027 {
2028 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2029 {
2030 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2031 cChannels++;
2032 }
2033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2035 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2036 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2037 // only if we need to.
2038 //
2039 // The amount of memory to clear is the number of channesl that we trimmed
2040 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2041
2042 if ( pChannelList->numChannels > cChannels )
2043 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302044 vos_mem_set(&pChannelList->channelList[ cChannels ],
2045 sizeof( pChannelList->channelList[ 0 ] ) *
2046 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 }
2048
2049 pChannelList->numChannels = cChannels;
2050 }
2051 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2052 {
2053 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2054 {
2055 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2056 {
2057 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2058 cChannels++;
2059 }
2060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2062 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2063 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2064 // only if we need to.
2065 //
2066 // The amount of memory to clear is the number of channesl that we trimmed
2067 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2068 if ( pChannelList->numChannels > cChannels )
2069 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302070 vos_mem_set(&pChannelList->channelList[ cChannels ],
2071 sizeof( pChannelList->channelList[ 0 ] ) *
2072 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 }
2074
2075 pChannelList->numChannels = cChannels;
2076 }
2077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002078}
Jeff Johnson295189b2012-06-20 16:38:30 -07002079#define INFRA_AP_DEFAULT_CHANNEL 6
2080eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2081{
2082 tANI_U8 index= 0;
2083 eHalStatus status = eHAL_STATUS_FAILURE;
2084 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2085 {
2086 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2087 status = eHAL_STATUS_SUCCESS;
2088 break;
2089 }
2090 }
2091 return status;
2092}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002093
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002094
Jeff Johnson295189b2012-06-20 16:38:30 -07002095eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2096{
2097 eHalStatus status = eHAL_STATUS_SUCCESS;
2098 tANI_U8 num20MHzChannelsFound = 0;
2099 VOS_STATUS vosStatus;
2100 tANI_U8 Index = 0;
2101 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002102
Jeff Johnson295189b2012-06-20 16:38:30 -07002103
2104 //TODO: this interface changed to include the 40MHz channel list
2105 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2106 // Read the scan channel list (including the power limit) from EEPROM
2107 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2108 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2109 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002111 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 status = eHAL_STATUS_FAILURE;
2113 }
2114 else
2115 {
2116 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2117 {
2118 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2119 }
2120 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2121 // Move the channel list to the global data
2122 // structure -- this will be used as the scan list
2123 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2124 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2128 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2129 {
2130 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2131 }
2132 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2133 {
2134 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2135 }
2136 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 return (status);
2139}
2140
Jeff Johnson295189b2012-06-20 16:38:30 -07002141eHalStatus csrInitChannelList( tHalHandle hHal )
2142{
2143 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2144 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2146 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002147 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2148 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002150 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002151
2152 return (status);
2153}
Jeff Johnson295189b2012-06-20 16:38:30 -07002154eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2155 tCsrUpdateConfigParam *pUpdateConfigParam)
2156{
2157 eHalStatus status = eHAL_STATUS_FAILURE;
2158 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2160 status = CsrInit11dInfo(pMac, ps11dinfo);
2161 return status;
2162}
2163
Jeff Johnson295189b2012-06-20 16:38:30 -07002164static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2165{
2166 eHalStatus status = eHAL_STATUS_FAILURE;
2167 tANI_U8 index;
2168 tANI_U32 count=0;
2169 tSirMacChanInfo *pChanInfo;
2170 tSirMacChanInfo *pChanInfoStart;
2171 tANI_BOOLEAN applyConfig = TRUE;
2172
2173 if(!ps11dinfo)
2174 {
2175 return (status);
2176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002177 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2178 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302179 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2180 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2181 ps11dinfo->Channels.channelList,
2182 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 }
2184 else
2185 {
2186 //No change
2187 return (eHAL_STATUS_SUCCESS);
2188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302190
2191 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2192 WNI_CFG_COUNTRY_CODE_LEN);
2193
2194
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 //Tush: at csropen get this initialized with default, during csr reset if this
2196 // already set with some value no need initilaize with default again
2197 if(0 == pMac->scan.countryCodeCurrent[0])
2198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302199 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2200 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302203 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2204 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302206 vos_mem_set(pChanInfo,
2207 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2208 0);
2209
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002211 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2212 {
2213 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2214 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2215 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2216 pChanInfo++;
2217 count++;
2218 }
2219 if(count)
2220 {
2221 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2222 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302223 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002224 }
2225 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2226 if( HAL_STATUS_SUCCESS(status) )
2227 {
2228 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2229 {
2230 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2231 {
2232 applyConfig = FALSE;
2233 }
2234 }
2235
2236 if(TRUE == applyConfig)
2237 {
2238 // 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 Johnsone7245742012-09-05 17:12:55 -07002240 }
2241
2242 }
2243 return (status);
2244}
2245/* Initialize the Channel + Power List in the local cache and in the CFG */
2246eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2247{
2248 tANI_U8 index;
2249 tANI_U32 count=0;
2250 tSirMacChanInfo *pChanInfo;
2251 tSirMacChanInfo *pChanInfoStart;
2252
2253 if(!ps11dinfo || !pMac)
2254 {
2255 return eHAL_STATUS_FAILURE;
2256 }
2257
Kiet Lam64c1b492013-07-12 13:56:44 +05302258 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2259 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002260 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302261 vos_mem_set(pChanInfo,
2262 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2263 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002264 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
2266 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2267 {
2268 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2269 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2270 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2271 pChanInfo++;
2272 count++;
2273 }
2274 if(count)
2275 {
2276 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2277 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302278 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 }
2280
Jeff Johnsone7245742012-09-05 17:12:55 -07002281 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002282}
2283
2284//pCommand may be NULL
2285//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2286void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2287{
2288 tListElem *pEntry, *pNextEntry;
2289 tSmeCmd *pDupCommand;
2290 tDblLinkList localList;
2291
2292 vos_mem_zero(&localList, sizeof(tDblLinkList));
2293 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2294 {
2295 smsLog(pMac, LOGE, FL(" failed to open list"));
2296 return;
2297 }
2298 csrLLLock( &pMac->sme.smeCmdPendingList );
2299 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2300 while( pEntry )
2301 {
2302 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2303 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 // Remove the previous command if..
2305 // - the new roam command is for the same RoamReason...
2306 // - the new roam command is a NewProfileList.
2307 // - the new roam command is a Forced Dissoc
2308 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2309 if (
2310 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2311 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002312 /* This peermac check is requried for Softap/GO scenarios
2313 * For STA scenario below OR check will suffice as pCommand will
2314 * always be NULL for STA scenarios
2315 */
2316 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2318 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2319 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2320 ||
2321 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002322 ( (sessionId == pDupCommand->sessionId) &&
2323 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 ((eCsrForcedDisassoc == eRoamReason) ||
2325 (eCsrHddIssued == eRoamReason))
2326 )
2327 )
2328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002329 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 // Remove the 'stale' roam command from the pending list...
2331 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2332 {
2333 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2334 }
2335 }
2336 pEntry = pNextEntry;
2337 }
2338 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2339
2340 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2341 {
2342 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2343 //Tell caller that the command is cancelled
2344 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2345 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2346 csrReleaseCommandRoam(pMac, pDupCommand);
2347 }
2348 csrLLClose(&localList);
2349}
Jeff Johnson295189b2012-06-20 16:38:30 -07002350eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2351 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2352{
2353 eHalStatus status = eHAL_STATUS_SUCCESS;
2354#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2355 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2356#endif
2357 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2359 {
2360 pSession = CSR_GET_SESSION( pMac, sessionId );
2361 }
2362 else
2363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002364 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 VOS_ASSERT(0);
2366 return eHAL_STATUS_FAILURE;
2367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002370 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002372 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2373 /*
2374 * Decrement bRefAssocStartCnt for FT reassoc failure.
2375 * Reason: For FT reassoc failures, we first call
2376 * csrRoamCallCallback before notifying a failed roam
2377 * completion through csrRoamComplete. The latter in
2378 * turn calls csrRoamProcessResults which tries to
2379 * once again call csrRoamCallCallback if bRefAssocStartCnt
2380 * is non-zero. Since this is redundant for FT reassoc
2381 * failure, decrement bRefAssocStartCnt.
2382 */
2383 pSession->bRefAssocStartCnt--;
2384 }
2385
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 if ( (pSession == NULL) ||
2387 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002389 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 return eHAL_STATUS_FAILURE;
2391 }
2392
2393 if(NULL != pSession->callback)
2394 {
2395 if( pRoamInfo )
2396 {
2397 pRoamInfo->sessionId = (tANI_U8)sessionId;
2398 }
2399
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302400 /* avoid holding the global lock when making the roaming callback, original change came
2401 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2402 is possible on other OS ports where the callback may need to take locks to protect
2403 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2405 that may actually depend on the lock being held */
2406 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2407 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2408 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2409 }
2410 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2411 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2412#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302413 vos_mem_set(&connectionStatus,
2414 sizeof(vos_event_wlan_status_payload_type), 0);
2415
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2417 {
2418 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2419 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2420 if(NULL != pRoamInfo->pBssDesc)
2421 {
2422 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2423 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2426 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2427 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302428 vos_mem_copy(connectionStatus.ssid,
2429 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2430
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2432 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2435 {
2436 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2437 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2438 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 if(eCSR_ROAM_RESULT_FORCED == u2)
2441 {
2442 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2443 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2444 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2447 {
2448 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2449 connectionStatus.reason = eCSR_REASON_DISASSOC;
2450 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2453 {
2454 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2455 connectionStatus.reason = eCSR_REASON_DEAUTH;
2456 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002458#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2459
2460 return (status);
2461}
Jeff Johnson295189b2012-06-20 16:38:30 -07002462// Returns whether handoff is currently in progress or not
2463tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2464{
2465#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2466 return csrNeighborRoamIsHandoffInProgress(pMac);
2467#else
2468 return eANI_BOOLEAN_FALSE;
2469#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002470}
Jeff Johnson295189b2012-06-20 16:38:30 -07002471eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2472 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2473{
2474 eHalStatus status = eHAL_STATUS_SUCCESS;
2475 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2476 tANI_U16 reasonCode;
2477 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002478
2479 if(!pSession)
2480 {
2481 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2482 return eHAL_STATUS_FAILURE;
2483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002484
2485 //Restore AC weight in case we change it
2486 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2487 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002488 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 -07002489 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2490 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2491 }
2492
2493 if ( fMICFailure )
2494 {
2495 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2496 }
2497 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2498 {
2499 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002500 }
2501 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 {
2503 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002505#ifdef WLAN_FEATURE_VOWIFI_11R
2506 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2507 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2508 {
2509 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302510 vos_mem_copy(&bssId,
2511 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2512 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002513 }
2514 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002515#endif
2516 if(pSession->pConnectBssDesc)
2517 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302518 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002519 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002520
Jeff Johnson295189b2012-06-20 16:38:30 -07002521
Arif Hussain24bafea2013-11-15 15:10:03 -08002522 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2523 " subState = %d reason=%d",
2524 MAC_ADDR_ARRAY(bssId), NewSubstate, reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002525
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2527
2528 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2529
2530 if(HAL_STATUS_SUCCESS(status))
2531 {
2532 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002533#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2534 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2535 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2536 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002537 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2539 }
2540#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002541 }
2542 else
2543 {
2544 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2545 }
2546
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 return (status);
2548}
Jeff Johnson295189b2012-06-20 16:38:30 -07002549
Jeff Johnson295189b2012-06-20 16:38:30 -07002550/* ---------------------------------------------------------------------------
2551 \fn csrRoamIssueDisassociateStaCmd
2552 \brief csr function that HDD calls to disassociate a associated station
2553 \param sessionId - session Id for Soft AP
2554 \param pPeerMacAddr - MAC of associated station to delete
2555 \param reason - reason code, be one of the tSirMacReasonCodes
2556 \return eHalStatus
2557 ---------------------------------------------------------------------------*/
2558eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2559 tANI_U32 sessionId,
2560 tANI_U8 *pPeerMacAddr,
2561 tANI_U32 reason)
2562{
2563 eHalStatus status = eHAL_STATUS_SUCCESS;
2564 tSmeCmd *pCommand;
2565
2566 do
2567 {
2568 pCommand = csrGetCommandBuffer( pMac );
2569 if ( !pCommand )
2570 {
2571 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2572 status = eHAL_STATUS_RESOURCES;
2573 break;
2574 }
2575 pCommand->command = eSmeCommandRoam;
2576 pCommand->sessionId = (tANI_U8)sessionId;
2577 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2578 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2579 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2580 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2581 if( !HAL_STATUS_SUCCESS( status ) )
2582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002583 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 csrReleaseCommandRoam( pMac, pCommand );
2585 }
2586 }while(0);
2587
2588 return status;
2589}
2590
2591
Jeff Johnson295189b2012-06-20 16:38:30 -07002592/* ---------------------------------------------------------------------------
2593 \fn csrRoamIssueDeauthSta
2594 \brief csr function that HDD calls to delete a associated station
2595 \param sessionId - session Id for Soft AP
2596 \param pPeerMacAddr - MAC of associated station to delete
2597 \param reason - reason code, be one of the tSirMacReasonCodes
2598 \return eHalStatus
2599 ---------------------------------------------------------------------------*/
2600eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2601 tANI_U32 sessionId,
2602 tANI_U8 *pPeerMacAddr,
2603 tANI_U32 reason)
2604{
2605 eHalStatus status = eHAL_STATUS_SUCCESS;
2606 tSmeCmd *pCommand;
2607
2608 do
2609 {
2610 pCommand = csrGetCommandBuffer( pMac );
2611 if ( !pCommand )
2612 {
2613 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2614 status = eHAL_STATUS_RESOURCES;
2615 break;
2616 }
2617 pCommand->command = eSmeCommandRoam;
2618 pCommand->sessionId = (tANI_U8)sessionId;
2619 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2620 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2621 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2622 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2623 if( !HAL_STATUS_SUCCESS( status ) )
2624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002625 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 csrReleaseCommandRoam( pMac, pCommand );
2627 }
2628 }while(0);
2629
2630 return status;
2631}
Jeff Johnson295189b2012-06-20 16:38:30 -07002632eHalStatus
2633csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2634 tANI_BOOLEAN bEnable )
2635{
2636 eHalStatus status = eHAL_STATUS_FAILURE;
2637 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2638 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 if (!pSession)
2640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002641 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 return (status);
2643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 if (pSession->pConnectBssDesc)
2645 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302646 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 }
2648 else
2649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002650 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 return (status);
2652 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002653 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2654 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2656 return (status);
2657}
Jeff Johnson295189b2012-06-20 16:38:30 -07002658eHalStatus
2659csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2660 VOS_MODULE_ID modId, void *pUsrContext,
2661 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2662{
2663 eHalStatus status = eHAL_STATUS_SUCCESS;
2664 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 if (!pSession)
2667 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002668 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 return (status);
2670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 if(pSession->pConnectBssDesc)
2672 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302673 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 }
2675 else
2676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002677 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 return (status);
2679 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002680 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2681 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2683 return (status);
2684}
Jeff Johnson295189b2012-06-20 16:38:30 -07002685eHalStatus
2686csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2687 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2688{
2689 eHalStatus status = eHAL_STATUS_SUCCESS;
2690 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2691 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2692
2693 if (!pSession)
2694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002695 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 return (status);
2697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 if(pSession->pConnectBssDesc)
2699 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302700 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 }
2702 else
2703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002704 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 return (status);
2706 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002707 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2708 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002709
2710 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2711
2712 return (status);
2713}
Jeff Johnson295189b2012-06-20 16:38:30 -07002714eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2715{
2716 eHalStatus status = eHAL_STATUS_SUCCESS;
2717 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2718 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002719
2720 if (!pSession)
2721 {
2722 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2723 return eHAL_STATUS_FAILURE;
2724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 if(pSession->pConnectBssDesc)
2727 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302728 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002730 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2731 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2733
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302734 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002735 if(!HAL_STATUS_SUCCESS(status))
2736 {
2737 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2738 }
2739
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 return (status);
2741}
2742
Jeff Johnson295189b2012-06-20 16:38:30 -07002743eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2744{
2745 eHalStatus status = eHAL_STATUS_SUCCESS;
2746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2747 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002748
2749 if(!pSession)
2750 {
2751 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2752 return eHAL_STATUS_FAILURE;
2753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002754
2755 // If no BSS description was found in this connection (happens with start IBSS), then
2756 // nix the BSS description that we keep around for the connected BSS) and get out...
2757 if(NULL == pBssDesc)
2758 {
2759 csrFreeConnectBssDesc(pMac, sessionId);
2760 }
2761 else
2762 {
2763 size = pBssDesc->length + sizeof( pBssDesc->length );
2764 if(NULL != pSession->pConnectBssDesc)
2765 {
2766 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2767 {
2768 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2769 csrFreeConnectBssDesc(pMac, sessionId);
2770 }
2771 }
2772 if(NULL == pSession->pConnectBssDesc)
2773 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302774 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302776 if (NULL == pSession->pConnectBssDesc)
2777 status = eHAL_STATUS_FAILURE;
2778 else
2779 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 return (status);
2782}
2783
Jeff Johnson295189b2012-06-20 16:38:30 -07002784eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2785 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2786 tDot11fBeaconIEs *pIes)
2787{
2788 eHalStatus status = eHAL_STATUS_SUCCESS;
2789 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302791 if (pIes == NULL)
2792 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002793
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 do
2795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302796 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2797 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 //get qos
2799 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2800 //get SSID
2801 if(pIes->SSID.present)
2802 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302803 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2805 }
2806 else
2807 pBssConfig->SSID.length = 0;
2808 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002810 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 //Return failed if profile doesn't have an SSID either.
2812 if(pProfile->SSIDs.numOfSSIDs == 0)
2813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002814 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 status = eHAL_STATUS_FAILURE;
2816 break;
2817 }
2818 }
2819 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2820 {
2821 pBssConfig->eBand = eCSR_BAND_5G;
2822 }
2823 else
2824 {
2825 pBssConfig->eBand = eCSR_BAND_24;
2826 }
2827 //phymode
2828 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2829 {
2830 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2831 }
2832 else
2833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002834 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 //force it
2836 if(eCSR_BAND_24 == pBssConfig->eBand)
2837 {
2838 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2839 }
2840 else
2841 {
2842 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2843 }
2844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 //Qos
2846 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2847 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2848 {
2849 //Joining BSS is not 11n capable and WMM is disabled on client.
2850 //Disable QoS and WMM
2851 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2852 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302853
2854 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302855 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302856 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2857 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2858 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2859 {
2860 //Joining BSS is 11n capable and WMM is disabled on AP.
2861 //Assume all HT AP's are QOS AP's and enable WMM
2862 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2863 }
2864
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 //auth type
2866 switch( pProfile->negotiatedAuthType )
2867 {
2868 default:
2869 case eCSR_AUTH_TYPE_WPA:
2870 case eCSR_AUTH_TYPE_WPA_PSK:
2871 case eCSR_AUTH_TYPE_WPA_NONE:
2872 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2873 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2874 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 case eCSR_AUTH_TYPE_SHARED_KEY:
2876 pBssConfig->authType = eSIR_SHARED_KEY;
2877 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 case eCSR_AUTH_TYPE_AUTOSWITCH:
2879 pBssConfig->authType = eSIR_AUTO_SWITCH;
2880 break;
2881 }
2882 //short slot time
2883 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2884 {
2885 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2886 }
2887 else
2888 {
2889 pBssConfig->uShortSlotTime = 0;
2890 }
2891 if(pBssConfig->BssCap.ibss)
2892 {
2893 //We don't support 11h on IBSS
2894 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2895 }
2896 else
2897 {
2898 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2899 }
2900 //power constraint
2901 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2902 //heartbeat
2903 if ( CSR_IS_11A_BSS( pBssDesc ) )
2904 {
2905 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2906 }
2907 else
2908 {
2909 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2910 }
2911 //Join timeout
2912 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002913 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 if ( pBssDesc->beaconInterval )
2915 {
2916 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002917 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 }
2919 else
2920 {
2921 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2922 }
2923 //validate CB
2924 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2925 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 return (status);
2927}
2928
Jeff Johnson295189b2012-06-20 16:38:30 -07002929static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2930 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2931{
2932 eHalStatus status = eHAL_STATUS_SUCCESS;
2933 tANI_U8 operationChannel = 0;
2934 tANI_U8 qAPisEnabled = FALSE;
2935 //SSID
2936 pBssConfig->SSID.length = 0;
2937 if(pProfile->SSIDs.numOfSSIDs)
2938 {
2939 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05302940 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
2941 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 }
2943 else
2944 {
2945 //SSID must present
2946 return eHAL_STATUS_FAILURE;
2947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 //Settomg up the capabilities
2949 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2950 {
2951 pBssConfig->BssCap.ibss = 1;
2952 }
2953 else
2954 {
2955 pBssConfig->BssCap.ess = 1;
2956 }
2957 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2958 {
2959 pBssConfig->BssCap.privacy = 1;
2960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 pBssConfig->eBand = pMac->roam.configParam.eBand;
2962 //phymode
2963 if(pProfile->ChannelInfo.ChannelList)
2964 {
2965 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2968 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 //QOS
2970 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 if ( pBssConfig->BssCap.ess == 1 )
2972 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 /*For Softap case enable WMM*/
2974 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2975 qAPisEnabled = TRUE;
2976 }
2977 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2979 qAPisEnabled = TRUE;
2980 } else {
2981 qAPisEnabled = FALSE;
2982 }
2983 } else {
2984 qAPisEnabled = TRUE;
2985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2987 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2988 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2989 )
2990 {
2991 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2992 } else {
2993 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2994 }
2995
2996 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002997 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 {
2999 default:
3000 case eCSR_AUTH_TYPE_WPA:
3001 case eCSR_AUTH_TYPE_WPA_PSK:
3002 case eCSR_AUTH_TYPE_WPA_NONE:
3003 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3004 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3005 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 case eCSR_AUTH_TYPE_SHARED_KEY:
3007 pBssConfig->authType = eSIR_SHARED_KEY;
3008 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 case eCSR_AUTH_TYPE_AUTOSWITCH:
3010 pBssConfig->authType = eSIR_AUTO_SWITCH;
3011 break;
3012 }
3013 //short slot time
3014 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3015 {
3016 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3017 }
3018 else
3019 {
3020 pBssConfig->uShortSlotTime = 0;
3021 }
3022 //power constraint. We don't support 11h on IBSS
3023 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3024 pBssConfig->uPowerLimit = 0;
3025 //heartbeat
3026 if ( eCSR_BAND_5G == pBssConfig->eBand )
3027 {
3028 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3029 }
3030 else
3031 {
3032 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3033 }
3034 //Join timeout
3035 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003036
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 return (status);
3038}
Jeff Johnson295189b2012-06-20 16:38:30 -07003039static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3040{
3041 eHalStatus status = eHAL_STATUS_FAILURE;
3042 tDot11fBeaconIEs *pIes = NULL;
3043
3044 do
3045 {
3046 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3047 {
3048 //err msg
3049 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003050 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 break;
3052 }
3053 //check if the AP is QAP & it supports APSD
3054 if( CSR_IS_QOS_BSS(pIes) )
3055 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303056 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 }
3058 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303059
3060 if (NULL != pIes)
3061 {
3062 vos_mem_free(pIes);
3063 }
3064
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 return status;
3066}
3067
Jeff Johnson295189b2012-06-20 16:38:30 -07003068void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3069{
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3071 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3072 // See !!Note: below in this function...
3073 tANI_U32 PrivacyEnabled = 0;
3074 tANI_U32 RsnEnabled = 0;
3075 tANI_U32 WepDefaultKeyId = 0;
3076 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3077 tANI_U32 Key0Length = 0;
3078 tANI_U32 Key1Length = 0;
3079 tANI_U32 Key2Length = 0;
3080 tANI_U32 Key3Length = 0;
3081
3082 // Reserve for the biggest key
3083 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3084 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3085 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3086 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3087
3088 switch ( pProfile->negotiatedUCEncryptionType )
3089 {
3090 case eCSR_ENCRYPT_TYPE_NONE:
3091
3092 // for NO encryption, turn off Privacy and Rsn.
3093 PrivacyEnabled = 0;
3094 RsnEnabled = 0;
3095
3096 // WEP key length and Wep Default Key ID don't matter in this case....
3097
3098 // clear out the WEP keys that may be hanging around.
3099 Key0Length = 0;
3100 Key1Length = 0;
3101 Key2Length = 0;
3102 Key3Length = 0;
3103
3104 break;
3105
3106 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303107 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003108
3109 // Privacy is ON. NO RSN for Wep40 static key.
3110 PrivacyEnabled = 1;
3111 RsnEnabled = 0;
3112
3113 // Set the Wep default key ID.
3114 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 // Wep key size if 5 bytes (40 bits).
3116 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3117
3118 // set encryption keys in the CFG database or clear those that are not present in this profile.
3119 if ( pProfile->Keys.KeyLength[0] )
3120 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303121 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3122 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3124 }
3125 else
3126 {
3127 Key0Length = 0;
3128 }
3129
3130 if ( pProfile->Keys.KeyLength[1] )
3131 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303132 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3133 WNI_CFG_WEP_KEY_LENGTH_5);
3134 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136 else
3137 {
3138 Key1Length = 0;
3139 }
3140
3141 if ( pProfile->Keys.KeyLength[2] )
3142 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303143 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3144 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3146 }
3147 else
3148 {
3149 Key2Length = 0;
3150 }
3151
3152 if ( pProfile->Keys.KeyLength[3] )
3153 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303154 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3155 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3157 }
3158 else
3159 {
3160 Key3Length = 0;
3161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 break;
3163
3164 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303165 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003166
3167 // Privacy is ON. NO RSN for Wep40 static key.
3168 PrivacyEnabled = 1;
3169 RsnEnabled = 0;
3170
3171 // Set the Wep default key ID.
3172 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3173
3174 // Wep key size if 13 bytes (104 bits).
3175 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3176
3177 // set encryption keys in the CFG database or clear those that are not present in this profile.
3178 if ( pProfile->Keys.KeyLength[0] )
3179 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303180 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3181 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3183 }
3184 else
3185 {
3186 Key0Length = 0;
3187 }
3188
3189 if ( pProfile->Keys.KeyLength[1] )
3190 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303191 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3192 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3194 }
3195 else
3196 {
3197 Key1Length = 0;
3198 }
3199
3200 if ( pProfile->Keys.KeyLength[2] )
3201 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303202 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3203 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3205 }
3206 else
3207 {
3208 Key2Length = 0;
3209 }
3210
3211 if ( pProfile->Keys.KeyLength[3] )
3212 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303213 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3214 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3216 }
3217 else
3218 {
3219 Key3Length = 0;
3220 }
3221
3222 break;
3223
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 case eCSR_ENCRYPT_TYPE_TKIP:
3225 case eCSR_ENCRYPT_TYPE_AES:
3226#ifdef FEATURE_WLAN_WAPI
3227 case eCSR_ENCRYPT_TYPE_WPI:
3228#endif /* FEATURE_WLAN_WAPI */
3229 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3230 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3231 PrivacyEnabled = (0 != fPrivacy);
3232
3233 // turn on RSN enabled for WPA associations
3234 RsnEnabled = 1;
3235
3236 // WEP key length and Wep Default Key ID don't matter in this case....
3237
3238 // clear out the static WEP keys that may be hanging around.
3239 Key0Length = 0;
3240 Key1Length = 0;
3241 Key2Length = 0;
3242 Key3Length = 0;
3243
3244 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 default:
3246 PrivacyEnabled = 0;
3247 RsnEnabled = 0;
3248 break;
3249 }
3250
3251 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3252 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3253 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3254 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3255 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3256 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3257 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3258 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3259}
3260
Jeff Johnson295189b2012-06-20 16:38:30 -07003261static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3262{
3263 tANI_U32 len = 0;
3264 if(pSSID->length <= WNI_CFG_SSID_LEN)
3265 {
3266 len = pSSID->length;
3267 }
3268 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3269}
3270
Jeff Johnson295189b2012-06-20 16:38:30 -07003271eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3272{
3273 eHalStatus status = eHAL_STATUS_SUCCESS;
3274 tANI_U32 QoSEnabled;
3275 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 // set the CFG enable/disable variables based on the qosType being configured...
3277 switch( qosType )
3278 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3280 QoSEnabled = FALSE;
3281 WmeEnabled = TRUE;
3282 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3284 QoSEnabled = FALSE;
3285 WmeEnabled = TRUE;
3286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3288 QoSEnabled = FALSE;
3289 WmeEnabled = TRUE;
3290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3292 QoSEnabled = TRUE;
3293 WmeEnabled = FALSE;
3294 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 case eCSR_MEDIUM_ACCESS_11e_HCF:
3296 QoSEnabled = TRUE;
3297 WmeEnabled = FALSE;
3298 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 default:
3300 case eCSR_MEDIUM_ACCESS_DCF:
3301 QoSEnabled = FALSE;
3302 WmeEnabled = FALSE;
3303 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 }
3305 //save the WMM setting for later use
3306 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3308 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 return (status);
3310}
Jeff Johnson295189b2012-06-20 16:38:30 -07003311static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3312 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3313{
3314 eHalStatus status = eHAL_STATUS_FAILURE;
3315 int i;
3316 eCsrCfgDot11Mode cfgDot11Mode;
3317 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303318 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3319 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003321
3322 if( NULL != pIes )
3323 {
3324 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 // Originally, we thought that for 11a networks, the 11a rates are always
3326 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3327 // appear in the Operational Rate set. Consequently, in either case, we
3328 // would blindly put the rates we support into our Operational Rate set
3329 // (including the basic rates, which we have already verified are
3330 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 // However, it turns out that this is not always the case. Some AP's
3332 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3333 // too. Now, we're a little more careful:
3334 pDstRate = pOpRateSet->rate;
3335 if(pIes->SuppRates.present)
3336 {
3337 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3338 {
3339 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3340 {
3341 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003342 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 }
3344 }
3345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3347 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3348 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3349 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3350 {
3351 // If there are Extended Rates in the beacon, we will reflect those
3352 // extended rates that we support in out Extended Operational Rate
3353 // set:
3354 pDstRate = pExRateSet->rate;
3355 if(pIes->ExtSuppRates.present)
3356 {
3357 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3358 {
3359 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3360 {
3361 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3362 pExRateSet->numRates++;
3363 }
3364 }
3365 }
3366 }
3367 }//Parsing BSSDesc
3368 else
3369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003370 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 }
3372 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3373 return status;
3374}
3375
3376static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3377 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3378{
3379 int i;
3380 tANI_U8 *pDstRate;
3381 eCsrCfgDot11Mode cfgDot11Mode;
3382 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3383 tANI_U32 OperationalRatesLength = 0;
3384 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3385 tANI_U32 ExtendedOperationalRatesLength = 0;
3386 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3387 tANI_U32 ProprietaryOperationalRatesLength = 0;
3388 tANI_U32 PropRatesEnable = 0;
3389 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3390 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 if( NULL != pIes )
3393 {
3394 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 // Originally, we thought that for 11a networks, the 11a rates are always
3396 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3397 // appear in the Operational Rate set. Consequently, in either case, we
3398 // would blindly put the rates we support into our Operational Rate set
3399 // (including the basic rates, which we have already verified are
3400 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 // However, it turns out that this is not always the case. Some AP's
3402 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3403 // too. Now, we're a little more careful:
3404 pDstRate = OperationalRates;
3405 if(pIes->SuppRates.present)
3406 {
3407 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3408 {
3409 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3410 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3411 {
3412 *pDstRate++ = pIes->SuppRates.rates[ i ];
3413 OperationalRatesLength++;
3414 }
3415 }
3416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3418 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3419 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3420 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3421 {
3422 // If there are Extended Rates in the beacon, we will reflect those
3423 // extended rates that we support in out Extended Operational Rate
3424 // set:
3425 pDstRate = ExtendedOperationalRates;
3426 if(pIes->ExtSuppRates.present)
3427 {
3428 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3429 {
3430 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3431 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3432 {
3433 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3434 ExtendedOperationalRatesLength++;
3435 }
3436 }
3437 }
3438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 // Enable proprietary MAC features if peer node is Airgo node and STA
3440 // user wants to use them
3441 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3442 {
3443 PropRatesEnable = 1;
3444 }
3445 else
3446 {
3447 PropRatesEnable = 0;
3448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 // For ANI network companions, we need to populate the proprietary rate
3450 // set with any proprietary rates we found in the beacon, only if user
3451 // allows them...
3452 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3453 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3454 {
3455 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3456 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3457 {
3458 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3459 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303460 vos_mem_copy(ProprietaryOperationalRates,
3461 pIes->Airgo.PropSuppRates.rates,
3462 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 }
3464 else {
3465 // No proprietary modes...
3466 ProprietaryOperationalRatesLength = 0;
3467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 /* Get MCS Rate */
3469 pDstRate = MCSRateIdxSet;
3470 if ( pIes->HTCaps.present )
3471 {
3472 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3473 {
3474 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3475 {
3476 MCSRateLength++;
3477 *pDstRate++ = i;
3478 }
3479 }
3480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 // Set the operational rate set CFG variables...
3482 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3483 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3484 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3485 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3486 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3487 ProprietaryOperationalRates,
3488 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3489 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3490 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3491 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3492 }//Parsing BSSDesc
3493 else
3494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003495 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 }
3497}
3498
Jeff Johnson295189b2012-06-20 16:38:30 -07003499static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3500 tCsrRoamProfile *pProfile )
3501{
3502 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3503 { 8,
3504 { SIR_MAC_RATE_6,
3505 SIR_MAC_RATE_9,
3506 SIR_MAC_RATE_12,
3507 SIR_MAC_RATE_18,
3508 SIR_MAC_RATE_24,
3509 SIR_MAC_RATE_36,
3510 SIR_MAC_RATE_48,
3511 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3513 { 4,
3514 { SIR_MAC_RATE_1,
3515 SIR_MAC_RATE_2,
3516 SIR_MAC_RATE_5_5,
3517 SIR_MAC_RATE_11 } } };
3518
3519
3520 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3521 { SIR_MAC_RATE_72,
3522 SIR_MAC_RATE_96,
3523 SIR_MAC_RATE_108 } };
3524 eCsrCfgDot11Mode cfgDot11Mode;
3525 eCsrBand eBand;
3526 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3527 tANI_U32 OperationalRatesLength = 0;
3528 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3529 tANI_U32 ExtendedOperationalRatesLength = 0;
3530 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3531 tANI_U32 ProprietaryOperationalRatesLength = 0;
3532 tANI_U32 PropRatesEnable = 0;
3533 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 if(pProfile->ChannelInfo.ChannelList)
3535 {
3536 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3540 // networks, the 11b rates appear in the Operational Rate set. In either case,
3541 // we can blindly put the rates we support into our Operational Rate set
3542 // (including the basic rates, which we have already verified are supported
3543 // earlier in the roaming decision).
3544 if ( eCSR_BAND_5G == eBand )
3545 {
3546 // 11a rates into the Operational Rate Set.
3547 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3548 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303549 vos_mem_copy(OperationalRates,
3550 DefaultSupportedRates11a.supportedRateSet.rate,
3551 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003552
3553 // Nothing in the Extended rate set.
3554 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 // populate proprietary rates if user allows them
3556 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3557 {
3558 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3559 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303560 vos_mem_copy(ProprietaryOperationalRates,
3561 DefaultSupportedPropRates.propRate,
3562 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 }
3564 else
3565 {
3566 // No proprietary modes
3567 ProprietaryOperationalRatesLength = 0;
3568 }
3569 }
3570 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3571 {
3572 // 11b rates into the Operational Rate Set.
3573 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3574 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303575 vos_mem_copy(OperationalRates,
3576 DefaultSupportedRates11b.supportedRateSet.rate,
3577 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 // Nothing in the Extended rate set.
3579 ExtendedOperationalRatesLength = 0;
3580 // No proprietary modes
3581 ProprietaryOperationalRatesLength = 0;
3582 }
3583 else
3584 {
3585 // 11G
3586
3587 // 11b rates into the Operational Rate Set.
3588 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3589 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303590 vos_mem_copy(OperationalRates,
3591 DefaultSupportedRates11b.supportedRateSet.rate,
3592 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003593
3594 // 11a rates go in the Extended rate set.
3595 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3596 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303597 vos_mem_copy(ExtendedOperationalRates,
3598 DefaultSupportedRates11a.supportedRateSet.rate,
3599 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003600
3601 // populate proprietary rates if user allows them
3602 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3603 {
3604 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3605 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303606 vos_mem_copy(ProprietaryOperationalRates,
3607 DefaultSupportedPropRates.propRate,
3608 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 }
3610 else
3611 {
3612 // No proprietary modes
3613 ProprietaryOperationalRatesLength = 0;
3614 }
3615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3617 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3618 {
3619 PropRatesEnable = 1;
3620 }
3621 else
3622 {
3623 PropRatesEnable = 0;
3624 }
3625
3626 // Set the operational rate set CFG variables...
3627 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3628 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3629 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3630 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3631 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3632 ProprietaryOperationalRates,
3633 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3634 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003635}
Jeff Johnson295189b2012-06-20 16:38:30 -07003636void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3637{
3638 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003639
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3641 tANI_U32 sessionId;
3642 tSmeCmd *pCommand = NULL;
3643
3644 if(NULL == pEntry)
3645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003646 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 return;
3648 }
3649 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3650 sessionId = pCommand->sessionId;
3651
3652 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3653 {
3654 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3655 }
3656}
3657
Jeff Johnson295189b2012-06-20 16:38:30 -07003658//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3659tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3660{
3661 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3662 {
3663 return (WNI_CFG_PHY_MODE_11B);
3664 }
3665 else
3666 {
3667 if(eCSR_BAND_24 == band)
3668 return (WNI_CFG_PHY_MODE_11G);
3669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 return (WNI_CFG_PHY_MODE_11A);
3671}
Jeff Johnson295189b2012-06-20 16:38:30 -07003672
Jeff Johnsone7245742012-09-05 17:12:55 -07003673
3674#ifdef WLAN_FEATURE_11AC
3675ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3676{
3677 switch ( aniCBMode )
3678 {
3679 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3680 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3681 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3682 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3683 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3684 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3685 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3686 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3687 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003688 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003689 return PHY_SINGLE_CHANNEL_CENTERED;
3690 }
3691}
3692#endif
3693
Jeff Johnson295189b2012-06-20 16:38:30 -07003694//pIes may be NULL
3695eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3696 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303697 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698{
3699 eHalStatus status = eHAL_STATUS_SUCCESS;
3700 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3701 tANI_U8 channel = 0;
3702 //Make sure we have the domain info for the BSS we try to connect to.
3703 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303704 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303706 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 {
3708 //Make sure the 11d info from this BSSDesc can be applied
3709 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303710 if (VOS_TRUE == resetCountry)
3711 {
3712 csrApplyCountryInformation(pMac, FALSE);
3713 }
3714 else
3715 {
3716 csrApplyCountryInformation(pMac, TRUE);
3717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 }
Kiran4a17ebe2013-01-31 10:43:43 -08003719 if ((csrIs11dSupported (pMac)) && pIes)
3720 {
3721 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003722 {
Kiran4a17ebe2013-01-31 10:43:43 -08003723 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003724 }
3725 else
3726 {
3727 //Let's also update the below to make sure we don't update CC while
3728 //connected to an AP which is advertising some CC
3729 palCopyMemory(pMac->hHdd, pMac->scan.currentCountryBssid,
3730 pBssDesc->bssId, sizeof(tSirMacAddr));
3731 }
Kiran4a17ebe2013-01-31 10:43:43 -08003732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 //Qos
3735 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3736 //SSID
3737 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3738 //fragment threshold
3739 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3740 //RTS threshold
3741 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3742
3743 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3744
3745 //Auth type
3746 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3747 //encryption type
3748 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3749 //short slot time
3750 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 //11d
3752 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3753 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3754 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 /*//11h
3756 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3757 */
3758 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3759 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003760
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003761 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 {
3763 channel = pProfile->operationChannel;
3764 }
3765 else
3766 {
3767 if(pBssDesc)
3768 {
3769 channel = pBssDesc->channelId;
3770 }
3771 }
3772 if(0 != channel)
3773 {
3774 if(CSR_IS_CHANNEL_24GHZ(channel))
3775 {//for now if we are on 2.4 Ghz, CB will be always disabled
3776 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3777 }
3778 else
3779 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003780 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 }
3782 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003783#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003784 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3785 // in function csrConvertCBIniValueToPhyCBState()
3786 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3787 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003788 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003789 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003790 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003791 }
3792 else
3793 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003794 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003795 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003796 }
3797 else
3798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3800 //Rate
3801 //Fixed Rate
3802 if(pBssDesc)
3803 {
3804 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3805 }
3806 else
3807 {
3808 csrSetCfgRateSetFromProfile(pMac, pProfile);
3809 }
3810 //Make this the last CFG to set. The callback will trigger a join_req
3811 //Join time out
3812 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3813
3814 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 return (status);
3816}
3817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3819 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3820{
3821 eHalStatus status;
3822 tBssConfigParam *pBssConfig;
3823 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003824
3825 if(!pSession)
3826 {
3827 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3828 return eHAL_STATUS_FAILURE;
3829 }
3830
Kiet Lam64c1b492013-07-12 13:56:44 +05303831 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3832 if ( NULL == pBssConfig )
3833 status = eHAL_STATUS_FAILURE;
3834 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303836 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3838 if(HAL_STATUS_SUCCESS(status))
3839 {
3840 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003841 /* This will allow to pass cbMode during join req */
3842 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 //For IBSS, we need to prepare some more information
3844 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 )
3847 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003848 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 }
3850 // If we are in an IBSS, then stop the IBSS...
3851 ////Not worry about WDS connection for now
3852 if ( csrIsConnStateIbss( pMac, sessionId ) )
3853 {
3854 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3855 }
3856 else
3857 {
3858 // if we are in an Infrastructure association....
3859 if ( csrIsConnStateInfra( pMac, sessionId ) )
3860 {
3861 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3862 // across SSIDs (roaming to a new SSID)... //
3863 //Not worry about WDS connection for now
3864 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303865 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 {
3867 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303868 status = csrRoamIssueDisassociate( pMac, sessionId,
3869 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303871 else
3872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3874 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303875 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303877 // Set parameters for this Bss.
3878 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3879 pBssDesc, pBssConfig,
3880 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303884 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 {
3886 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3887 // Nothing to stop.
3888 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303890 )
3891 {
3892 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3893 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3894 // Set parameters for this Bss.
3895 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3896 pBssDesc, pBssConfig,
3897 pIes, is11rRoamingFlag);
3898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 }
3900 }
3901 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303902 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 return (status);
3905}
3906
Jeff Johnson295189b2012-06-20 16:38:30 -07003907eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3908 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3909{
3910 eCsrJoinState eRoamState = eCsrContinueRoaming;
3911 eHalStatus status;
3912 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3913 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3914 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003915
3916 if(!pSession)
3917 {
3918 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3919 return (eCsrStopRoaming);
3920 }
3921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 if( CSR_IS_WDS_STA( pProfile ) )
3923 {
3924 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3925 if( !HAL_STATUS_SUCCESS( status ) )
3926 {
3927 eRoamState = eCsrStopRoaming;
3928 }
3929 }
3930 else
3931 {
3932 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3933 {
3934 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3935 return (eCsrStopRoaming);
3936 }
3937 if ( csrIsInfraBssDesc( pBssDesc ) )
3938 {
3939 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3940 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3941 // have changed and handle the changes (without disturbing the current association).
3942
3943 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3944 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3945 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3946 )
3947 {
3948 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3949 // with Authenticating first. To force this, stop the current association (Disassociate) and
3950 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3951 // a new Association.
3952 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3953 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07003954 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3956 {
3957 eRoamState = eCsrReassocToSelfNoCapChange;
3958 }
3959 else
3960 {
3961 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05303963 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3965 if(HAL_STATUS_SUCCESS(status))
3966 {
3967 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003968 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303970 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3971 pBssDesc, &bssConfig,
3972 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 if(!HAL_STATUS_SUCCESS(status))
3974 {
3975 eRoamState = eCsrStopRoaming;
3976 }
3977 }
3978 else
3979 {
3980 eRoamState = eCsrStopRoaming;
3981 }
3982 }//same profile
3983 }
3984 else
3985 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303986 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003989 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303993 }
3994 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 {
3996 // 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 +05303997 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 // work much better.
3999 //
4000 //
4001 // stop the existing network before attempting to join the new network...
4002 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4003 {
4004 eRoamState = eCsrStopRoaming;
4005 }
4006 }
4007 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304008 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 {
4010 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4011 {
4012 eRoamState = eCsrStopRoaming;
4013 }
4014 }
4015 if( pIesLocal && !pScanResult->pvIes )
4016 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304017 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 }
4019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 return( eRoamState );
4021}
4022
Jeff Johnson295189b2012-06-20 16:38:30 -07004023eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4024 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4025{
4026 eHalStatus status = eHAL_STATUS_SUCCESS;
4027 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304028 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 roamInfo.pBssDesc = pBssDesc;
4030 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4031 return (status);
4032}
Jeff Johnson295189b2012-06-20 16:38:30 -07004033//In case no matching BSS is found, use whatever default we can find
4034static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4035{
4036 //Need to get all negotiated types in place first
4037 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004038 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 {
4040 default:
4041 case eCSR_AUTH_TYPE_WPA:
4042 case eCSR_AUTH_TYPE_WPA_PSK:
4043 case eCSR_AUTH_TYPE_WPA_NONE:
4044 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4045 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4046 break;
4047
4048 case eCSR_AUTH_TYPE_SHARED_KEY:
4049 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4050 break;
4051
4052 case eCSR_AUTH_TYPE_AUTOSWITCH:
4053 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4054 break;
4055 }
4056 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4057 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4058 //In this case, the multicast encryption needs to follow the uncast ones.
4059 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4060 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4061}
4062
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004063
4064static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4065{
4066 switch(pCommand->u.roamCmd.roamReason)
4067 {
4068 case eCsrLostLink1:
4069 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4070 break;
4071 case eCsrLostLink2:
4072 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4073 break;
4074 case eCsrLostLink3:
4075 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4076 break;
4077 default:
4078 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4079 pCommand->u.roamCmd.roamReason);
4080 break;
4081 }
4082}
4083
Jeff Johnson295189b2012-06-20 16:38:30 -07004084static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4085{
4086 eHalStatus status;
4087 tCsrScanResult *pScanResult = NULL;
4088 eCsrJoinState eRoamState = eCsrStopRoaming;
4089 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4090 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4091 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4092#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4093 v_U8_t acm_mask = 0;
4094#endif
4095 tANI_U32 sessionId = pCommand->sessionId;
4096 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4097 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4098 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004099
4100 if(!pSession)
4101 {
4102 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4103 return (eCsrStopRoaming);
4104 }
4105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 do
4107 {
4108 // Check for Cardbus eject condition, before trying to Roam to any BSS
4109 //***if( !balIsCardPresent(pAdapter) ) break;
4110
Kiet Lam64c1b492013-07-12 13:56:44 +05304111 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004112 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 if(NULL != pBSSList)
4114 {
4115 // When handling AP's capability change, continue to associate to
4116 // same BSS and make sure pRoamBssEntry is not Null.
4117 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4118 {
4119 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4120 {
4121 //Try the first BSS
4122 pCommand->u.roamCmd.pLastRoamBss = NULL;
4123 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4124 }
4125 else
4126 {
4127 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4128 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4129 {
4130 //Done with all the BSSs
4131 //In this case, will tell HDD the completion
4132 break;
4133 }
4134 else
4135 {
4136 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304137 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4139 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4140 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4141 pRoamInfo = &roamInfo;
4142 }
4143 }
4144 while(pCommand->u.roamCmd.pRoamBssEntry)
4145 {
4146 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 /*If concurrency enabled take the concurrent connected channel first. */
4148 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004149 if (vos_concurrent_sessions_running() &&
4150 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 {
4152 concurrentChannel =
4153 csrGetConcurrentOperationChannel(pMac);
4154 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004155 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 if ((concurrentChannel) &&
4157 (concurrentChannel ==
4158 pScanResult->Result.BssDescriptor.channelId))
4159 {
4160 //make this 0 because we do not want the
4161 //below check to pass as we don't want to
4162 //connect on other channel
4163 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4164 FL("Concurrent channel match =%d"),
4165 concurrentChannel);
4166 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 }
4168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004169
4170 if (!concurrentChannel)
4171 {
4172
4173 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4174 sessionId, &pScanResult->Result.BssDescriptor,
4175 pCommand->u.roamCmd.roamId)))
4176 {
4177 //Ok to roam this
4178 break;
4179 }
4180 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004181 else
4182 {
4183 eRoamState = eCsrStopRoamingDueToConcurrency;
4184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4186 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4187 {
4188 //Done with all the BSSs
4189 fDone = eANI_BOOLEAN_TRUE;
4190 break;
4191 }
4192 }
4193 if(fDone)
4194 {
4195 break;
4196 }
4197 }
4198 }
4199 //We have something to roam, tell HDD when it is infra.
4200 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4201 //For WDS, the indication is eCSR_ROAM_WDS_IND
4202 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4203 {
4204 if(pRoamInfo)
4205 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004206 if(pSession->bRefAssocStartCnt)
4207 {
4208 pSession->bRefAssocStartCnt--;
4209 //Complete the last association attemp because a new one is about to be tried
4210 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4211 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004213 }
4214 }
4215 /* If the roaming has stopped, not to continue the roaming command*/
4216 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4217 {
4218 //No need to complete roaming here as it already completes
4219 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4220 pCommand->u.roamCmd.roamReason);
4221 eRoamState = eCsrStopRoaming;
4222 csrSetAbortRoamingCommand(pMac, pCommand);
4223 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304225 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 if(pScanResult)
4227 {
4228 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004231 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 fDone = eANI_BOOLEAN_TRUE;
4233 eRoamState = eCsrStopRoaming;
4234 break;
4235 }
4236 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4237 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4238 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4239 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4240 CSR_IS_QOS_BSS(pIesLocal) &&
4241 CSR_IS_UAPSD_BSS(pIesLocal) )
4242 {
4243#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4245 pIesLocal);
4246 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4247#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 }
4249 else
4250 {
4251 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4252 }
4253 if( pIesLocal && !pScanResult->Result.pvIes)
4254 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304255 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 }
4257 }
4258 else
4259 {
4260 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4261 }
4262 roamInfo.pProfile = pProfile;
4263 pSession->bRefAssocStartCnt++;
4264 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4265 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4268 {
4269 // If this is a start IBSS profile, then we need to start the IBSS.
4270 if ( CSR_IS_START_IBSS(pProfile) )
4271 {
4272 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 // Attempt to start this IBSS...
4274 csrRoamAssignDefaultParam( pMac, pCommand );
4275 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4276 if(HAL_STATUS_SUCCESS(status))
4277 {
4278 if ( fSameIbss )
4279 {
4280 eRoamState = eCsrStartIbssSameIbss;
4281 }
4282 else
4283 {
4284 eRoamState = eCsrContinueRoaming;
4285 }
4286 }
4287 else
4288 {
4289 //it somehow fail need to stop
4290 eRoamState = eCsrStopRoaming;
4291 }
4292 break;
4293 }
4294 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 )
4297 {
4298 // Attempt to start this WDS...
4299 csrRoamAssignDefaultParam( pMac, pCommand );
4300 /* For AP WDS, we dont have any BSSDescription */
4301 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4302 if(HAL_STATUS_SUCCESS(status))
4303 {
4304 eRoamState = eCsrContinueRoaming;
4305 }
4306 else
4307 {
4308 //it somehow fail need to stop
4309 eRoamState = eCsrStopRoaming;
4310 }
4311 }
4312 else
4313 {
4314 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004315 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 eRoamState = eCsrStopRoaming;
4317 break;
4318 }
4319 }
4320 else //We have BSS
4321 {
4322 //Need to assign these value because they are used in csrIsSameProfile
4323 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4324 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4325 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4326 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4327 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4328 {
4329 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4330 {
4331 eRoamState = eCsrStartIbssSameIbss;
4332 break;
4333 }
4334 }
4335 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4336 {
4337 //trying to connect to the one already connected
4338 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4339 eRoamState = eCsrReassocToSelfNoCapChange;
4340 break;
4341 }
4342 // Attempt to Join this Bss...
4343 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4344 break;
4345 }
4346
4347 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4349 {
4350 //Need to indicate association_completion if association_start has been done
4351 if(pSession->bRefAssocStartCnt > 0)
4352 {
4353 pSession->bRefAssocStartCnt--;
4354 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004355 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4357 eCSR_ROAM_ASSOCIATION_COMPLETION,
4358 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4359 }
4360 }
4361
4362 return( eRoamState );
4363}
4364
Jeff Johnson295189b2012-06-20 16:38:30 -07004365static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4366{
4367 eHalStatus status = eHAL_STATUS_SUCCESS;
4368 eCsrJoinState RoamState;
4369 tANI_U32 sessionId = pCommand->sessionId;
4370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 //***if( hddIsRadioStateOn( pAdapter ) )
4372 {
4373 // Attept to join a Bss...
4374 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004375
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004377 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 {
4379 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 // and if connected in Infrastructure mode...
4381 if ( csrIsConnStateInfra(pMac, sessionId) )
4382 {
4383 //... then we need to issue a disassociation
4384 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4385 if(!HAL_STATUS_SUCCESS(status))
4386 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004387 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 //roam command is completed by caller in the failed case
4389 fComplete = eANI_BOOLEAN_TRUE;
4390 }
4391 }
4392 else if( csrIsConnStateIbss(pMac, sessionId) )
4393 {
4394 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4395 if(!HAL_STATUS_SUCCESS(status))
4396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004397 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 //roam command is completed by caller in the failed case
4399 fComplete = eANI_BOOLEAN_TRUE;
4400 }
4401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4403 {
4404 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4405 if(!HAL_STATUS_SUCCESS(status))
4406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004407 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 //roam command is completed by caller in the failed case
4409 fComplete = eANI_BOOLEAN_TRUE;
4410 }
4411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 else
4413 {
4414 fComplete = eANI_BOOLEAN_TRUE;
4415 }
4416 if(fComplete)
4417 {
4418 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004419 if(eCsrStopRoamingDueToConcurrency == RoamState)
4420 {
4421 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4422 }
4423 else
4424 {
4425 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 }
4428 }
4429 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4430 {
4431 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4432 }
4433 else if ( eCsrStartIbssSameIbss == RoamState )
4434 {
4435 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4436 }
4437 }//hddIsRadioStateOn
4438
4439 return status;
4440}
Jeff Johnson295189b2012-06-20 16:38:30 -07004441eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4442{
4443 tANI_U32 sessionId;
4444 tCsrRoamSession *pSession;
4445 tCsrScanResult *pScanResult = NULL;
4446 tSirBssDescription *pBssDesc = NULL;
4447 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 sessionId = pCommand->sessionId;
4449 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004450
4451 if(!pSession)
4452 {
4453 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4454 return eHAL_STATUS_FAILURE;
4455 }
4456
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4458 {
4459 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004460 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4462 return eHAL_STATUS_FAILURE;
4463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 if (pCommand->u.roamCmd.pRoamBssEntry)
4465 {
4466 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4467 pBssDesc = &pScanResult->Result.BssDescriptor;
4468 }
4469 else
4470 {
4471 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004472 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4474 return eHAL_STATUS_FAILURE;
4475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4477 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4478 return status;
4479}
4480
Jeff Johnson295189b2012-06-20 16:38:30 -07004481eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4482{
4483 eHalStatus status = eHAL_STATUS_SUCCESS;
4484 tCsrRoamInfo roamInfo;
4485 tANI_U32 sessionId = pCommand->sessionId;
4486 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004487
4488 if(!pSession)
4489 {
4490 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4491 return eHAL_STATUS_FAILURE;
4492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004493
4494 switch ( pCommand->u.roamCmd.roamReason )
4495 {
4496 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004498 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 case eCsrSmeIssuedDisassocForHandoff:
4501 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4502#if 0 // TODO : Confirm this change
4503 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4504#else
4505 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4506#endif
4507
4508 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004511 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004515 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 case eCsrHddIssuedReassocToSameAP:
4518 case eCsrSmeIssuedReassocToSameAP:
4519 {
4520 tDot11fBeaconIEs *pIes = NULL;
4521
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 if( pSession->pConnectBssDesc )
4523 {
4524 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4525 if(!HAL_STATUS_SUCCESS(status) )
4526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004527 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 }
4529 else
4530 {
4531 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4532 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4533 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4535 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4536 pSession->bRefAssocStartCnt++;
4537 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4538 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4539
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004540 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004541 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4542 &pCommand->u.roamCmd.roamProfile );
4543 if(!HAL_STATUS_SUCCESS(status))
4544 {
4545 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004546 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004547 }
4548
Kiet Lam64c1b492013-07-12 13:56:44 +05304549 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 pIes = NULL;
4551 }
4552 }
4553 break;
4554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004556 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4558 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4559 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004561 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4563 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 case eCsrStopBss:
4566 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4567 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4568 break;
4569
4570 case eCsrForcedDisassocSta:
4571 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4572 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4573 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4574 pCommand->u.roamCmd.reason);
4575 break;
4576
4577 case eCsrForcedDeauthSta:
4578 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4579 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4580 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4581 pCommand->u.roamCmd.reason);
4582 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004583
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004584 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004585 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004586 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4587 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004589
4590 default:
4591 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4592
4593 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4594 {
4595 //Remember the roaming profile
4596 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304597 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4598 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304600 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4602 }
4603 }
4604
4605 //At this point, original uapsd_mask is saved in pCurRoamProfile
4606 //uapsd_mask in the pCommand may change from this point on.
4607
4608 // Attempt to roam with the new scan results (if we need to..)
4609 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004610 if(!HAL_STATUS_SUCCESS(status))
4611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004612 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 break;
4615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 return (status);
4617}
4618
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004619void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4620{
4621 pCommand->u.roamCmd.pLastRoamBss = NULL;
4622 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4623 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304624 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004625}
4626
Jeff Johnson295189b2012-06-20 16:38:30 -07004627void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4628{
4629 if(pCommand->u.roamCmd.fReleaseBssList)
4630 {
4631 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4632 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4633 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4634 }
4635 if(pCommand->u.roamCmd.fReleaseProfile)
4636 {
4637 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4638 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4639 }
4640 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4641 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304642 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004643}
4644
Jeff Johnson295189b2012-06-20 16:38:30 -07004645void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4646{
Kiet Lam64c1b492013-07-12 13:56:44 +05304647 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004648}
Jeff Johnson295189b2012-06-20 16:38:30 -07004649void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4650{
4651 tListElem *pEntry;
4652 tSmeCmd *pCommand;
4653 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004654 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4656 if ( pEntry )
4657 {
4658 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 // If the head of the queue is Active and it is a ROAM command, remove
4660 // and put this on the Free queue.
4661 if ( eSmeCommandRoam == pCommand->command )
4662 {
4663 //we need to process the result first before removing it from active list because state changes
4664 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4665 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4666 if( fReleaseCommand )
4667 {
4668 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4669 {
4670 csrReleaseCommandRoam( pMac, pCommand );
4671 }
4672 else
4673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004674 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004675 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 }
4677 }
4678 else
4679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004680 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004681 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 }
4683 }
4684 else
4685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004686 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 }
4688 }
4689 else
4690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004691 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 if( fReleaseCommand )
4694 {
4695 smeProcessPendingQueue( pMac );
4696 }
4697}
4698
Jeff Johnson295189b2012-06-20 16:38:30 -07004699void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4700{
4701 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004702 if(!pSession)
4703 {
4704 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4705 return;
4706 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304707 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4708 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 pSession->NumPmkidCandidate = 0;
4710}
Jeff Johnson295189b2012-06-20 16:38:30 -07004711#ifdef FEATURE_WLAN_WAPI
4712void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4713{
4714 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004715 if(!pSession)
4716 {
4717 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4718 return;
4719 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304720 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4721 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 pSession->NumBkidCandidate = 0;
4723}
4724#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004725extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4726
Jeff Johnson295189b2012-06-20 16:38:30 -07004727static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4728 tSirBssDescription *pSirBssDesc,
4729 tDot11fBeaconIEs *pIes)
4730{
4731 eHalStatus status = eHAL_STATUS_SUCCESS;
4732 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4733 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004734
4735 if(!pSession)
4736 {
4737 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4738 return eHAL_STATUS_FAILURE;
4739 }
4740
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 if((eCSR_AUTH_TYPE_WPA == authType) ||
4742 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4743 (eCSR_AUTH_TYPE_RSN == authType) ||
4744 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4745#if defined WLAN_FEATURE_VOWIFI_11R
4746 ||
4747 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4748 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4749#endif /* FEATURE_WLAN_WAPI */
4750#ifdef FEATURE_WLAN_WAPI
4751 ||
4752 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4753 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4754#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004755#ifdef WLAN_FEATURE_11W
4756 ||
4757 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4758#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 )
4760 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004763 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 }
4765 if( pIesLocal )
4766 {
4767 tANI_U32 nIeLen;
4768 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 if((eCSR_AUTH_TYPE_RSN == authType) ||
4770#if defined WLAN_FEATURE_VOWIFI_11R
4771 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4772 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4773#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004774#if defined WLAN_FEATURE_11W
4775 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4776#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4778 {
4779 if(pIesLocal->RSN.present)
4780 {
4781 //Calculate the actual length
4782 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4783 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4784 + 2 //akm_suite_count
4785 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4786 + 2; //reserved
4787 if( pIesLocal->RSN.pmkid_count )
4788 {
4789 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4790 }
4791 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304792 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4793 if (NULL == pSession->pWpaRsnRspIE)
4794 status = eHAL_STATUS_FAILURE;
4795 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304797 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4799 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4800 //copy upto akm_suites
4801 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304802 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4803 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004804 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304805 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4806 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004807 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304808 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4809 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004810 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 if( pIesLocal->RSN.pwise_cipher_suite_count )
4812 {
4813 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304814 vos_mem_copy(pIeBuf,
4815 pIesLocal->RSN.pwise_cipher_suites,
4816 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4818 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304819 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 pIeBuf += 2;
4821 if( pIesLocal->RSN.akm_suite_count )
4822 {
4823 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304824 vos_mem_copy(pIeBuf,
4825 pIesLocal->RSN.akm_suites,
4826 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4828 }
4829 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304830 vos_mem_copy(pIeBuf,
4831 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4832 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4834 }
4835 }
4836 }
4837 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4838 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4839 {
4840 if(pIesLocal->WPA.present)
4841 {
4842 //Calculate the actual length
4843 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4844 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4845 + 2 //auth_suite_count
4846 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4847 // The WPA capabilities follows the Auth Suite (two octects)--
4848 // this field is optional, and we always "send" zero, so just
4849 // remove it. This is consistent with our assumptions in the
4850 // frames compiler; c.f. bug 15234:
4851 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304852
4853 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4854 if ( NULL == pSession->pWpaRsnRspIE )
4855 status = eHAL_STATUS_FAILURE;
4856 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 {
4858 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4859 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4860 pIeBuf = pSession->pWpaRsnRspIE + 2;
4861 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304862 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304864 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4865 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304867 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4868 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4870 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4871 }
4872 }
4873 }
4874#ifdef FEATURE_WLAN_WAPI
4875 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4876 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4877 {
4878 if(pIesLocal->WAPI.present)
4879 {
4880 //Calculate the actual length
4881 nIeLen = 4 //version + akm_suite_count
4882 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4883 + 2 //pwise_cipher_suite_count
4884 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4885 + 6; //gp_cipher_suite + preauth + reserved
4886 if( pIesLocal->WAPI.bkid_count )
4887 {
4888 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4889 }
4890
4891 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304892 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4893 if ( NULL == pSession->pWapiRspIE )
4894 status = eHAL_STATUS_FAILURE;
4895 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 {
4897 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4898 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4899 pIeBuf = pSession->pWapiRspIE + 2;
4900 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304901 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 pIeBuf += 4;
4903 if( pIesLocal->WAPI.akm_suite_count )
4904 {
4905 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304906 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4907 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304909 }
4910 vos_mem_copy(pIeBuf,
4911 &pIesLocal->WAPI.unicast_cipher_suite_count,
4912 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4915 {
4916 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304917 vos_mem_copy( pIeBuf,
4918 pIesLocal->WAPI.unicast_cipher_suites,
4919 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4921 }
lukez3c809222013-05-03 10:23:02 -07004922 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05304923 vos_mem_copy(pIeBuf,
4924 pIesLocal->WAPI.multicast_cipher_suite,
4925 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004926 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304927 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05304928 vos_mem_copy(pIeBuf,
4929 pIesLocal->WAPI.multicast_cipher_suite + 4,
4930 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004931 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304932 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304933 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
4934
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004935 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 if( pIesLocal->WAPI.bkid_count )
4937 {
4938 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304939 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
4940 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4942 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304943 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 }
4946 }
4947#endif /* FEATURE_WLAN_WAPI */
4948 if( !pIes )
4949 {
4950 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304951 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 }
4953 }
4954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 return (status);
4956}
4957
Jeff Johnson295189b2012-06-20 16:38:30 -07004958static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4959{
4960 v_U8_t bACWeights[WLANTL_MAX_AC];
4961 v_U8_t paramBk, paramBe, paramVi, paramVo;
4962 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4964 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4965 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4966 //This doesn't address the case where the lower AC needs a real higher weight
4967 if( pIEs->WMMParams.present )
4968 {
4969 //no change to the lowest ones
4970 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4971 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4972 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4973 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4974 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4975 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4976 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4977 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4978 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4979 {
4980 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4981 fWeightChange = VOS_TRUE;
4982 }
4983 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4984 {
4985 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4986 fWeightChange = VOS_TRUE;
4987 }
4988 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4989 {
4990 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4991 fWeightChange = VOS_TRUE;
4992 }
4993 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4994 {
4995 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4996 fWeightChange = VOS_TRUE;
4997 }
4998 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4999 {
5000 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5001 fWeightChange = VOS_TRUE;
5002 }
5003 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5004 {
5005 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5006 fWeightChange = VOS_TRUE;
5007 }
5008 if(fWeightChange)
5009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005010 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 bACWeights[2], bACWeights[3]);
5012 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5013 }
5014 }
5015}
Jeff Johnson295189b2012-06-20 16:38:30 -07005016#ifdef WLAN_FEATURE_VOWIFI_11R
5017//Returns whether the current association is a 11r assoc or not
5018tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5019{
5020#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5021 return csrNeighborRoamIs11rAssoc(pMac);
5022#else
5023 return eANI_BOOLEAN_FALSE;
5024#endif
5025}
5026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005027#ifdef FEATURE_WLAN_CCX
5028//Returns whether the current association is a CCX assoc or not
5029tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5030{
5031#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5032 return csrNeighborRoamIsCCXAssoc(pMac);
5033#else
5034 return eANI_BOOLEAN_FALSE;
5035#endif
5036}
5037#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005038#ifdef FEATURE_WLAN_LFR
5039//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305040tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005041{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305042 tCsrRoamSession *pSession = NULL;
5043
5044 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5045 {
5046 pSession = CSR_GET_SESSION( pMac, sessionId );
5047 if (NULL != pSession->pCurRoamProfile)
5048 {
5049 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5050 {
5051 return eANI_BOOLEAN_FALSE;
5052 }
5053 }
5054 }
5055
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005056#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5057 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5058 {
5059 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5060 }
5061 else
5062#endif
5063 {
5064 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005065 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005066 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005067}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005068
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005069#ifdef FEATURE_WLAN_CCX
5070/* ---------------------------------------------------------------------------
5071
5072 \fn csrNeighborRoamIsCCXAssoc
5073
5074 \brief This function returns whether the current association is a CCX assoc or not
5075
5076 \param pMac - The handle returned by macOpen.
5077
5078 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5079
5080---------------------------------------------------------------------------*/
5081tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5082{
5083 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5084}
5085#endif /* FEATURE_WLAN_CCX */
5086
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005087#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5088//Returns whether "FW based BG scan" is currently enabled...or not
5089tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5090{
5091 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5092}
5093#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005094#endif
5095
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005096#if defined(FEATURE_WLAN_CCX)
5097tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5098{
5099 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5100}
5101#endif /*FEATURE_WLAN_CCX*/
5102
Jeff Johnson295189b2012-06-20 16:38:30 -07005103//Return true means the command can be release, else not
5104static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5105 eCsrRoamCompleteResult Result, void *Context )
5106{
5107 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5108 tSirBssDescription *pSirBssDesc = NULL;
5109 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5110 tCsrScanResult *pScanResult = NULL;
5111 tCsrRoamInfo roamInfo;
5112 sme_QosAssocInfo assocInfo;
5113 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5114 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5115 tDot11fBeaconIEs *pIes = NULL;
5116 tANI_U32 sessionId = pCommand->sessionId;
5117 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5118 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5119 eRoamCmdStatus roamStatus;
5120 eCsrRoamResult roamResult;
5121 eHalStatus status;
5122 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005124
Jeff Johnson32d95a32012-09-10 13:15:23 -07005125 if(!pSession)
5126 {
5127 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5128 return eANI_BOOLEAN_FALSE;
5129 }
5130
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005131 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 switch( Result )
5133 {
5134 case eCsrJoinSuccess:
5135 // reset the IDLE timer
5136 // !!
5137 // !! fall through to the next CASE statement here is intentional !!
5138 // !!
5139 case eCsrReassocSuccess:
5140 if(eCsrReassocSuccess == Result)
5141 {
5142 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5143 }
5144 else
5145 {
5146 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5147 }
5148 // Success Join Response from LIM. Tell NDIS we are connected and save the
5149 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005150 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305151 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 //always free the memory here
5153 if(pSession->pWpaRsnRspIE)
5154 {
5155 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305156 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 pSession->pWpaRsnRspIE = NULL;
5158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005159#ifdef FEATURE_WLAN_WAPI
5160 if(pSession->pWapiRspIE)
5161 {
5162 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305163 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 pSession->pWapiRspIE = NULL;
5165 }
5166#endif /* FEATURE_WLAN_WAPI */
5167#ifdef FEATURE_WLAN_BTAMP_UT_RF
5168 //Reset counter so no join retry is needed.
5169 pSession->maxRetryCount = 0;
5170 csrRoamStopJoinRetryTimer(pMac, sessionId);
5171#endif
5172 /* This creates problem since we have not saved the connected profile.
5173 So moving this after saving the profile
5174 */
5175 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5176 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5177 {
5178 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5179 }
5180 else
5181 {
5182 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 //Use the last connected bssdesc for reassoc-ing to the same AP.
5185 //NOTE: What to do when reassoc to a different AP???
5186 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5187 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5188 {
5189 pSirBssDesc = pSession->pConnectBssDesc;
5190 if(pSirBssDesc)
5191 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305192 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5193 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 }
5195 }
5196 else
5197 {
5198
5199 if(pCommand->u.roamCmd.pRoamBssEntry)
5200 {
5201 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5202 if(pScanResult != NULL)
5203 {
5204 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5205 //this can be NULL
5206 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305207 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5208 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 }
5210 }
5211 }
5212 if( pSirBssDesc )
5213 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5216 //Save WPA/RSN IE
5217 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5218#ifdef FEATURE_WLAN_CCX
5219 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5220#endif
5221
5222 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5223 // substate change.
5224 // Moving even save profile above so that below mentioned conditon is also met.
5225 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5226 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5228 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5229 // will be dropped for the security context may not be set properly.
5230 //
5231 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5232 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5233 //
5234 // this reordering was done on titan_prod_usb branch and is being replicated here.
5235 //
5236
5237 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5238 !pProfile->bWPSAssociation)
5239 {
5240 // Issue the set Context request to LIM to establish the Unicast STA context
5241 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5242 pProfile->negotiatedUCEncryptionType,
5243 pSirBssDesc, &(pSirBssDesc->bssId),
5244 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5245 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005246 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5248 }
5249 // Issue the set Context request to LIM to establish the Broadcast STA context
5250 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5251 pSirBssDesc, &BroadcastMac,
5252 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5253 }
5254 else
5255 {
5256 //Need to wait for supplicant authtication
5257 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 //Set the subestate to WaitForKey in case authentiation is needed
5259 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5260
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 if(pProfile->bWPSAssociation)
5262 {
5263 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5264 }
5265 else
5266 {
5267 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5268 }
5269
5270 //Save sessionId in case of timeout
5271 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5272 //This time should be long enough for the rest of the process plus setting key
5273 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5274 {
5275 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005276 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5278 }
5279 }
5280
5281 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5282 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 if(Context)
5284 {
5285 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5286 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5288 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5289#ifdef WLAN_FEATURE_VOWIFI_11R
5290 len += pJoinRsp->parsedRicRspLen;
5291#endif /* WLAN_FEATURE_VOWIFI_11R */
5292#ifdef FEATURE_WLAN_CCX
5293 len += pJoinRsp->tspecIeLen;
5294#endif
5295 if(len)
5296 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305297 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5298 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305300 vos_mem_copy(pSession->connectedInfo.pbFrames,
5301 pJoinRsp->frames, len);
5302 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5303 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5304 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005305#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305306 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307#endif /* WLAN_FEATURE_VOWIFI_11R */
5308#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305309 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305311 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5312 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5313 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5314 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 }
5316 }
5317 if(pCommand->u.roamCmd.fReassoc)
5318 {
5319 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5320 }
5321 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5322 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5323 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5324 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5325 }
5326 else
5327 {
5328 if(pCommand->u.roamCmd.fReassoc)
5329 {
5330 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5331 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5332 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5333 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5334 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5335 }
5336 }
5337#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5338 // Indicate SME-QOS with reassoc success event, only after
5339 // copying the frames
5340 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5341#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 roamInfo.pBssDesc = pSirBssDesc;
5343 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5344 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5345#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5346 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5347#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5348 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5350 //It may be better to let QoS do this????
5351 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005353 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5355 pmcStartUapsd( pMac, NULL, NULL );
5356 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305357 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5359 if( pSession->bRefAssocStartCnt > 0 )
5360 {
5361 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005362 //Remove this code once SLM_Sessionization is supported
5363 //BMPS_WORKAROUND_NOT_NEEDED
5364 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005365 {
5366 pMac->roam.configParam.doBMPSWorkaround = 1;
5367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5369 }
5370
5371 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 // reset the PMKID candidate list
5373 csrResetPMKIDCandidateList( pMac, sessionId );
5374 //Update TL's AC weight base on the current EDCA parameters
5375 //These parameters may change in the course of the connection, that sictuation
5376 //is not taken care here. This change is mainly to address a WIFI WMM test where
5377 //BE has a equal or higher TX priority than VI.
5378 //We only do this for infra link
5379 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5380 {
5381 csrCheckAndUpdateACWeight(pMac, pIes);
5382 }
5383#ifdef FEATURE_WLAN_WAPI
5384 // reset the BKID candidate list
5385 csrResetBKIDCandidateList( pMac, sessionId );
5386#endif /* FEATURE_WLAN_WAPI */
5387 }
5388 else
5389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005390 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 csrScanCancelIdleScan(pMac);
5393 //Not to signal link up because keys are yet to be set.
5394 //The linkup function will overwrite the sub-state that we need to keep at this point.
5395 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5396 {
5397 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5400 //enough to let security and DHCP handshake succeed before entry into BMPS
5401 if (pmcShouldBmpsTimerRun(pMac))
5402 {
5403 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5404 != eHAL_STATUS_SUCCESS)
5405 {
5406 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5407 }
5408 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 break;
5411
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 case eCsrStartBssSuccess:
5413 // on the StartBss Response, LIM is returning the Bss Description that we
5414 // are beaconing. Add this Bss Description to our scan results and
5415 // chain the Profile to this Bss Description. On a Start BSS, there was no
5416 // detected Bss description (no partner) so we issued the Start Bss to
5417 // start the Ibss without any Bss description. Lim was kind enough to return
5418 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005419 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305422 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 if( CSR_IS_IBSS( pProfile ) )
5424 {
5425 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 else if (CSR_IS_INFRA_AP(pProfile))
5428 {
5429 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 else
5432 {
5433 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5434 }
5435 if( !CSR_IS_WDS_STA( pProfile ) )
5436 {
5437 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005441 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 roamInfo.pBssDesc = pSirBssDesc;
5443 //We need to associate_complete it first, becasue Associate_start already indicated.
5444 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5445 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5446 break;
5447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005450 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 }
5452 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5453 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5454 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5455 if(pSirBssDesc)
5456 {
5457 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305458 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5459 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 }
5461 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305462 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005463#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5464 {
5465 vos_log_ibss_pkt_type *pIbssLog;
5466 tANI_U32 bi;
5467
5468 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5469 if(pIbssLog)
5470 {
5471 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5472 {
5473 //We start the IBSS (didn't find any matched IBSS out there)
5474 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5475 }
5476 else
5477 {
5478 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5479 }
5480 if(pSirBssDesc)
5481 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305482 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5484 }
5485 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5486 {
5487 //***U8 is not enough for beacon interval
5488 pIbssLog->beaconInterval = (v_U8_t)bi;
5489 }
5490 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5491 }
5492 }
5493#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5494 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5495 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5497 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5499 csrRoamIssueSetContextReq( pMac, sessionId,
5500 pProfile->negotiatedMCEncryptionType,
5501 pSirBssDesc, &BroadcastMac,
5502 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5503 }
5504 }
5505 else
5506 {
5507 //Keep the state to eCSR_ROAMING_STATE_JOINING
5508 //Need to send join_req.
5509 if(pCommand->u.roamCmd.pRoamBssEntry)
5510 {
5511 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5512 {
5513 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5514 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5515 // Set the roaming substate to 'join attempt'...
5516 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005517 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 }
5519 }
5520 else
5521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005522 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 VOS_ASSERT( 0 );
5524 }
5525 }
5526 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5527 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5528 //trigger the connection start indication in Vista
5529 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5530 {
5531 roamStatus = eCSR_ROAM_IBSS_IND;
5532 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5533 if( CSR_IS_WDS( pProfile ) )
5534 {
5535 roamStatus = eCSR_ROAM_WDS_IND;
5536 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 if( CSR_IS_INFRA_AP( pProfile ) )
5539 {
5540 roamStatus = eCSR_ROAM_INFRA_IND;
5541 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005543
5544 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5545 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5546 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305547 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5549 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005550 //We start the IBSS (didn't find any matched IBSS out there)
5551 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305553 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5554 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005555 //Remove this code once SLM_Sessionization is supported
5556 //BMPS_WORKAROUND_NOT_NEEDED
5557 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005558 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005559 {
5560 pMac->roam.configParam.doBMPSWorkaround = 1;
5561 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005562
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5564 }
5565
5566 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005567
5568 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 {
5570 //need to send stop BSS because we fail to send join_req
5571 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5572 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5573 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 case eCsrStartBssFailure:
5577#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5578 {
5579 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5581 if(pIbssLog)
5582 {
5583 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5584 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5585 }
5586 }
5587#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 roamStatus = eCSR_ROAM_IBSS_IND;
5589 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5590 if( CSR_IS_WDS( pProfile ) )
5591 {
5592 roamStatus = eCSR_ROAM_WDS_IND;
5593 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 if( CSR_IS_INFRA_AP( pProfile ) )
5596 {
5597 roamStatus = eCSR_ROAM_INFRA_IND;
5598 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 if(Context)
5601 {
5602 pSirBssDesc = (tSirBssDescription *)Context;
5603 }
5604 else
5605 {
5606 pSirBssDesc = NULL;
5607 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305608 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 roamInfo.pBssDesc = pSirBssDesc;
5610 //We need to associate_complete it first, becasue Associate_start already indicated.
5611 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5612 csrSetDefaultDot11Mode( pMac );
5613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 case eCsrSilentlyStopRoaming:
5615 // We are here because we try to start the same IBSS
5616 //No message to PE
5617 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005618 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5620 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305621 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5623 if( roamInfo.pBssDesc )
5624 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305625 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5626 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 }
5628 //Since there is no change in the current state, simply pass back no result otherwise
5629 //HDD may be mistakenly mark to disconnected state.
5630 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5631 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 case eCsrSilentlyStopRoamingSaveState:
5634 //We are here because we try to connect to the same AP
5635 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005636 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305637 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005638
5639 //to aviod resetting the substate to NONE
5640 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5641 //No need to change substate to wai_for_key because there is no state change
5642 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5643 if( roamInfo.pBssDesc )
5644 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305645 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5646 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5649 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5650 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5651 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5652 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5653 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5654 roamInfo.staId = pSession->connectedInfo.staId;
5655 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 pSession->bRefAssocStartCnt--;
5658 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5659 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5660 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5661 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 case eCsrReassocFailure:
5663#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5664 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5665#endif
5666 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005667 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 csrFreeConnectBssDesc(pMac, sessionId);
5669 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5670 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305671 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5673 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5674 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5675 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5676 eCSR_ROAM_WDS_IND,
5677 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5678 //Need to issue stop_bss
5679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 case eCsrJoinFailure:
5681 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005682 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 default:
5684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005685 smsLog(pMac, LOGW, FL("receives no association indication"));
5686 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005687 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5689 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5690 {
5691 //do not free for the other profiles as we need to send down stop BSS later
5692 csrFreeConnectBssDesc(pMac, sessionId);
5693 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5694 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5695 csrSetDefaultDot11Mode( pMac );
5696 }
5697
5698 switch( pCommand->u.roamCmd.roamReason )
5699 {
5700 // If this transition is because of an 802.11 OID, then we transition
5701 // back to INIT state so we sit waiting for more OIDs to be issued and
5702 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005703 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 case eCsrSmeIssuedAssocToSimilarAP:
5705 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005706 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305708 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5710 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5711 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305712 vos_mem_copy(&roamInfo.bssid,
5713 &pSession->joinFailStatusCode.bssId,
5714 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005715
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 /* Defeaturize this later if needed */
5717#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5718 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5719 if (csrRoamIsHandoffInProgress(pMac))
5720 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 /* Should indicate neighbor roam algorithm about the connect failure here */
5722 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005724#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 if(pSession->bRefAssocStartCnt > 0)
5726 {
5727 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005728 if(eCsrJoinFailureDueToConcurrency == Result)
5729 {
5730 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5731 eCSR_ROAM_ASSOCIATION_COMPLETION,
5732 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5733 }
5734 else
5735 {
5736 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 eCSR_ROAM_ASSOCIATION_COMPLETION,
5738 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005741 else
5742 {
5743 /* bRefAssocStartCnt is not incremented when
5744 * eRoamState == eCsrStopRoamingDueToConcurrency
5745 * in csrRoamJoinNextBss API. so handle this in
5746 * else case by sending assoc failure
5747 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005748 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005749 pCommand->u.scanCmd.roamId,
5750 eCSR_ROAM_ASSOCIATION_FAILURE,
5751 eCSR_ROAM_RESULT_FAILURE);
5752 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005753 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005754#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5755 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5756#endif
5757 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5758 csrScanStartIdleScan(pMac);
5759#ifdef FEATURE_WLAN_BTAMP_UT_RF
5760 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5761 //BT activity and not able to recevie WLAN traffic. Retry the join
5762 if( CSR_IS_WDS_STA(pProfile) )
5763 {
5764 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5765 }
5766#endif
5767 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 case eCsrHddIssuedReassocToSameAP:
5769 case eCsrSmeIssuedReassocToSameAP:
5770 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5771
5772 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5773#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5774 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5775#endif
5776 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5777 csrScanStartIdleScan(pMac);
5778 break;
5779 case eCsrForcedDisassoc:
5780 case eCsrForcedDeauth:
5781 case eCsrSmeIssuedIbssJoinFailure:
5782 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5783
5784 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5785 {
5786 // Notify HDD that IBSS join failed
5787 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5788 }
5789 else
5790 {
5791 csrRoamCallCallback(pMac, sessionId, NULL,
5792 pCommand->u.roamCmd.roamId,
5793 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5794 }
5795#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5796 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5797#endif
5798 csrRoamLinkDown(pMac, sessionId);
5799 csrScanStartIdleScan(pMac);
5800 break;
5801 case eCsrForcedIbssLeave:
5802 csrRoamCallCallback(pMac, sessionId, NULL,
5803 pCommand->u.roamCmd.roamId,
5804 eCSR_ROAM_IBSS_LEAVE,
5805 eCSR_ROAM_RESULT_IBSS_STOP);
5806 break;
5807 case eCsrForcedDisassocMICFailure:
5808 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5809
5810 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5811#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5812 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5813#endif
5814 csrScanStartIdleScan(pMac);
5815 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 case eCsrStopBss:
5817 csrRoamCallCallback(pMac, sessionId, NULL,
5818 pCommand->u.roamCmd.roamId,
5819 eCSR_ROAM_INFRA_IND,
5820 eCSR_ROAM_RESULT_INFRA_STOPPED);
5821 break;
5822 case eCsrForcedDisassocSta:
5823 case eCsrForcedDeauthSta:
5824 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5825 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5826 {
5827 pSession = CSR_GET_SESSION(pMac, sessionId);
5828 if (!pSession)
5829 break;
5830
5831 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5832 {
5833 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305834 vos_mem_copy(roamInfo.peerMac,
5835 pCommand->u.roamCmd.peerMac,
5836 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5838 roamInfo.statusCode = eSIR_SME_SUCCESS;
5839 status = csrRoamCallCallback(pMac, sessionId,
5840 &roamInfo, pCommand->u.roamCmd.roamId,
5841 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5842 }
5843 }
5844 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 case eCsrLostLink1:
5846 // if lost link roam1 failed, then issue lost link Scan2 ...
5847 csrScanRequestLostLink2(pMac, sessionId);
5848 break;
5849 case eCsrLostLink2:
5850 // if lost link roam2 failed, then issue lost link scan3 ...
5851 csrScanRequestLostLink3(pMac, sessionId);
5852 break;
5853 case eCsrLostLink3:
5854 default:
5855 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5856
5857 //We are done with one round of lostlink roaming here
5858 csrScanHandleFailedLostlink3(pMac, sessionId);
5859 break;
5860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 break;
5862 }
5863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 return ( fReleaseCommand );
5865}
5866
Jeff Johnson295189b2012-06-20 16:38:30 -07005867eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5868{
5869 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 return (status);
5871}
5872
Jeff Johnson295189b2012-06-20 16:38:30 -07005873eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5874{
5875 eHalStatus status = eHAL_STATUS_SUCCESS;
5876 tANI_U32 size = 0;
5877
5878 do
5879 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305880 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5882 {
5883 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305884 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5885 if ( NULL == pDstProfile->BSSIDs.bssid )
5886 status = eHAL_STATUS_FAILURE;
5887 else
5888 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 if(!HAL_STATUS_SUCCESS(status))
5890 {
5891 break;
5892 }
5893 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305894 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5895 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 }
5897 if(pSrcProfile->SSIDs.numOfSSIDs)
5898 {
5899 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305900 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5901 if ( NULL == pDstProfile->SSIDs.SSIDList )
5902 status = eHAL_STATUS_FAILURE;
5903 else
5904 status = eHAL_STATUS_SUCCESS;
5905 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 {
5907 break;
5908 }
5909 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305910 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5911 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 }
5913 if(pSrcProfile->nWPAReqIELength)
5914 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305915 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5916 if ( NULL == pDstProfile->pWPAReqIE )
5917 status = eHAL_STATUS_FAILURE;
5918 else
5919 status = eHAL_STATUS_SUCCESS;
5920
5921 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 {
5923 break;
5924 }
5925 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305926 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
5927 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 }
5929 if(pSrcProfile->nRSNReqIELength)
5930 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305931 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
5932 if ( NULL == pDstProfile->pRSNReqIE )
5933 status = eHAL_STATUS_FAILURE;
5934 else
5935 status = eHAL_STATUS_SUCCESS;
5936
5937 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 {
5939 break;
5940 }
5941 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305942 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
5943 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 }
5945#ifdef FEATURE_WLAN_WAPI
5946 if(pSrcProfile->nWAPIReqIELength)
5947 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305948 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
5949 if ( NULL == pDstProfile->pWAPIReqIE )
5950 status = eHAL_STATUS_FAILURE;
5951 else
5952 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 if(!HAL_STATUS_SUCCESS(status))
5954 {
5955 break;
5956 }
5957 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305958 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
5959 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 }
5961#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 if(pSrcProfile->nAddIEScanLength)
5963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305964 pDstProfile->pAddIEScan = vos_mem_malloc(pSrcProfile->nAddIEScanLength);
5965 if ( NULL == pDstProfile->pAddIEScan )
5966 status = eHAL_STATUS_FAILURE;
5967 else
5968 status = eHAL_STATUS_SUCCESS;
5969
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 if(!HAL_STATUS_SUCCESS(status))
5971 {
5972 break;
5973 }
5974 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305975 vos_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5976 pSrcProfile->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 if(pSrcProfile->nAddIEAssocLength)
5979 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305980 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
5981 if ( NULL == pDstProfile->pAddIEAssoc )
5982 status = eHAL_STATUS_FAILURE;
5983 else
5984 status = eHAL_STATUS_SUCCESS;
5985
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 if(!HAL_STATUS_SUCCESS(status))
5987 {
5988 break;
5989 }
5990 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305991 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5992 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 if(pSrcProfile->ChannelInfo.ChannelList)
5995 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305996 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
5997 pSrcProfile->ChannelInfo.numOfChannels);
5998 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
5999 status = eHAL_STATUS_FAILURE;
6000 else
6001 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if(!HAL_STATUS_SUCCESS(status))
6003 {
6004 break;
6005 }
6006 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306007 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6008 pSrcProfile->ChannelInfo.ChannelList,
6009 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 pDstProfile->AuthType = pSrcProfile->AuthType;
6012 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6013 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6014 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6015 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6016 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006017#ifdef WLAN_FEATURE_11W
6018 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6019 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6020 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 pDstProfile->BSSType = pSrcProfile->BSSType;
6023 pDstProfile->phyMode = pSrcProfile->phyMode;
6024 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6025
6026#ifdef FEATURE_WLAN_WAPI
6027 if(csrIsProfileWapi(pSrcProfile))
6028 {
6029 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6030 {
6031 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6032 }
6033 }
6034#endif /* FEATURE_WLAN_WAPI */
6035 pDstProfile->CBMode = pSrcProfile->CBMode;
6036 /*Save the WPS info*/
6037 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6038 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 pDstProfile->privacy = pSrcProfile->privacy;
6041 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6042 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6043 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6044 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6045 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6046 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6047 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6048 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6049 pDstProfile->wps_state = pSrcProfile->wps_state;
6050 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306051 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6052 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006053#ifdef WLAN_FEATURE_VOWIFI_11R
6054 if (pSrcProfile->MDID.mdiePresent)
6055 {
6056 pDstProfile->MDID.mdiePresent = 1;
6057 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6058 }
6059#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 }while(0);
6061
6062 if(!HAL_STATUS_SUCCESS(status))
6063 {
6064 csrReleaseProfile(pMac, pDstProfile);
6065 pDstProfile = NULL;
6066 }
6067
6068 return (status);
6069}
Jeff Johnson295189b2012-06-20 16:38:30 -07006070eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6071{
6072 eHalStatus status = eHAL_STATUS_SUCCESS;
6073 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6074 do
6075 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306076 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 if(pSrcProfile->bssid)
6078 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306079 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6080 if ( NULL == pDstProfile->BSSIDs.bssid )
6081 status = eHAL_STATUS_FAILURE;
6082 else
6083 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 if(!HAL_STATUS_SUCCESS(status))
6085 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306086 smsLog( pMac, LOGE,
6087 FL("failed to allocate memory for BSSID"
6088 "%02x:%02x:%02x:%02x:%02x:%02x"),
6089 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6090 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 break;
6092 }
6093 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306094 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6095 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 }
6097 if(pSrcProfile->SSID.ssId)
6098 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306099 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6100 if ( NULL == pDstProfile->SSIDs.SSIDList )
6101 status = eHAL_STATUS_FAILURE;
6102 else
6103 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 if(!HAL_STATUS_SUCCESS(status))
6105 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306106 smsLog( pMac, LOGE,
6107 FL("failed to allocate memory for SSIDList"
6108 "%02x:%02x:%02x:%02x:%02x:%02x"),
6109 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6110 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 break;
6112 }
6113 pDstProfile->SSIDs.numOfSSIDs = 1;
6114 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6115 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306116 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6117 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006119 if(pSrcProfile->nAddIEAssocLength)
6120 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306121 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6122 if ( NULL == pDstProfile->pAddIEAssoc)
6123 status = eHAL_STATUS_FAILURE;
6124 else
6125 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006126 if(!HAL_STATUS_SUCCESS(status))
6127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006128 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006129 break;
6130 }
6131 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306132 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6133 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006134 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306135 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6136 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6137 status = eHAL_STATUS_FAILURE;
6138 else
6139 status = eHAL_STATUS_SUCCESS;
6140
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 if(!HAL_STATUS_SUCCESS(status))
6142 {
6143 break;
6144 }
6145 pDstProfile->ChannelInfo.numOfChannels = 1;
6146 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 pDstProfile->AuthType.numEntries = 1;
6148 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6149 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6150 pDstProfile->EncryptionType.numEntries = 1;
6151 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6152 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6153 pDstProfile->mcEncryptionType.numEntries = 1;
6154 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6155 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6156 pDstProfile->BSSType = pSrcProfile->BSSType;
6157 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306158 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6159 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006160#ifdef WLAN_FEATURE_VOWIFI_11R
6161 if (pSrcProfile->MDID.mdiePresent)
6162 {
6163 pDstProfile->MDID.mdiePresent = 1;
6164 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6165 }
6166#endif
6167
6168 }while(0);
6169
6170 if(!HAL_STATUS_SUCCESS(status))
6171 {
6172 csrReleaseProfile(pMac, pDstProfile);
6173 pDstProfile = NULL;
6174 }
6175
6176 return (status);
6177}
6178
Jeff Johnson295189b2012-06-20 16:38:30 -07006179eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6180 tScanResultHandle hBSSList,
6181 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6182 tANI_BOOLEAN fClearScan)
6183{
6184 eHalStatus status = eHAL_STATUS_SUCCESS;
6185 tSmeCmd *pCommand;
6186
6187 pCommand = csrGetCommandBuffer(pMac);
6188 if(NULL == pCommand)
6189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006190 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 status = eHAL_STATUS_RESOURCES;
6192 }
6193 else
6194 {
6195 if( fClearScan )
6196 {
6197 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306198 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 }
6200 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6201 if(NULL == pProfile)
6202 {
6203 //We can roam now
6204 //Since pProfile is NULL, we need to build our own profile, set everything to default
6205 //We can only support open and no encryption
6206 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6207 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6208 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6209 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6210 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6211 }
6212 else
6213 {
6214 //make a copy of the profile
6215 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6216 if(HAL_STATUS_SUCCESS(status))
6217 {
6218 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6219 }
6220 }
6221 pCommand->command = eSmeCommandRoam;
6222 pCommand->sessionId = (tANI_U8)sessionId;
6223 pCommand->u.roamCmd.hBSSList = hBSSList;
6224 pCommand->u.roamCmd.roamId = roamId;
6225 pCommand->u.roamCmd.roamReason = reason;
6226 //We need to free the BssList when the command is done
6227 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6228 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6230 FL("CSR PERSONA=%d"),
6231 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6233 if( !HAL_STATUS_SUCCESS( status ) )
6234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006235 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 csrReleaseCommandRoam( pMac, pCommand );
6237 }
6238 }
6239
6240 return (status);
6241}
Jeff Johnson295189b2012-06-20 16:38:30 -07006242eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6243 tCsrRoamModifyProfileFields *pMmodProfileFields,
6244 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6245{
6246 eHalStatus status = eHAL_STATUS_SUCCESS;
6247 tSmeCmd *pCommand;
6248
6249 pCommand = csrGetCommandBuffer(pMac);
6250 if(NULL == pCommand)
6251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006252 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 status = eHAL_STATUS_RESOURCES;
6254 }
6255 else
6256 {
6257 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306258 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 if(pProfile)
6260 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 //This is likely trying to reassoc to different profile
6262 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6263 //make a copy of the profile
6264 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6265 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 }
6267 else
6268 {
6269 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6270 //how to update WPA/WPA2 info in roamProfile??
6271 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 if(HAL_STATUS_SUCCESS(status))
6274 {
6275 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6276 }
6277 pCommand->command = eSmeCommandRoam;
6278 pCommand->sessionId = (tANI_U8)sessionId;
6279 pCommand->u.roamCmd.roamId = roamId;
6280 pCommand->u.roamCmd.roamReason = reason;
6281 //We need to free the BssList when the command is done
6282 //For reassoc there is no BSS list, so the boolean set to false
6283 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6284 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6285 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6287 if( !HAL_STATUS_SUCCESS( status ) )
6288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006289 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6291 csrReleaseCommandRoam( pMac, pCommand );
6292 }
6293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 return (status);
6295}
6296
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006297eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6298 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306299// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006300{
6301 eHalStatus status = eHAL_STATUS_SUCCESS;
6302 tSmeCmd *pCommand;
6303
6304 pCommand = csrGetCommandBuffer(pMac);
6305 if(NULL == pCommand)
6306 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006307 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006308 status = eHAL_STATUS_RESOURCES;
6309 }
6310 else
6311 {
6312 if(pBssDescription)
6313 {
6314 //copy over the parameters we need later
6315 pCommand->command = eSmeCommandRoam;
6316 pCommand->sessionId = (tANI_U8)sessionId;
6317 pCommand->u.roamCmd.roamReason = reason;
6318 //this is the important parameter
6319 //in this case we are using this field for the "next" BSS
6320 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6321 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6322 if( !HAL_STATUS_SUCCESS( status ) )
6323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006324 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006325 csrReleaseCommandPreauth( pMac, pCommand );
6326 }
6327 }
6328 else
6329 {
6330 //Return failure
6331 status = eHAL_STATUS_RESOURCES;
6332 }
6333 }
6334 return (status);
6335}
6336
6337eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6338{
6339 tListElem *pEntry;
6340 tSmeCmd *pCommand;
6341 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6342 if ( pEntry )
6343 {
6344 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6345 if ( (eSmeCommandRoam == pCommand->command) &&
6346 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6347 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006348 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006349 pCommand->command, pCommand->u.roamCmd.roamReason);
6350 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6351 csrReleaseCommandPreauth( pMac, pCommand );
6352 }
6353 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006354 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006355 pCommand->command, pCommand->u.roamCmd.roamReason);
6356 }
6357 }
6358 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006359 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006360 }
6361 smeProcessPendingQueue( pMac );
6362 return eHAL_STATUS_SUCCESS;
6363}
6364
Jeff Johnson295189b2012-06-20 16:38:30 -07006365eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6366 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6367{
6368 eHalStatus status = eHAL_STATUS_FAILURE;
6369 tScanResultHandle hBSSList;
6370 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6372 if(HAL_STATUS_SUCCESS(status))
6373 {
6374 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6375 if(pRoamId)
6376 {
6377 *pRoamId = roamId;
6378 }
6379 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6380 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6381 if(!HAL_STATUS_SUCCESS(status))
6382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006383 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 csrScanResultPurge(pMac, hBSSList);
6385 }
6386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 return (status);
6388}
6389
Jeff Johnson295189b2012-06-20 16:38:30 -07006390eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6391 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6392{
6393 eHalStatus status = eHAL_STATUS_SUCCESS;
6394 tScanResultHandle hBSSList;
6395 tCsrScanResultFilter *pScanFilter;
6396 tANI_U32 roamId = 0;
6397 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6398 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 if (NULL == pProfile)
6400 {
6401 smsLog(pMac, LOGP, FL("No profile specified"));
6402 return eHAL_STATUS_FAILURE;
6403 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006404 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 if( CSR_IS_WDS( pProfile ) &&
6407 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006409 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006410 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 return status;
6412 }
6413 csrRoamCancelRoaming(pMac, sessionId);
6414 csrScanRemoveFreshScanCommand(pMac, sessionId);
6415 csrScanCancelIdleScan(pMac);
6416 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306417 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6419 {
6420 csrScanDisable(pMac);
6421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6423 //Check whether ssid changes
6424 if(csrIsConnStateConnected(pMac, sessionId))
6425 {
6426 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6427 {
6428 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6429 }
6430 }
6431#ifdef FEATURE_WLAN_BTAMP_UT_RF
6432 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6433#endif
6434 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006436 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6438 if(pRoamId)
6439 {
6440 roamId = *pRoamId;
6441 }
6442 if(!HAL_STATUS_SUCCESS(status))
6443 {
6444 fCallCallback = eANI_BOOLEAN_TRUE;
6445 }
6446 }
6447 else
6448 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306449 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6450 if ( NULL == pScanFilter )
6451 status = eHAL_STATUS_FAILURE;
6452 else
6453 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 if(HAL_STATUS_SUCCESS(status))
6455 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306456 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 //Try to connect to any BSS
6458 if(NULL == pProfile)
6459 {
6460 //No encryption
6461 pScanFilter->EncryptionType.numEntries = 1;
6462 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6463 }//we don't have a profile
6464 else
6465 {
6466 //Here is the profile we need to connect to
6467 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6468 }//We have a profile
6469 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6470 if(pRoamId)
6471 {
6472 *pRoamId = roamId;
6473 }
6474
6475 if(HAL_STATUS_SUCCESS(status))
6476 {
6477 /*Save the WPS info*/
6478 if(NULL != pProfile)
6479 {
6480 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6481 }
6482 else
6483 {
6484 pScanFilter->bWPSAssociation = 0;
6485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 do
6487 {
6488 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 )
6491 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006492 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6494 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6495 if(!HAL_STATUS_SUCCESS(status))
6496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006497 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 fCallCallback = eANI_BOOLEAN_TRUE;
6499 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006500 else
6501 {
6502 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 break;
6505 }
6506 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006507 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 if(HAL_STATUS_SUCCESS(status))
6509 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6511 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6512 if(!HAL_STATUS_SUCCESS(status))
6513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006514 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 csrScanResultPurge(pMac, hBSSList);
6516 fCallCallback = eANI_BOOLEAN_TRUE;
6517 }
6518 }//Have scan result
6519 else if(NULL != pProfile)
6520 {
6521 //Check whether it is for start ibss
6522 if(CSR_IS_START_IBSS(pProfile))
6523 {
6524 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6525 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6526 if(!HAL_STATUS_SUCCESS(status))
6527 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006528 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 fCallCallback = eANI_BOOLEAN_TRUE;
6530 }
6531 }
6532 else
6533 {
6534 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006535 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 if(!HAL_STATUS_SUCCESS(status))
6537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006538 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 fCallCallback = eANI_BOOLEAN_TRUE;
6540 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006541 else
6542 {
6543 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 }
6546 }
6547 else
6548 {
6549 fCallCallback = eANI_BOOLEAN_TRUE;
6550 }
6551 } while (0);
6552 if(NULL != pProfile)
6553 {
6554 //we need to free memory for filter if profile exists
6555 csrFreeScanFilter(pMac, pScanFilter);
6556 }
6557 }//Got the scan filter from profile
6558
Kiet Lam64c1b492013-07-12 13:56:44 +05306559 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 }//allocated memory for pScanFilter
6561 }//No Bsslist coming in
6562 //tell the caller if we fail to trigger a join request
6563 if( fCallCallback )
6564 {
6565 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6566 }
6567
6568 return (status);
6569}
Jeff Johnson295189b2012-06-20 16:38:30 -07006570eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6571 tCsrRoamModifyProfileFields modProfileFields,
6572 tANI_U32 *pRoamId)
6573{
6574 eHalStatus status = eHAL_STATUS_SUCCESS;
6575 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6576 tANI_U32 roamId = 0;
6577 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 if (NULL == pProfile)
6579 {
6580 smsLog(pMac, LOGP, FL("No profile specified"));
6581 return eHAL_STATUS_FAILURE;
6582 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006583 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 -07006584 csrRoamCancelRoaming(pMac, sessionId);
6585 csrScanRemoveFreshScanCommand(pMac, sessionId);
6586 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306587 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 if(csrIsConnStateConnected(pMac, sessionId))
6590 {
6591 if(pProfile)
6592 {
6593 if(pProfile->SSIDs.numOfSSIDs &&
6594 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6595 {
6596 fCallCallback = eANI_BOOLEAN_FALSE;
6597 }
6598 else
6599 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006600 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 }
6602 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306603 else if (!vos_mem_compare(&modProfileFields,
6604 &pSession->connectedProfile.modifyProfileFields,
6605 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 {
6607 fCallCallback = eANI_BOOLEAN_FALSE;
6608 }
6609 else
6610 {
6611 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006612 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 }
6614 }
6615 else
6616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006617 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 if(!fCallCallback)
6620 {
6621 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6622 if(pRoamId)
6623 {
6624 *pRoamId = roamId;
6625 }
6626
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6628 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 }
6630 else
6631 {
6632 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6633 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 return status;
6636}
Jeff Johnson295189b2012-06-20 16:38:30 -07006637eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6638{
6639 eHalStatus status = eHAL_STATUS_FAILURE;
6640 tScanResultHandle hBSSList = NULL;
6641 tCsrScanResultFilter *pScanFilter = NULL;
6642 tANI_U32 roamId;
6643 tCsrRoamProfile *pProfile = NULL;
6644 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006645
6646 if(!pSession)
6647 {
6648 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6649 return eHAL_STATUS_FAILURE;
6650 }
6651
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 do
6653 {
6654 if(pSession->pCurRoamProfile)
6655 {
6656 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306657 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306659 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6660 if ( NULL == pProfile )
6661 status = eHAL_STATUS_FAILURE;
6662 else
6663 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 if(!HAL_STATUS_SUCCESS(status))
6665 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306666 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306668 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306670 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6671 if ( NULL == pScanFilter )
6672 status = eHAL_STATUS_FAILURE;
6673 else
6674 status = eHAL_STATUS_SUCCESS;
6675
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 if(!HAL_STATUS_SUCCESS(status))
6677 {
6678 break;
6679 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306680 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6682 if(!HAL_STATUS_SUCCESS(status))
6683 {
6684 break;
6685 }
6686 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6687 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6688 if(HAL_STATUS_SUCCESS(status))
6689 {
6690 //we want to put the last connected BSS to the very beginning, if possible
6691 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6692 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6693 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6694 if(!HAL_STATUS_SUCCESS(status))
6695 {
6696 csrScanResultPurge(pMac, hBSSList);
6697 break;
6698 }
6699 }
6700 else
6701 {
6702 //Do a scan on this profile
6703 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006704 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 if(!HAL_STATUS_SUCCESS(status))
6706 {
6707 break;
6708 }
6709 }
6710 }//We have a profile
6711 else
6712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006713 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 break;
6715 }
6716 }while(0);
6717 if(pScanFilter)
6718 {
6719 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306720 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 }
6722 if(NULL != pProfile)
6723 {
6724 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306725 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 return (status);
6728}
Jeff Johnson295189b2012-06-20 16:38:30 -07006729eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6730{
6731 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 if(csrIsConnStateConnected(pMac, sessionId))
6733 {
6734 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6735 if(HAL_STATUS_SUCCESS(status))
6736 {
6737 status = csrRoamJoinLastProfile(pMac, sessionId);
6738 }
6739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 return (status);
6741}
6742
Jeff Johnson295189b2012-06-20 16:38:30 -07006743eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6744{
6745 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006746 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 csrRoamCancelRoaming(pMac, sessionId);
6748 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6749 if(csrIsConnStateDisconnected(pMac, sessionId))
6750 {
6751 status = csrRoamJoinLastProfile(pMac, sessionId);
6752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 return (status);
6754}
6755
Jeff Johnson295189b2012-06-20 16:38:30 -07006756eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6757{
6758 eHalStatus status = eHAL_STATUS_SUCCESS;
6759 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6760 eCsrRoamSubState NewSubstate;
6761 tANI_U32 sessionId = pCommand->sessionId;
6762
6763 // change state to 'Roaming'...
6764 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6765
6766 if ( csrIsConnStateIbss( pMac, sessionId ) )
6767 {
6768 // If we are in an IBSS, then stop the IBSS...
6769 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6770 fComplete = (!HAL_STATUS_SUCCESS(status));
6771 }
6772 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006774 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 -07006775 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6776 //Restore AC weight in case we change it
6777 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6778 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6779 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6780 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6781 {
6782 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6783 }
6784 if( fDisassoc )
6785 {
6786 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6787 }
6788 else
6789 {
6790 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6791 }
6792 fComplete = (!HAL_STATUS_SUCCESS(status));
6793 }
6794 else if ( csrIsConnStateWds( pMac, sessionId ) )
6795 {
6796 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6797 {
6798 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6799 fComplete = (!HAL_STATUS_SUCCESS(status));
6800 }
6801 //This has to be WDS station
6802 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6803 {
6804
6805 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6806 if( fDisassoc )
6807 {
6808 status = csrRoamIssueDisassociate( pMac, sessionId,
6809 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6810 fComplete = (!HAL_STATUS_SUCCESS(status));
6811 }
6812 }
6813 } else {
6814 // we got a dis-assoc request while not connected to any peer
6815 // just complete the command
6816 fComplete = eANI_BOOLEAN_TRUE;
6817 status = eHAL_STATUS_FAILURE;
6818 }
6819 if(fComplete)
6820 {
6821 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6822 }
6823
6824 if(HAL_STATUS_SUCCESS(status))
6825 {
6826 if ( csrIsConnStateInfra( pMac, sessionId ) )
6827 {
6828 //Set the state to disconnect here
6829 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6830 }
6831 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006832 else
6833 {
6834 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 return (status);
6837}
6838
Jeff Johnson295189b2012-06-20 16:38:30 -07006839/* This is been removed from latest code base */
6840/*
6841static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6842{
6843 eHalStatus status;
6844 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006845 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6846 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 return ( status );
6848}
6849*/
6850
Jeff Johnson295189b2012-06-20 16:38:30 -07006851eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6852{
6853 eHalStatus status = eHAL_STATUS_SUCCESS;
6854 tSmeCmd *pCommand;
6855 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 do
6857 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006858 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 pCommand = csrGetCommandBuffer( pMac );
6860 if ( !pCommand )
6861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006862 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 status = eHAL_STATUS_RESOURCES;
6864 break;
6865 }
6866 //Change the substate in case it is wait-for-key
6867 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6868 {
6869 csrRoamStopWaitForKeyTimer( pMac );
6870 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6871 }
6872 pCommand->command = eSmeCommandRoam;
6873 pCommand->sessionId = (tANI_U8)sessionId;
6874 switch ( reason )
6875 {
6876 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6877 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6878 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 case eCSR_DISCONNECT_REASON_DEAUTH:
6880 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6881 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 case eCSR_DISCONNECT_REASON_HANDOFF:
6883 fHighPriority = eANI_BOOLEAN_TRUE;
6884 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6887 case eCSR_DISCONNECT_REASON_DISASSOC:
6888 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6889 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6891 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006893 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6894 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6895 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 default:
6897 break;
6898 }
6899 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6900 if( !HAL_STATUS_SUCCESS( status ) )
6901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006902 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 csrReleaseCommandRoam( pMac, pCommand );
6904 }
6905 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 return( status );
6907}
6908
Jeff Johnson295189b2012-06-20 16:38:30 -07006909eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6910{
6911 eHalStatus status = eHAL_STATUS_SUCCESS;
6912 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 pCommand = csrGetCommandBuffer( pMac );
6914 if ( NULL != pCommand )
6915 {
6916 //Change the substate in case it is wait-for-key
6917 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6918 {
6919 csrRoamStopWaitForKeyTimer( pMac );
6920 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6921 }
6922 pCommand->command = eSmeCommandRoam;
6923 pCommand->sessionId = (tANI_U8)sessionId;
6924 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6925 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6926 if( !HAL_STATUS_SUCCESS( status ) )
6927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006928 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 csrReleaseCommandRoam( pMac, pCommand );
6930 }
6931 }
6932 else
6933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006934 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 status = eHAL_STATUS_RESOURCES;
6936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 return ( status );
6938}
6939
Jeff Johnson295189b2012-06-20 16:38:30 -07006940eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6941{
6942 eHalStatus status = eHAL_STATUS_SUCCESS;
6943 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006944
6945 if(!pSession)
6946 {
6947 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6948 return eHAL_STATUS_FAILURE;
6949 }
6950
Jeff Johnson295189b2012-06-20 16:38:30 -07006951#ifdef FEATURE_WLAN_BTAMP_UT_RF
6952 //Stop te retry
6953 pSession->maxRetryCount = 0;
6954 csrRoamStopJoinRetryTimer(pMac, sessionId);
6955#endif
6956 //Not to call cancel roaming here
6957 //Only issue disconnect when necessary
6958 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6959 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6960 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6961
6962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006963 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 return (status);
6967}
6968
Jeff Johnson295189b2012-06-20 16:38:30 -07006969eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6970{
6971 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006972
6973 if(!pSession)
6974 {
6975 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6976 return eHAL_STATUS_FAILURE;
6977 }
6978
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6981
6982 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6983}
6984
Jeff Johnson295189b2012-06-20 16:38:30 -07006985eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6986 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6987{
6988 eHalStatus status = eHAL_STATUS_SUCCESS;
6989 tDot11fBeaconIEs *pIesTemp = pIes;
6990 tANI_U8 index;
6991 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6992 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006993
6994 if(!pSession)
6995 {
6996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6997 return eHAL_STATUS_FAILURE;
6998 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006999 if(pConnectProfile->pAddIEAssoc)
7000 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307001 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007002 pConnectProfile->pAddIEAssoc = NULL;
7003 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307004 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7006 pConnectProfile->AuthInfo = pProfile->AuthType;
7007 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7008 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7009 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7010 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7011 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7012 pConnectProfile->BSSType = pProfile->BSSType;
7013 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7014 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007015 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7016
Kiet Lam64c1b492013-07-12 13:56:44 +05307017 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007018 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7019 if(pProfile->nAddIEAssocLength)
7020 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307021 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7022 if ( NULL == pConnectProfile->pAddIEAssoc )
7023 status = eHAL_STATUS_FAILURE;
7024 else
7025 status = eHAL_STATUS_SUCCESS;
7026 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007027 {
7028 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7029 return eHAL_STATUS_FAILURE;
7030 }
7031 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307032 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7033 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007034 }
7035
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 //Save bssid
7037 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7038#ifdef WLAN_FEATURE_VOWIFI_11R
7039 if (pSirBssDesc->mdiePresent)
7040 {
7041 pConnectProfile->MDID.mdiePresent = 1;
7042 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7043 }
7044#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007045 if( NULL == pIesTemp )
7046 {
7047 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007049#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007050 if ((csrIsProfileCCX(pProfile) ||
7051 ((pIesTemp->CCXVersion.present)
7052 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7053 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7054 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7055 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007056#ifdef WLAN_FEATURE_11W
7057 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7058#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307059 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007060 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 {
7062 pConnectProfile->isCCXAssoc = 1;
7063 }
7064#endif
7065 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007066 if(HAL_STATUS_SUCCESS(status))
7067 {
7068 if(pIesTemp->SSID.present)
7069 {
7070 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307071 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7072 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 }
7074
7075 //Save the bss desc
7076 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307077
7078 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307080 //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 -07007081 pConnectProfile->qap = TRUE;
7082 }
7083 else
7084 {
7085 pConnectProfile->qap = FALSE;
7086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 if ( NULL == pIes )
7088 {
7089 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307090 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 }
7092 }
7093 //Save Qos connection
7094 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7095
7096 if(!HAL_STATUS_SUCCESS(status))
7097 {
7098 csrFreeConnectBssDesc(pMac, sessionId);
7099 }
7100 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7101 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307102 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7103 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7104 pConnectProfile->SSID.ssId,
7105 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 {
7107 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7108 break;
7109 }
7110 pConnectProfile->handoffPermitted = FALSE;
7111 }
7112
7113 return (status);
7114}
7115
Jeff Johnson295189b2012-06-20 16:38:30 -07007116static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7117{
7118 tListElem *pEntry = NULL;
7119 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 //The head of the active list is the request we sent
7121 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7122 if(pEntry)
7123 {
7124 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7127 {
7128 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7129 {
7130#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7131 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7132#endif
7133 }
7134 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7135 }
7136 else
7137 {
7138 tANI_U32 roamId = 0;
7139 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007140 if(!pSession)
7141 {
7142 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7143 return;
7144 }
7145
Jeff Johnson295189b2012-06-20 16:38:30 -07007146
7147 //The head of the active list is the request we sent
7148 //Try to get back the same profile and roam again
7149 if(pCommand)
7150 {
7151 roamId = pCommand->u.roamCmd.roamId;
7152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7154 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007155 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007156#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7157 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7158 if (csrRoamIsHandoffInProgress(pMac))
7159 {
7160 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7161 /* Should indicate neighbor roam algorithm about the connect failure here */
7162 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7163 }
7164#endif
7165 if (pCommand)
7166 {
7167 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7168 {
7169 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7170 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7171 csrRoamReissueRoamCommand(pMac);
7172 }
7173 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7174 {
7175 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7176 }
7177 else
7178 {
7179 csrRoam(pMac, pCommand);
7180 }
7181 }
7182 else
7183 {
7184 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7185 }
7186 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7187}
7188
Jeff Johnson295189b2012-06-20 16:38:30 -07007189eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7190 tDot11fBeaconIEs *pIes,
7191 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7192{
7193 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007194 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7195 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007196
7197 // Set the roaming substate to 'join attempt'...
7198 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007200 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 return (status);
7202}
7203
Jeff Johnson295189b2012-06-20 16:38:30 -07007204static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7205 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7206{
7207 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 // Set the roaming substate to 'join attempt'...
7209 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7210
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007211 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007212
7213 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007214 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007215}
7216
Jeff Johnson295189b2012-06-20 16:38:30 -07007217void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7218{
7219 tListElem *pEntry;
7220 tSmeCmd *pCommand;
7221 tCsrRoamInfo roamInfo;
7222 tANI_U32 sessionId;
7223 tCsrRoamSession *pSession;
7224
7225 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7226 if(pEntry)
7227 {
7228 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7229 if ( eSmeCommandRoam == pCommand->command )
7230 {
7231 sessionId = pCommand->sessionId;
7232 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007233
7234 if(!pSession)
7235 {
7236 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7237 return;
7238 }
7239
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 if( pCommand->u.roamCmd.fStopWds )
7241 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307242 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7244 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7245 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7248 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7249 eCSR_ROAM_WDS_IND,
7250 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7252 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7253 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7254 eCSR_ROAM_INFRA_IND,
7255 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7256 }
7257
Jeff Johnson295189b2012-06-20 16:38:30 -07007258
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007261 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7263 }
7264 }
7265 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007267 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7269 }
7270 }
7271 else
7272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007273 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 }
7275 }
7276 else
7277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007278 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 }
7280}
7281
Jeff Johnson295189b2012-06-20 16:38:30 -07007282tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7283{
7284 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7285 tListElem *pEntry;
7286 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 //alwasy lock active list before locking pending list
7288 csrLLLock( &pMac->sme.smeCmdActiveList );
7289 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7290 if(pEntry)
7291 {
7292 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7293 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7294 {
7295 fRet = eANI_BOOLEAN_TRUE;
7296 }
7297 }
7298 if(eANI_BOOLEAN_FALSE == fRet)
7299 {
7300 csrLLLock(&pMac->sme.smeCmdPendingList);
7301 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7302 while(pEntry)
7303 {
7304 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7305 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7306 {
7307 fRet = eANI_BOOLEAN_TRUE;
7308 break;
7309 }
7310 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7311 }
7312 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7313 }
7314 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 return (fRet);
7316}
7317
Jeff Johnson295189b2012-06-20 16:38:30 -07007318tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7319{
7320 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7321 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7323 {
7324 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7325 {
7326 break;
7327 }
7328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 return ( fRet );
7330}
7331
Jeff Johnson295189b2012-06-20 16:38:30 -07007332tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7333{
7334 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 //alwasy lock active list before locking pending list
7336 csrLLLock( &pMac->sme.smeCmdActiveList );
7337 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7338 if(eANI_BOOLEAN_FALSE == fRet)
7339 {
7340 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7341 }
7342 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 return (fRet);
7344}
7345
Jeff Johnson295189b2012-06-20 16:38:30 -07007346tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7347{
7348 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7349 tListElem *pEntry;
7350 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 //alwasy lock active list before locking pending list
7352 csrLLLock( &pMac->sme.smeCmdActiveList );
7353 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7354 if( pEntry )
7355 {
7356 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7357 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7358 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7359 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7360 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7361 {
7362 fRet = eANI_BOOLEAN_TRUE;
7363 }
7364 }
7365 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 return (fRet);
7367}
Jeff Johnson295189b2012-06-20 16:38:30 -07007368eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7369{
7370 eHalStatus status = eHAL_STATUS_SUCCESS;
7371 tSmeCmd *pCommand = NULL;
7372 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7373 tANI_BOOLEAN fRemoveCmd = FALSE;
7374 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 // Delete the old assoc command. All is setup for reassoc to be serialized
7376 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7377 if ( pEntry )
7378 {
7379 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7380 if ( !pCommand )
7381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007382 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 return eHAL_STATUS_RESOURCES;
7384 }
7385 if ( eSmeCommandRoam == pCommand->command )
7386 {
7387 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7388 {
7389 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7390 }
7391 else
7392 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007393 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 }
7395 if (fRemoveCmd == FALSE)
7396 {
7397 // Implies we did not get the serialized assoc command we
7398 // were expecting
7399 pCommand = NULL;
7400 }
7401 }
7402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 if(NULL == pCommand)
7404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007405 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 return eHAL_STATUS_RESOURCES;
7407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 do
7409 {
7410 //Change the substate in case it is wait-for-key
7411 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7412 {
7413 csrRoamStopWaitForKeyTimer( pMac );
7414 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7415 }
7416 pCommand->command = eSmeCommandRoam;
7417 pCommand->sessionId = (tANI_U8)sessionId;
7418 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7420 if( !HAL_STATUS_SUCCESS( status ) )
7421 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007422 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 csrReleaseCommandRoam( pMac, pCommand );
7424 }
7425 } while( 0 );
7426
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 return( status );
7428}
7429static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7430{
7431 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7432 tCsrScanResult *pScanResult = NULL;
7433 tSirBssDescription *pBssDesc = NULL;
7434 tSmeCmd *pCommand = NULL;
7435 tANI_U32 sessionId;
7436 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 if(NULL == pEntry)
7438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007439 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 return;
7441 }
7442 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7443 sessionId = pCommand->sessionId;
7444 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007445
7446 if(!pSession)
7447 {
7448 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7449 return;
7450 }
7451
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7453 {
7454 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007455 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7457 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007458 /* If the roaming has stopped, not to continue the roaming command*/
7459 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7460 {
7461 //No need to complete roaming here as it already completes
7462 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7463 pCommand->u.roamCmd.roamReason);
7464 csrSetAbortRoamingCommand( pMac, pCommand );
7465 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 else
7468 {
7469 if ( CCM_IS_RESULT_SUCCESS(result) )
7470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007471 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 // Successfully set the configuration parameters for the new Bss. Attempt to
7473 // join the roaming Bss.
7474 if(pCommand->u.roamCmd.pRoamBssEntry)
7475 {
7476 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7477 pBssDesc = &pScanResult->Result.BssDescriptor;
7478 }
7479 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7480 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 )
7483 {
7484 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7485 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7486 pBssDesc, pCommand->u.roamCmd.roamId )))
7487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007488 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 //We need to complete the command
7490 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7491 }
7492 }
7493 else
7494 {
7495 if (!pCommand->u.roamCmd.pRoamBssEntry)
7496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007497 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 //We need to complete the command
7499 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7500 return;
7501 }
7502 // If we are roaming TO an Infrastructure BSS...
7503 VOS_ASSERT(pScanResult != NULL);
7504 if ( csrIsInfraBssDesc( pBssDesc ) )
7505 {
7506 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7508 {
7509 // ..and currently in an Infrastructure connection....
7510 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7511 {
7512 // ...and the SSIDs are equal, then we Reassoc.
7513 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7514 pIesLocal ) )
7515 // ..and currently in an infrastructure connection
7516 {
7517 // then issue a Reassoc.
7518 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7519 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7520 &pCommand->u.roamCmd.roamProfile );
7521 }
7522 else
7523 {
7524
7525 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7526 // previously associated AP.
7527 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7528 pIesLocal,
7529 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7530 {
7531 //try something else
7532 csrRoam( pMac, pCommand );
7533 }
7534 }
7535 }
7536 else
7537 {
7538 eHalStatus status = eHAL_STATUS_SUCCESS;
7539
7540 /* We need to come with other way to figure out that this is because of HO in BMP
7541 The below API will be only available for Android as it uses a different HO algorithm */
7542 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7543 * use join request */
7544#ifdef WLAN_FEATURE_VOWIFI_11R
7545 if (csrRoamIsHandoffInProgress(pMac) &&
7546 csrRoamIs11rAssoc(pMac))
7547 {
7548 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7549 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7550 }
7551 else
7552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007553#ifdef FEATURE_WLAN_CCX
7554 if (csrRoamIsHandoffInProgress(pMac) &&
7555 csrRoamIsCCXAssoc(pMac))
7556 {
7557 // Now serialize the reassoc command.
7558 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7559 }
7560 else
7561#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007562#ifdef FEATURE_WLAN_LFR
7563 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307564 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007565 {
7566 // Now serialize the reassoc command.
7567 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7568 }
7569 else
7570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 // else we are not connected and attempting to Join. Issue the
7572 // Join request.
7573 {
7574 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7575 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7576 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7577 }
7578 if(!HAL_STATUS_SUCCESS(status))
7579 {
7580 //try something else
7581 csrRoam( pMac, pCommand );
7582 }
7583 }
7584 if( !pScanResult->Result.pvIes )
7585 {
7586 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307587 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 }
7589 }
7590 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7591 else
7592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007593 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 }
7595 }//else
7596 }//if ( WNI_CFG_SUCCESS == result )
7597 else
7598 {
7599 // In the event the configuration failed, for infra let the roam processor
7600 //attempt to join something else...
7601 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7602 {
7603 csrRoam(pMac, pCommand);
7604 }
7605 else
7606 {
7607 //We need to complete the command
7608 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7609 {
7610 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7611 }
7612 else
7613 {
7614 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7615 }
7616 }
7617 }
7618 }//we have active entry
7619}
7620
Jeff Johnson295189b2012-06-20 16:38:30 -07007621static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7622{
7623 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007624 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007627 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7629 // join the new one...
7630 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7632 }
7633 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007634 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007635 /***profHandleLostLinkAfterReset(pAdapter);
7636 // In the event the authenticate fails, let the roam processor attempt to join something else...
7637 roamRoam( pAdapter );***/
7638 }
7639}
7640
Jeff Johnson295189b2012-06-20 16:38:30 -07007641static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7642{
7643 eCsrRoamCompleteResult result;
7644 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7645 tCsrRoamInfo roamInfo;
7646 tANI_U32 roamId = 0;
7647
7648 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007650 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007652 /* Defeaturize this part later if needed */
7653#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7654 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7655 * we need the response contents while processing the result in csrRoamProcessResults() */
7656 if (csrRoamIsHandoffInProgress(pMac))
7657 {
7658 /* Need to dig more on indicating events to SME QoS module */
7659 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7660 csrRoamComplete( pMac, result, pSmeJoinRsp);
7661 }
7662 else
7663#endif
7664 {
7665 csrRoamComplete( pMac, result, NULL );
7666 }
7667 }
7668 /* Should we handle this similar to handling the join failure? Is it ok
7669 * to call csrRoamComplete() with state as CsrJoinFailure */
7670 else
7671 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007672 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 result = eCsrReassocFailure;
7674#ifdef WLAN_FEATURE_VOWIFI_11R
7675 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7676 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7677 {
7678 // Inform HDD to turn off FT flag in HDD
7679 if (pNeighborRoamInfo)
7680 {
7681 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7682 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7683 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007684 /*
7685 * Since the above callback sends a disconnect
7686 * to HDD, we should clean-up our state
7687 * machine as well to be in sync with the upper
7688 * layers. There is no need to send a disassoc
7689 * since: 1) we will never reassoc to the current
7690 * AP in LFR, and 2) there is no need to issue a
7691 * disassoc to the AP with which we were trying
7692 * to reassoc.
7693 */
7694 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7695 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007696 }
7697 }
7698#endif
7699 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7700 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7701 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7702 //The disassoc rsp message will remove the command from active list
7703 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7704 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7705 {
7706 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7707 }
7708 }
7709}
7710
Jeff Johnson295189b2012-06-20 16:38:30 -07007711static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7712{
Jeff Johnson295189b2012-06-20 16:38:30 -07007713#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7714 {
7715 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7717 if(pIbssLog)
7718 {
7719 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7720 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7721 {
7722 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7723 }
7724 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7725 }
7726 }
7727#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7729 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7730 {
7731 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7732 }
7733 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7734 {
7735 csrRoamReissueRoamCommand(pMac);
7736 }
7737}
7738
Jeff Johnson295189b2012-06-20 16:38:30 -07007739void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7740{
7741 tSirResultCodes statusCode;
7742#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7743 tScanResultHandle hBSSList;
7744 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7745 eHalStatus status;
7746 tCsrRoamInfo roamInfo;
7747 tCsrScanResultFilter *pScanFilter = NULL;
7748 tANI_U32 roamId = 0;
7749 tCsrRoamProfile *pCurRoamProfile = NULL;
7750 tListElem *pEntry = NULL;
7751 tSmeCmd *pCommand = NULL;
7752#endif
7753 tANI_U32 sessionId;
7754 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007755
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 tSirSmeDisassocRsp SmeDisassocRsp;
7757
7758 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7759 sessionId = SmeDisassocRsp.sessionId;
7760 statusCode = SmeDisassocRsp.statusCode;
7761
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007762 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007763
7764 if ( csrIsConnStateInfra( pMac, sessionId ) )
7765 {
7766 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007769
7770 if(!pSession)
7771 {
7772 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7773 return;
7774 }
7775
Jeff Johnson295189b2012-06-20 16:38:30 -07007776 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7777 {
7778 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7779 }
7780 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7781 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7782 {
7783 if ( eSIR_SME_SUCCESS == statusCode )
7784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007785 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7787 }
7788 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007792 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007793#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007794 /*
7795 * First ensure if the roam profile is in the scan cache.
7796 * If not, post a reassoc failure and disconnect.
7797 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307798 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7799 if ( NULL == pScanFilter )
7800 status = eHAL_STATUS_FAILURE;
7801 else
7802 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007803 if(HAL_STATUS_SUCCESS(status))
7804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307805 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007806 status = csrRoamPrepareFilterFromProfile(pMac,
7807 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7808 if(!HAL_STATUS_SUCCESS(status))
7809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007810 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007811 __func__, status);
7812 goto POST_ROAM_FAILURE;
7813 }
7814 else
7815 {
7816 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7817 if (!HAL_STATUS_SUCCESS(status))
7818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007819 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007820 __func__, status);
7821 goto POST_ROAM_FAILURE;
7822 }
7823 }
7824 }
7825 else
7826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007827 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007828 __func__, status);
7829 goto POST_ROAM_FAILURE;
7830 }
7831
7832 /*
7833 * After ensuring that the roam profile is in the scan result list,
7834 * dequeue the command from the active list.
7835 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7837 if ( pEntry )
7838 {
7839 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007840 /* If the head of the queue is Active and it is a ROAM command, remove
7841 * and put this on the Free queue.
7842 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 if ( eSmeCommandRoam == pCommand->command )
7844 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007845
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007846 /*
7847 * we need to process the result first before removing it from active list
7848 * because state changes still happening insides roamQProcessRoamResults so
7849 * no other roam command should be issued.
7850 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7852 if(pCommand->u.roamCmd.fReleaseProfile)
7853 {
7854 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7855 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 else
7860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007861 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007862 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 }
7864 }
7865 else
7866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007867 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 }
7869 }
7870 else
7871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007872 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007874
7875 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7877
Kiet Lam64c1b492013-07-12 13:56:44 +05307878 vos_mem_copy(roamInfo.bssid,
7879 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7880 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007881
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007882 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7883 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007884
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007885 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307886 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7887 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307889 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007890 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7891 //make sure to put it at the head of the cmd queue
7892 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7893 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7894 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7895
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 if(!HAL_STATUS_SUCCESS(status))
7897 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007898 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007899 __func__, status);
7900 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 }
7902
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007903 /* Notify sub-modules like QoS etc. that handoff happening */
7904 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007905 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307906 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307908 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007909 return;
7910 }
7911
7912POST_ROAM_FAILURE:
7913 if (pScanFilter)
7914 {
7915 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307916 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007917 }
7918 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05307919 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007920
7921 /* Inform the upper layers that the reassoc failed */
7922 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7923 csrRoamCallCallback(pMac, sessionId,
7924 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7925
7926 /*
7927 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7928 * Upon success, we would re-enter this routine after receiving the disassoc
7929 * response and will fall into the reassoc fail sub-state. And, eventually
7930 * call csrRoamComplete which would remove the roam command from SME active
7931 * queue.
7932 */
7933 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7934 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007936 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007937 __func__, status);
7938 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007940#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007941
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7943 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7944 {
7945 // Disassoc due to Reassoc failure falls into this codepath....
7946 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7947 }
7948 else
7949 {
7950 if ( eSIR_SME_SUCCESS == statusCode )
7951 {
7952 // Successfully disassociated from the 'old' Bss...
7953 //
7954 // We get Disassociate response in three conditions.
7955 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7956 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7957 // Infrastructure network.
7958 // - Third is where we are doing an Infra to Infra roam between networks with different
7959 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7960
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007961 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 }
7963 else
7964 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007965 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 }
7967 //We are not done yet. Get the data and continue roaming
7968 csrRoamReissueRoamCommand(pMac);
7969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007970}
7971
Jeff Johnson295189b2012-06-20 16:38:30 -07007972static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7973{
7974 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007976 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007977 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7978 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7979 {
7980 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7981 }
7982 else
7983 {
7984 if ( eSIR_SME_SUCCESS == statusCode )
7985 {
7986 // Successfully deauth from the 'old' Bss...
7987 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007988 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 }
7990 else
7991 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007992 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 }
7994 //We are not done yet. Get the data and continue roaming
7995 csrRoamReissueRoamCommand(pMac);
7996 }
7997}
7998
Jeff Johnson295189b2012-06-20 16:38:30 -07007999static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8000{
8001 eCsrRoamCompleteResult result;
8002
8003 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008005 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 result = eCsrStartBssSuccess;
8007 }
8008 else
8009 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008010 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008011 //Let csrRoamComplete decide what to do
8012 result = eCsrStartBssFailure;
8013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008015}
8016
Jeff Johnson295189b2012-06-20 16:38:30 -07008017/*
8018 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8019 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8020 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8021 For the messages where sender allocates memory for specific structures, then it can be
8022 cast accordingly.
8023*/
8024void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8025{
8026 tSirSmeRsp *pSmeRsp;
8027 tSmeIbssPeerInd *pIbssPeerInd;
8028 tCsrRoamInfo roamInfo;
8029 // TODO Session Id need to be acquired in this function
8030 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008032 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 pSmeRsp->messageType, pSmeRsp->messageType,
8034 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 pSmeRsp->messageType = (pSmeRsp->messageType);
8036 pSmeRsp->length = (pSmeRsp->length);
8037 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008038 switch (pSmeRsp->messageType)
8039 {
8040
8041 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8042 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8043 {
8044 //We sent a JOIN_REQ
8045 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8046 }
8047 break;
8048
8049 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8050 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8051 {
8052 //We sent a AUTH_REQ
8053 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8054 }
8055 break;
8056
8057 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8058 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8059 {
8060 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8061 }
8062 break;
8063
8064 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8065 {
8066 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8067 }
8068 break;
8069
8070 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8071 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8072 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8073 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8074 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8075 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8076//HO
8077 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008079 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8081 }
8082 break;
8083
8084 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8085 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8086 {
8087 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8088 }
8089 break;
8090
8091 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8092 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8093 {
8094 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8095 }
8096 break;
8097
8098 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8099 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8100 {
8101 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008103 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8105 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8106 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008107 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308108 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8109 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8111 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308112 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8113 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008114 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8115 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8116 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8117 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008119 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 pSmeRsp->messageType, pSmeRsp->messageType,
8121 pMac->roam.curSubState[pSmeRsp->sessionId] );
8122
8123 //If we are connected, check the link status change
8124 if(!csrIsConnStateDisconnected(pMac, sessionId))
8125 {
8126 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8127 }
8128 break;
8129 }
8130}
8131
Jeff Johnson295189b2012-06-20 16:38:30 -07008132void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8133{
8134 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 switch (pSirMsg->messageType)
8136 {
8137 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008138 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 csrRoamStatsRspProcessor( pMac, pSirMsg );
8140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8142 {
8143 tCsrRoamSession *pSession;
8144 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8145 tCsrRoamInfo roamInfo;
8146 tCsrRoamInfo *pRoamInfo = NULL;
8147 tANI_U32 sessionId;
8148 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008149 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308150 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8153 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8154 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008155
8156 if(!pSession)
8157 {
8158 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8159 return;
8160 }
8161
Jeff Johnson295189b2012-06-20 16:38:30 -07008162 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8163 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8165 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8166 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8168 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308169 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8170 sizeof(tSirMacAddr));
8171 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8172 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8175 {
8176 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8177 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8178 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8179 }
8180 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8181 {
8182 vos_sleep( 100 );
8183 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8184 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8185 }
8186
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 }
8188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 default:
8190 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8191 break;
8192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008193}
8194
Jeff Johnson295189b2012-06-20 16:38:30 -07008195eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8196 tSirBssDescription *pBssDescription,
8197 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8198 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8199 tANI_U8 keyId, tANI_U16 keyLength,
8200 tANI_U8 *pKey, tANI_U8 paeRole )
8201{
8202 eHalStatus status = eHAL_STATUS_SUCCESS;
8203 tAniEdType edType;
8204
8205 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8206 {
8207 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8208 }
8209
8210 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8211
8212 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8213 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8214 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8215 addKey )
8216 {
8217 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 setKey.encType = EncryptType;
8219 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308220 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 setKey.paeRole = paeRole; //0 for supplicant
8222 setKey.keyId = keyId; // Kye index
8223 setKey.keyLength = keyLength;
8224 if( keyLength )
8225 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308226 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 }
8228 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 return (status);
8231}
8232
Jeff Johnson295189b2012-06-20 16:38:30 -07008233static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8234 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8235{
8236 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8237 tSmeCmd *pCommand = NULL;
8238#ifdef FEATURE_WLAN_CCX
8239 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8240#endif /* FEATURE_WLAN_CCX */
8241
8242 do
8243 {
8244 pCommand = csrGetCommandBuffer(pMac);
8245 if(NULL == pCommand)
8246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008247 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 status = eHAL_STATUS_RESOURCES;
8249 break;
8250 }
8251 pCommand->command = eSmeCommandSetKey;
8252 pCommand->sessionId = (tANI_U8)sessionId;
8253 // validate the key length, Adjust if too long...
8254 // for static WEP the keys are not set thru' SetContextReq
8255 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8256 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8257 {
8258 //KeyLength maybe 0 for static WEP
8259 if( pSetKey->keyLength )
8260 {
8261 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8262 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008263 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008264 break;
8265 }
8266
8267 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308268 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8269 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 }
8271 }
8272 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8273 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8274 {
8275 //KeyLength maybe 0 for static WEP
8276 if( pSetKey->keyLength )
8277 {
8278 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008280 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 break;
8282 }
8283
8284 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308285 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8286 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 }
8288 }
8289 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8290 {
8291 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008293 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 break;
8295 }
8296 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308297 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8298 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 }
8300 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8301 {
8302 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008304 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 break;
8306 }
8307 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308308 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8309 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 }
8311#ifdef FEATURE_WLAN_WAPI
8312 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8313 {
8314 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008316 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 break;
8318 }
8319 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308320 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8321 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 }
8323#endif /* FEATURE_WLAN_WAPI */
8324#ifdef FEATURE_WLAN_CCX
8325 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8326 {
8327 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008329 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 break;
8331 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308332 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8333 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 pSession->ccxCckmInfo.reassoc_req_num=1;
8335 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8336 status = eHAL_STATUS_SUCCESS;
8337 break;
8338 }
8339#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008340
Jeff Johnson295189b2012-06-20 16:38:30 -07008341#ifdef WLAN_FEATURE_11W
8342 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008343 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008345 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008347 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 break;
8349 }
8350 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308351 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 }
8353#endif
8354 status = eHAL_STATUS_SUCCESS;
8355 pCommand->u.setKeyCmd.roamId = roamId;
8356 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8357 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308358 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8359 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8361 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308362 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 //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
8364
8365 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8366 if( !HAL_STATUS_SUCCESS( status ) )
8367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008368 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 }
8370 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008371 // Free the command if there has been a failure, or it is a
8372 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008373 if ( ( NULL != pCommand ) &&
8374 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008375#ifdef FEATURE_WLAN_CCX
8376 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8377#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008378 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 {
8380 csrReleaseCommandSetKey( pMac, pCommand );
8381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 return( status );
8383}
8384
Jeff Johnson295189b2012-06-20 16:38:30 -07008385eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8386 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8387{
8388 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8389 tSmeCmd *pCommand = NULL;
8390 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 do
8392 {
8393 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8394 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008395 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 status = eHAL_STATUS_CSR_WRONG_STATE;
8397 break;
8398 }
8399 pCommand = csrGetCommandBuffer(pMac);
8400 if(NULL == pCommand)
8401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008402 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 status = eHAL_STATUS_RESOURCES;
8404 break;
8405 }
8406 pCommand->command = eSmeCommandRemoveKey;
8407 pCommand->sessionId = (tANI_U8)sessionId;
8408 pCommand->u.removeKeyCmd.roamId = roamId;
8409 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308410 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8411 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8413 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8414 {
8415 //in this case, put it to the end of the Q incase there is a set key pending.
8416 fImediate = eANI_BOOLEAN_FALSE;
8417 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008418 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008420 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8422 if( !HAL_STATUS_SUCCESS( status ) )
8423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008424 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 break;
8426 }
8427 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8429 {
8430 csrReleaseCommandRemoveKey( pMac, pCommand );
8431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 return (status );
8433}
8434
Jeff Johnson295189b2012-06-20 16:38:30 -07008435eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8436{
8437 eHalStatus status;
8438 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8439 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8440 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8441 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008442#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8443 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8444 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008445 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308447 vos_mem_set(&setKeyEvent,
8448 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8450 {
8451 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8452 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8453 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8454 }
8455 else
8456 {
8457 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8458 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8459 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8460 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308461 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008462 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 {
8464 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 //It has to be static WEP here
8466 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8467 {
8468 setKeyEvent.keyId = (v_U8_t)defKeyId;
8469 }
8470 }
8471 else
8472 {
8473 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8474 }
8475 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8476 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8477 }
8478#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 if( csrIsSetKeyAllowed(pMac, sessionId) )
8480 {
8481 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8482 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8483 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8484 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8485 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8486 pCommand->u.setKeyCmd.keyRsc);
8487 }
8488 else
8489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008490 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 //Set this status so the error handling take care of the case.
8492 status = eHAL_STATUS_CSR_WRONG_STATE;
8493 }
8494 if( !HAL_STATUS_SUCCESS(status) )
8495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008496 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008498#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008499 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 {
8501 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8502 {
8503 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8504 }
8505 else
8506 {
8507 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8508 }
8509 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8510 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8511 }
8512#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 return ( status );
8515}
8516
Jeff Johnson295189b2012-06-20 16:38:30 -07008517eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8518{
8519 eHalStatus status;
8520 tpSirSmeRemoveKeyReq pMsg = NULL;
8521 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8522 tANI_U8 *p;
8523 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008524#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8525 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8526 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308527 vos_mem_set(&removeKeyEvent,
8528 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8530 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8531 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308532 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8534 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8535 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8536#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 if( csrIsSetKeyAllowed(pMac, sessionId) )
8538 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308539 pMsg = vos_mem_malloc(wMsgLen);
8540 if ( NULL == pMsg )
8541 status = eHAL_STATUS_FAILURE;
8542 else
8543 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 }
8545 else
8546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008547 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 //Set the error status so error handling kicks in below
8549 status = eHAL_STATUS_CSR_WRONG_STATE;
8550 }
8551 if( HAL_STATUS_SUCCESS( status ) )
8552 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308553 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8555 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 pMsg->sessionId = (tANI_U8)sessionId;
8557 pMsg->transactionId = 0;
8558 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8559 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8560 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308561 vos_mem_copy(p,
8562 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8563 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 p += sizeof(tSirMacAddr);
8565 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308566 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 p += sizeof(tSirMacAddr);
8568 // edType
8569 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8570 p++;
8571 // weptype
8572 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8573 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8574 {
8575 *p = (tANI_U8)eSIR_WEP_STATIC;
8576 }
8577 else
8578 {
8579 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8580 }
8581 p++;
8582 //keyid
8583 *p = pCommand->u.removeKeyCmd.keyId;
8584 p++;
8585 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 status = palSendMBMessage(pMac->hHdd, pMsg);
8587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 if( !HAL_STATUS_SUCCESS( status ) )
8589 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008590 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008591#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8592 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008593 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8595#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008598 return ( status );
8599}
8600
Jeff Johnson295189b2012-06-20 16:38:30 -07008601eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8602{
8603 eHalStatus status;
8604
8605 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8606 {
8607 status = eHAL_STATUS_CSR_WRONG_STATE;
8608 }
8609 else
8610 {
8611 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 return ( status );
8614}
8615
Jeff Johnson295189b2012-06-20 16:38:30 -07008616/*
8617 Prepare a filter base on a profile for parsing the scan results.
8618 Upon successful return, caller MUST call csrFreeScanFilter on
8619 pScanFilter when it is done with the filter.
8620*/
8621eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8622 tCsrScanResultFilter *pScanFilter)
8623{
8624 eHalStatus status = eHAL_STATUS_SUCCESS;
8625 tANI_U32 size = 0;
8626 tANI_U8 index = 0;
8627
8628 do
8629 {
8630 if(pProfile->BSSIDs.numOfBSSIDs)
8631 {
8632 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308633 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8634 if ( NULL == pScanFilter->BSSIDs.bssid )
8635 status = eHAL_STATUS_FAILURE;
8636 else
8637 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 if(!HAL_STATUS_SUCCESS(status))
8639 {
8640 break;
8641 }
8642 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308643 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 }
8645 if(pProfile->SSIDs.numOfSSIDs)
8646 {
8647 if( !CSR_IS_WDS_STA( pProfile ) )
8648 {
8649 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8650 }
8651 else
8652 {
8653 //For WDS station
8654 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8655 pScanFilter->SSIDs.numOfSSIDs = 1;
8656 }
8657 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308658 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8659 if ( NULL == pScanFilter->SSIDs.SSIDList )
8660 status = eHAL_STATUS_FAILURE;
8661 else
8662 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 if(!HAL_STATUS_SUCCESS(status))
8664 {
8665 break;
8666 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308667 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8668 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 }
8670 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8671 {
8672 pScanFilter->ChannelInfo.numOfChannels = 0;
8673 pScanFilter->ChannelInfo.ChannelList = NULL;
8674 }
8675 else if(pProfile->ChannelInfo.numOfChannels)
8676 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308677 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8678 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8679 pProfile->ChannelInfo.numOfChannels);
8680 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8681 status = eHAL_STATUS_FAILURE;
8682 else
8683 status = eHAL_STATUS_SUCCESS;
8684
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 pScanFilter->ChannelInfo.numOfChannels = 0;
8686 if(HAL_STATUS_SUCCESS(status))
8687 {
8688 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8689 {
8690 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8691 {
8692 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8693 = pProfile->ChannelInfo.ChannelList[index];
8694 pScanFilter->ChannelInfo.numOfChannels++;
8695 }
8696 else
8697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008698 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 }
8701 }
8702 else
8703 {
8704 break;
8705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 }
8707 else
8708 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008709 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 status = eHAL_STATUS_FAILURE;
8711 break;
8712 }
8713 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8714 pScanFilter->authType = pProfile->AuthType;
8715 pScanFilter->EncryptionType = pProfile->EncryptionType;
8716 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8717 pScanFilter->BSSType = pProfile->BSSType;
8718 pScanFilter->phyMode = pProfile->phyMode;
8719#ifdef FEATURE_WLAN_WAPI
8720 //check if user asked for WAPI with 11n or auto mode, in that case modify
8721 //the phymode to 11g
8722 if(csrIsProfileWapi(pProfile))
8723 {
8724 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8725 {
8726 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8727 }
8728 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8729 {
8730 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8731 }
8732 if(!pScanFilter->phyMode)
8733 {
8734 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8735 }
8736 }
8737#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 /*Save the WPS info*/
8739 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 if( pProfile->countryCode[0] )
8741 {
8742 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308743 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8744 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 }
8746#ifdef WLAN_FEATURE_VOWIFI_11R
8747 if (pProfile->MDID.mdiePresent)
8748 {
8749 pScanFilter->MDID.mdiePresent = 1;
8750 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8751 }
8752#endif
8753
8754 }while(0);
8755
8756 if(!HAL_STATUS_SUCCESS(status))
8757 {
8758 csrFreeScanFilter(pMac, pScanFilter);
8759 }
8760
8761 return(status);
8762}
8763
Jeff Johnson295189b2012-06-20 16:38:30 -07008764tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8765 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8766{
8767 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8768 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 do
8770 {
8771 // Validate the type is ok...
8772 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8773 pCommand = csrGetCommandBuffer( pMac );
8774 if ( !pCommand )
8775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008776 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 break;
8778 }
8779 //Change the substate in case it is waiting for key
8780 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8781 {
8782 csrRoamStopWaitForKeyTimer( pMac );
8783 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8784 }
8785 pCommand->command = eSmeCommandWmStatusChange;
8786 pCommand->sessionId = (tANI_U8)sessionId;
8787 pCommand->u.wmStatusChangeCmd.Type = Type;
8788 if ( eCsrDisassociated == Type )
8789 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308790 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8791 pSmeRsp,
8792 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 }
8794 else
8795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308796 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8797 pSmeRsp,
8798 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 }
8800 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8801 {
8802 fCommandQueued = eANI_BOOLEAN_TRUE;
8803 }
8804 else
8805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008806 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 csrReleaseCommandWmStatusChange( pMac, pCommand );
8808 }
8809
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8811 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 return( fCommandQueued );
8814}
8815
Jeff Johnson295189b2012-06-20 16:38:30 -07008816static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8817{
8818 v_S7_t rssi = 0;
8819 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8820 if(pGetRssiReq)
8821 {
8822 if(NULL != pGetRssiReq->pVosContext)
8823 {
8824 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8825 }
8826 else
8827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008828 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 return;
8830 }
8831
8832 if(NULL != pGetRssiReq->rssiCallback)
8833 {
8834 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8835 }
8836 else
8837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008838 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008839 return;
8840 }
8841 }
8842 else
8843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008844 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008845 }
8846 return;
8847}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308848
8849static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8850{
8851 tANI_S8 snr = 0;
8852 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8853
8854 if (pGetSnrReq)
8855 {
8856 if (VOS_STATUS_SUCCESS !=
8857 WDA_GetSnr(pGetSnrReq->staId, &snr))
8858 {
8859 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8860 return;
8861 }
8862
8863 if (pGetSnrReq->snrCallback)
8864 {
8865 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8866 pGetSnrReq->pDevContext);
8867 }
8868 else
8869 {
8870 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8871 return;
8872 }
8873 }
8874 else
8875 {
8876 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8877 }
8878 return;
8879}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008880#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8881void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8882{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008883 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8884
Jeff Johnson36d483b2013-04-08 11:08:53 -07008885 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008886 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008887 /* Get roam Rssi request is backed up and passed back to the response,
8888 Extract the request message to fetch callback */
8889 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8890 v_S7_t rssi = pRoamRssiRsp->rssi;
8891
8892 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008893 {
8894 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8895 reqBkp->rssiCallback = NULL;
8896 vos_mem_free(reqBkp);
8897 }
8898 else
8899 {
8900 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8901 if (NULL != reqBkp)
8902 {
8903 vos_mem_free(reqBkp);
8904 }
8905 }
8906 }
8907 else
8908 {
8909 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8910 }
8911 return;
8912}
8913#endif
8914
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008915
8916#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8917void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8918{
8919 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
8920
8921 if (NULL != pTsmStatsRsp)
8922 {
8923 /* Get roam Rssi request is backed up and passed back to the response,
8924 Extract the request message to fetch callback */
8925 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
8926
8927 if (NULL != reqBkp)
8928 {
8929 if (NULL != reqBkp->tsmStatsCallback)
8930 {
8931 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
8932 pTsmStatsRsp->staId, reqBkp->pDevContext);
8933 reqBkp->tsmStatsCallback = NULL;
8934 }
8935 vos_mem_free(reqBkp);
8936 }
8937 else
8938 {
8939 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
8940 if (NULL != reqBkp)
8941 {
8942 vos_mem_free(reqBkp);
8943 }
8944 }
8945 }
8946 else
8947 {
8948 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
8949 }
8950 return;
8951}
8952
8953void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
8954{
8955 tANI_U32 roamTS2 = 0;
8956 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008957 tpPESession pSessionEntry = NULL;
8958 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008959
8960 if (NULL == pSession)
8961 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008962 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008963 return;
8964 }
8965
8966 roamTS2 = vos_timer_get_system_time();
8967 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08008968 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
8969 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008970 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008971
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008972 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
8973 if (NULL == pSessionEntry)
8974 {
8975 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
8976 return;
8977 }
8978 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008979 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
8980 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
8981}
8982#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
8983
Jeff Johnsone7245742012-09-05 17:12:55 -07008984static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8985{
8986 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8987 if(pTlRssiInd)
8988 {
8989 if(NULL != pTlRssiInd->tlCallback)
8990 {
8991 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008992 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008993 }
8994 else
8995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008996 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008997 }
8998 }
8999 else
9000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009001 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009002 }
9003 return;
9004}
Jeff Johnson295189b2012-06-20 16:38:30 -07009005
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309006eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9007{
9008 tpSirResetAPCapsChange pMsg;
9009 tANI_U16 len;
9010 eHalStatus status = eHAL_STATUS_SUCCESS;
9011
9012 /* Create the message and send to lim */
9013 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309014 pMsg = vos_mem_malloc(len);
9015 if ( NULL == pMsg )
9016 status = eHAL_STATUS_FAILURE;
9017 else
9018 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309019 if (HAL_STATUS_SUCCESS(status))
9020 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309021 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309022 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9023 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309024 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009025 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9026 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309027 status = palSendMBMessage(pMac->hHdd, pMsg);
9028 }
9029 else
9030 {
9031 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9032 }
9033 return status;
9034}
9035
Jeff Johnson295189b2012-06-20 16:38:30 -07009036void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9037{
9038 tSirSmeAssocInd *pAssocInd;
9039 tSirSmeDisassocInd *pDisassocInd;
9040 tSirSmeDeauthInd *pDeauthInd;
9041 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9042 tSirSmeNewBssInfo *pNewBss;
9043 tSmeIbssPeerInd *pIbssPeerInd;
9044 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9045 tSirSmeApNewCaps *pApNewCaps;
9046 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9047 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9048 tCsrRoamInfo *pRoamInfo = NULL;
9049 tCsrRoamInfo roamInfo;
9050 eHalStatus status;
9051 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9052 tCsrRoamSession *pSession = NULL;
9053 tpSirSmeSwitchChannelInd pSwitchChnInd;
9054 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009055 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 pSirMsg->messageType = (pSirMsg->messageType);
9057 pSirMsg->length = (pSirMsg->length);
9058 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309059 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 switch( pSirMsg->messageType )
9061 {
9062 case eWNI_SME_ASSOC_IND:
9063 {
9064 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009065 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9067 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9068 if( HAL_STATUS_SUCCESS( status ) )
9069 {
9070 pSession = CSR_GET_SESSION(pMac, sessionId);
9071
Jeff Johnson32d95a32012-09-10 13:15:23 -07009072 if(!pSession)
9073 {
9074 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9075 return;
9076 }
9077
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 pRoamInfo = &roamInfo;
9079
9080 // Required for indicating the frames to upper layer
9081 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9082 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9083
9084 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9085 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9086 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9087 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9088
9089 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9090 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9091 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9092
9093 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9094 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309095 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9096 sizeof(tSirMacAddr));
9097 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9098 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009099 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9100 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9103 {
9104 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9105 {
9106 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9107 pSession->pConnectBssDesc,
9108 &(pRoamInfo->peerMac),
9109 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9110 pRoamInfo->fAuthRequired = FALSE;
9111 }
9112 else
9113 {
9114 pRoamInfo->fAuthRequired = TRUE;
9115 }
9116 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9117 if (!HAL_STATUS_SUCCESS(status))
9118 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 /* Send Association completion message to PE */
9121 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9122
9123 /* send a message to CSR itself just to avoid the EAPOL frames going
9124 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9126 {
9127 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9130 {
9131 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9132 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9133 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 }
9136 }
9137 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 // Check if AP dis-associated us because of MIC failure. If so,
9140 // then we need to take action immediately and not wait till the
9141 // the WmStatusChange requests is pushed and processed
9142 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9143 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9144 if( HAL_STATUS_SUCCESS( status ) )
9145 {
Kiet Lam82004c62013-11-11 13:24:28 +05309146 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC for session %d "), sessionId);
9147 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer =" MAC_ADDRESS_STR " "
9148 " reason = %d status = %d "),
9149 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9150 pDisassocInd->reasonCode, pDisassocInd->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009151 // If we are in neighbor preauth done state then on receiving
9152 // disassoc or deauth we dont roam instead we just disassoc
9153 // from current ap and then go to disconnected state
9154 // This happens for CCX and 11r FT connections ONLY.
9155#ifdef WLAN_FEATURE_VOWIFI_11R
9156 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9157 {
9158 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9159 }
9160#endif
9161#ifdef FEATURE_WLAN_CCX
9162 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9163 {
9164 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9165 }
9166#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009167#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309168 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009169 {
9170 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9171 }
9172#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009173 pSession = CSR_GET_SESSION( pMac, sessionId );
9174
Jeff Johnson32d95a32012-09-10 13:15:23 -07009175 if(!pSession)
9176 {
9177 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9178 return;
9179 }
9180
Jeff Johnson295189b2012-06-20 16:38:30 -07009181 if ( csrIsConnStateInfra( pMac, sessionId ) )
9182 {
9183 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009185#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9186 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9187#endif
9188 csrRoamLinkDown(pMac, sessionId);
9189 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9191 {
9192
9193 pRoamInfo = &roamInfo;
9194
9195 pRoamInfo->statusCode = pDisassocInd->statusCode;
9196 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9197
9198 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
9199
Kiet Lam64c1b492013-07-12 13:56:44 +05309200 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9201 sizeof(tSirMacAddr));
9202 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9203 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009204
9205 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009206
9207 /*
9208 * STA/P2P client got disassociated so remove any pending deauth
9209 * commands in sme pending list
9210 */
9211 pCommand.command = eSmeCommandRoam;
9212 pCommand.sessionId = (tANI_U8)sessionId;
9213 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Kiet Lam64c1b492013-07-12 13:56:44 +05309214 vos_mem_copy(pCommand.u.roamCmd.peerMac,
9215 pDisassocInd->peerMacAddr,
9216 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009217 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 }
Kiet Lam82004c62013-11-11 13:24:28 +05309220 else
9221 {
9222 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9223 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009227 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9229 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9230 if( HAL_STATUS_SUCCESS( status ) )
9231 {
9232 // If we are in neighbor preauth done state then on receiving
9233 // disassoc or deauth we dont roam instead we just disassoc
9234 // from current ap and then go to disconnected state
9235 // This happens for CCX and 11r FT connections ONLY.
9236#ifdef WLAN_FEATURE_VOWIFI_11R
9237 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9238 {
9239 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9240 }
9241#endif
9242#ifdef FEATURE_WLAN_CCX
9243 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9244 {
9245 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9246 }
9247#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009248#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309249 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009250 {
9251 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9252 }
9253#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 pSession = CSR_GET_SESSION( pMac, sessionId );
9255
Jeff Johnson32d95a32012-09-10 13:15:23 -07009256 if(!pSession)
9257 {
9258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9259 return;
9260 }
9261
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 if ( csrIsConnStateInfra( pMac, sessionId ) )
9263 {
9264 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009266#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9267 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9268#endif
9269 csrRoamLinkDown(pMac, sessionId);
9270 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9272 {
9273
9274 pRoamInfo = &roamInfo;
9275
9276 pRoamInfo->statusCode = pDeauthInd->statusCode;
9277 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9278
9279 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9280
Kiet Lam64c1b492013-07-12 13:56:44 +05309281 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9282 sizeof(tSirMacAddr));
9283 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9284 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009285
9286 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 }
9289 break;
9290
9291 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 -08009292 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009293 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9294 //Update with the new channel id.
9295 //The channel id is hidden in the statusCode.
9296 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9297 if( HAL_STATUS_SUCCESS( status ) )
9298 {
9299 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009300 if(!pSession)
9301 {
9302 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9303 return;
9304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9306 if(pSession->pConnectBssDesc)
9307 {
9308 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9309 }
9310 }
9311 break;
9312
9313 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009314 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 {
9316 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9317 sessionId = pDeauthRsp->sessionId;
9318 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9319 {
9320 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009321 if(!pSession)
9322 {
9323 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9324 return;
9325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9327 {
9328 pRoamInfo = &roamInfo;
9329 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309330 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9331 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9333 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9334 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9335 }
9336 }
9337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 break;
9339
9340 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009341 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009342 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 {
9344 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9345 sessionId = pDisassocRsp->sessionId;
9346 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9347 {
9348 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009349 if(!pSession)
9350 {
9351 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9352 return;
9353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9355 {
9356 pRoamInfo = &roamInfo;
9357 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309358 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9359 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9361 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9362 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9363 }
9364 }
9365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 case eWNI_SME_MIC_FAILURE_IND:
9368 {
9369 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9370 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9371 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009372
9373 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9374 if( HAL_STATUS_SUCCESS( status ) )
9375 {
9376 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9377 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9378 pRoamInfo = &roamInfo;
9379 if(pMicInd->info.multicast)
9380 {
9381 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9382 }
9383 else
9384 {
9385 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9386 }
9387 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9388 }
9389
Jeff Johnson295189b2012-06-20 16:38:30 -07009390#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9391 {
lukez3c809222013-05-03 10:23:02 -07009392 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009394 if(!pSession)
9395 {
9396 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9397 return;
9398 }
lukez3c809222013-05-03 10:23:02 -07009399
Kiet Lam64c1b492013-07-12 13:56:44 +05309400 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009401 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9402 secEvent.encryptionModeMulticast =
9403 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9404 secEvent.encryptionModeUnicast =
9405 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9406 secEvent.authMode =
9407 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309408 vos_mem_copy(secEvent.bssid,
9409 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9411 }
9412#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009413 }
9414 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9416 {
9417 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9418 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009419 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009420
9421 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9422 if( HAL_STATUS_SUCCESS( status ) )
9423 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309424 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9426 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9427 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9428 }
9429 }
9430 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009431
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9433 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9434 switch( pStatusChangeMsg->statusChangeCode )
9435 {
9436 case eSIR_SME_IBSS_ACTIVE:
9437 sessionId = csrFindIbssSession( pMac );
9438 if( CSR_SESSION_ID_INVALID != sessionId )
9439 {
9440 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009441 if(!pSession)
9442 {
9443 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9444 return;
9445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9447 if(pSession->pConnectBssDesc)
9448 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309449 vos_mem_copy(&roamInfo.bssid,
9450 pSession->pConnectBssDesc->bssId,
9451 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9453 pRoamInfo = &roamInfo;
9454 }
9455 else
9456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009457 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 }
9459 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9460 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9461 }
9462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 case eSIR_SME_IBSS_INACTIVE:
9464 sessionId = csrFindIbssSession( pMac );
9465 if( CSR_SESSION_ID_INVALID != sessionId )
9466 {
9467 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 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9474 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9475 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9476 }
9477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9479 sessionId = csrFindIbssSession( pMac );
9480 if( CSR_SESSION_ID_INVALID != sessionId )
9481 {
9482 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009483 if(!pSession)
9484 {
9485 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9486 return;
9487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 // update the connection state information
9489 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009490#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9491 {
9492 vos_log_ibss_pkt_type *pIbssLog;
9493 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9495 if(pIbssLog)
9496 {
9497 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9498 if(pNewBss)
9499 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309500 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 if(pNewBss->ssId.length)
9502 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309503 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9504 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 }
9506 pIbssLog->operatingChannel = pNewBss->channelNumber;
9507 }
9508 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9509 {
9510 //***U8 is not enough for beacon interval
9511 pIbssLog->beaconInterval = (v_U8_t)bi;
9512 }
9513 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9514 }
9515 }
9516#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009518
9519 if ((eCSR_ENCRYPT_TYPE_NONE ==
9520 pSession->connectedProfile.EncryptionType ))
9521 {
9522 csrRoamIssueSetContextReq( pMac, sessionId,
9523 pSession->connectedProfile.EncryptionType,
9524 pSession->pConnectBssDesc,
9525 &Broadcastaddr,
9526 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9529 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309530 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9531 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 pRoamInfo = &roamInfo;
9533 //This BSSID is th ereal BSSID, let's save it
9534 if(pSession->pConnectBssDesc)
9535 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309536 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9537 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009540 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 // detection by LIM that the capabilities of the associated AP have changed.
9543 case eSIR_SME_AP_CAPS_CHANGED:
9544 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009545 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9547 if( HAL_STATUS_SUCCESS( status ) )
9548 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009549 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9550 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309551 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009552 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9553 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9554 )
9555 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309556 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9557 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009558 }
9559 else
9560 {
9561 smsLog(pMac, LOGW,
9562 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009563 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009564 pMac->roam.curState[sessionId],
9565 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309566 /* We ignore the caps change event if CSR is not in full connected state.
9567 * Send one event to PE to reset limSentCapsChangeNtf
9568 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9569 * otherwise lim cannot send any CAPS change events to SME */
9570 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 }
9573 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309574
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 default:
9576 roamStatus = eCSR_ROAM_FAILED;
9577 result = eCSR_ROAM_RESULT_NONE;
9578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 } // end switch on statusChangeCode
9580 if(eCSR_ROAM_RESULT_NONE != result)
9581 {
9582 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9583 }
9584 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 case eWNI_SME_IBSS_NEW_PEER_IND:
9586 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009587#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9588 {
9589 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9591 if(pIbssLog)
9592 {
9593 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309594 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9596 }
9597 }
9598#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 sessionId = csrFindIbssSession( pMac );
9600 if( CSR_SESSION_ID_INVALID != sessionId )
9601 {
9602 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009603
9604 if(!pSession)
9605 {
9606 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9607 return;
9608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9610 if(pSession->pConnectBssDesc)
9611 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309612 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9613 sizeof(tCsrBssid));
9614 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9615 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9617 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309618 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9619 - sizeof(tSmeIbssPeerInd)));
9620 if ( NULL == roamInfo.pbFrames )
9621 status = eHAL_STATUS_FAILURE;
9622 else
9623 status = eHAL_STATUS_SUCCESS;
9624 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 {
9626 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309627 vos_mem_copy(roamInfo.pbFrames,
9628 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9629 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 }
9631 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9632 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9633 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309634 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9635 if ( NULL == roamInfo.pBssDesc )
9636 status = eHAL_STATUS_FAILURE;
9637 else
9638 status = eHAL_STATUS_SUCCESS;
9639 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309641 vos_mem_copy(roamInfo.pBssDesc,
9642 pSession->pConnectBssDesc,
9643 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 }
9645 if(HAL_STATUS_SUCCESS(status))
9646 {
9647 pRoamInfo = &roamInfo;
9648 }
9649 else
9650 {
9651 if(roamInfo.pbFrames)
9652 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309653 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009654 }
9655 if(roamInfo.pBssDesc)
9656 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309657 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 }
9659 }
9660 }
9661 else
9662 {
9663 pRoamInfo = &roamInfo;
9664 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009665 if ((eCSR_ENCRYPT_TYPE_NONE ==
9666 pSession->connectedProfile.EncryptionType ))
9667 {
9668 csrRoamIssueSetContextReq( pMac, sessionId,
9669 pSession->connectedProfile.EncryptionType,
9670 pSession->pConnectBssDesc,
9671 &(pIbssPeerInd->peerAddr),
9672 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009674 }
9675 else
9676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009677 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 }
9679 //send up the sec type for the new peer
9680 if (pRoamInfo)
9681 {
9682 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9683 }
9684 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9685 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9686 if(pRoamInfo)
9687 {
9688 if(roamInfo.pbFrames)
9689 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309690 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 }
9692 if(roamInfo.pBssDesc)
9693 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309694 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 }
9696 }
9697 }
9698 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9700 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9701 sessionId = csrFindIbssSession( pMac );
9702 if( CSR_SESSION_ID_INVALID != sessionId )
9703 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009704#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9705 {
9706 vos_log_ibss_pkt_type *pIbssLog;
9707
9708 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9709 if(pIbssLog)
9710 {
9711 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9712 if(pIbssPeerInd)
9713 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309714 vos_mem_copy(pIbssLog->peerMacAddr,
9715 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 }
9717 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9718 }
9719 }
9720#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009721 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9723 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9724 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309725 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9726 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9728 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9729 }
9730 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 case eWNI_SME_SETCONTEXT_RSP:
9732 {
9733 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9734 tListElem *pEntry;
9735 tSmeCmd *pCommand;
9736
9737 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9738 if ( pEntry )
9739 {
9740 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9741 if ( eSmeCommandSetKey == pCommand->command )
9742 {
9743 sessionId = pCommand->sessionId;
9744 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009745
9746 if(!pSession)
9747 {
9748 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9749 return;
9750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009751
9752#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9753 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9754 {
9755 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309756 vos_mem_set(&setKeyEvent,
9757 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 if( pRsp->peerMacAddr[0] & 0x01 )
9759 {
9760 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9761 }
9762 else
9763 {
9764 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9765 }
9766 setKeyEvent.encryptionModeMulticast =
9767 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9768 setKeyEvent.encryptionModeUnicast =
9769 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309770 vos_mem_copy(setKeyEvent.bssid,
9771 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 setKeyEvent.authMode =
9773 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009774 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 {
9776 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9777 }
9778 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9779 }
9780#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9781 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9782 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009783 csrRoamStopWaitForKeyTimer( pMac );
9784
Jeff Johnson295189b2012-06-20 16:38:30 -07009785 //We are done with authentication, whethere succeed or not
9786 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 //We do it here because this linkup function is not called after association
9788 //when a key needs to be set.
9789 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9790 {
9791 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9792 }
9793 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009794 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309796 vos_mem_copy(&roamInfo.peerMac,
9797 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009798 //Make sure we install the GTK before indicating to HDD as authenticated
9799 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309800 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9801 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009802 {
Yathish9f22e662012-12-10 14:21:35 -08009803#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9804 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9805 {
9806 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309807 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009808 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9809 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9810 pMsg->seesionId = sessionId;
9811 status = palSendMBMessage(pMac->hHdd, pMsg );
9812 }
9813#endif
9814 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009815 }
9816 else
9817 {
9818 result = eCSR_ROAM_RESULT_NONE;
9819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 pRoamInfo = &roamInfo;
9821 }
9822 else
9823 {
9824 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009825 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9826 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9827 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 }
9829 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9830 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9832 // can go ahead and initiate the TSPEC if any are pending
9833 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009834#ifdef FEATURE_WLAN_CCX
9835 //Send Adjacent AP repot to new AP.
9836 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9837 pSession->isPrevApInfoValid &&
9838 pSession->connectedProfile.isCCXAssoc)
9839 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009840#ifdef FEATURE_WLAN_CCX_UPLOAD
9841 csrSendCcxAdjacentApRepInd(pMac, pSession);
9842#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9844#endif
9845 pSession->isPrevApInfoValid = FALSE;
9846 }
9847#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009848 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9849 {
9850 csrReleaseCommandSetKey( pMac, pCommand );
9851 }
9852 }
9853 else
9854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009855 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 }
9857 }
9858 else
9859 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009860 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009862 smeProcessPendingQueue( pMac );
9863 }
9864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 case eWNI_SME_REMOVEKEY_RSP:
9866 {
9867 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9868 tListElem *pEntry;
9869 tSmeCmd *pCommand;
9870
9871 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9872 if ( pEntry )
9873 {
9874 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9875 if ( eSmeCommandRemoveKey == pCommand->command )
9876 {
9877 sessionId = pCommand->sessionId;
9878 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009879
9880 if(!pSession)
9881 {
9882 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9883 return;
9884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009885#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9886 {
9887 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309888 vos_mem_set(&removeKeyEvent,
9889 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009890 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9891 removeKeyEvent.encryptionModeMulticast =
9892 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9893 removeKeyEvent.encryptionModeUnicast =
9894 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309895 vos_mem_copy( removeKeyEvent.bssid,
9896 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 removeKeyEvent.authMode =
9898 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009899 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 {
9901 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9902 }
9903 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9904 }
9905#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009906 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309908 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9909 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 result = eCSR_ROAM_RESULT_NONE;
9911 pRoamInfo = &roamInfo;
9912 }
9913 else
9914 {
9915 result = eCSR_ROAM_RESULT_FAILURE;
9916 }
9917 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9918 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9919 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9920 {
9921 csrReleaseCommandRemoveKey( pMac, pCommand );
9922 }
9923 }
9924 else
9925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009926 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 }
9928 }
9929 else
9930 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009931 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 smeProcessPendingQueue( pMac );
9934 }
9935 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009937 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 csrRoamStatsRspProcessor( pMac, pSirMsg );
9939 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009940#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9941 case eWNI_SME_GET_ROAM_RSSI_RSP:
9942 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9943 csrRoamRssiRspProcessor( pMac, pSirMsg );
9944 break;
9945#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009946#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9947 case eWNI_SME_GET_TSM_STATS_RSP:
9948 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
9949 csrTsmStatsRspProcessor( pMac, pSirMsg );
9950 break;
9951#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009953 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 csrUpdateRssi( pMac, pSirMsg );
9955 break;
9956
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309957 case eWNI_SME_GET_SNR_REQ:
9958 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9959 csrUpdateSnr(pMac, pSirMsg);
9960 break;
9961
Jeff Johnson295189b2012-06-20 16:38:30 -07009962#ifdef WLAN_FEATURE_VOWIFI_11R
9963 case eWNI_SME_FT_PRE_AUTH_RSP:
9964 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9965 break;
9966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9968 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009969 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 -07009970 sessionId = pSmeMaxAssocInd->sessionId;
9971 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309972 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
9973 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9975 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9976 break;
9977
9978 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009979 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 btampEstablishLogLinkHdlr( pSirMsg );
9981 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009982 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009983 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009984 csrRoamRssiIndHdlr( pMac, pSirMsg );
9985 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009986#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9987 case eWNI_SME_CANDIDATE_FOUND_IND:
9988 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9989 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9990 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009991 case eWNI_SME_HANDOFF_REQ:
9992 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9993 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9994 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009995#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009996
9997 default:
9998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010000}
10001
Jeff Johnson295189b2012-06-20 16:38:30 -070010002void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10003 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10004{
10005 if(pSession)
10006 {
10007 if(pSession->bRefAssocStartCnt)
10008 {
10009 pSession->bRefAssocStartCnt--;
10010 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10011 //Need to call association_completion because there is an assoc_start pending.
10012 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10013 eCSR_ROAM_ASSOCIATION_COMPLETION,
10014 eCSR_ROAM_RESULT_FAILURE);
10015 }
10016 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10017 }
10018 else
10019 {
10020 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10021 }
10022}
10023
10024
10025eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10026{
10027 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10029 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10030 {
10031 status = csrScanRequestLostLink1( pMac, sessionId );
10032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 return(status);
10034}
10035
Jeff Johnson295189b2012-06-20 16:38:30 -070010036//return a boolean to indicate whether roaming completed or continue.
10037tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10038 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10039{
10040 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10041 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10042 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10043 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010044 if(!pSession)
10045 {
10046 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10047 return eANI_BOOLEAN_FALSE;
10048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 //Check whether time is up
10050 if(pSession->fCancelRoaming || fForce ||
10051 ((curTime - pSession->roamingStartTime) > roamTime) ||
10052 eCsrReassocRoaming == pSession->roamingReason ||
10053 eCsrDynamicRoaming == pSession->roamingReason)
10054 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010055 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010056 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10057 {
10058 //roaming is cancelled, tell HDD to indicate disconnect
10059 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10060 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10061 //to be eSIR_BEACON_MISSED
10062 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10063 {
10064 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10065 }
10066 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10067 {
10068 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10069 }
10070 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10071 {
10072 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10073 }
10074 else
10075 {
10076 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10077 }
10078 }
10079 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10080 pSession->roamingReason = eCsrNotRoaming;
10081 }
10082 else
10083 {
10084 pSession->roamResult = roamResult;
10085 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10086 {
10087 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10088 pSession->roamingReason = eCsrNotRoaming;
10089 }
10090 else
10091 {
10092 fCompleted = eANI_BOOLEAN_FALSE;
10093 }
10094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010095 return(fCompleted);
10096}
10097
Jeff Johnson295189b2012-06-20 16:38:30 -070010098void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10099{
10100 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010101
10102 if(!pSession)
10103 {
10104 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10105 return;
10106 }
10107
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 if(CSR_IS_ROAMING(pSession))
10109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010110 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10112 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10113 {
10114 //No need to do anything in here because the handler takes care of it
10115 }
10116 else
10117 {
10118 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10119 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10120 //Roaming is stopped after here
10121 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10122 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010123 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 csrRoamStopRoamingTimer(pMac, sessionId);
10125 }
10126 }
10127}
10128
Jeff Johnson295189b2012-06-20 16:38:30 -070010129void csrRoamRoamingTimerHandler(void *pv)
10130{
10131 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10132 tpAniSirGlobal pMac = pInfo->pMac;
10133 tANI_U32 sessionId = pInfo->sessionId;
10134 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010135
10136 if(!pSession)
10137 {
10138 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10139 return;
10140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010141
10142 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10143 {
10144 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10145 {
10146 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10147 pSession->roamingReason = eCsrNotRoaming;
10148 }
10149 }
10150}
10151
Jeff Johnson295189b2012-06-20 16:38:30 -070010152eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10153{
10154 eHalStatus status;
10155 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010156
10157 if(!pSession)
10158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010159 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010160 return eHAL_STATUS_FAILURE;
10161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010162
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010163 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010165 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010166
10167 return (status);
10168}
10169
Jeff Johnson295189b2012-06-20 16:38:30 -070010170eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10171{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010172 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010173}
10174
Jeff Johnson295189b2012-06-20 16:38:30 -070010175void csrRoamWaitForKeyTimeOutHandler(void *pv)
10176{
10177 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10178 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010179 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
10180
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010181 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010182 pMac->roam.neighborRoamInfo.neighborRoamState,
10183 pMac->roam.curSubState[pInfo->sessionId]);
10184
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10186 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010187#ifdef FEATURE_WLAN_LFR
10188 if (csrNeighborRoamIsHandoffInProgress(pMac))
10189 {
10190 /*
10191 * Enable heartbeat timer when hand-off is in progress
10192 * and Key Wait timer expired.
10193 */
10194 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010195 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010196 pMac->roam.configParam.HeartbeatThresh24);
10197 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10198 pMac->roam.configParam.HeartbeatThresh24,
10199 NULL, eANI_BOOLEAN_FALSE);
10200 }
10201#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010202 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010203
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010205 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10206 {
10207 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10208 pInfo->sessionId);
10209 }
10210
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010211 if (pSession)
10212 {
10213 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10214 {
10215 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10216 smeProcessPendingQueue(pMac);
10217 }
10218 else
10219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010220 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010221 __func__);
10222 }
10223 }
10224 else
10225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010226 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 }
10229
10230}
10231
Jeff Johnson295189b2012-06-20 16:38:30 -070010232eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10233{
10234 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010235#ifdef FEATURE_WLAN_LFR
10236 if (csrNeighborRoamIsHandoffInProgress(pMac))
10237 {
10238 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010239 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010240 __func__,
10241 pMac->roam.neighborRoamInfo.neighborRoamState,
10242 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10243 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10244 }
10245#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010246 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010247 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010248
10249 return (status);
10250}
10251
Jeff Johnson295189b2012-06-20 16:38:30 -070010252eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10253{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010254 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010255 pMac->roam.neighborRoamInfo.neighborRoamState,
10256 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10257#ifdef FEATURE_WLAN_LFR
10258 if (csrNeighborRoamIsHandoffInProgress(pMac))
10259 {
10260 /*
10261 * Enable heartbeat timer when hand-off is in progress
10262 * and Key Wait timer got stopped for some reason
10263 */
10264 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010265 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010266 pMac->roam.configParam.HeartbeatThresh24);
10267 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10268 pMac->roam.configParam.HeartbeatThresh24,
10269 NULL, eANI_BOOLEAN_FALSE);
10270 }
10271#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010272 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010273}
10274
Jeff Johnson295189b2012-06-20 16:38:30 -070010275void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10276 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10277{
10278 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10279 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010280 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10281 /* To silence the KW tool Null chaeck is added */
10282 if(!pSession)
10283 {
10284 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10285 return;
10286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010287
10288 if(pCommand)
10289 {
10290 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10294 {
10295 //if success, force roaming completion
10296 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10297 }
10298 else
10299 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010300 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010301 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10303 }
10304}
10305
Jeff Johnson295189b2012-06-20 16:38:30 -070010306eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10307{
10308 eHalStatus status = eHAL_STATUS_SUCCESS;
10309 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10310 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10311 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10312 tCsrRoamInfo *pRoamInfo = NULL;
10313 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010314 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010316 /* To silence the KW tool Null chaeck is added */
10317 if(!pSession)
10318 {
10319 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10320 return eHAL_STATUS_FAILURE;
10321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010323 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10325 if ( eWNI_SME_DISASSOC_IND == type )
10326 {
10327 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10328 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10329 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010330 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 }
10332 else if ( eWNI_SME_DEAUTH_IND == type )
10333 {
10334 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10335 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10336 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010337 /* Convert into proper reason code */
10338 pSession->joinFailStatusCode.reasonCode =
10339 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010340 0 : pDeauthIndMsg->reasonCode;
10341 /* cfg layer expects 0 as reason code if
10342 the driver dosent know the reason code
10343 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 }
10345 else
10346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010347 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010348 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010349 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 }
10351
10352 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 {
10355 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10356 }
10357
10358 if ( eWNI_SME_DISASSOC_IND == type )
10359 {
10360 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10361 }
10362 else if ( eWNI_SME_DEAUTH_IND == type )
10363 {
10364 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 if(!HAL_STATUS_SUCCESS(status))
10367 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010368 //If fail to send confirmation to PE, not to trigger roaming
10369 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 }
10371
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010372 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010373 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10375 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 if( eWNI_SME_DISASSOC_IND == type)
10377 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010378 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010379 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10380 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010381 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 else if( eWNI_SME_DEAUTH_IND == type )
10384 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010385 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010386 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10387 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010388 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10389 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010390 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010391
10392 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10393 that we are roaming. But if we cannot possibly roam, or if we are unable to
10394 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010395 if(fToRoam)
10396 {
10397 //Only remove the connected BSS in infrastructure mode
10398 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10399 //Not to do anying for lostlink with WDS
10400 if( pMac->roam.configParam.nRoamingTime )
10401 {
10402 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10403 ( eWNI_SME_DEAUTH_IND == type ) ?
10404 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10405 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010406 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 //For IBSS, we need to give some more info to HDD
10408 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10409 {
10410 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10411 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10412 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10413 }
10414 else
10415 {
10416 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10417 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010418 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10420 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10421 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10422 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10423 }
10424 else
10425 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010426 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 fToRoam = eANI_BOOLEAN_FALSE;
10428 }
10429 }
10430 else
10431 {
10432 //We are told not to roam, indicate lostlink
10433 fToRoam = eANI_BOOLEAN_FALSE;
10434 }
10435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 if(!fToRoam)
10437 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010438 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010439 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010440 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010441 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10442 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10443 * csrRoamCheckForLinkStatusChange API.
10444 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010445 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10446 }
10447
10448 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 Still enable idle scan for polling in case concurrent sessions are running */
10450 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10451 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010452 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 }
10454 }
10455
10456 return (status);
10457}
10458
Jeff Johnson295189b2012-06-20 16:38:30 -070010459eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10460{
10461 eHalStatus status = eHAL_STATUS_SUCCESS;
10462 tListElem *pEntry = NULL;
10463 tSmeCmd *pCommand = NULL;
10464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010465
10466 if(!pSession)
10467 {
10468 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10469 return eHAL_STATUS_FAILURE;
10470 }
10471
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 //Only remove the connected BSS in infrastructure mode
10474 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10475 if(pMac->roam.configParam.nRoamingTime)
10476 {
10477 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10478 {
10479 //before starting the lost link logic release the roam command for handoff
10480 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10481 if(pEntry)
10482 {
10483 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10484 }
10485 if(pCommand)
10486 {
10487 if (( eSmeCommandRoam == pCommand->command ) &&
10488 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10489 {
10490 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10491 {
10492 csrReleaseCommandRoam( pMac, pCommand );
10493 }
10494 }
10495 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010496 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 }
10498 }
10499 else
10500 {
10501 //We are told not to roam, indicate lostlink
10502 status = eHAL_STATUS_FAILURE;
10503 }
10504
10505 return (status);
10506}
Jeff Johnson295189b2012-06-20 16:38:30 -070010507void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10508{
10509 tListElem *pEntry;
10510 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10512 if ( pEntry )
10513 {
10514 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10515 if ( eSmeCommandWmStatusChange == pCommand->command )
10516 {
10517 // Nothing to process in a Lost Link completion.... It just kicks off a
10518 // roaming sequence.
10519 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10520 {
10521 csrReleaseCommandWmStatusChange( pMac, pCommand );
10522 }
10523 else
10524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010525 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 }
10527
10528 }
10529 else
10530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010531 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 }
10533 }
10534 else
10535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010536 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 smeProcessPendingQueue( pMac );
10539}
10540
Jeff Johnson295189b2012-06-20 16:38:30 -070010541void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10542{
10543 eHalStatus status = eHAL_STATUS_FAILURE;
10544 tSirSmeRsp *pSirSmeMsg;
10545 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010546
10547 if(!pSession)
10548 {
10549 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10550 return;
10551 }
10552
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 switch ( pCommand->u.wmStatusChangeCmd.Type )
10554 {
10555 case eCsrDisassociated:
10556 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10557 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10558 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 case eCsrDeauthenticated:
10560 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10561 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10562 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010563 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010564 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 break;
10566 }
10567 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10568 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10569 {
10570 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10571 {
10572 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010573 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 }
10575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10577 // command here since there is nothing else to do.
10578 csrRoamWmStatusChangeComplete( pMac );
10579}
10580
Jeff Johnson295189b2012-06-20 16:38:30 -070010581//This function returns band and mode information.
10582//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10583//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010584static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10585 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010586{
Jeff Johnson295189b2012-06-20 16:38:30 -070010587 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10588 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10589 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010591
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 //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 -070010593 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10594 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10595 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10596 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 {
10598 switch( pMac->roam.configParam.uCfgDot11Mode )
10599 {
10600 case eCSR_CFG_DOT11_MODE_11A:
10601 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10602 eBand = eCSR_BAND_5G;
10603 break;
10604 case eCSR_CFG_DOT11_MODE_11B:
10605 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10606 eBand = eCSR_BAND_24;
10607 break;
10608 case eCSR_CFG_DOT11_MODE_11G:
10609 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10610 eBand = eCSR_BAND_24;
10611 break;
10612 case eCSR_CFG_DOT11_MODE_11N:
10613 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010614 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10615 break;
10616#ifdef WLAN_FEATURE_11AC
10617 case eCSR_CFG_DOT11_MODE_11AC:
10618 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10619 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010620 /* If the operating channel is in 2.4 GHz band, check for
10621 * INI item to disable VHT operation in 2.4 GHz band
10622 */
10623 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10624 !pMac->roam.configParam.enableVhtFor24GHz)
10625 {
10626 /* Disable 11AC operation */
10627 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10628 }
10629 else
10630 {
10631 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10632 }
10633 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010634 }
10635 else
10636 {
10637 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10638 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10639 }
10640 break;
10641 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10642 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10643 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010644 /* If the operating channel is in 2.4 GHz band, check for
10645 * INI item to disable VHT operation in 2.4 GHz band
10646 */
10647 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10648 !pMac->roam.configParam.enableVhtFor24GHz)
10649 {
10650 /* Disable 11AC operation */
10651 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10652 }
10653 else
10654 {
10655 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10656 }
10657 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010658 }
10659 else
10660 {
10661 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10662 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10663 }
10664 break;
10665#endif
10666 case eCSR_CFG_DOT11_MODE_AUTO:
10667 eBand = pMac->roam.configParam.eBand;
10668 if (eCSR_BAND_24 == eBand)
10669 {
10670 // WiFi tests require IBSS networks to start in 11b mode
10671 // without any change to the default parameter settings
10672 // on the adapter. We use ACU to start an IBSS through
10673 // creation of a startIBSS profile. This startIBSS profile
10674 // has Auto MACProtocol and the adapter property setting
10675 // for dot11Mode is also AUTO. So in this case, let's
10676 // start the IBSS network in 11b mode instead of 11g mode.
10677 // So this is for Auto=profile->MacProtocol && Auto=Global.
10678 // dot11Mode && profile->channel is < 14, then start the IBSS
10679 // in b mode.
10680 //
10681 // Note: we used to have this start as an 11g IBSS for best
10682 // performance... now to specify that the user will have to
10683 // set the do11Mode in the property page to 11g to force it.
10684 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10685 }
10686 else
10687 {
10688#ifdef WLAN_FEATURE_11AC
10689 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10690 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010691 /* If the operating channel is in 2.4 GHz band, check for
10692 * INI item to disable VHT operation in 2.4 GHz band
10693 */
10694 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10695 !pMac->roam.configParam.enableVhtFor24GHz)
10696 {
10697 /* Disable 11AC operation */
10698 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10699 }
10700 else
10701 {
10702 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10703 }
10704 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010705 }
10706 else
10707 {
10708 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10709 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10710 }
10711#else
10712 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10713 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10714#endif
10715 }
10716 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 default:
10718 // Global dot11 Mode setting is 11a/b/g.
10719 // use the channel number to determine the Mode setting.
10720 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10721 {
10722 eBand = pMac->roam.configParam.eBand;
10723 if(eCSR_BAND_24 == eBand)
10724 {
10725 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10726 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10727 }
10728 else
10729 {
10730 //prefer 5GHz
10731 eBand = eCSR_BAND_5G;
10732 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10733 }
10734 }
10735 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10736 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010737 // WiFi tests require IBSS networks to start in 11b mode
10738 // without any change to the default parameter settings
10739 // on the adapter. We use ACU to start an IBSS through
10740 // creation of a startIBSS profile. This startIBSS profile
10741 // has Auto MACProtocol and the adapter property setting
10742 // for dot11Mode is also AUTO. So in this case, let's
10743 // start the IBSS network in 11b mode instead of 11g mode.
10744 // So this is for Auto=profile->MacProtocol && Auto=Global.
10745 // dot11Mode && profile->channel is < 14, then start the IBSS
10746 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010747 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010748 // Note: we used to have this start as an 11g IBSS for best
10749 // performance... now to specify that the user will have to
10750 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10752 eBand = eCSR_BAND_24;
10753 }
10754 else
10755 {
10756 // else, it's a 5.0GHz channel. Set mode to 11a.
10757 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10758 eBand = eCSR_BAND_5G;
10759 }
10760 break;
10761 }//switch
10762 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10763 else
10764 {
10765 //dot11 mode is set, lets pick the band
10766 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10767 {
10768 // channel is Auto also.
10769 eBand = pMac->roam.configParam.eBand;
10770 if(eCSR_BAND_ALL == eBand)
10771 {
10772 //prefer 5GHz
10773 eBand = eCSR_BAND_5G;
10774 }
10775 }
10776 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10777 {
10778 eBand = eCSR_BAND_24;
10779 }
10780 else
10781 {
10782 eBand = eCSR_BAND_5G;
10783 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010784 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 if(pBand)
10786 {
10787 *pBand = eBand;
10788 }
10789
10790 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010791 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010792 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10793 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010794
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010795 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10796 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 -070010797 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010798#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010799 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010800#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010801 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10802 {
10803 //We cannot do 11n here
10804 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10805 {
10806 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10807 }
10808 else
10809 {
10810 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10811 }
10812 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010813 return( cfgDot11Mode );
10814}
10815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10817{
10818 eHalStatus status;
10819 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010820
10821 if(!pSession)
10822 {
10823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10824 return eHAL_STATUS_FAILURE;
10825 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010826
10827#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10828 {
10829 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10831 if(pIbssLog)
10832 {
10833 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10834 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10835 }
10836 }
10837#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 // Set the roaming substate to 'stop Bss request'...
10839 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10840
10841 // attempt to stop the Bss (reason code is ignored...)
10842 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010843 if(!HAL_STATUS_SUCCESS(status))
10844 {
10845 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10846 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 return (status);
10848}
10849
Jeff Johnson295189b2012-06-20 16:38:30 -070010850//pNumChan is a caller allocated space with the sizeof pChannels
10851eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10852{
10853
10854 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10855 (tANI_U8 *)pChannels,
10856 pNumChan));
10857}
10858
Kiran4a17ebe2013-01-31 10:43:43 -080010859tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10860{
10861 tANI_U32 cfgLength = 0;
10862 tANI_U16 cfgId = 0;
10863 tPowerdBm maxTxPwr = 0;
10864 tANI_U8 *pCountryInfo = NULL;
10865 eHalStatus status;
10866 tANI_U8 count = 0;
10867 tANI_U8 firstChannel;
10868 tANI_U8 maxChannels;
10869
10870 if (CSR_IS_CHANNEL_5GHZ(channel))
10871 {
10872 cfgId = WNI_CFG_MAX_TX_POWER_5;
10873 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10874 }
10875 else if (CSR_IS_CHANNEL_24GHZ(channel))
10876 {
10877 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10878 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10879 }
10880 else
10881 return maxTxPwr;
10882
Kiet Lam64c1b492013-07-12 13:56:44 +053010883 pCountryInfo = vos_mem_malloc(cfgLength);
10884 if ( NULL == pCountryInfo )
10885 status = eHAL_STATUS_FAILURE;
10886 else
10887 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010888 if (status != eHAL_STATUS_SUCCESS)
10889 {
10890 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010891 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010892 __FUNCTION__, status);
10893 goto error;
10894 }
10895 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10896 if (status != eHAL_STATUS_SUCCESS)
10897 {
10898 goto error;
10899 }
10900 /* Identify the channel and maxtxpower */
10901 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10902 {
10903 firstChannel = pCountryInfo[count++];
10904 maxChannels = pCountryInfo[count++];
10905 maxTxPwr = pCountryInfo[count++];
10906
10907 if ((channel >= firstChannel) &&
10908 (channel < (firstChannel + maxChannels)))
10909 {
10910 break;
10911 }
10912 }
10913
10914error:
10915 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010916 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010917
10918 return maxTxPwr;
10919}
10920
10921
Jeff Johnson295189b2012-06-20 16:38:30 -070010922tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10923{
10924 tANI_BOOLEAN fValid = FALSE;
10925 tANI_U32 idxValidChannels;
10926 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10927
10928 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10929 {
10930 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10931 {
10932 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10933 {
10934 fValid = TRUE;
10935 break;
10936 }
10937 }
10938 }
10939 pMac->roam.numValidChannels = len;
10940 return fValid;
10941}
10942
Jeff Johnson295189b2012-06-20 16:38:30 -070010943tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10944{
10945 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10946 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10948 {
10949 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10950 {
10951 fValid = eANI_BOOLEAN_TRUE;
10952 break;
10953 }
10954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 return (fValid);
10956}
10957
Jeff Johnson295189b2012-06-20 16:38:30 -070010958//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010959 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010960{
Jeff Johnsone7245742012-09-05 17:12:55 -070010961 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 tANI_U8 centerChn;
10963 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10965 {
10966 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10967 }
10968 else
10969 {
10970 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10971 }
10972 //Figure what the other side's CB mode
10973 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10974 {
10975 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10976 {
10977 if(pIes->HTInfo.present)
10978 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010979 /* This is called during INFRA STA/CLIENT and should use the merged value of
10980 * supported channel width and recommended tx width as per standard
10981 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010982 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010983 pIes->HTCaps.supportedChannelWidthSet,
10984 pIes->HTInfo.recommendedTxWidthSet,
10985 pIes->HTInfo.secondaryChannelOffset);
10986
10987 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10988 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010990 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10991 switch (eRet) {
10992 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10993 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10994 break;
10995 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10996 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10997 break;
10998 case PHY_SINGLE_CHANNEL_CENTERED:
10999 default:
11000 centerChn = primaryChn;
11001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011003 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011005 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011006 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 }
11008 }
11009 }
11010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011011 return eRet;
11012}
Jeff Johnson295189b2012-06-20 16:38:30 -070011013tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11014{
11015 tANI_BOOLEAN fFound = FALSE;
11016 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11018 {
11019 if( pCipherList->encryptionType[idx] == encryptionType )
11020 {
11021 fFound = TRUE;
11022 break;
11023 }
11024 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011025 return fFound;
11026}
Jeff Johnson295189b2012-06-20 16:38:30 -070011027tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11028{
11029 tANI_BOOLEAN fFound = FALSE;
11030 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11032 {
11033 if( pAuthList->authType[idx] == authType )
11034 {
11035 fFound = TRUE;
11036 break;
11037 }
11038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 return fFound;
11040}
Jeff Johnson295189b2012-06-20 16:38:30 -070011041tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11042{
11043 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11044 tCsrScanResultFilter *pScanFilter = NULL;
11045 eHalStatus status = eHAL_STATUS_SUCCESS;
11046
11047 if(pProfile1 && pProfile2)
11048 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011049 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11050 if ( NULL == pScanFilter )
11051 status = eHAL_STATUS_FAILURE;
11052 else
11053 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011054 if(HAL_STATUS_SUCCESS(status))
11055 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011056 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011057 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11058 if(HAL_STATUS_SUCCESS(status))
11059 {
11060 fCheck = eANI_BOOLEAN_FALSE;
11061 do
11062 {
11063 tANI_U32 i;
11064 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11065 {
11066 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11067 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11068 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11069 if ( fCheck ) break;
11070 }
11071 if(!fCheck)
11072 {
11073 break;
11074 }
11075 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11076 || pProfile2->BSSType != pProfile1->BSSType
11077 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11078 )
11079 {
11080 fCheck = eANI_BOOLEAN_FALSE;
11081 break;
11082 }
11083#ifdef WLAN_FEATURE_VOWIFI_11R
11084 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11085 {
11086 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11087 {
11088 fCheck = eANI_BOOLEAN_FALSE;
11089 break;
11090 }
11091 }
11092#endif
11093 //Match found
11094 fCheck = eANI_BOOLEAN_TRUE;
11095 }while(0);
11096 csrFreeScanFilter(pMac, pScanFilter);
11097 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011098 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 }
11100 }
11101
11102 return (fCheck);
11103}
11104
Jeff Johnson295189b2012-06-20 16:38:30 -070011105tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11106{
11107 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11108 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011109 do
11110 {
11111 //Only check for static WEP
11112 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11113 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11114 {
11115 fCheck = eANI_BOOLEAN_TRUE;
11116 break;
11117 }
11118 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11119 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11120 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11121 {
11122 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011123 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11124 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011125 {
11126 break;
11127 }
11128 }
11129 if( i == CSR_MAX_NUM_KEY)
11130 {
11131 fCheck = eANI_BOOLEAN_TRUE;
11132 }
11133 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 return (fCheck);
11135}
11136
Jeff Johnson295189b2012-06-20 16:38:30 -070011137//IBSS
11138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11140{
11141 tANI_U8 channel = 0;
11142 tANI_U32 idx;
11143 tANI_U32 idxValidChannels;
11144 tANI_BOOLEAN fFound = FALSE;
11145 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11146
11147 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11148 {
11149 channel = pMac->roam.configParam.AdHocChannel5G;
11150 if(!csrRoamIsChannelValid(pMac, channel))
11151 {
11152 channel = 0;
11153 }
11154 }
11155 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11156 {
11157 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11158 {
11159 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11160 {
11161 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11162 {
11163 fFound = TRUE;
11164 channel = csrStartIbssChannels50[ idx ];
11165 }
11166 }
11167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11169 if (!fFound)
11170 {
11171 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11172 {
11173 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11174 {
11175 channel = csrStartIbssChannels50[ idx ];
11176 break;
11177 }
11178 }
11179 }
11180 }//if
11181
11182 return( channel );
11183}
11184
Jeff Johnson295189b2012-06-20 16:38:30 -070011185tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11186{
11187 tANI_U8 channel = 1;
11188 tANI_U32 idx;
11189 tANI_U32 idxValidChannels;
11190 tANI_BOOLEAN fFound = FALSE;
11191 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11192
11193 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11194 {
11195 channel = pMac->roam.configParam.AdHocChannel24;
11196 if(!csrRoamIsChannelValid(pMac, channel))
11197 {
11198 channel = 0;
11199 }
11200 }
11201
11202 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11203 {
11204 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11205 {
11206 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11207 {
11208 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11209 {
11210 fFound = TRUE;
11211 channel = csrStartIbssChannels24[ idx ];
11212 }
11213 }
11214 }
11215 }
11216
11217 return( channel );
11218}
11219
Jeff Johnson295189b2012-06-20 16:38:30 -070011220static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11221 tCsrRoamStartBssParams *pParam )
11222{
11223 eCsrCfgDot11Mode cfgDot11Mode;
11224 eCsrBand eBand;
11225 tANI_U8 channel = 0;
11226 tSirNwType nwType;
11227 tANI_U8 operationChannel = 0;
11228
11229 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11230 {
11231 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11232 }
11233
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011235
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11237 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11238 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11239 )
11240 {
11241 /* This should never happen */
11242 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011243 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 pProfile->csrPersona);
11245 VOS_ASSERT(0);
11246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011247 switch( cfgDot11Mode )
11248 {
11249 case eCSR_CFG_DOT11_MODE_11G:
11250 nwType = eSIR_11G_NW_TYPE;
11251 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011252 case eCSR_CFG_DOT11_MODE_11B:
11253 nwType = eSIR_11B_NW_TYPE;
11254 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011255 case eCSR_CFG_DOT11_MODE_11A:
11256 nwType = eSIR_11A_NW_TYPE;
11257 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011258 default:
11259 case eCSR_CFG_DOT11_MODE_11N:
11260 case eCSR_CFG_DOT11_MODE_TAURUS:
11261 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11262 if(eCSR_BAND_24 == eBand)
11263 {
11264 nwType = eSIR_11G_NW_TYPE;
11265 }
11266 else
11267 {
11268 nwType = eSIR_11A_NW_TYPE;
11269 }
11270 break;
11271 }
11272
11273 pParam->extendedRateSet.numRates = 0;
11274
11275 switch ( nwType )
11276 {
11277 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011278 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 case eSIR_11A_NW_TYPE:
11280
11281 pParam->operationalRateSet.numRates = 8;
11282
11283 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11284 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11285 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11286 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11287 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11288 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11289 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11290 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11291
11292 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11293 {
11294 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11295 if( 0 == channel &&
11296 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11297 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11298 )
11299 {
11300 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11301 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11302 nwType = eSIR_11B_NW_TYPE;
11303 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11304 pParam->operationalRateSet.numRates = 4;
11305 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11306 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11307 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11308 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11309 }
11310 }
11311 else
11312 {
11313 channel = operationChannel;
11314 }
11315 break;
11316
11317 case eSIR_11B_NW_TYPE:
11318 pParam->operationalRateSet.numRates = 4;
11319 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11320 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11321 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11322 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11324 {
11325 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11326 }
11327 else
11328 {
11329 channel = operationChannel;
11330 }
11331
11332 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 /* For P2P Client and P2P GO, disable 11b rates */
11335 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11336 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11337 )
11338 {
11339 pParam->operationalRateSet.numRates = 8;
11340
11341 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11342 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11343 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11344 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11345 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11346 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11347 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11348 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11349 }
11350 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 {
11352 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11354 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11355 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11356 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11357
11358 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011359 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11360 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11361 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11362 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11363 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11364 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11365 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11366 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11367 }
11368
11369 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11370 {
11371 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11372 }
11373 else
11374 {
11375 channel = operationChannel;
11376 }
11377
11378 break;
11379 }
11380 pParam->operationChn = channel;
11381 pParam->sirNwType = nwType;
11382}
11383
Jeff Johnson295189b2012-06-20 16:38:30 -070011384static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11385 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11386{
11387
11388 if( pParam )
11389 {
11390 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011391 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011393 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011394
11395 if( pIes )
11396 {
11397 if(pIes->SuppRates.present)
11398 {
11399 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11400 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011402 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 -070011403 pIes->SuppRates.num_rates);
11404 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11405 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011406 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11407 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011409 if (pIes->ExtSuppRates.present)
11410 {
11411 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11412 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11413 {
11414 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11415 SIR_MAC_RATESET_EID_MAX, resetting to \
11416 SIR_MAC_RATESET_EID_MAX"),
11417 pIes->ExtSuppRates.num_rates);
11418 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11419 }
11420 palCopyMemory(pMac->hHdd, pParam->extendedRateSet.rate,
11421 pIes->ExtSuppRates.rates,
11422 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 if( pIes->SSID.present )
11425 {
11426 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011427 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11428 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 }
11430 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 }
11432 else
11433 {
11434 pParam->ssId.length = 0;
11435 pParam->operationalRateSet.numRates = 0;
11436 }
11437 }
11438}
11439
Jeff Johnson295189b2012-06-20 16:38:30 -070011440static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11441{
11442 tANI_U8 MaxRate = 0;
11443 tANI_U32 i;
11444 tANI_U8 *pRate;
11445
11446 pRate = pSirRateSet->rate;
11447 for ( i = 0; i < pSirRateSet->numRates; i++ )
11448 {
11449 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11450 }
11451
11452 // Save the max rate in the connected state information...
11453
11454 // modify LastRates variable as well
11455
11456 return;
11457}
11458
Jeff Johnson295189b2012-06-20 16:38:30 -070011459eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11460 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11461{
11462 eHalStatus status = eHAL_STATUS_SUCCESS;
11463 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 // Set the roaming substate to 'Start BSS attempt'...
11465 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011466#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11467 //Need to figure out whether we need to log WDS???
11468 if( CSR_IS_IBSS( pProfile ) )
11469 {
11470 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11472 if(pIbssLog)
11473 {
11474 if(pBssDesc)
11475 {
11476 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011477 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 }
11479 else
11480 {
11481 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11482 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011483 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 if(pProfile->ChannelInfo.numOfChannels == 0)
11485 {
11486 pIbssLog->channelSetting = AUTO_PICK;
11487 }
11488 else
11489 {
11490 pIbssLog->channelSetting = SPECIFIED;
11491 }
11492 pIbssLog->operatingChannel = pParam->operationChn;
11493 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11494 }
11495 }
11496#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11497 //Put RSN information in for Starting BSS
11498 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11499 pParam->pRSNIE = pProfile->pRSNReqIE;
11500
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 pParam->privacy = pProfile->privacy;
11502 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11503 pParam->authType = pProfile->csr80211AuthType;
11504 pParam->beaconInterval = pProfile->beaconInterval;
11505 pParam->dtimPeriod = pProfile->dtimPeriod;
11506 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11507 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11508 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11509 {
11510 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11511 {
11512 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11513 }
11514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 pParam->protEnabled = pProfile->protEnabled;
11516 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11517 pParam->ht_protection = pProfile->cfg_protection;
11518 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011519
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11521 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 pParam->bssPersona = pProfile->csrPersona;
11523 // When starting an IBSS, start on the channel from the Profile.
11524 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 return (status);
11526}
11527
Jeff Johnson295189b2012-06-20 16:38:30 -070011528static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011529 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011530{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011531 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011532 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011534
11535 if(!pSession)
11536 {
11537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11538 return;
11539 }
11540
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 if( pBssDesc )
11542 {
11543 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11544 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11545 //The following code has to be do after that.
11546 //For WDS station, use selfMac as the self BSSID
11547 if( CSR_IS_WDS_STA( pProfile ) )
11548 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011549 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11550 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 }
11552 }
11553 else
11554 {
11555 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 //Use the first SSID
11557 if(pProfile->SSIDs.numOfSSIDs)
11558 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011559 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11560 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011561 }
11562 //For WDS station, use selfMac as the self BSSID
11563 if( CSR_IS_WDS_STA( pProfile ) )
11564 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011565 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11566 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 }
11568 //Use the first BSSID
11569 else if( pProfile->BSSIDs.numOfBSSIDs )
11570 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011571 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11572 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 }
11574 else
11575 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011576 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 }
11578 }
11579 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 //Set operating channel in pProfile which will be used
11581 //in csrRoamSetBssConfigCfg() to determine channel bonding
11582 //mode and will be configured in CFG later
11583 pProfile->operationChannel = Channel;
11584
11585 if(Channel == 0)
11586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011587 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011588 }
11589 else
11590 {
11591
11592 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011593 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011594 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011595 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011596 {
11597 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11598 }
11599 else
11600 {
11601 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11602 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011603 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011604 pBssConfig->cbMode = cbMode;
11605 pSession->bssParams.cbMode = cbMode;
11606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 }
11608}
11609
Jeff Johnson295189b2012-06-20 16:38:30 -070011610static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11611 tANI_BOOLEAN *pfSameIbss )
11612{
11613 eHalStatus status = eHAL_STATUS_SUCCESS;
11614 tANI_BOOLEAN fSameIbss = FALSE;
11615
11616 if ( csrIsConnStateIbss( pMac, sessionId ) )
11617 {
11618 // Check if any profile parameter has changed ? If any profile parameter
11619 // has changed then stop old BSS and start a new one with new parameters
11620 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11621 {
11622 fSameIbss = TRUE;
11623 }
11624 else
11625 {
11626 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11627 }
11628 }
11629 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11630 {
11631 // Disassociate from the connected Infrastructure network...
11632 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11633 }
11634 else
11635 {
11636 tBssConfigParam *pBssConfig;
11637
Kiet Lam64c1b492013-07-12 13:56:44 +053011638 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11639 if ( NULL == pBssConfig )
11640 status = eHAL_STATUS_FAILURE;
11641 else
11642 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 if(HAL_STATUS_SUCCESS(status))
11644 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011645 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 // there is no Bss description before we start an IBSS so we need to adopt
11647 // all Bss configuration parameters from the Profile.
11648 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11649 if(HAL_STATUS_SUCCESS(status))
11650 {
11651 //save dotMode
11652 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11653 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011654 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011655 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11656 NULL, pBssConfig,
11657 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011659
11660 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 }//Allocate memory
11662 }
11663
11664 if(pfSameIbss)
11665 {
11666 *pfSameIbss = fSameIbss;
11667 }
11668 return( status );
11669}
11670
Jeff Johnson295189b2012-06-20 16:38:30 -070011671static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11672 tSirSmeNewBssInfo *pNewBss )
11673{
11674 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011675
11676 if(!pSession)
11677 {
11678 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11679 return;
11680 }
11681
Jeff Johnson295189b2012-06-20 16:38:30 -070011682 if( pNewBss )
11683 {
11684 // Set the operating channel.
11685 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11686 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011687 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11688 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 return;
11691}
11692
Jeff Johnson295189b2012-06-20 16:38:30 -070011693#ifdef FEATURE_WLAN_WAPI
11694eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11695 tANI_U32 numItems )
11696{
11697 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11698 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011701 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 return status;
11703 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011704 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 pSession = CSR_GET_SESSION( pMac, sessionId );
11706 if(numItems <= CSR_MAX_BKID_ALLOWED)
11707 {
11708 status = eHAL_STATUS_SUCCESS;
11709 //numItems may be 0 to clear the cache
11710 pSession->NumBkidCache = (tANI_U16)numItems;
11711 if(numItems && pBKIDCache)
11712 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011713 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11714 sizeof(tBkidCacheInfo) * numItems);
11715 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 }
11717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 return (status);
11719}
Jeff Johnson295189b2012-06-20 16:38:30 -070011720eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11721 tBkidCacheInfo *pBkidCache)
11722{
11723 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11724 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011725 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011727 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011728 return status;
11729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011730 pSession = CSR_GET_SESSION( pMac, sessionId );
11731 if(pNum && pBkidCache)
11732 {
11733 if(pSession->NumBkidCache == 0)
11734 {
11735 *pNum = 0;
11736 status = eHAL_STATUS_SUCCESS;
11737 }
11738 else if(*pNum >= pSession->NumBkidCache)
11739 {
11740 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011742 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 -070011743 pSession->NumBkidCache);
11744 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11745 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011746 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11747 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 *pNum = pSession->NumBkidCache;
11749 status = eHAL_STATUS_SUCCESS;
11750 }
11751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011753}
Jeff Johnson295189b2012-06-20 16:38:30 -070011754tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11755{
11756 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011757}
11758#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011759eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11760 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11761{
11762 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11763 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011764
11765 if(!pSession)
11766 {
11767 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11768 return eHAL_STATUS_FAILURE;
11769 }
11770
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011771 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011772 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11773 {
11774#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11775 {
11776 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011777 vos_mem_set(&secEvent,
11778 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11780 secEvent.encryptionModeMulticast =
11781 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11782 secEvent.encryptionModeUnicast =
11783 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011784 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011785 secEvent.authMode =
11786 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11787 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11788 }
11789#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 status = eHAL_STATUS_SUCCESS;
11791 //numItems may be 0 to clear the cache
11792 pSession->NumPmkidCache = (tANI_U16)numItems;
11793 if(numItems && pPMKIDCache)
11794 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011795 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11796 sizeof(tPmkidCacheInfo) * numItems);
11797 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 }
11799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 return (status);
11801}
11802
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011803eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11804 tANI_U8 *pBSSId )
11805{
11806 eHalStatus status = eHAL_STATUS_FAILURE;
11807 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11808 tANI_BOOLEAN fMatchFound = FALSE;
11809 tANI_U32 Index;
11810 if(!pSession)
11811 {
11812 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11813 return eHAL_STATUS_FAILURE;
11814 }
11815 do
11816 {
11817 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11818 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011819 smsLog(pMac, LOGW, "Delete PMKID for "
11820 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011821 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
11822 {
11823 fMatchFound = TRUE;
11824 break;
11825 }
11826 }
11827 if( !fMatchFound ) break;
11828 palZeroMemory( pMac->hHdd, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo));
11829 status = eHAL_STATUS_SUCCESS;
11830 }
11831 while( 0 );
11832 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11833 fMatchFound, status);
11834 return status;
11835}
Jeff Johnson295189b2012-06-20 16:38:30 -070011836tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11837{
11838 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11839}
11840
Jeff Johnson295189b2012-06-20 16:38:30 -070011841eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11842{
11843 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11844 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011845
11846 if(!pSession)
11847 {
11848 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11849 return eHAL_STATUS_FAILURE;
11850 }
11851
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 if(pNum && pPmkidCache)
11853 {
11854 if(pSession->NumPmkidCache == 0)
11855 {
11856 *pNum = 0;
11857 status = eHAL_STATUS_SUCCESS;
11858 }
11859 else if(*pNum >= pSession->NumPmkidCache)
11860 {
11861 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011863 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 -070011864 pSession->NumPmkidCache);
11865 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11866 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011867 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11868 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 *pNum = pSession->NumPmkidCache;
11870 status = eHAL_STATUS_SUCCESS;
11871 }
11872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 return (status);
11874}
11875
Jeff Johnson295189b2012-06-20 16:38:30 -070011876eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11877{
11878 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11879 tANI_U32 len;
11880 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011881
11882 if(!pSession)
11883 {
11884 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11885 return eHAL_STATUS_FAILURE;
11886 }
11887
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 if(pLen)
11889 {
11890 len = *pLen;
11891 *pLen = pSession->nWpaRsnReqIeLength;
11892 if(pBuf)
11893 {
11894 if(len >= pSession->nWpaRsnReqIeLength)
11895 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011896 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11897 pSession->nWpaRsnReqIeLength);
11898 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 }
11900 }
11901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 return (status);
11903}
11904
Jeff Johnson295189b2012-06-20 16:38:30 -070011905eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11906{
11907 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11908 tANI_U32 len;
11909 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011910
11911 if(!pSession)
11912 {
11913 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11914 return eHAL_STATUS_FAILURE;
11915 }
11916
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 if(pLen)
11918 {
11919 len = *pLen;
11920 *pLen = pSession->nWpaRsnRspIeLength;
11921 if(pBuf)
11922 {
11923 if(len >= pSession->nWpaRsnRspIeLength)
11924 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011925 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11926 pSession->nWpaRsnRspIeLength);
11927 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 }
11929 }
11930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 return (status);
11932}
Jeff Johnson295189b2012-06-20 16:38:30 -070011933#ifdef FEATURE_WLAN_WAPI
11934eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11935{
11936 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11937 tANI_U32 len;
11938 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011939
11940 if(!pSession)
11941 {
11942 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11943 return eHAL_STATUS_FAILURE;
11944 }
11945
Jeff Johnson295189b2012-06-20 16:38:30 -070011946 if(pLen)
11947 {
11948 len = *pLen;
11949 *pLen = pSession->nWapiReqIeLength;
11950 if(pBuf)
11951 {
11952 if(len >= pSession->nWapiReqIeLength)
11953 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011954 vos_mem_copy(pBuf, pSession->pWapiReqIE,
11955 pSession->nWapiReqIeLength);
11956 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 }
11958 }
11959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 return (status);
11961}
Jeff Johnson295189b2012-06-20 16:38:30 -070011962eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11963{
11964 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11965 tANI_U32 len;
11966 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011967
11968 if(!pSession)
11969 {
11970 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11971 return eHAL_STATUS_FAILURE;
11972 }
11973
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 if(pLen)
11975 {
11976 len = *pLen;
11977 *pLen = pSession->nWapiRspIeLength;
11978 if(pBuf)
11979 {
11980 if(len >= pSession->nWapiRspIeLength)
11981 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011982 vos_mem_copy(pBuf, pSession->pWapiRspIE,
11983 pSession->nWapiRspIeLength);
11984 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 }
11986 }
11987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 return (status);
11989}
11990#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011991eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11992{
11993 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011995
11996 if(!pSession)
11997 {
11998 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11999 return (retStatus);
12000 }
12001
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 if(CSR_IS_ROAMING(pSession))
12003 {
12004 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12005 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 return (retStatus);
12008}
12009
Jeff Johnson295189b2012-06-20 16:38:30 -070012010//This function remove the connected BSS from te cached scan result
12011eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12012 tCsrRoamConnectedProfile *pConnProfile)
12013{
12014 eHalStatus status = eHAL_STATUS_FAILURE;
12015 tCsrScanResultFilter *pScanFilter = NULL;
12016 tListElem *pEntry;
12017 tCsrScanResult *pResult;
12018 tDot11fBeaconIEs *pIes;
12019 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12021 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12022 {
12023 do
12024 {
12025 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012026 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12027 if ( NULL == pScanFilter )
12028 status = eHAL_STATUS_FAILURE;
12029 else
12030 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012032 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12033 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12034 if ( NULL == pScanFilter->BSSIDs.bssid )
12035 status = eHAL_STATUS_FAILURE;
12036 else
12037 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012038 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012039 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12040 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012041 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12042 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12043 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012044 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12045 if ( NULL == pScanFilter->SSIDs.SSIDList )
12046 status = eHAL_STATUS_FAILURE;
12047 else
12048 status = eHAL_STATUS_SUCCESS;
12049 if (!HAL_STATUS_SUCCESS(status)) break;
12050 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12051 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 }
12053 pScanFilter->authType.numEntries = 1;
12054 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12055 pScanFilter->BSSType = pConnProfile->BSSType;
12056 pScanFilter->EncryptionType.numEntries = 1;
12057 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12058 pScanFilter->mcEncryptionType.numEntries = 1;
12059 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12060 //We ignore the channel for now, BSSID should be enough
12061 pScanFilter->ChannelInfo.numOfChannels = 0;
12062 //Also ignore the following fields
12063 pScanFilter->uapsd_mask = 0;
12064 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12065 pScanFilter->countryCode[0] = 0;
12066 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 csrLLLock(&pMac->scan.scanResultList);
12068 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12069 while( pEntry )
12070 {
12071 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12072 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12073 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12074 pScanFilter, NULL, NULL, NULL, &pIes);
12075 //Release the IEs allocated by csrMatchBSS is needed
12076 if( !pResult->Result.pvIes )
12077 {
12078 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012079 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 }
12081 if(fMatch)
12082 {
12083 //We found the one
12084 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12085 {
12086 //Free the memory
12087 csrFreeScanResultEntry( pMac, pResult );
12088 }
12089 break;
12090 }
12091 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12092 }//while
12093 csrLLUnlock(&pMac->scan.scanResultList);
12094 }while(0);
12095 if(pScanFilter)
12096 {
12097 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012098 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 }
12100 }
12101 return (status);
12102}
12103
Jeff Johnson295189b2012-06-20 16:38:30 -070012104//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012105eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12106{
12107 eHalStatus status = eHAL_STATUS_SUCCESS;
12108 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12110 {
12111 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12112 {
12113 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12114 {
12115 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012116 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012117 status = eHAL_STATUS_CSR_WRONG_STATE;
12118 break;
12119 }
12120 if( csrIsConnStateInfra( pMac, sessionId ) )
12121 {
12122 if( chnId &&
12123 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012125 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12127 status = eHAL_STATUS_CSR_WRONG_STATE;
12128 break;
12129 }
12130 }
12131 }
12132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 return ( status );
12134}
12135
Jeff Johnson295189b2012-06-20 16:38:30 -070012136static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12137{
12138 eHalStatus status = eHAL_STATUS_SUCCESS;
12139 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12140 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012141
12142 if(!pSession)
12143 {
12144 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12145 return eHAL_STATUS_FAILURE;
12146 }
12147
Jeff Johnson295189b2012-06-20 16:38:30 -070012148 if ( csrIsConnStateIbss( pMac, sessionId ) )
12149 {
12150 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12151 }
12152 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12153 {
12154 // Disassociate from the connected Infrastructure network...
12155 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12156 }
12157 else
12158 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12160 //Otherwise we need to add code to handle the
12161 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12162 //send stop_bss to PE, before we can continue.
12163 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012164 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012166 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12167 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 // there is no Bss description before we start an WDS so we need
12169 // to adopt all Bss configuration parameters from the Profile.
12170 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12171 if(HAL_STATUS_SUCCESS(status))
12172 {
12173 //Save profile for late use
12174 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012175 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12176 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012178 vos_mem_set(pSession->pCurRoamProfile,
12179 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012182 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012183 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012184 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12185 NULL, &bssConfig,
12186 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 }
12188 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012189
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 return( status );
12191}
12192
Jeff Johnson295189b2012-06-20 16:38:30 -070012193////////////////////Mail box
12194
Jeff Johnson295189b2012-06-20 16:38:30 -070012195//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12196//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012197static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12198 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12200{
12201 tCsrChannelSet channelGroup;
12202 tSirMacCapabilityInfo *pAP_capabilityInfo;
12203 tAniBool fTmp;
12204 tANI_BOOLEAN found = FALSE;
12205 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012206 tANI_S8 pwrLimit = 0;
12207 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12209 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12210 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12211 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012212 // 802.11h
12213 //We can do this because it is in HOST CPU order for now.
12214 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012215 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12216 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12217 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 fTmp = (tAniBool)pal_cpu_to_be32(1);
12219 }
12220 else
12221 fTmp = (tAniBool)0;
12222
12223 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012224 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 pBuf += sizeof(tAniBool);
12226 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012227 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 // This is required for 11k test VoWiFi Ent: Test 2.
12229 // We need the power capabilities for Assoc Req.
12230 // This macro is provided by the halPhyCfg.h. We pick our
12231 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012232 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12233 if (0 != pwrLimit)
12234 {
12235 *pBuf++ = pwrLimit;
12236 }
12237 else
12238 {
12239 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 size = sizeof(pMac->roam.validChannelList);
12242 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12243 {
12244 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12245 for ( i = 0; i < size; i++)
12246 {
12247 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12248
12249 }
12250 }
12251 else
12252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012253 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 *pBuf++ = 0; //tSirSupChnl->numChnl
12255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 //Check whether it is ok to enter UAPSD
12257#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12258 if( btcIsReadyForUapsd(pMac) )
12259#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12260 {
12261 *pBuf++ = uapsdMask;
12262 }
12263#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12264 else
12265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012266 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 *pBuf++ = 0;
12268 }
12269#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12270
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012272 vos_mem_copy(pBuf, pBssDescription,
12273 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12275}
12276
Jeff Johnson295189b2012-06-20 16:38:30 -070012277/*
12278 * The communication between HDD and LIM is thru mailbox (MB).
12279 * Both sides will access the data structure "tSirSmeJoinReq".
12280 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12281 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12282 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12283 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12284 */
12285eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012286 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012287{
12288 eHalStatus status = eHAL_STATUS_SUCCESS;
12289 tSirSmeJoinReq *pMsg;
12290 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012291 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 tANI_U16 msgLen, wTmp, ieLen;
12293 tSirMacRateSet OpRateSet;
12294 tSirMacRateSet ExRateSet;
12295 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12296 tANI_U32 dwTmp;
12297 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012298 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012299
12300 if(!pSession)
12301 {
12302 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12303 return eHAL_STATUS_FAILURE;
12304 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012305 /* To satisfy klockworks */
12306 if (NULL == pBssDescription)
12307 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012308 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012309 return eHAL_STATUS_FAILURE;
12310 }
12311
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 do {
12313 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12314 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012315 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12317 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12318 // IE fields, but the length field in the bssDescription needs to be interpreted to
12319 // determine length of the IE fields.
12320 //
12321 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12322 // add in the length from the bssDescription (then add the size of the 'length' field
12323 // itself because that is NOT included in the length field).
12324 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12325 pBssDescription->length + sizeof( pBssDescription->length ) +
12326 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 +053012327 pMsg = vos_mem_malloc(msgLen);
12328 if (NULL == pMsg)
12329 status = eHAL_STATUS_FAILURE;
12330 else
12331 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012333 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012334 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 pMsg->length = pal_cpu_to_be16(msgLen);
12336 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 // sessionId
12338 *pBuf = (tANI_U8)sessionId;
12339 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 // transactionId
12341 *pBuf = 0;
12342 *( pBuf + 1 ) = 0;
12343 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 // ssId
12345 if( pIes->SSID.present && pIes->SSID.num_ssid )
12346 {
12347 // ssId len
12348 *pBuf = pIes->SSID.num_ssid;
12349 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012350 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012351 pBuf += pIes->SSID.num_ssid;
12352 }
12353 else
12354 {
12355 *pBuf = 0;
12356 pBuf++;
12357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012358 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012359 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12360 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 pBuf += sizeof(tSirMacAddr);
12362 // bsstype
12363 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12364 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012365 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 pBuf += sizeof(tSirBssType);
12367 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012368 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12369 if (pBssDescription->channelId <= 14 &&
12370 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12371 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12372 {
12373 //Need to disable VHT operation in 2.4 GHz band
12374 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12375 }
12376 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 //Persona
12379 *pBuf = (tANI_U8)pProfile->csrPersona;
12380 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012381 //CBMode
12382 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12383 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012384
12385 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012386 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12387
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 // uapsdPerAcBitmask
12389 *pBuf = pProfile->uapsd_mask;
12390 pBuf++;
12391
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012392
12393
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012395 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 {
12397 // OperationalRateSet
12398 if (OpRateSet.numRates) {
12399 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012400 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012401 pBuf += OpRateSet.numRates;
12402 } else *pBuf++ = 0;
12403 // ExtendedRateSet
12404 if (ExRateSet.numRates) {
12405 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012406 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 pBuf += ExRateSet.numRates;
12408 } else *pBuf++ = 0;
12409 }
12410 else
12411 {
12412 *pBuf++ = 0;
12413 *pBuf++ = 0;
12414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 // rsnIE
12416 if ( csrIsProfileWpa( pProfile ) )
12417 {
12418 // Insert the Wpa IE into the join request
12419 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12420 (tCsrWpaIe *)( wpaRsnIE ) );
12421 }
12422 else if( csrIsProfileRSN( pProfile ) )
12423 {
12424 // Insert the RSN IE into the join request
12425 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12426 (tCsrRSNIe *)( wpaRsnIE ) );
12427 }
12428#ifdef FEATURE_WLAN_WAPI
12429 else if( csrIsProfileWapi( pProfile ) )
12430 {
12431 // Insert the WAPI IE into the join request
12432 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12433 (tCsrWapiIe *)( wpaRsnIE ) );
12434 }
12435#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 else
12437 {
12438 ieLen = 0;
12439 }
12440 //remember the IE for future use
12441 if( ieLen )
12442 {
12443 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012445 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 -070012446 ieLen = DOT11F_IE_RSN_MAX_LEN;
12447 }
12448#ifdef FEATURE_WLAN_WAPI
12449 if( csrIsProfileWapi( pProfile ) )
12450 {
12451 //Check whether we need to allocate more memory
12452 if(ieLen > pSession->nWapiReqIeLength)
12453 {
12454 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12455 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012456 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012458 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12459 if (NULL == pSession->pWapiReqIE)
12460 status = eHAL_STATUS_FAILURE;
12461 else
12462 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 if(!HAL_STATUS_SUCCESS(status)) break;
12464 }
12465 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012466 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012468 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012470 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 pBuf += ieLen;
12472 }
12473 else//should be WPA/WPA2 otherwise
12474#endif /* FEATURE_WLAN_WAPI */
12475 {
12476 //Check whether we need to allocate more memory
12477 if(ieLen > pSession->nWpaRsnReqIeLength)
12478 {
12479 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12480 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012481 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012483 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12484 if (NULL == pSession->pWpaRsnReqIE)
12485 status = eHAL_STATUS_FAILURE;
12486 else
12487 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 if(!HAL_STATUS_SUCCESS(status)) break;
12489 }
12490 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012491 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012493 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012494 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012495 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 pBuf += ieLen;
12497 }
12498 }
12499 else
12500 {
12501 //free whatever old info
12502 pSession->nWpaRsnReqIeLength = 0;
12503 if(pSession->pWpaRsnReqIE)
12504 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012505 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 pSession->pWpaRsnReqIE = NULL;
12507 }
12508#ifdef FEATURE_WLAN_WAPI
12509 pSession->nWapiReqIeLength = 0;
12510 if(pSession->pWapiReqIE)
12511 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012512 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 pSession->pWapiReqIE = NULL;
12514 }
12515#endif /* FEATURE_WLAN_WAPI */
12516 //length is two bytes
12517 *pBuf = 0;
12518 *(pBuf + 1) = 0;
12519 pBuf += 2;
12520 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012521#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012522 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012524 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012525 //length is two bytes
12526 *pBuf = 0;
12527 *(pBuf + 1) = 0;
12528 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012529 }
12530 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012532 // cckmIE
12533 if( csrIsProfileCCX( pProfile ) )
12534 {
12535 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012536#ifdef FEATURE_WLAN_CCX_UPLOAD
12537 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12538 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12539 pSession->suppCckmIeInfo.cckmIe, ieLen);
12540#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012541 ieLen = csrConstructCcxCckmIe( pMac,
12542 pSession,
12543 pProfile,
12544 pBssDescription,
12545 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 pSession->nWpaRsnReqIeLength,
12547 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012548#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012549 }
12550 else
12551 {
12552 ieLen = 0;
12553 }
12554 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12555 if( ieLen )
12556 {
12557 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12558 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012559 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012560 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012561 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012562 pBuf += ieLen;
12563 }
12564 else
12565 {
12566 //Indicate you have no CCKM IE
12567 //length is two bytes
12568 *pBuf = 0;
12569 *(pBuf + 1) = 0;
12570 pBuf += 2;
12571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 }
12573#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 // addIEScan
12575 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12576 {
12577 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 if(ieLen > pSession->nAddIEScanLength)
12579 {
12580 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12581 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012582 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012584 pSession->pAddIEScan = vos_mem_malloc(ieLen);
12585 if (NULL == pSession->pAddIEScan)
12586 status = eHAL_STATUS_FAILURE;
12587 else
12588 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 if(!HAL_STATUS_SUCCESS(status)) break;
12590 }
12591 pSession->nAddIEScanLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012592 vos_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012594 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012595 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012596 vos_mem_copy(pBuf, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 pBuf += ieLen;
12598 }
12599 else
12600 {
12601 pSession->nAddIEScanLength = 0;
12602 if(pSession->pAddIEScan)
12603 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012604 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 pSession->pAddIEScan = NULL;
12606 }
12607 *pBuf = 0;
12608 *(pBuf + 1) = 0;
12609 pBuf += 2;
12610 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 // addIEAssoc
12612 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12613 {
12614 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 if(ieLen > pSession->nAddIEAssocLength)
12616 {
12617 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012618 {
12619 vos_mem_free(pSession->pAddIEAssoc);
12620 }
12621 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12622 if (NULL == pSession->pAddIEAssoc)
12623 status = eHAL_STATUS_FAILURE;
12624 else
12625 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012627 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012629 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012631 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012633 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 pBuf += ieLen;
12635 }
12636 else
12637 {
12638 pSession->nAddIEAssocLength = 0;
12639 if(pSession->pAddIEAssoc)
12640 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012641 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 pSession->pAddIEAssoc = NULL;
12643 }
12644 *pBuf = 0;
12645 *(pBuf + 1) = 0;
12646 pBuf += 2;
12647 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012648
12649 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012651 //Unmask any AC in reassoc that is ACM-set
12652 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12653 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012655 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12656 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012657#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012658 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012659#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012660 uapsd_mask &= ~(acm_mask);
12661 }
12662 else
12663 {
12664 uapsd_mask = 0;
12665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 }
12667 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012668
Jeff Johnson295189b2012-06-20 16:38:30 -070012669 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012670 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012671 pBuf += sizeof(tANI_U32);
12672
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012674 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012675 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012676#ifdef WLAN_FEATURE_11W
12677 //MgmtEncryption
12678 if (pProfile->MFPEnabled)
12679 {
12680 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12681 }
12682 else
12683 {
12684 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12685 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012686 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012687 pBuf += sizeof(tANI_U32);
12688#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012689#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012690 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012691 if (csrIsProfile11r( pProfile )
12692#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012693 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12694 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012695#endif
12696 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012697 {
12698 // is11Rconnection;
12699 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012700 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012701 pBuf += sizeof(tAniBool);
12702 }
12703 else
12704 {
12705 // is11Rconnection;
12706 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012707 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012708 pBuf += sizeof(tAniBool);
12709 }
12710#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012711#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012712
12713 // isCCXFeatureIniEnabled
12714 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12715 {
12716 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012717 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012718 pBuf += sizeof(tAniBool);
12719 }
12720 else
12721 {
12722 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012723 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012724 pBuf += sizeof(tAniBool);
12725 }
12726
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012727 /* A profile can not be both CCX and 11R. But an 802.11R AP
12728 * may be advertising support for CCX as well. So if we are
12729 * associating Open or explicitly CCX then we will get CCX.
12730 * If we are associating explictly 11R only then we will get
12731 * 11R.
12732 */
12733 if ((csrIsProfileCCX(pProfile) ||
12734 ((pIes->CCXVersion.present)
12735 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012736 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12737 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12738 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012739#ifdef WLAN_FEATURE_11W
12740 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12741#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012742 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012743 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12744 {
12745 // isCCXconnection;
12746 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012747 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012748 pBuf += sizeof(tAniBool);
12749 }
12750 else
12751 {
12752 //isCCXconnection;
12753 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012754 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012755 pBuf += sizeof(tAniBool);
12756 }
12757
12758 if (eWNI_SME_JOIN_REQ == messageType)
12759 {
12760 tCCXTspecInfo ccxTspec;
12761 // CCX-Tspec IEs in the ASSOC request is presently not supported
12762 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012763 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12764 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012765 pBuf += sizeof(tCCXTspecInfo);
12766 }
12767 else if (eWNI_SME_REASSOC_REQ == messageType)
12768 {
12769 if ((csrIsProfileCCX(pProfile) ||
12770 ((pIes->CCXVersion.present)
12771 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012772 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12773 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12774 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012775#ifdef WLAN_FEATURE_11W
12776 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12777#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012778 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012779 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 {
12781 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012783 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12785 *pBuf = ccxTspec.numTspecs;
12786 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 // Copy the TSPEC information only if present
12788 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012789 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12790 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 }
12792 pBuf += sizeof(ccxTspec.tspec);
12793 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012794 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 tCCXTspecInfo ccxTspec;
12797 // CCX-Tspec IEs in the ASSOC request is presently not supported
12798 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012799 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12800 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 pBuf += sizeof(tCCXTspecInfo);
12802 }
12803 }
12804#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012805#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012807 if (pMac->roam.configParam.isFastTransitionEnabled
12808#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012809 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012810#endif
12811 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012813 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012814 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012815 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012816 }
12817 else
12818 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012819 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012820 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012821 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 }
12823#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012824#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012825 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012826 {
12827 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012828 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012829 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012830 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012831 }
12832 else
12833 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012834 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012835 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012836 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012837 }
12838#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012839
12840 // txLdpcIniFeatureEnabled
12841 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12842 pBuf++;
12843
Kiran4a17ebe2013-01-31 10:43:43 -080012844 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12845 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12846 {
12847 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12848 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12849 csrApplyPower2Current(pMac);
12850 }
12851
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012852#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012853 // txBFIniFeatureEnabled
12854 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12855 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012856
12857 // txBFCsnValue
12858 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12859 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012860#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012861 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12862 pBuf++;
12863
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012864 //BssDesc
12865 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12866 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012867
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012868 status = palSendMBMessage(pMac->hHdd, pMsg );
12869 if(!HAL_STATUS_SUCCESS(status))
12870 {
12871 break;
12872 }
12873 else
12874 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012875#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012876 if (eWNI_SME_JOIN_REQ == messageType)
12877 {
12878 //Tush-QoS: notify QoS module that join happening
12879 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12880 }
12881 else if (eWNI_SME_REASSOC_REQ == messageType)
12882 {
12883 //Tush-QoS: notify QoS module that reassoc happening
12884 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012886#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012889 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012890}
12891
Jeff Johnson295189b2012-06-20 16:38:30 -070012892//
12893eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12894{
12895 eHalStatus status = eHAL_STATUS_SUCCESS;
12896 tSirSmeDisassocReq *pMsg;
12897 tANI_U8 *pBuf;
12898 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12900 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12901 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012903 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12904 if (NULL == pMsg)
12905 status = eHAL_STATUS_FAILURE;
12906 else
12907 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012909 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12911 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 pBuf = &pMsg->sessionId;
12913 // sessionId
12914 *pBuf++ = (tANI_U8)sessionId;
12915 // transactionId
12916 *pBuf = 0;
12917 *( pBuf + 1 ) = 0;
12918 pBuf += sizeof(tANI_U16);
12919
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012920 if ( (pSession->pCurRoamProfile != NULL) &&
12921 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12922 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 {
12924 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012925 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12926 sizeof( tSirMacAddr ));
12927 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012929 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012930 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12931 //perMacAddr is passed as bssId for softAP
12932 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 pBuf = pBuf + sizeof ( tSirMacAddr );
12934 }
12935 else
12936 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012938 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12939 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053012941 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
12942 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012943 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 if(!HAL_STATUS_SUCCESS(status))
12946 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012947 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 break;
12949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 // reasonCode
12951 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053012952 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
12953 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 if(!HAL_STATUS_SUCCESS(status))
12955 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012956 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 break;
12958 }
12959 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12961 Here we should not send the disassoc over the air to the AP */
12962 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12963#ifdef WLAN_FEATURE_VOWIFI_11R
12964 && csrRoamIs11rAssoc(pMac)
12965#endif
12966 )
12967 {
12968 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12969 }
12970 pBuf += sizeof(tANI_U8);
12971 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012973 return( status );
12974}
Jeff Johnson295189b2012-06-20 16:38:30 -070012975eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12976{
12977 eHalStatus status = eHAL_STATUS_SUCCESS;
12978 tSirSmeTkipCntrMeasReq *pMsg;
12979 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 do
12981 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012982 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
12983 if ( NULL == pMsg )
12984 status = eHAL_STATUS_FAILURE;
12985 else
12986 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012988 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12990 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 pBuf = &pMsg->sessionId;
12992 // sessionId
12993 *pBuf++ = (tANI_U8)sessionId;
12994 // transactionId
12995 *pBuf = 0;
12996 *( pBuf + 1 ) = 0;
12997 pBuf += sizeof(tANI_U16);
12998 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053012999 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13000 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 pBuf = pBuf + sizeof ( tSirMacAddr );
13002 // bEnable
13003 *pBuf = (tANI_BOOLEAN)bEnable;
13004 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 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 return( status );
13012}
Jeff Johnson295189b2012-06-20 16:38:30 -070013013eHalStatus
13014csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13015 VOS_MODULE_ID modId, tSirMacAddr bssId,
13016 void *pUsrContext, void *pfnSapEventCallback,
13017 tANI_U8 *pAssocStasBuf )
13018{
13019 eHalStatus status = eHAL_STATUS_SUCCESS;
13020 tSirSmeGetAssocSTAsReq *pMsg;
13021 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13022 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 do
13024 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013025 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13026 if ( NULL == pMsg )
13027 status = eHAL_STATUS_FAILURE;
13028 else
13029 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013031 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013032 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 pBuf = (tANI_U8 *)&pMsg->bssId;
13034 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013036 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 // modId
13039 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013040 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 // pUsrContext
13043 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013044 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013045 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 // pfnSapEventCallback
13047 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013048 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013049 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 // pAssocStasBuf
13051 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013052 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 status = palSendMBMessage( pMac->hHdd, pMsg );
13056 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 return( status );
13058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013059eHalStatus
13060csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13061 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13062 {
13063 eHalStatus status = eHAL_STATUS_SUCCESS;
13064 tSirSmeGetWPSPBCSessionsReq *pMsg;
13065 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13066 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 do
13068 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013069 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13070 if ( NULL == pMsg )
13071 status = eHAL_STATUS_FAILURE;
13072 else
13073 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013075 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013078 VOS_ASSERT(pBuf);
13079
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 // pUsrContext
13082 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013083 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 // pSapEventCallback
13086 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013087 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013090 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013093 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013095 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 return( status );
13099}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013100
13101eHalStatus
13102csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13103{
13104 tpSirChangeBIParams pMsg;
13105 tANI_U16 len = 0;
13106 eHalStatus status = eHAL_STATUS_SUCCESS;
13107 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13108
13109 if(!pSession)
13110 {
13111 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13112 return eHAL_STATUS_FAILURE;
13113 }
13114
13115 //NO need to update the Beacon Params if update beacon parameter flag is not set
13116 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13117 return eHAL_STATUS_SUCCESS;
13118
13119 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13120
13121 /* Create the message and send to lim */
13122 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013123 pMsg = vos_mem_malloc(len);
13124 if ( NULL == pMsg )
13125 status = eHAL_STATUS_FAILURE;
13126 else
13127 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013128 if(HAL_STATUS_SUCCESS(status))
13129 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013130 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013131 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13132 pMsg->length = len;
13133
13134 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013135 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13136 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013137 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13138 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013139 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013140 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013141 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13142 status = palSendMBMessage(pMac->hHdd, pMsg);
13143 }
13144 return status;
13145}
13146
Jeff Johnson295189b2012-06-20 16:38:30 -070013147eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13148{
13149 eHalStatus status = eHAL_STATUS_SUCCESS;
13150 tSirSmeDeauthReq *pMsg;
13151 tANI_U8 *pBuf;
13152 tANI_U16 wTmp;
13153 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13154 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13155 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013157 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13158 if ( NULL == pMsg )
13159 status = eHAL_STATUS_FAILURE;
13160 else
13161 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013163 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13165 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13166 //sessionId
13167 pBuf = &pMsg->sessionId;
13168 *pBuf++ = (tANI_U8)sessionId;
13169
13170 //tansactionId
13171 *pBuf = 0;
13172 *(pBuf + 1 ) = 0;
13173 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13177 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013178 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13179 sizeof( pMsg->peerMacAddr ) );
13180 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 pBuf = pBuf + sizeof(tSirMacAddr);
13182 }
13183 else
13184 {
13185 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013186 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13187 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 }
13190 if(!HAL_STATUS_SUCCESS(status))
13191 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013192 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 break;
13194 }
13195 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013196 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13197 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 pBuf = pBuf + sizeof(tSirMacAddr);
13199 if(!HAL_STATUS_SUCCESS(status))
13200 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013201 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 break;
13203 }
13204 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013205 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13206 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 if(!HAL_STATUS_SUCCESS(status))
13208 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013209 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013210 break;
13211 }
13212 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 return( status );
13215}
13216
Jeff Johnson295189b2012-06-20 16:38:30 -070013217eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13218{
13219 eHalStatus status = eHAL_STATUS_SUCCESS;
13220 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013222 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13223 if ( NULL == pMsg )
13224 status = eHAL_STATUS_FAILURE;
13225 else
13226 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013228 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13230 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13231 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013232 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13233 sizeof(pMsg->peerMacAddr));
13234 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 if(!HAL_STATUS_SUCCESS(status))
13236 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013237 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 break;
13239 }
13240//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013241 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13242 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 if(!HAL_STATUS_SUCCESS(status))
13244 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013245 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 break;
13247 }
13248//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 return( status );
13252}
13253
Jeff Johnson295189b2012-06-20 16:38:30 -070013254eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13255{
13256 eHalStatus status = eHAL_STATUS_SUCCESS;
13257 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013259 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13260 if ( NULL == pMsg )
13261 status = eHAL_STATUS_FAILURE;
13262 else
13263 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013264 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013265 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13267 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13268 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013269 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13270 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 if(!HAL_STATUS_SUCCESS(status))
13272 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013273 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 break;
13275 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013276 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13277 sizeof(pMsg->peerMacAddr));
13278 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 if(!HAL_STATUS_SUCCESS(status))
13280 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013281 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 break;
13283 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 return( status );
13287}
Jeff Johnson295189b2012-06-20 16:38:30 -070013288eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13289{
13290 eHalStatus status = eHAL_STATUS_SUCCESS;
13291 tSirSmeAssocCnf *pMsg;
13292 tANI_U8 *pBuf;
13293 tSirResultCodes statusCode;
13294 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013296 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13297 if ( NULL == pMsg )
13298 status = eHAL_STATUS_FAILURE;
13299 else
13300 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013302 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13304 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 pBuf = (tANI_U8 *)&pMsg->statusCode;
13306 if(HAL_STATUS_SUCCESS(Halstatus))
13307 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13308 else
13309 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013310 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 pBuf += sizeof(tSirResultCodes);
13312 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013313 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13314 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 pBuf += sizeof (tSirMacAddr);
13316 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013317 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13318 sizeof(tSirMacAddr));
13319 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 pBuf += sizeof (tSirMacAddr);
13321 // aid
13322 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013323 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 pBuf += sizeof (tANI_U16);
13325 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013326 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13327 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 pBuf += sizeof (tSirMacAddr);
13329 // alternateChannelId
13330 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 status = palSendMBMessage( pMac->hHdd, pMsg );
13332 if(!HAL_STATUS_SUCCESS(status))
13333 {
13334 //pMsg is freed by palSendMBMessage
13335 break;
13336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 return( status );
13339}
Jeff Johnson295189b2012-06-20 16:38:30 -070013340eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13341 tpSirSmeAssocInd pAssocInd,
13342 eHalStatus Halstatus,
13343 tANI_U8 sessionId)
13344{
13345 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13347 tANI_U8 *pBuf;
13348 tSirResultCodes statusCode;
13349 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013351 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13352 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13353 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013354
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13356 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13357
13358 pMsg->sessionId = sessionId;
13359
13360 pBuf = (tANI_U8 *)&pMsg->statusCode;
13361 if(HAL_STATUS_SUCCESS(Halstatus))
13362 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13363 else
13364 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013365 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 pBuf += sizeof(tSirResultCodes);
13367 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013368 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 pBuf += sizeof (tSirMacAddr);
13370 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013371 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13372 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 pBuf += sizeof (tSirMacAddr);
13374 // StaId
13375 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013376 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 pBuf += sizeof (tANI_U16);
13378 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013379 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 pBuf += sizeof (tSirMacAddr);
13381 // alternateChannelId
13382 *pBuf = 11;
13383 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013384 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 //Wmm
13386 *pBuf = pAssocInd->wmmEnabledSta;
13387 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013389 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013392 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013394 //reassocReq
13395 *pBuf = pAssocInd->reassocReq;
13396 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13398 msgQ.bodyptr = pMsg;
13399 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013402 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013403}
Jeff Johnson295189b2012-06-20 16:38:30 -070013404
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013405eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13407 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13408 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13409 tANI_U8 *pKeyRsc )
13410{
13411 tSirSmeSetContextReq *pMsg;
13412 tANI_U16 msgLen;
13413 eHalStatus status = eHAL_STATUS_FAILURE;
13414 tAniEdType tmpEdType;
13415 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013416 tANI_U8 *pBuf = NULL;
13417 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013421 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13422 // key set. Since we only support upto one key, we always allocate memory for 1 key
13423 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13424 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13425 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13426 ( sizeof( pMsg->keyMaterial.key ) );
13427
Kiet Lam64c1b492013-07-12 13:56:44 +053013428 pMsg = vos_mem_malloc(msgLen);
13429 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13430 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13432 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 //sessionId
13434 pBuf = &pMsg->sessionId;
13435 *pBuf = (tANI_U8)sessionId;
13436 pBuf++;
13437 // transactionId
13438 *pBuf = 0;
13439 *(pBuf + 1) = 0;
13440 pBuf += sizeof(tANI_U16);
13441 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013442 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013443
13444 pBuf += sizeof(tSirMacAddr);
13445
13446 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013447 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13448 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013449
13450 pBuf += sizeof(tSirMacAddr);
13451
13452 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13454 // in the tSirKeyMaterial keyMaterial; field).
13455 //
13456 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13457 // shorter than this max size. Is LIM interpreting this ok ?
13458 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 -070013459 // set pMsg->keyMaterial.edType
13460 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013461 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 // set the pMsg->keyMaterial.numKeys field
13464 *p = numKeys;
13465 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 // set pSirKey->keyId = keyId;
13467 *p = keyId;
13468 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 // set pSirKey->unicast = (tANI_U8)fUnicast;
13470 *p = (tANI_U8)fUnicast;
13471 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 // set pSirKey->keyDirection = aniKeyDirection;
13473 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013474 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 p += sizeof(tAniKeyDirection);
13476 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013477 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 // set pSirKey->paeRole
13480 *p = paeRole; // 0 is Supplicant
13481 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 // set pSirKey->keyLength = keyLength;
13483 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 if ( keyLength && pKey )
13485 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013486 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 if(keyLength == 16)
13488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013489 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 -070013490 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13491 pKey[5], pKey[6], pKey[7], pKey[8],
13492 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13493 }
13494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 return( status );
13498}
13499
Jeff Johnson295189b2012-06-20 16:38:30 -070013500eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13501 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13502{
13503 eHalStatus status;
13504 tSirSmeStartBssReq *pMsg;
13505 tANI_U8 *pBuf = NULL;
13506 tANI_U8 *wTmpBuf = NULL;
13507 tANI_U16 msgLen, wTmp;
13508 tANI_U32 dwTmp;
13509 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013510 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013513
13514 if(!pSession)
13515 {
13516 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13517 return eHAL_STATUS_FAILURE;
13518 }
13519
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 do {
13521 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13522 pSession->joinFailStatusCode.reasonCode = 0;
13523 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013524 pMsg = vos_mem_malloc(msgLen);
13525 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13526 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 //sessionId
13531 *pBuf = (tANI_U8)sessionId;
13532 pBuf++;
13533 // transactionId
13534 *pBuf = 0;
13535 *(pBuf + 1) = 0;
13536 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013538 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 pBuf += sizeof(tSirMacAddr);
13540 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013541 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 pBuf += sizeof(tSirMacAddr);
13543 // beaconInterval
13544 if( pBssDesc && pBssDesc->beaconInterval )
13545 {
13546 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13547 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 else if(pParam->beaconInterval)
13549 {
13550 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13551 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 else
13553 {
13554 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13555 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013556 if(csrIsconcurrentsessionValid (pMac, sessionId,
13557 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013558 == eHAL_STATUS_SUCCESS )
13559 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013560 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013561 pParam->bssPersona);
13562 //Update the beacon Interval
13563 pParam->beaconInterval = wTmp;
13564 }
13565 else
13566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013567 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013568 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013569 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013570 return status;
13571 }
13572
Kiet Lam64c1b492013-07-12 13:56:44 +053013573 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 pBuf += sizeof(tANI_U16);
13575 // dot11mode
13576 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13577 pBuf += 1;
13578 // bssType
13579 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013580 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 pBuf += sizeof(tSirBssType);
13582 // ssId
13583 if( pParam->ssId.length )
13584 {
13585 // ssId len
13586 *pBuf = pParam->ssId.length;
13587 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013588 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 pBuf += pParam->ssId.length;
13590 }
13591 else
13592 {
13593 *pBuf = 0;
13594 pBuf++;
13595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 // set the channel Id
13597 *pBuf = pParam->operationChn;
13598 pBuf++;
13599 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013600 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013601 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013602 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013603
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 // Set privacy
13605 *pBuf = pParam->privacy;
13606 pBuf++;
13607
13608 //Set Uapsd
13609 *pBuf = pParam->ApUapsdEnable;
13610 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 //Set SSID hidden
13612 *pBuf = pParam->ssidHidden;
13613 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13615 pBuf++;
13616
13617 //Ht protection Enable/Disable
13618 *pBuf = (tANI_U8)pParam->protEnabled;
13619 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 //Enable Beacons to Receive for OBSS protection Enable/Disable
13621 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13622 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 //set cfg related to protection
13624 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013625 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 // Set Auth type
13628 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013629 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 // Set DTIM
13632 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013633 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 // Set wps_state
13636 *pBuf = pParam->wps_state;
13637 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013638 // set isCoalesingInIBSSAllowed
13639 *pBuf = pMac->isCoalesingInIBSSAllowed;
13640 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 //Persona
13642 *pBuf = (tANI_U8)pParam->bssPersona;
13643 pBuf++;
13644
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013645 //txLdpcIniFeatureEnabled
13646 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13647 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013648
krunal soni4f087d22013-07-29 16:32:26 -070013649 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13651 {
13652 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013653 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 break;
13655 }
13656 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013657 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 pBuf += sizeof(tANI_U16);
13659 if( wTmp )
13660 {
13661 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013662 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 pBuf += wTmp;
13664 }
13665 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013666 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13669 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013670 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13671 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 pBuf += pParam->operationalRateSet.numRates ;
13673 *pBuf++ = pParam->extendedRateSet.numRates;
13674 if(0 != pParam->extendedRateSet.numRates)
13675 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013676 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13677 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 pBuf += pParam->extendedRateSet.numRates;
13679 }
krunal sonie9002db2013-11-25 14:24:17 -080013680
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13682 pMsg->length = pal_cpu_to_be16(msgLen);
13683
13684 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 return( status );
13687}
13688
Jeff Johnson295189b2012-06-20 16:38:30 -070013689eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13690{
13691 eHalStatus status = eHAL_STATUS_FAILURE;
13692 tSirSmeStopBssReq *pMsg;
13693 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13694 tANI_U8 *pBuf;
13695 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013696
13697 if(!pSession)
13698 {
13699 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13700 return eHAL_STATUS_FAILURE;
13701 }
13702
Jeff Johnson295189b2012-06-20 16:38:30 -070013703 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013704 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13705 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13706 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13708 pBuf = &pMsg->sessionId;
13709 //sessionId
13710 *pBuf = (tANI_U8)sessionId;
13711 pBuf++;
13712 // transactionId
13713 *pBuf = 0;
13714 pBuf += sizeof(tANI_U16);
13715 //reason code
13716 *pBuf = 0;
13717 pBuf += sizeof(tSirResultCodes);
13718 // bssid
13719 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13720 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13721 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013722 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13723 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 }
13725 else
13726 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013727 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13728 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 }
13730 pBuf += sizeof(tSirMacAddr);
13731 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13732 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 status = palSendMBMessage( pMac->hHdd, pMsg );
13734#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013735 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13736 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13737 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13739 pMsg->reasonCode = 0;
13740 // bssid
13741 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13742 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13743 {
13744 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13745 }
13746 else
13747 {
13748 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13749 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013750 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 pMsg->transactionId = 0;
13752 pMsg->sessionId = (tANI_U8)sessionId;
13753 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13754 status = palSendMBMessage( pMac->hHdd, pMsg );
13755#endif
13756 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 return( status );
13758}
13759
Jeff Johnson295189b2012-06-20 16:38:30 -070013760eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13761 tCsrRoamModifyProfileFields *pModProfileFields,
13762 tANI_U32 *pRoamId, v_BOOL_t fForce)
13763{
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 eHalStatus status = eHAL_STATUS_FAILURE;
13765 tANI_U32 roamId = 0;
13766 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 (fForce || (!vos_mem_compare( &pModProfileFields,
13769 &pSession->connectedProfile.modifyProfileFields,
13770 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 {
13772 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13773 if(pRoamId)
13774 {
13775 *pRoamId = roamId;
13776 }
13777
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13779 eCsrSmeIssuedReassocToSameAP, roamId,
13780 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 return status;
13783}
Jeff Johnson295189b2012-06-20 16:38:30 -070013784static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13785{
13786 eHalStatus status = eHAL_STATUS_SUCCESS;
13787 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013788 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13790 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13791 return (status);
13792}
Jeff Johnson295189b2012-06-20 16:38:30 -070013793eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13794{
13795 eHalStatus status = eHAL_STATUS_SUCCESS;
13796 tListElem *pEntry = NULL;
13797 tSmeCmd *pCommand = NULL;
13798 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 do
13800 {
13801 if(pMsg == NULL)
13802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013803 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 status = eHAL_STATUS_FAILURE;
13805 break;
13806 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13808 if(pEntry)
13809 {
13810 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13811 if(eSmeCommandAddStaSession == pCommand->command)
13812 {
13813 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013814 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 //Remove this command out of the active list
13818 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13819 {
13820 //Now put this command back on the avilable command list
13821 csrReleaseCommand(pMac, pCommand);
13822 }
13823 smeProcessPendingQueue( pMac );
13824 }
13825 else
13826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013827 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 -070013828 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 status = eHAL_STATUS_FAILURE;
13830 break;
13831 }
13832 }
13833 else
13834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013835 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 -070013836 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 status = eHAL_STATUS_FAILURE;
13838 break;
13839 }
13840 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013842}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013843eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13844 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013845{
13846 tSirSmeAddStaSelfReq *pMsg;
13847 tANI_U16 msgLen;
13848 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013850 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013851 pMsg = vos_mem_malloc(msgLen);
13852 if ( NULL == pMsg ) break;
13853 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13855 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013857 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013858 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13859
13860 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13861
Arif Hussain24bafea2013-11-15 15:10:03 -080013862 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
13863 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 return( status );
13867}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013868eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13869 tANI_U32 sessionId,
13870 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013871{
13872 eHalStatus status = eHAL_STATUS_SUCCESS;
13873 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 pCommand = csrGetCommandBuffer(pMac);
13875 if(NULL == pCommand)
13876 {
13877 status = eHAL_STATUS_RESOURCES;
13878 }
13879 else
13880 {
13881 pCommand->command = eSmeCommandAddStaSession;
13882 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013883 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13884 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013885 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13887 if( !HAL_STATUS_SUCCESS( status ) )
13888 {
13889 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013890 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 }
13892 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 return (status);
13894}
Jeff Johnson295189b2012-06-20 16:38:30 -070013895eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13896{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013897 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013898}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013899eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13900 csrRoamCompleteCallback callback,
13901 void *pContext, tANI_U8 *pSelfMacAddr,
13902 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013903{
13904 eHalStatus status = eHAL_STATUS_SUCCESS;
13905 tANI_U32 i;
13906 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 *pbSessionId = CSR_SESSION_ID_INVALID;
13908 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13909 {
13910 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13911 {
13912 pSession = CSR_GET_SESSION( pMac, i );
13913 status = eHAL_STATUS_SUCCESS;
13914 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13915 pSession->sessionId = (tANI_U8)i;
13916 pSession->callback = callback;
13917 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013918 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013920 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13921 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013923 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013925 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 break;
13927 }
13928#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013929 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13930 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013932 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013934 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 break;
13936 }
13937#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013938 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 break;
13940 }
13941 }
13942 if( CSR_ROAM_SESSION_MAX == i )
13943 {
13944 //No session is available
13945 status = eHAL_STATUS_RESOURCES;
13946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 return ( status );
13948}
Jeff Johnson295189b2012-06-20 16:38:30 -070013949eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13950{
13951 eHalStatus status = eHAL_STATUS_SUCCESS;
13952 tListElem *pEntry = NULL;
13953 tSmeCmd *pCommand = NULL;
13954 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 do
13956 {
13957 if(pMsg == NULL)
13958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013959 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 status = eHAL_STATUS_FAILURE;
13961 break;
13962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13964 if(pEntry)
13965 {
13966 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13967 if(eSmeCommandDelStaSession == pCommand->command)
13968 {
13969 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013971 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 //This session is done.
13973 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 if(pCommand->u.delStaSessionCmd.callback)
13975 {
13976
13977 status = sme_ReleaseGlobalLock( &pMac->sme );
13978 if ( HAL_STATUS_SUCCESS( status ) )
13979 {
13980 pCommand->u.delStaSessionCmd.callback(
13981 pCommand->u.delStaSessionCmd.pContext);
13982 status = sme_AcquireGlobalLock( &pMac->sme );
13983 if (! HAL_STATUS_SUCCESS( status ) )
13984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013985 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 return status;
13987 }
13988 }
13989 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013990 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 }
13992 }
13993
13994 //Remove this command out of the active list
13995 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13996 {
13997 //Now put this command back on the avilable command list
13998 csrReleaseCommand(pMac, pCommand);
13999 }
14000 smeProcessPendingQueue( pMac );
14001 }
14002 else
14003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014004 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 -070014005 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014006 status = eHAL_STATUS_FAILURE;
14007 break;
14008 }
14009 }
14010 else
14011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014012 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 -070014013 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 status = eHAL_STATUS_FAILURE;
14015 break;
14016 }
14017 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019}
Jeff Johnson295189b2012-06-20 16:38:30 -070014020eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14021{
14022 tSirSmeDelStaSelfReq *pMsg;
14023 tANI_U16 msgLen;
14024 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14027 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014028 pMsg = vos_mem_malloc(msgLen);
14029 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14030 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14032 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014034 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14035 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014037 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 return( status );
14039}
Jeff Johnson295189b2012-06-20 16:38:30 -070014040eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14041 tSirMacAddr sessionMacAddr,
14042 csrRoamSessionCloseCallback callback,
14043 void *pContext)
14044{
14045 eHalStatus status = eHAL_STATUS_SUCCESS;
14046 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 pCommand = csrGetCommandBuffer(pMac);
14048 if(NULL == pCommand)
14049 {
14050 status = eHAL_STATUS_RESOURCES;
14051 }
14052 else
14053 {
14054 pCommand->command = eSmeCommandDelStaSession;
14055 pCommand->sessionId = (tANI_U8)sessionId;
14056 pCommand->u.delStaSessionCmd.callback = callback;
14057 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014058 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14059 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14061 if( !HAL_STATUS_SUCCESS( status ) )
14062 {
14063 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014064 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014065 }
14066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 return (status);
14068}
Jeff Johnson295189b2012-06-20 16:38:30 -070014069eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14070{
14071 return csrSendMBDelSelfStaReqMsg( pMac,
14072 pCommand->u.delStaSessionCmd.selfMacAddr );
14073}
Jeff Johnson295189b2012-06-20 16:38:30 -070014074static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14075{
14076 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14077 tListElem *pEntry, *pNext;
14078 tSmeCmd *pCommand;
14079 tDblLinkList localList;
14080
14081 vos_mem_zero(&localList, sizeof(tDblLinkList));
14082 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14083 {
14084 smsLog(pMac, LOGE, FL(" failed to open list"));
14085 return;
14086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 csrLLLock(pList);
14088 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14089 while(pEntry != NULL)
14090 {
14091 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14092 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14093 if(pCommand->sessionId == sessionId)
14094 {
14095 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14096 {
14097 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14098 }
14099 }
14100 pEntry = pNext;
14101 }
14102 csrLLUnlock(pList);
14103
14104 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14105 {
14106 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14107 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14108 }
14109 csrLLClose(&localList);
14110}
14111
Jeff Johnson295189b2012-06-20 16:38:30 -070014112void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14113{
14114 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14115 {
14116 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 csrRoamStop(pMac, sessionId);
14118 csrFreeConnectBssDesc(pMac, sessionId);
14119 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14120 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014121 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014122#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014123 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014124#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014125 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14126 if (pMac->fScanOffload)
14127 {
14128 purgeSmeSessionCmdList(pMac, sessionId,
14129 &pMac->sme.smeScanCmdPendingList);
14130 }
14131
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 purgeCsrSessionCmdList(pMac, sessionId);
14133 csrInitSession(pMac, sessionId);
14134 }
14135}
14136
Jeff Johnson295189b2012-06-20 16:38:30 -070014137eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14138 tANI_BOOLEAN fSync,
14139 csrRoamSessionCloseCallback callback,
14140 void *pContext )
14141{
14142 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14144 {
14145 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14146 if(fSync)
14147 {
14148 csrCleanupSession(pMac, sessionId);
14149 }
14150 else
14151 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014152 purgeSmeSessionCmdList(pMac, sessionId,
14153 &pMac->sme.smeCmdPendingList);
14154 if (pMac->fScanOffload)
14155 {
14156 purgeSmeSessionCmdList(pMac, sessionId,
14157 &pMac->sme.smeScanCmdPendingList);
14158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 purgeCsrSessionCmdList(pMac, sessionId);
14160 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14161 pSession->selfMacAddr, callback, pContext);
14162 }
14163 }
14164 else
14165 {
14166 status = eHAL_STATUS_INVALID_PARAMETER;
14167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014168 return ( status );
14169}
14170
Jeff Johnson295189b2012-06-20 16:38:30 -070014171static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14172{
14173 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014174
14175 if(!pSession)
14176 {
14177 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14178 return;
14179 }
14180
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14182 pSession->sessionId = CSR_SESSION_ID_INVALID;
14183 pSession->callback = NULL;
14184 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14186 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14187 csrFreeRoamProfile( pMac, sessionId );
14188 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14189 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14190 csrFreeConnectBssDesc(pMac, sessionId);
14191 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014192 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14193 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014195 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 pSession->pWpaRsnReqIE = NULL;
14197 }
14198 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014199 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014200 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014201 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 pSession->pWpaRsnRspIE = NULL;
14203 }
14204 pSession->nWpaRsnRspIeLength = 0;
14205#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014206 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014208 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 pSession->pWapiReqIE = NULL;
14210 }
14211 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014212 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014213 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014214 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014215 pSession->pWapiRspIE = NULL;
14216 }
14217 pSession->nWapiRspIeLength = 0;
14218#endif /* FEATURE_WLAN_WAPI */
Kiet Lam64c1b492013-07-12 13:56:44 +053014219 if (pSession->pAddIEScan)
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014221 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 pSession->pAddIEScan = NULL;
14223 }
14224 pSession->nAddIEScanLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014225 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014227 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014228 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014231}
14232
Jeff Johnson295189b2012-06-20 16:38:30 -070014233eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14234{
14235 eHalStatus status = eHAL_STATUS_FAILURE;
14236 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14238 {
14239 if( CSR_IS_SESSION_VALID( pMac, i ) )
14240 {
14241 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14242 {
14243 //Found it
14244 status = eHAL_STATUS_SUCCESS;
14245 *pSessionId = i;
14246 break;
14247 }
14248 }
14249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 return( status );
14251}
14252
Jeff Johnson295189b2012-06-20 16:38:30 -070014253//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14254//session because for IBSS, the bssid changes.
14255static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14256{
14257 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14258 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14260 {
14261 if( CSR_IS_SESSION_VALID( pMac, i ) )
14262 {
14263 pSession = CSR_GET_SESSION( pMac, i );
14264 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14265 {
14266 //Found it
14267 nRet = i;
14268 break;
14269 }
14270 }
14271 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 return (nRet);
14273}
Jeff Johnson295189b2012-06-20 16:38:30 -070014274static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14275{
14276 /* Update the current BSS info in ho control block based on connected
14277 profile info from pmac global structure */
14278
Arif Hussain24bafea2013-11-15 15:10:03 -080014279 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14280 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 /* Check for user misconfig of RSSI trigger threshold */
14282 pMac->roam.configParam.vccRssiThreshold =
14283 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14284 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14285 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 /* Check for user misconfig of UL MAC Loss trigger threshold */
14287 pMac->roam.configParam.vccUlMacLossThreshold =
14288 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14289 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014290#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14291 {
14292 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014293 /* Indicate the neighbor roal algorithm about the connect indication */
14294 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14295 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14296 }
14297#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014298}
14299
Jeff Johnson295189b2012-06-20 16:38:30 -070014300static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14301{
14302 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014303
14304 if(!pSession)
14305 {
14306 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14307 return;
14308 }
14309
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 //Only to handle the case for Handover on infra link
14311 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14312 {
14313 return;
14314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14316 csrRoamDeregStatisticsReq(pMac);
14317 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14318#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14319 /* Indicate the neighbor roal algorithm about the disconnect indication */
14320 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14321#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014322
14323 //Remove this code once SLM_Sessionization is supported
14324 //BMPS_WORKAROUND_NOT_NEEDED
14325 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014326 csrIsInfraApStarted( pMac ) &&
14327 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014328 {
14329 pMac->roam.configParam.doBMPSWorkaround = 0;
14330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014331}
14332
Jeff Johnson295189b2012-06-20 16:38:30 -070014333void csrRoamTlStatsTimerHandler(void *pv)
14334{
14335 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14336 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14338
Jeff Johnsone7245742012-09-05 17:12:55 -070014339 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14340
Jeff Johnson295189b2012-06-20 16:38:30 -070014341#if 0
14342 // TODO Persession .???
14343 //req TL for stats
14344 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014346 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 }
14348 else
14349 {
14350 //save in SME
14351 csrRoamSaveStatsFromTl(pMac, tlStats);
14352 }
14353#endif
14354 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14355 {
14356 if(pMac->roam.tlStatsReqInfo.periodicity)
14357 {
14358 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014359 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14360 pMac->roam.tlStatsReqInfo.periodicity);
14361 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014363 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 return;
14365 }
14366 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14367 }
14368 }
14369}
Jeff Johnson295189b2012-06-20 16:38:30 -070014370void csrRoamPeStatsTimerHandler(void *pv)
14371{
14372 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14373 eHalStatus status;
14374 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14375 VOS_STATUS vosStatus;
14376 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 pPeStatsReqListEntry->timerRunning = FALSE;
14378 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14379 {
14380 // If we entered here, meaning the timer could not be successfully
14381 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14382
14383 /* Destroy the timer */
14384 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14385 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14386 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014387 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 }
14389
14390 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014391 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014392 pPeStatsReqListEntry = NULL;
14393 }
14394 else
14395 {
14396 if(!pPeStatsReqListEntry->rspPending)
14397 {
14398 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14399 pPeStatsReqListEntry->staId);
14400 if(!HAL_STATUS_SUCCESS(status))
14401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014402 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 }
14404 else
14405 {
14406 pPeStatsReqListEntry->rspPending = TRUE;
14407 }
14408 }
14409
14410 //send down a req
14411 if(pPeStatsReqListEntry->periodicity &&
14412 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14413 {
14414 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14415 if(ePMC_FULL_POWER == powerState)
14416 {
14417 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14418 {
14419 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14420 }
14421 }
14422 else
14423 {
14424 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14425 {
14426 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14427 }
14428 }
14429 //start timer
14430 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14431 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014433 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014434 return;
14435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 pPeStatsReqListEntry->timerRunning = TRUE;
14437
14438 }
14439
14440 }
14441}
Jeff Johnson295189b2012-06-20 16:38:30 -070014442void csrRoamStatsClientTimerHandler(void *pv)
14443{
14444 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14446 {
14447#if 0
14448 // TODO Stats fix for multisession
14449 //start the timer
14450 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14451
14452 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014454 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 }
14456#endif
14457 }
14458#if 0
14459 //send up the stats report
14460 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14461 pStaEntry->staId, pStaEntry->pContext);
14462#endif
14463}
14464
14465
14466
Jeff Johnson295189b2012-06-20 16:38:30 -070014467eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14468{
14469 tAniGetPEStatsReq *pMsg;
14470 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014471 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14472 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014474 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014475 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014476 }
14477 // need to initiate a stats request to PE
14478 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14479 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14480 pMsg->staId = staId;
14481 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 if(!HAL_STATUS_SUCCESS(status))
14484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014485 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 return status;
14488}
Jeff Johnson295189b2012-06-20 16:38:30 -070014489void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14490{
14491 tAniGetPEStatsRsp *pSmeStatsRsp;
14492 eHalStatus status = eHAL_STATUS_FAILURE;
14493 tListElem *pEntry = NULL;
14494 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14495 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14496 tANI_U32 tempMask = 0;
14497 tANI_U8 counter = 0;
14498 tANI_U8 *pStats = NULL;
14499 tANI_U32 length = 0;
14500 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014501 v_S7_t rssi = 0, snr = 0;
14502 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014503 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014504 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14505 if(pSmeStatsRsp->rc)
14506 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014507 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 goto post_update;
14509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 tempMask = pSmeStatsRsp->statsMask;
14511 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 /* subtract all statistics from this length, and after processing the entire
14513 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14514 * in this 'stats' message.
14515 */
14516 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 //new stats info from PE, fill up the stats strucutres in PMAC
14518 while(tempMask)
14519 {
14520 if(tempMask & 1)
14521 {
14522 switch(counter)
14523 {
14524 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014525 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014526 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14527 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 pStats += sizeof(tCsrSummaryStatsInfo);
14529 length -= sizeof(tCsrSummaryStatsInfo);
14530 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014532 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014533 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14534 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14536 length -= sizeof(tCsrGlobalClassAStatsInfo);
14537 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014539 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014540 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14541 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014542 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14543 length -= sizeof(tCsrGlobalClassBStatsInfo);
14544 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014546 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014547 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14548 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14550 length -= sizeof(tCsrGlobalClassCStatsInfo);
14551 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014553 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14555 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014556 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14557 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 }
14559 else
14560 {
14561 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014562 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 VOS_ASSERT( 0 );
14564 }
14565 if(!HAL_STATUS_SUCCESS(status))
14566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014567 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 }
14569 pStats += sizeof(tCsrPerStaStatsInfo);
14570 length -= sizeof(tCsrPerStaStatsInfo);
14571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014573 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 }
14576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 tempMask >>=1;
14578 counter++;
14579 }
14580 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14581 if (length != 0)
14582 {
14583 pRssi = (tANI_U32*)pStats;
14584 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014585 pStats += sizeof(tANI_U32);
14586 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014587 }
14588 else
14589 {
14590 /* If riva is not sending rssi, continue to use the hack */
14591 rssi = RSSI_HACK_BMPS;
14592 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014593
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014595
14596 if (length != 0)
14597 {
14598 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014599 pStats += sizeof(tANI_U32);
14600 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014601 }
14602 else
14603 {
14604 linkCapacity = 0;
14605 }
14606
14607 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014608
14609 if (length != 0)
14610 {
14611 pSnr = (tANI_U32*)pStats;
14612 snr = (v_S7_t)*pSnr;
14613 }
14614 else
14615 {
14616 snr = SNR_HACK_BMPS;
14617 }
14618
14619 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014620post_update:
14621 //make sure to update the pe stats req list
14622 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14623 if(pEntry)
14624 {
14625 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14626 pPeStaEntry->rspPending = FALSE;
14627
14628 }
14629 //check the one timer cases
14630 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14631 if(pEntry)
14632 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014633 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014634 if(pTempStaEntry->timerExpired)
14635 {
14636 //send up the stats report
14637 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14638 pTempStaEntry->staId, pTempStaEntry->pContext);
14639 //also remove from the client list
14640 csrRoamRemoveStatListEntry(pMac, pEntry);
14641 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 }
14643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014644}
Jeff Johnson295189b2012-06-20 16:38:30 -070014645tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14646{
14647 tListElem *pEntry = NULL;
14648 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014649 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014650 if(!pEntry)
14651 {
14652 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014653 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 return NULL;
14655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014656 while( pEntry )
14657 {
14658 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014659 if(pTempStaEntry->statsMask == statsMask)
14660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014661 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014662 break;
14663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014664 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 return pEntry;
14667}
14668
Jeff Johnson295189b2012-06-20 16:38:30 -070014669tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14670 tANI_BOOLEAN update)
14671{
14672 tListElem *pEntry;
14673 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014674 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014675 if(!pEntry)
14676 {
14677 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014678 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014679 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 return NULL;
14681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014682 while( pEntry )
14683 {
14684 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14686 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014688 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 if(update)
14690 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014691 pTempStaEntry->periodicity = pStaEntry->periodicity;
14692 pTempStaEntry->callback = pStaEntry->callback;
14693 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 }
14695 break;
14696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014697 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 return pEntry;
14700}
Jeff Johnson295189b2012-06-20 16:38:30 -070014701tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14702{
14703 tListElem *pEntry;
14704 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014705 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 if(!pEntry)
14707 {
14708 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014709 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014710 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 return NULL;
14712 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 while( pEntry )
14714 {
14715 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014718 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014719 break;
14720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 return pEntry;
14724}
Jeff Johnson295189b2012-06-20 16:38:30 -070014725eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14726 csrRoamLinkQualityIndCallback callback,
14727 void *pContext)
14728{
14729 pMac->roam.linkQualityIndInfo.callback = callback;
14730 pMac->roam.linkQualityIndInfo.context = pContext;
14731 if( NULL == callback )
14732 {
14733 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14734 }
14735 else
14736 {
14737 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 /* do we need to invoke the callback to notify client of initial value ?? */
14739 }
14740 return eHAL_STATUS_SUCCESS;
14741}
Jeff Johnson295189b2012-06-20 16:38:30 -070014742void csrRoamVccTrigger(tpAniSirGlobal pMac)
14743{
14744 eCsrRoamLinkQualityInd newVccLinkQuality;
14745 tANI_U32 ul_mac_loss = 0;
14746 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14748 /*-------------------------------------------------------------------------
14749 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 Check for a change in link quality and notify client if necessary
14751 -------------------------------------------------------------------------*/
14752 ul_mac_loss_trigger_threshold =
14753 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014755 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014757 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014759 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14761 }
14762 else
14763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014764 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14766 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14768 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014771 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014774 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 newVccLinkQuality );
14776
14777 /* we now invoke the callback once to notify client of initial value */
14778 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14779 pMac->roam.linkQualityIndInfo.context );
14780 //event: EVENT_WLAN_VCC
14781 }
14782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 pMac->roam.vccLinkQuality = newVccLinkQuality;
14784
Jeff Johnson295189b2012-06-20 16:38:30 -070014785}
Jeff Johnson295189b2012-06-20 16:38:30 -070014786VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14787 v_U8_t rssiNotification,
14788 void * context)
14789{
14790 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14791 eCsrRoamLinkQualityInd newVccLinkQuality;
14792 // TODO : Session info unavailable
14793 tANI_U32 sessionId = 0;
14794 VOS_STATUS status = VOS_STATUS_SUCCESS;
14795 /*-------------------------------------------------------------------------
14796 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 Check for a change in link quality and notify client if necessary
14798 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014799 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 pMac->roam.configParam.vccRssiThreshold);
14801 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014803 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 return VOS_STATUS_SUCCESS;
14805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014808 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14810 }
14811 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014813 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14815 }
14816 else
14817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014818 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 //Set to this so the code below won't do anything
14820 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 VOS_ASSERT(0);
14822 }
14823
Jeff Johnson295189b2012-06-20 16:38:30 -070014824 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014826 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014829 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 /* we now invoke the callback once to notify client of initial value */
14832 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14833 pMac->roam.linkQualityIndInfo.context );
14834 //event: EVENT_WLAN_VCC
14835 }
14836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 return status;
14839}
Jeff Johnson295189b2012-06-20 16:38:30 -070014840tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14841 tDblLinkList *pStaList,
14842 tCsrStatsClientReqInfo *pStaEntry)
14843{
14844 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 //if same entity requested for same set of stats with different periodicity &
14846 // callback update it
14847 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14848 {
14849
Kiet Lam64c1b492013-07-12 13:56:44 +053014850 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14851 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 {
14853 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014854 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 return NULL;
14856 }
14857
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 pNewStaEntry->callback = pStaEntry->callback;
14859 pNewStaEntry->pContext = pStaEntry->pContext;
14860 pNewStaEntry->periodicity = pStaEntry->periodicity;
14861 pNewStaEntry->requesterId = pStaEntry->requesterId;
14862 pNewStaEntry->statsMask = pStaEntry->statsMask;
14863 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14864 pNewStaEntry->pMac = pStaEntry->pMac;
14865 pNewStaEntry->staId = pStaEntry->staId;
14866 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14867
14868 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14869 }
14870 return pNewStaEntry;
14871}
14872
Jeff Johnson295189b2012-06-20 16:38:30 -070014873tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14874 tDblLinkList *pStaList,
14875 tCsrPeStatsReqInfo *pStaEntry)
14876{
14877 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014878 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14879 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 {
14881 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014882 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 return NULL;
14884 }
14885
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14887 pNewStaEntry->numClient = pStaEntry->numClient;
14888 pNewStaEntry->periodicity = pStaEntry->periodicity;
14889 pNewStaEntry->statsMask = pStaEntry->statsMask;
14890 pNewStaEntry->pMac = pStaEntry->pMac;
14891 pNewStaEntry->staId = pStaEntry->staId;
14892 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14893 pNewStaEntry->rspPending = pStaEntry->rspPending;
14894
14895 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 return pNewStaEntry;
14897}
Jeff Johnson295189b2012-06-20 16:38:30 -070014898eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14899 tCsrRssiCallback callback,
14900 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14901{
14902 eHalStatus status = eHAL_STATUS_SUCCESS;
14903 vos_msg_t msg;
14904 tANI_U32 sessionId;
14905
14906 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014907 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014908 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14909 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014911 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014912 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14915
14916 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14917 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14918 pMsg->sessionId = sessionId;
14919 pMsg->staId = staId;
14920 pMsg->rssiCallback = callback;
14921 pMsg->pDevContext = pContext;
14922 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 msg.type = eWNI_SME_GET_RSSI_REQ;
14924 msg.bodyptr = pMsg;
14925 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014928 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014929 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 status = eHAL_STATUS_FAILURE;
14931 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014932 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 return status;
14934}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014935
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014936eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14937 tCsrSnrCallback callback,
14938 tANI_U8 staId, tCsrBssid bssId,
14939 void *pContext)
14940{
14941 eHalStatus status = eHAL_STATUS_SUCCESS;
14942 vos_msg_t msg;
14943 tANI_U32 sessionId;
14944
14945 tAniGetSnrReq *pMsg;
14946
14947 smsLog(pMac, LOG2, FL("called"));
14948
14949 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14950 if (NULL == pMsg )
14951 {
14952 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14953 return status;
14954 }
14955
14956 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14957
14958 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14959 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14960 pMsg->sessionId = sessionId;
14961 pMsg->staId = staId;
14962 pMsg->snrCallback = callback;
14963 pMsg->pDevContext = pContext;
14964 msg.type = eWNI_SME_GET_SNR_REQ;
14965 msg.bodyptr = pMsg;
14966 msg.reserved = 0;
14967
14968 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14969 {
14970 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14971 vos_mem_free((v_VOID_t *)pMsg);
14972 status = eHAL_STATUS_FAILURE;
14973 }
14974
14975 smsLog(pMac, LOG2, FL("returned"));
14976 return status;
14977}
14978
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014979#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14980eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14981 tCsrRssiCallback callback,
14982 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14983{
14984 eHalStatus status = eHAL_STATUS_SUCCESS;
14985 tAniGetRssiReq *pMsg;
14986
Kiet Lam64c1b492013-07-12 13:56:44 +053014987 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14988 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014989 {
14990 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053014991 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014992 }
14993 // need to initiate a stats request to PE
14994 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14995 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14996 pMsg->staId = staId;
14997 pMsg->rssiCallback = callback;
14998 pMsg->pDevContext = pContext;
14999 pMsg->pVosContext = pVosContext;
15000 status = palSendMBMessage(pMac->hHdd, pMsg );
15001 if(!HAL_STATUS_SUCCESS(status))
15002 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015003 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15004 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015005 status = eHAL_STATUS_FAILURE;
15006 }
15007 return status;
15008}
15009#endif
15010
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015011
15012
15013#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15014eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15015 tCsrTsmStatsCallback callback,
15016 tANI_U8 staId,
15017 tCsrBssid bssId,
15018 void *pContext,
15019 void* pVosContext,
15020 tANI_U8 tid)
15021{
15022 eHalStatus status = eHAL_STATUS_SUCCESS;
15023 tAniGetTsmStatsReq *pMsg = NULL;
15024
15025 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15026 if ( !HAL_STATUS_SUCCESS(status) )
15027 {
15028 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15029 return status;
15030 }
15031 // need to initiate a stats request to PE
15032 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15033 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15034 pMsg->staId = staId;
15035 pMsg->tid = tid;
15036 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15037 pMsg->tsmStatsCallback = callback;
15038 pMsg->pDevContext = pContext;
15039 pMsg->pVosContext = pVosContext;
15040 status = palSendMBMessage(pMac->hHdd, pMsg );
15041 if(!HAL_STATUS_SUCCESS(status))
15042 {
15043 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15044 //pMsg is freed by palSendMBMessage
15045 status = eHAL_STATUS_FAILURE;
15046 }
15047 return status;
15048}
15049#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15050
15051
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015052/* ---------------------------------------------------------------------------
15053 \fn csrGetTLSTAState
15054 \helper function to get teh TL STA State whenever the function is called.
15055
15056 \param staId - The staID to be passed to the TL
15057 to get the relevant TL STA State
15058 \return the state as tANI_U16
15059 ---------------------------------------------------------------------------*/
15060tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15061{
15062 WLANTL_STAStateType tlSTAState;
15063 tlSTAState = WLANTL_STA_INIT;
15064
15065 //request TL for STA State
15066 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15067 {
15068 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15069 }
15070
15071 return tlSTAState;
15072}
15073
Jeff Johnson295189b2012-06-20 16:38:30 -070015074eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15075 tANI_U32 statsMask,
15076 tCsrStatsCallback callback,
15077 tANI_U32 periodicity, tANI_BOOLEAN cache,
15078 tANI_U8 staId, void *pContext)
15079{
15080 tCsrStatsClientReqInfo staEntry;
15081 tCsrStatsClientReqInfo *pStaEntry = NULL;
15082 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15083 tListElem *pEntry = NULL;
15084 tANI_BOOLEAN found = FALSE;
15085 eHalStatus status = eHAL_STATUS_SUCCESS;
15086 tANI_BOOLEAN insertInClientList = FALSE;
15087 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015088 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015089
15090 if( csrIsAllSessionDisconnected(pMac) )
15091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015092 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015093 return eHAL_STATUS_FAILURE;
15094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 if((!statsMask) && (!callback))
15096 {
15097 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015098 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 return eHAL_STATUS_FAILURE;
15100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 //for the search list method for deregister
15102 staEntry.requesterId = requesterId;
15103 staEntry.statsMask = statsMask;
15104 //requester wants to deregister or just an error
15105 if((statsMask) && (!callback))
15106 {
15107 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15108 if(!pEntry)
15109 {
15110 //msg
15111 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015112 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 return eHAL_STATUS_FAILURE;
15114 }
15115 else
15116 {
15117 //clean up & return
15118 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015119 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015120 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015121 pStaEntry->pPeStaEntry->numClient--;
15122 //check if we need to delete the entry from peStatsReqList too
15123 if(!pStaEntry->pPeStaEntry->numClient)
15124 {
15125 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015128
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 //check if we need to stop the tl stats timer too
15130 pMac->roam.tlStatsReqInfo.numClient--;
15131 if(!pMac->roam.tlStatsReqInfo.numClient)
15132 {
15133 if(pMac->roam.tlStatsReqInfo.timerRunning)
15134 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015135 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15136 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015138 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 return eHAL_STATUS_FAILURE;
15140 }
15141 }
15142 pMac->roam.tlStatsReqInfo.periodicity = 0;
15143 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15144 }
15145 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 // Destroy the vos timer...
15147 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15148 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015150 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 csrRoamRemoveStatListEntry(pMac, pEntry);
15153 pStaEntry = NULL;
15154 return eHAL_STATUS_SUCCESS;
15155 }
15156 }
15157
15158 if(cache && !periodicity)
15159 {
15160 //return the cached stats
15161 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15162 }
15163 else
15164 {
15165 //add the request in the client req list
15166 staEntry.callback = callback;
15167 staEntry.pContext = pContext;
15168 staEntry.periodicity = periodicity;
15169 staEntry.pPeStaEntry = NULL;
15170 staEntry.staId = staId;
15171 staEntry.pMac = pMac;
15172 staEntry.timerExpired = FALSE;
15173
15174
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 //if periodic report requested with non cached result from PE/TL
15176 if(periodicity)
15177 {
15178
15179 //if looking for stats from PE
15180 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15181 {
15182
15183 //check if same request made already & waiting for rsp
15184 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15185 periodicity, &found, staId);
15186 if(!pPeStaEntry)
15187 {
15188 //bail out, maxed out on number of req for PE
15189 return eHAL_STATUS_FAILURE;
15190 }
15191 else
15192 {
15193 staEntry.pPeStaEntry = pPeStaEntry;
15194 }
15195
15196 }
15197 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15198 if(statsMask & (1 << eCsrGlobalClassDStats))
15199 {
15200 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015202 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015203 }
15204 else
15205 {
15206
15207 //update periodicity
15208 if(pMac->roam.tlStatsReqInfo.periodicity)
15209 {
15210 pMac->roam.tlStatsReqInfo.periodicity =
15211 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15212 }
15213 else
15214 {
15215 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15216 }
15217 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15218 {
15219 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15220 }
15221
15222 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15223 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015224 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015225 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015227 //req TL for class D stats
15228 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015230 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015231 }
15232 else
15233 {
15234 //save in SME
15235 csrRoamSaveStatsFromTl(pMac, pTlStats);
15236 }
15237 vos_mem_free(pTlStats);
15238 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015239 }
15240 else
15241 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015242 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015244
Jeff Johnson295189b2012-06-20 16:38:30 -070015245 if(pMac->roam.tlStatsReqInfo.periodicity)
15246 {
15247 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015248 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15249 pMac->roam.tlStatsReqInfo.periodicity);
15250 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015252 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 return eHAL_STATUS_FAILURE;
15254 }
15255 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15256 }
15257 }
15258 }
15259 pMac->roam.tlStatsReqInfo.numClient++;
15260 }
15261
15262 insertInClientList = TRUE;
15263 }
15264 //if one time report requested with non cached result from PE/TL
15265 else if(!cache && !periodicity)
15266 {
15267 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15268 {
15269 //send down a req
15270 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15271 if(!HAL_STATUS_SUCCESS(status))
15272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015273 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 }
15275 //so that when the stats rsp comes back from PE we respond to upper layer
15276 //right away
15277 staEntry.timerExpired = TRUE;
15278 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015279 }
15280 if(statsMask & (1 << eCsrGlobalClassDStats))
15281 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015282 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015283 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015285 //req TL for class D stats
15286 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015288 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015289 }
15290 else
15291 {
15292 //save in SME
15293 csrRoamSaveStatsFromTl(pMac, pTlStats);
15294 }
15295 vos_mem_free(pTlStats);
15296 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 }
15298 else
15299 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015300 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015302
15303 }
15304 //if looking for stats from TL only
15305 if(!insertInClientList)
15306 {
15307 //return the stats
15308 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 if(insertInClientList)
15312 {
15313 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15314 if(!pStaEntry)
15315 {
15316 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015317 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 return eHAL_STATUS_FAILURE;
15319 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015320 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 //Init & start timer if needed
15322 if(periodicity)
15323 {
15324 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15325 csrRoamStatsClientTimerHandler, pStaEntry );
15326 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015328 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015329 return eHAL_STATUS_FAILURE;
15330 }
15331 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15332 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015334 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 return eHAL_STATUS_FAILURE;
15336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 }
15340 return eHAL_STATUS_SUCCESS;
15341}
15342
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015343#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15344
15345static tSirRetStatus
15346csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15347 tANI_U8* pBD,
15348 tANI_U8 type,
15349 tANI_U8 subType,
15350 tSirMacAddr peerAddr,
15351 tSirMacAddr selfMacAddr)
15352{
15353 tSirRetStatus statusCode = eSIR_SUCCESS;
15354 tpSirMacMgmtHdr pMacHdr;
15355
15356 /* Prepare MAC management header */
15357 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15358
15359 /* Prepare FC */
15360 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15361 pMacHdr->fc.type = type;
15362 pMacHdr->fc.subType = subType;
15363
15364 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015365 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15366 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015367
15368 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15369
15370 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015371 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15372 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015373 return statusCode;
15374} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15375
15376static tSirRetStatus
15377csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15378 tANI_U8 nChannelNum,
15379 tANI_U32 dot11mode,
15380 tSirMacAddr selfMacAddr,
15381 tANI_U8 *pFrame,
15382 tANI_U16 *pusLen)
15383{
15384 tDot11fProbeRequest pr;
15385 tANI_U32 nStatus, nBytes, nPayload;
15386 tSirRetStatus nSirStatus;
15387 /*Bcast tx*/
15388 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15389 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15390
15391
Kiet Lam64c1b492013-07-12 13:56:44 +053015392 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015393
15394 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15395
15396 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15397 {
15398 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15399 }
15400
15401
15402 if (IS_DOT11_MODE_HT(dot11mode))
15403 {
15404 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15405 }
15406
15407
15408 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15409 if ( DOT11F_FAILED( nStatus ) )
15410 {
15411 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15412 "Failed to calculate the packed size f"
15413 "or a Probe Request (0x%08x).\n", nStatus );
15414
15415
15416 nPayload = sizeof( tDot11fProbeRequest );
15417 }
15418 else if ( DOT11F_WARNED( nStatus ) )
15419 {
15420 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15421 "There were warnings while calculating"
15422 "the packed size for a Probe Request ("
15423 "0x%08x).\n", nStatus );
15424 }
15425
15426 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15427
15428 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015429 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015430
15431
15432 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015433 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015434
15435 if ( eSIR_SUCCESS != nSirStatus )
15436 {
15437 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15438 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15439 nSirStatus );
15440 return nSirStatus;
15441 }
15442
15443
15444 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15445 sizeof( tSirMacMgmtHdr ),
15446 nPayload, &nPayload );
15447 if ( DOT11F_FAILED( nStatus ) )
15448 {
15449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15450 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15451 return eSIR_FAILURE;
15452 }
15453 else if ( DOT11F_WARNED( nStatus ) )
15454 {
15455 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015456 "There were warnings while packing a Probe Request (0x%08x).\n",
15457 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015458 }
15459
15460 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15461 return eSIR_SUCCESS;
15462}
15463
15464eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15465{
15466 vos_msg_t msg;
15467 tSirRoamOffloadScanReq *pRequestBuf;
15468 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15469 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015470 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015471 tANI_U8 *ChannelList = NULL;
15472 tANI_U32 sessionId;
15473 eHalStatus status = eHAL_STATUS_SUCCESS;
15474 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015475 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015476 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015477 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15478
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015479 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015480 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015481 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015482 return eHAL_STATUS_FAILURE;
15483 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015484
15485 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15486 {
15487 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15488 return eHAL_STATUS_FAILURE;
15489 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015490 status = csrRoamGetSessionIdFromBSSID(pMac,
15491 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15492 &sessionId);
15493 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15494 * It is important to ensure that the command is passed down to the FW only
15495 * if the Infra Station is in a connected state.A connected station could also be
15496 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15497 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15498 * irrespective of whichever state we are in.*/
15499 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15500 (command != ROAM_SCAN_OFFLOAD_STOP))
15501 {
15502 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15503 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15504 return eHAL_STATUS_FAILURE;
15505 }
15506
15507 if ( !HAL_STATUS_SUCCESS( status ) )
15508 {
15509 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15510 return eHAL_STATUS_FAILURE;
15511 }
15512 pSession = CSR_GET_SESSION( pMac, sessionId );
15513 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15514 if (NULL == pRequestBuf)
15515 {
15516 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15517 return eHAL_STATUS_FAILED_ALLOC;
15518 }
15519
Kiet Lam64c1b492013-07-12 13:56:44 +053015520 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015521 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15522 * host driver reloads, but Riva still up and running*/
15523 if(command == ROAM_SCAN_OFFLOAD_STOP)
15524 pRequestBuf->RoamScanOffloadEnabled = 0;
15525 else
15526 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015527 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15528 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015529 sizeof(tCsrBssid));
15530 pRequestBuf->ConnectedNetwork.ssId.length =
15531 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15532 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15533 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15534 pRequestBuf->ConnectedNetwork.ssId.length);
15535 pRequestBuf->ConnectedNetwork.authentication =
15536 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15537 pRequestBuf->ConnectedNetwork.encryption =
15538 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15539 pRequestBuf->ConnectedNetwork.mcencryption =
15540 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15541 pRequestBuf->LookupThreshold =
15542 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15543 pRequestBuf->RoamRssiDiff =
15544 pMac->roam.configParam.RoamRssiDiff;
15545 pRequestBuf->Command = command;
15546 pRequestBuf->StartScanReason = reason;
15547 pRequestBuf->NeighborScanTimerPeriod =
15548 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15549 pRequestBuf->NeighborRoamScanRefreshPeriod =
15550 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15551 pRequestBuf->NeighborScanChannelMinTime =
15552 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15553 pRequestBuf->NeighborScanChannelMaxTime =
15554 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15555 pRequestBuf->EmptyRefreshScanPeriod =
15556 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015557 /* MAWC feature */
15558 pRequestBuf->MAWCEnabled =
15559 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015560#ifdef FEATURE_WLAN_CCX
15561 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15562#endif
15563 if (
15564#ifdef FEATURE_WLAN_CCX
15565 ((pNeighborRoamInfo->isCCXAssoc) &&
15566 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15567 eANI_BOOLEAN_FALSE)) ||
15568 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15569#endif // CCX
15570 currChannelListInfo->numOfChannels == 0)
15571 {
15572
15573 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
15574 * Give Preference to INI Channels.*/
15575 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15576 {
15577 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15578 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
15579 {
15580 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15581 {
15582 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15583 }
15584 ChannelList++;
15585 }
15586 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15587 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15588 }
15589 else{
15590 ChannelList = pMac->scan.occupiedChannels.channelList;
15591 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15592 {
15593 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15594 {
15595 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15596 }
15597 ChannelList++;
15598 }
15599 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15600 /* If the profile changes as to what it was earlier, inform the FW through
15601 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15602 * for the earlier profile and try to learn them afresh.*/
15603 if (reason == REASON_FLUSH_CHANNEL_LIST)
15604 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15605 else {
15606 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15607 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15608 else
15609 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15610 }
15611 }
15612 }
15613#ifdef FEATURE_WLAN_CCX
15614 else
15615 {
15616 /* If CCX is enabled, and a neighbor Report is received,then
15617 * Ignore the INI Channels or the Occupied Channel List. Consider
15618 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015619 if (currChannelListInfo->numOfChannels != 0)
15620 {
15621 ChannelList = currChannelListInfo->ChannelList;
15622 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015623 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015624 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15625 {
15626 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15627 }
15628 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015629 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015630 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15631 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15632 }
15633 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015634#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015635 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15636 {
15637 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15638 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15639 }
15640 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15641 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15642 pRequestBuf->ChannelCacheType,
15643 pRequestBuf->ConnectedNetwork.ChannelCount,
15644 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015645 num_channels = 0;
15646 ChannelList = NULL;
15647
15648 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015649 host_channels = sizeof(pMac->roam.validChannelList);
15650 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015651 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015652 ChannelList = pMac->roam.validChannelList;
15653 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015654 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015655 else
15656 {
15657 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15658 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015659 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015660 return eHAL_STATUS_FAILURE;
15661 }
15662 for(i=0; i<pMac->roam.numValidChannels; i++)
15663 {
15664 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15665 {
15666 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15667 }
15668 ChannelList++;
15669 }
15670 pRequestBuf->ValidChannelCount = num_channels;
15671
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015672 pRequestBuf->MDID.mdiePresent =
15673 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15674 pRequestBuf->MDID.mobilityDomain =
15675 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015676 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15677
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015678 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015679
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015680 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15681 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15682 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15683 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15684 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15685
15686 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15687 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015688 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015689 msg.reserved = 0;
15690 msg.bodyptr = pRequestBuf;
15691 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15692 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015693 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15694 vos_mem_free(pRequestBuf);
15695 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015696 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015697 else
15698 {
15699 if (ROAM_SCAN_OFFLOAD_START == command)
15700 bRoamScanOffloadStarted = VOS_TRUE;
15701 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15702 bRoamScanOffloadStarted = VOS_FALSE;
15703 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015704
15705 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15706 return status;
15707}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015708
15709eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15710{
15711 switch(reason)
15712 {
15713 case 0:
15714 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15715 break;
15716 case REASON_OS_REQUESTED_ROAMING_NOW:
15717 csrNeighborRoamProceedWithHandoffReq(pMac);
15718 break;
15719 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015720 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 -070015721 }
15722 return eHAL_STATUS_SUCCESS;
15723}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015724#endif
15725
Jeff Johnson295189b2012-06-20 16:38:30 -070015726tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15727 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15728{
15729 tANI_BOOLEAN found = FALSE;
15730 eHalStatus status = eHAL_STATUS_SUCCESS;
15731 tCsrPeStatsReqInfo staEntry;
15732 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15733 tListElem *pStaEntry = NULL;
15734 VOS_STATUS vosStatus;
15735 tPmcPowerState powerState;
15736 *pFound = FALSE;
15737
15738 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15739 if(pStaEntry)
15740 {
15741 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15742 if(pTempStaEntry->periodicity)
15743 {
15744 pTempStaEntry->periodicity =
15745 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15746 }
15747 else
15748 {
15749 pTempStaEntry->periodicity = periodicity;
15750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015751 pTempStaEntry->numClient++;
15752 found = TRUE;
15753 }
15754 else
15755 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015756 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015757 staEntry.numClient = 1;
15758 staEntry.periodicity = periodicity;
15759 staEntry.pMac = pMac;
15760 staEntry.rspPending = FALSE;
15761 staEntry.staId = staId;
15762 staEntry.statsMask = statsMask;
15763 staEntry.timerRunning = FALSE;
15764 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15765 if(!pTempStaEntry)
15766 {
15767 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015768 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015769 return NULL;
15770 }
15771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015772 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15773 if(ePMC_FULL_POWER == powerState)
15774 {
15775 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15776 {
15777 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15778 }
15779 }
15780 else
15781 {
15782 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15783 {
15784 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15785 }
15786 }
15787 if(!pTempStaEntry->timerRunning)
15788 {
15789 //send down a req in case of one time req, for periodic ones wait for timer to expire
15790 if(!pTempStaEntry->rspPending &&
15791 !pTempStaEntry->periodicity)
15792 {
15793 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15794 if(!HAL_STATUS_SUCCESS(status))
15795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015796 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015797 }
15798 else
15799 {
15800 pTempStaEntry->rspPending = TRUE;
15801 }
15802 }
15803 if(pTempStaEntry->periodicity)
15804 {
15805 if(!found)
15806 {
15807
15808 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15809 csrRoamPeStatsTimerHandler, pTempStaEntry );
15810 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015812 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015813 return NULL;
15814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 }
15816 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015817 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015818 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15819 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015821 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015822 return NULL;
15823 }
15824 pTempStaEntry->timerRunning = TRUE;
15825 }
15826 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015827 *pFound = found;
15828 return pTempStaEntry;
15829}
15830
Jeff Johnson295189b2012-06-20 16:38:30 -070015831/*
15832 pStaEntry is no longer invalid upon the return of this function.
15833*/
15834static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15835{
15836 if(pEntry)
15837 {
15838 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15839 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015840 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015841 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 }
15843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015844
15845void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15846{
15847 tListElem *pEntry;
15848 tCsrPeStatsReqInfo *pTempStaEntry;
15849 VOS_STATUS vosStatus;
15850 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 if(!pEntry)
15852 {
15853 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015854 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015855 return;
15856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 while( pEntry )
15858 {
15859 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015860 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015862 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 if(pTempStaEntry->timerRunning)
15864 {
15865 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15866 /* If we are not able to stop the timer here, just remove
15867 * the entry from the linked list. Destroy the timer object
15868 * and free the memory in the timer CB
15869 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015870 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 {
15872 /* the timer is successfully stopped */
15873 pTempStaEntry->timerRunning = FALSE;
15874
15875 /* Destroy the timer */
15876 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15877 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015879 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 }
15881 }
15882 else
15883 {
15884 // the timer could not be stopped. Hence destroy and free the
15885 // memory for the PE stat entry in the timer CB.
15886 pTempStaEntry->timerStopFailed = TRUE;
15887 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015889
15890 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15891 {
15892 // Only free the memory if we could stop the timer successfully
15893 if(!pTempStaEntry->timerStopFailed)
15894 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015895 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 pTempStaEntry = NULL;
15897 }
15898 break;
15899 }
15900
15901 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15902 }
15903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 return;
15905}
15906
15907
Jeff Johnsone7245742012-09-05 17:12:55 -070015908void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015909{
15910
Jeff Johnsone7245742012-09-05 17:12:55 -070015911 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15912 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15913 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15914 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15915 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15916 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15917 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015918 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015919 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15920 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15921 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15922 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15923 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15924 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015925 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015926 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15927 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015928
15929}
15930
Jeff Johnson295189b2012-06-20 16:38:30 -070015931void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15932 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15933{
15934 tANI_U8 stats[500];
15935 tANI_U8 *pStats = NULL;
15936 tANI_U32 tempMask = 0;
15937 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015938 if(!callback)
15939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015940 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 return;
15942 }
15943 if(!statsMask)
15944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015945 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015946 return;
15947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015948 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015949 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015950 while(tempMask)
15951 {
15952 if(tempMask & 1)
15953 {
15954 //new stats info from PE, fill up the stats strucutres in PMAC
15955 switch(counter)
15956 {
15957 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015958 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015959 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15960 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015961 pStats += sizeof(tCsrSummaryStatsInfo);
15962 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015963 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015964 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015965 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15966 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015967 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015968 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015970 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015971 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15972 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015973 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015975 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015976 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015977 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15978 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015979 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015980 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015981 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015982 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015983 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15984 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015986 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015987 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015988 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015989 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15990 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015991 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015992 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015994 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015996 }
15997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 tempMask >>=1;
15999 counter++;
16000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016002}
16003
Jeff Johnson295189b2012-06-20 16:38:30 -070016004eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16005{
16006 tListElem *pEntry = NULL;
16007 tListElem *pPrevEntry = NULL;
16008 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16009 eHalStatus status = eHAL_STATUS_SUCCESS;
16010 VOS_STATUS vosStatus;
16011 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 if(!pEntry)
16013 {
16014 //list empty
16015 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016016 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016017 return status;
16018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 while( pEntry )
16020 {
16021 if(pPrevEntry)
16022 {
16023 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16024 //send up the stats report
16025 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16026 pTempStaEntry->staId, pTempStaEntry->pContext);
16027 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016030 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16031 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016032 pTempStaEntry->pPeStaEntry->numClient--;
16033 //check if we need to delete the entry from peStatsReqList too
16034 if(!pTempStaEntry->pPeStaEntry->numClient)
16035 {
16036 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 //check if we need to stop the tl stats timer too
16040 pMac->roam.tlStatsReqInfo.numClient--;
16041 if(!pMac->roam.tlStatsReqInfo.numClient)
16042 {
16043 if(pMac->roam.tlStatsReqInfo.timerRunning)
16044 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016045 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16046 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016048 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016049 //we will continue
16050 }
16051 }
16052 pMac->roam.tlStatsReqInfo.periodicity = 0;
16053 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016055 if (pTempStaEntry->periodicity)
16056 {
16057 //While creating StaEntry in csrGetStatistics,
16058 //Initializing and starting timer only when periodicity is set.
16059 //So Stop and Destroy timer only when periodicity is set.
16060
Jeff Johnsone7245742012-09-05 17:12:55 -070016061 vos_timer_stop( &pTempStaEntry->timer );
16062 // Destroy the vos timer...
16063 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16064 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016066 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016068 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016069
Jeff Johnson295189b2012-06-20 16:38:30 -070016070
16071 pPrevEntry = pEntry;
16072 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16073 }
16074 //the last one
16075 if(pPrevEntry)
16076 {
16077 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16078 //send up the stats report
16079 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16080 pTempStaEntry->staId, pTempStaEntry->pContext);
16081 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016083 return status;
16084
16085}
16086
Jeff Johnson295189b2012-06-20 16:38:30 -070016087eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16088 tRequestFullPowerReason *pReason,
16089 tANI_BOOLEAN *pfNeedPower )
16090{
16091 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16092 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16093 tPmcState pmcState;
16094 eHalStatus status = eHAL_STATUS_SUCCESS;
16095 // TODO : Session info unavailable
16096 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016097 if( pfNeedPower )
16098 {
16099 *pfNeedPower = eANI_BOOLEAN_FALSE;
16100 }
16101 //We only handle CSR commands
16102 if( !(eSmeCsrCommandMask & pCommand->command) )
16103 {
16104 return eHAL_STATUS_SUCCESS;
16105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016106 //Check PMC state first
16107 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016108 switch( pmcState )
16109 {
16110 case REQUEST_IMPS:
16111 case IMPS:
16112 if( eSmeCommandScan == pCommand->command )
16113 {
16114 switch( pCommand->u.scanCmd.reason )
16115 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016116#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16117 case eCsrScanGetLfrResult:
16118#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016119 case eCsrScanGetResult:
16120 case eCsrScanBGScanAbort:
16121 case eCsrScanBGScanEnable:
16122 case eCsrScanGetScanChnInfo:
16123 //Internal process, no need for full power
16124 fNeedFullPower = eANI_BOOLEAN_FALSE;
16125 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016126 default:
16127 //Other scans are real scan, ask for power
16128 fNeedFullPower = eANI_BOOLEAN_TRUE;
16129 break;
16130 } //switch
16131 }
16132 else
16133 {
16134 //ask for power for roam and status change
16135 fNeedFullPower = eANI_BOOLEAN_TRUE;
16136 }
16137 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016138 case REQUEST_BMPS:
16139 case BMPS:
16140 case REQUEST_START_UAPSD:
16141 case UAPSD:
16142 //We treat WOWL same as BMPS
16143 case REQUEST_ENTER_WOWL:
16144 case WOWL:
16145 if( eSmeCommandRoam == pCommand->command )
16146 {
16147 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16148 tCsrScanResult *pScanResult;
16149 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016150 switch ( pCommand->u.roamCmd.roamReason )
16151 {
16152 case eCsrForcedDisassoc:
16153 case eCsrForcedDisassocMICFailure:
16154 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16155 fNeedFullPower = eANI_BOOLEAN_TRUE;
16156 break;
16157 case eCsrSmeIssuedDisassocForHandoff:
16158 case eCsrForcedDeauth:
16159 case eCsrHddIssuedReassocToSameAP:
16160 case eCsrSmeIssuedReassocToSameAP:
16161 fNeedFullPower = eANI_BOOLEAN_TRUE;
16162 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016163 case eCsrCapsChange:
16164 fNeedFullPower = eANI_BOOLEAN_TRUE;
16165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016166 default:
16167 //Check whether the profile is already connected. If so, no need for full power
16168 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16169 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16170 {
16171 //Only need to check the first one
16172 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16173 if( pEntry )
16174 {
16175 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16176#if 0
16177 // TODO : Session Specific info pConnectBssDesc
16178 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16179 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16180 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16181 {
16182 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16183 // with Authenticating first. To force this, stop the current association (Disassociate) and
16184 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16185 // a new Association.
16186 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16187 {
16188 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16189 {
16190 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16191 //No need for full power
16192 //Set the flag so the code later can avoid to do the above
16193 //check again.
16194 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16195 break;
16196 }
16197 }
16198 }
16199#endif
16200 }
16201 }
16202 //If we are here, full power is needed
16203 fNeedFullPower = eANI_BOOLEAN_TRUE;
16204 break;
16205 }
16206 }
16207 else if( eSmeCommandWmStatusChange == pCommand->command )
16208 {
16209 //need full power for all
16210 fNeedFullPower = eANI_BOOLEAN_TRUE;
16211 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16212 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016213#ifdef FEATURE_WLAN_TDLS
16214 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16215 {
16216 //TDLS link is getting established. need full power
16217 fNeedFullPower = eANI_BOOLEAN_TRUE;
16218 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16219 }
16220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016222 case REQUEST_STOP_UAPSD:
16223 case REQUEST_EXIT_WOWL:
16224 if( eSmeCommandRoam == pCommand->command )
16225 {
16226 fNeedFullPower = eANI_BOOLEAN_TRUE;
16227 switch ( pCommand->u.roamCmd.roamReason )
16228 {
16229 case eCsrForcedDisassoc:
16230 case eCsrForcedDisassocMICFailure:
16231 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16232 break;
16233 default:
16234 break;
16235 }
16236 }
16237 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016238 case STOPPED:
16239 case REQUEST_STANDBY:
16240 case STANDBY:
16241 case LOW_POWER:
16242 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016243 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016244 status = eHAL_STATUS_FAILURE;
16245 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016246 case FULL_POWER:
16247 case REQUEST_FULL_POWER:
16248 default:
16249 //No need to ask for full power. This has to be FULL_POWER state
16250 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016251 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016252 if( pReason )
16253 {
16254 *pReason = reason;
16255 }
16256 if( pfNeedPower )
16257 {
16258 *pfNeedPower = fNeedFullPower;
16259 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016260 return ( status );
16261}
16262
Jeff Johnson295189b2012-06-20 16:38:30 -070016263static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16264{
16265 eHalStatus status = eHAL_STATUS_SUCCESS;
16266 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16267 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016268 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016269 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16270 {
16271 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16272 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016273 return ( status );
16274}
16275
Jeff Johnson295189b2012-06-20 16:38:30 -070016276tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16277{
16278 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016279 if( pCmd )
16280 {
16281 pMac->roam.sPendingCommands++;
16282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016283 return ( pCmd );
16284}
16285
Jeff Johnson295189b2012-06-20 16:38:30 -070016286void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16287{
16288 if (pMac->roam.sPendingCommands > 0)
16289 {
16290 //All command allocated through csrGetCommandBuffer need to
16291 //decrement the pending count when releasing.
16292 pMac->roam.sPendingCommands--;
16293 smeReleaseCommand( pMac, pCommand );
16294 }
16295 else
16296 {
16297 smsLog(pMac, LOGE, FL( "no pending commands"));
16298 VOS_ASSERT(0);
16299 }
16300}
16301
Jeff Johnson295189b2012-06-20 16:38:30 -070016302//Return SUCCESS is the command is queued, failed
16303eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16304{
16305 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016306 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16307 {
16308 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16309 pCommand->u.scanCmd.reason);
16310 return eHAL_STATUS_CSR_WRONG_STATE;
16311 }
16312
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016313 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16314 {
16315 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16316 &pCommand->Link, LL_ACCESS_LOCK);
16317 // process the command queue...
16318 smeProcessPendingQueue(pMac);
16319 status = eHAL_STATUS_SUCCESS;
16320 goto end;
16321 }
16322
Jeff Johnson295189b2012-06-20 16:38:30 -070016323 //We can call request full power first before putting the command into pending Q
16324 //because we are holding SME lock at this point.
16325 status = csrRequestFullPower( pMac, pCommand );
16326 if( HAL_STATUS_SUCCESS( status ) )
16327 {
16328 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016329 //make sure roamCmdPendingList is not empty first
16330 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16331 if( fNoCmdPending )
16332 {
16333 smePushCommand( pMac, pCommand, fHighPriority );
16334 }
16335 else
16336 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016337 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 //no list lock is needed since SME lock is held
16339 if( !fHighPriority )
16340 {
16341 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16342 }
16343 else {
16344 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16345 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016347 }
16348 else if( eHAL_STATUS_PMC_PENDING == status )
16349 {
16350 //no list lock is needed since SME lock is held
16351 if( !fHighPriority )
16352 {
16353 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16354 }
16355 else {
16356 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16357 }
16358 //Let caller know the command is queue
16359 status = eHAL_STATUS_SUCCESS;
16360 }
16361 else
16362 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016363 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016364 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016365 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016366 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016367end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016368 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016369}
Jeff Johnson295189b2012-06-20 16:38:30 -070016370eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16371{
16372 eHalStatus status = eHAL_STATUS_SUCCESS;
16373 tSirUpdateAPWPSIEsReq *pMsg;
16374 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16375
16376 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16377 if (NULL == pSession)
16378 {
16379 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16380 return eHAL_STATUS_FAILURE;
16381 }
16382
Jeff Johnson295189b2012-06-20 16:38:30 -070016383 do
16384 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016385 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16386 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16387 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016388 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16389
16390 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016391 VOS_ASSERT(pBuf);
16392
Jeff Johnson295189b2012-06-20 16:38:30 -070016393 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016394 // transactionId
16395 *pBuf = 0;
16396 *( pBuf + 1 ) = 0;
16397 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016398 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016399 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16400 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016401 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016402 //sessionId
16403 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016404 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016405 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016407 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016410 return ( status );
16411}
Jeff Johnson295189b2012-06-20 16:38:30 -070016412eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16413{
16414 eHalStatus status = eHAL_STATUS_SUCCESS;
16415 tSirUpdateAPWPARSNIEsReq *pMsg;
16416 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16418 if (NULL == pSession)
16419 {
16420 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16421 return eHAL_STATUS_FAILURE;
16422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016423 do
16424 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016425 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16426 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16427 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016428 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 pBuf = (tANI_U8 *)&pMsg->transactionId;
16430 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016431 // transactionId
16432 *pBuf = 0;
16433 *( pBuf + 1 ) = 0;
16434 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016435 VOS_ASSERT(pBuf);
16436
Jeff Johnson295189b2012-06-20 16:38:30 -070016437 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016438 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16439 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016441 // sessionId
16442 *pBuf++ = (tANI_U8)sessionId;
16443
16444 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016445 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016447 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 return ( status );
16451}
Jeff Johnson295189b2012-06-20 16:38:30 -070016452
16453#ifdef WLAN_FEATURE_VOWIFI_11R
16454//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16455eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16456{
16457 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16458 tpSirFTPreAuthReq pftPreAuthReq;
16459 tANI_U16 auth_req_len = 0;
16460 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 auth_req_len = sizeof(tSirFTPreAuthReq);
16462 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016463 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016464 {
16465 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16466 return eHAL_STATUS_RESOURCES;
16467 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 // Save the SME Session ID here. We need it while processing the preauth response
16469 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016470 vos_mem_zero(pftPreAuthReq, auth_req_len);
16471
16472 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16473 sizeof(pBssDescription->length) + pBssDescription->length);
16474
16475 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16476
16477 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16478
Kiet Lam64c1b492013-07-12 13:56:44 +053016479 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16480 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16481 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16482 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016483
Jeff Johnson295189b2012-06-20 16:38:30 -070016484#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016485 if (csrRoamIs11rAssoc(pMac) &&
16486 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 {
16488 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016489 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16490 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016491 }
16492 else
16493#endif
16494 {
16495 pftPreAuthReq->ft_ies_length = 0;
16496 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016497 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16498 sizeof(pBssDescription->length) + pBssDescription->length);
16499 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016500 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16501}
Jeff Johnson295189b2012-06-20 16:38:30 -070016502/*--------------------------------------------------------------------------
16503 * This will receive and process the FT Pre Auth Rsp from the current
16504 * associated ap.
16505 *
16506 * This will invoke the hdd call back. This is so that hdd can now
16507 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16508 ------------------------------------------------------------------------*/
16509void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16510{
16511 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16512 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016513#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016514 tCsrRoamInfo roamInfo;
16515#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016516
16517#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016518 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016519#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016520#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016521 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016522 if (status != eHAL_STATUS_SUCCESS) {
16523 /*
16524 * Bail out if pre-auth was not even processed.
16525 */
16526 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16527 return;
16528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016529#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016530 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16531 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16532 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 // Implies a success
16534 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16536 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016537 /* No need to notify qos module if this is a non 11r roam*/
16538 if (csrRoamIs11rAssoc(pMac))
16539 {
16540 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016542 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16543 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016544 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16545 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 if (eHAL_STATUS_SUCCESS != status)
16547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016548 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016549 return;
16550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016551 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016552 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16553 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016554 if (csrRoamIs11rAssoc(pMac))
16555 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16556 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16557
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016558#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16559 if (csrRoamIsCCXAssoc(pMac))
16560 {
16561 /* read TSF */
16562 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16563
16564 // Save the bssid from the received response
16565 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16566 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16567 }
16568#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016569#ifdef FEATURE_WLAN_LFR
16570 // If Legacy Fast Roaming is enabled, signal the supplicant
16571 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016572 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016573 {
16574 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016575 vos_mem_copy((void *)&roamInfo.bssid,
16576 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016577 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16578 }
16579
16580#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016581
16582 // Done with it, init it.
16583 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16584}
16585#endif
16586#ifdef FEATURE_WLAN_BTAMP_UT_RF
16587void csrRoamJoinRetryTimerHandler(void *pv)
16588{
16589 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16590 tpAniSirGlobal pMac = pInfo->pMac;
16591 tANI_U32 sessionId = pInfo->sessionId;
16592 tCsrRoamSession *pSession;
16593
16594 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016596 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 pSession = CSR_GET_SESSION( pMac, sessionId );
16598 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16599 {
16600 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016602 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 }
16604 }
16605 }
16606}
Jeff Johnson295189b2012-06-20 16:38:30 -070016607eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16608{
16609 eHalStatus status = eHAL_STATUS_FAILURE;
16610 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16611
16612 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016614 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016615 pSession->maxRetryCount--;
16616 pSession->joinRetryTimerInfo.pMac = pMac;
16617 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016618 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16619 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016620 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016621 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016622 }
16623 }
16624 else
16625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016626 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016627 pSession->maxRetryCount);
16628 }
16629
16630 return (status);
16631}
Jeff Johnson295189b2012-06-20 16:38:30 -070016632eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16633{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016634 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016635 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16636 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016637 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016638 }
16639
16640 return eHAL_STATUS_SUCCESS;
16641}
16642#endif
16643
16644
16645/*
16646 pBuf points to the beginning of the message
16647 LIM packs disassoc rsp as below,
16648 messageType - 2 bytes
16649 messageLength - 2 bytes
16650 sessionId - 1 byte
16651 transactionId - 2 bytes (tANI_U16)
16652 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16653 peerMacAddr - 6 bytes
16654 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16655*/
16656static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16657{
16658 if(pBuf && pRsp)
16659 {
16660 pBuf += 4; //skip type and length
16661 pRsp->sessionId = *pBuf++;
16662 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16663 pBuf += 2;
16664 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16665 pBuf += 4;
16666 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16667 }
16668}
16669
Jeff Johnsond13512a2012-07-17 11:42:19 -070016670eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16671{
16672 static uNvTables nvTables;
16673 eHalStatus status = eHAL_STATUS_SUCCESS;
16674 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16675
16676 /* read the country code from NV and use it */
16677 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16678 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016679 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16680 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016681 return status;
16682 }
16683 else
16684 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016685 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016686 status = eHAL_STATUS_FAILURE;
16687 return status;
16688 }
16689}
16690
16691eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16692{
Kiet Lam64c1b492013-07-12 13:56:44 +053016693 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016694 return eHAL_STATUS_SUCCESS;
16695}
schang86c22c42013-03-13 18:41:24 -070016696
16697eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16698{
16699 tSirSetTxPowerReq *pMsg = NULL;
16700 eHalStatus status = eHAL_STATUS_SUCCESS;
16701 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16702
16703 if (!pSession)
16704 {
16705 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16706 return eHAL_STATUS_FAILURE;
16707 }
16708
Kiet Lam64c1b492013-07-12 13:56:44 +053016709 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16710 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16711 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16712 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16713 pMsg->length = sizeof(tSirSetTxPowerReq);
16714 pMsg->mwPower = mW;
16715 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16716 sizeof(tSirMacAddr));
16717 status = palSendMBMessage(pMac->hHdd, pMsg);
16718 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016719 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016720 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16721 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016722 }
16723 return status;
16724}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016725
16726/* Returns whether a session is in VOS_STA_MODE...or not */
16727tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16728{
16729 tCsrRoamSession *pSession = NULL;
16730 pSession = CSR_GET_SESSION ( pMac, sessionId );
16731 if(!pSession)
16732 {
16733 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16734 return eANI_BOOLEAN_FALSE;
16735 }
16736 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16737 {
16738 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16739 return eANI_BOOLEAN_FALSE;
16740 }
16741 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16742 {
16743 return eANI_BOOLEAN_FALSE;
16744 }
16745 /* There is a possibility that the above check may fail,because
16746 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16747 * when it is connected.So,we may sneak through the above check even
16748 * if we are not a STA mode INFRA station. So, if we sneak through
16749 * the above condition, we can use the following check if we are
16750 * really in STA Mode.*/
16751
16752 if ( NULL != pSession->pCurRoamProfile )
16753 {
16754 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16755 {
16756 return eANI_BOOLEAN_TRUE;
16757 } else {
16758 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16759 return eANI_BOOLEAN_FALSE;
16760 }
16761 }
16762
16763 return eANI_BOOLEAN_FALSE;
16764}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016765
16766#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16767eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16768 tCsrHandoffRequest *pHandoffInfo)
16769{
16770 eHalStatus status = eHAL_STATUS_SUCCESS;
16771 vos_msg_t msg;
16772
16773 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016774 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16775 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016776 {
16777 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016778 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016779 }
16780 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16781 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16782 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16783 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016784 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016785 pHandoffInfo->bssid,
16786 6);
16787 msg.type = eWNI_SME_HANDOFF_REQ;
16788 msg.bodyptr = pMsg;
16789 msg.reserved = 0;
16790 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16791 {
16792 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016793 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016794 status = eHAL_STATUS_FAILURE;
16795 }
16796 return status;
16797}
16798#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016799
16800#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16801/* ---------------------------------------------------------------------------
16802 \fn csrSetCCKMIe
16803 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16804 data structure and this IE will be packed inside reassociation request
16805 \param pMac - pMac global structure
16806 \param sessionId - Current session id
16807 \param pCckmIe - pointer to CCKM IE data
16808 \param ccKmIeLen - length of the CCKM IE
16809 \- return Success or failure
16810 -------------------------------------------------------------------------*/
16811VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16812 const tANI_U8 *pCckmIe,
16813 const tANI_U8 ccKmIeLen)
16814{
16815 eHalStatus status = eHAL_STATUS_SUCCESS;
16816 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16817
16818 if (!pSession)
16819 {
16820 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16821 return eHAL_STATUS_FAILURE;
16822 }
16823 palCopyMemory(pMac->hHdd, pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
16824 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16825 return status;
16826}
16827
16828/* ---------------------------------------------------------------------------
16829 \fn csrRoamReadTSF
16830 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16831 probe response reception from the hand off AP to arrive at the latest TSF value.
16832 \param pMac - pMac global structure
16833 \param pTimestamp - output TSF timestamp
16834 \- return Success or failure
16835 -------------------------------------------------------------------------*/
16836VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16837{
16838 eHalStatus status = eHAL_STATUS_SUCCESS;
16839 tCsrNeighborRoamBSSInfo handoffNode;
16840 tANI_U32 timer_diff = 0;
16841 tANI_U32 timeStamp[2];
16842 tpSirBssDescription pBssDescription = NULL;
16843
16844 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16845 pBssDescription = handoffNode.pBssDescription;
16846
16847 // Get the time diff in milli seconds
16848 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16849 // Convert msec to micro sec timer
16850 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16851
16852 timeStamp[0] = pBssDescription->timeStamp[0];
16853 timeStamp[1] = pBssDescription->timeStamp[1];
16854
16855 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16856
16857 palCopyMemory(pMac->hHdd, pTimestamp, (void *) &timeStamp[0],
16858 sizeof (tANI_U32) * 2);
16859 return status;
16860}
16861
16862#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16863