blob: 2174d2d65b0fd6238c2ddd4fcee49a112d2eae11 [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;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008968 smsLog(pMac, LOG1, "Bssid(%02X:%02X:%02X:%02X:%02X:%02X) Roaming Delay(%u ms)",
8969 pSession->connectedProfile.bssid[0], pSession->connectedProfile.bssid[1],
8970 pSession->connectedProfile.bssid[2], pSession->connectedProfile.bssid[3],
8971 pSession->connectedProfile.bssid[4], pSession->connectedProfile.bssid[5],
8972 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008973
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008974 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
8975 if (NULL == pSessionEntry)
8976 {
8977 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
8978 return;
8979 }
8980 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008981 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
8982 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
8983}
8984#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
8985
Jeff Johnsone7245742012-09-05 17:12:55 -07008986static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8987{
8988 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8989 if(pTlRssiInd)
8990 {
8991 if(NULL != pTlRssiInd->tlCallback)
8992 {
8993 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008994 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008995 }
8996 else
8997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008998 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008999 }
9000 }
9001 else
9002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009003 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009004 }
9005 return;
9006}
Jeff Johnson295189b2012-06-20 16:38:30 -07009007
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309008eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9009{
9010 tpSirResetAPCapsChange pMsg;
9011 tANI_U16 len;
9012 eHalStatus status = eHAL_STATUS_SUCCESS;
9013
9014 /* Create the message and send to lim */
9015 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309016 pMsg = vos_mem_malloc(len);
9017 if ( NULL == pMsg )
9018 status = eHAL_STATUS_FAILURE;
9019 else
9020 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309021 if (HAL_STATUS_SUCCESS(status))
9022 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309023 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309024 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9025 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309026 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009027 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9028 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309029 status = palSendMBMessage(pMac->hHdd, pMsg);
9030 }
9031 else
9032 {
9033 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9034 }
9035 return status;
9036}
9037
Jeff Johnson295189b2012-06-20 16:38:30 -07009038void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9039{
9040 tSirSmeAssocInd *pAssocInd;
9041 tSirSmeDisassocInd *pDisassocInd;
9042 tSirSmeDeauthInd *pDeauthInd;
9043 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9044 tSirSmeNewBssInfo *pNewBss;
9045 tSmeIbssPeerInd *pIbssPeerInd;
9046 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9047 tSirSmeApNewCaps *pApNewCaps;
9048 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9049 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9050 tCsrRoamInfo *pRoamInfo = NULL;
9051 tCsrRoamInfo roamInfo;
9052 eHalStatus status;
9053 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9054 tCsrRoamSession *pSession = NULL;
9055 tpSirSmeSwitchChannelInd pSwitchChnInd;
9056 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009057 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 pSirMsg->messageType = (pSirMsg->messageType);
9059 pSirMsg->length = (pSirMsg->length);
9060 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309061 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 switch( pSirMsg->messageType )
9063 {
9064 case eWNI_SME_ASSOC_IND:
9065 {
9066 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009067 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9069 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9070 if( HAL_STATUS_SUCCESS( status ) )
9071 {
9072 pSession = CSR_GET_SESSION(pMac, sessionId);
9073
Jeff Johnson32d95a32012-09-10 13:15:23 -07009074 if(!pSession)
9075 {
9076 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9077 return;
9078 }
9079
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 pRoamInfo = &roamInfo;
9081
9082 // Required for indicating the frames to upper layer
9083 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9084 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9085
9086 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9087 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9088 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9089 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9090
9091 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9092 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9093 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9094
9095 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9096 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309097 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9098 sizeof(tSirMacAddr));
9099 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9100 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9102 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9105 {
9106 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9107 {
9108 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9109 pSession->pConnectBssDesc,
9110 &(pRoamInfo->peerMac),
9111 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9112 pRoamInfo->fAuthRequired = FALSE;
9113 }
9114 else
9115 {
9116 pRoamInfo->fAuthRequired = TRUE;
9117 }
9118 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9119 if (!HAL_STATUS_SUCCESS(status))
9120 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 /* Send Association completion message to PE */
9123 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9124
9125 /* send a message to CSR itself just to avoid the EAPOL frames going
9126 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9128 {
9129 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9132 {
9133 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9134 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9135 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009137 }
9138 }
9139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 // Check if AP dis-associated us because of MIC failure. If so,
9142 // then we need to take action immediately and not wait till the
9143 // the WmStatusChange requests is pushed and processed
9144 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9145 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9146 if( HAL_STATUS_SUCCESS( status ) )
9147 {
Kiet Lam82004c62013-11-11 13:24:28 +05309148 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC for session %d "), sessionId);
9149 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer =" MAC_ADDRESS_STR " "
9150 " reason = %d status = %d "),
9151 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9152 pDisassocInd->reasonCode, pDisassocInd->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 // If we are in neighbor preauth done state then on receiving
9154 // disassoc or deauth we dont roam instead we just disassoc
9155 // from current ap and then go to disconnected state
9156 // This happens for CCX and 11r FT connections ONLY.
9157#ifdef WLAN_FEATURE_VOWIFI_11R
9158 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9159 {
9160 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9161 }
9162#endif
9163#ifdef FEATURE_WLAN_CCX
9164 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9165 {
9166 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9167 }
9168#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009169#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309170 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009171 {
9172 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9173 }
9174#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 pSession = CSR_GET_SESSION( pMac, sessionId );
9176
Jeff Johnson32d95a32012-09-10 13:15:23 -07009177 if(!pSession)
9178 {
9179 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9180 return;
9181 }
9182
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 if ( csrIsConnStateInfra( pMac, sessionId ) )
9184 {
9185 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009187#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9188 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9189#endif
9190 csrRoamLinkDown(pMac, sessionId);
9191 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9193 {
9194
9195 pRoamInfo = &roamInfo;
9196
9197 pRoamInfo->statusCode = pDisassocInd->statusCode;
9198 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9199
9200 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
9201
Kiet Lam64c1b492013-07-12 13:56:44 +05309202 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9203 sizeof(tSirMacAddr));
9204 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9205 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009206
9207 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009208
9209 /*
9210 * STA/P2P client got disassociated so remove any pending deauth
9211 * commands in sme pending list
9212 */
9213 pCommand.command = eSmeCommandRoam;
9214 pCommand.sessionId = (tANI_U8)sessionId;
9215 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Kiet Lam64c1b492013-07-12 13:56:44 +05309216 vos_mem_copy(pCommand.u.roamCmd.peerMac,
9217 pDisassocInd->peerMacAddr,
9218 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009219 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 }
Kiet Lam82004c62013-11-11 13:24:28 +05309222 else
9223 {
9224 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9225 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009229 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9231 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9232 if( HAL_STATUS_SUCCESS( status ) )
9233 {
9234 // If we are in neighbor preauth done state then on receiving
9235 // disassoc or deauth we dont roam instead we just disassoc
9236 // from current ap and then go to disconnected state
9237 // This happens for CCX and 11r FT connections ONLY.
9238#ifdef WLAN_FEATURE_VOWIFI_11R
9239 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9240 {
9241 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9242 }
9243#endif
9244#ifdef FEATURE_WLAN_CCX
9245 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9246 {
9247 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9248 }
9249#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009250#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309251 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009252 {
9253 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9254 }
9255#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 pSession = CSR_GET_SESSION( pMac, sessionId );
9257
Jeff Johnson32d95a32012-09-10 13:15:23 -07009258 if(!pSession)
9259 {
9260 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9261 return;
9262 }
9263
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 if ( csrIsConnStateInfra( pMac, sessionId ) )
9265 {
9266 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009268#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9269 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9270#endif
9271 csrRoamLinkDown(pMac, sessionId);
9272 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009273 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9274 {
9275
9276 pRoamInfo = &roamInfo;
9277
9278 pRoamInfo->statusCode = pDeauthInd->statusCode;
9279 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9280
9281 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9282
Kiet Lam64c1b492013-07-12 13:56:44 +05309283 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9284 sizeof(tSirMacAddr));
9285 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9286 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009287
9288 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 }
9291 break;
9292
9293 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 -08009294 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009295 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9296 //Update with the new channel id.
9297 //The channel id is hidden in the statusCode.
9298 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9299 if( HAL_STATUS_SUCCESS( status ) )
9300 {
9301 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009302 if(!pSession)
9303 {
9304 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9305 return;
9306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9308 if(pSession->pConnectBssDesc)
9309 {
9310 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9311 }
9312 }
9313 break;
9314
9315 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009316 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 {
9318 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9319 sessionId = pDeauthRsp->sessionId;
9320 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9321 {
9322 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009323 if(!pSession)
9324 {
9325 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9326 return;
9327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9329 {
9330 pRoamInfo = &roamInfo;
9331 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309332 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9333 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9335 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9336 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9337 }
9338 }
9339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 break;
9341
9342 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009343 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009344 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 {
9346 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9347 sessionId = pDisassocRsp->sessionId;
9348 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9349 {
9350 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009351 if(!pSession)
9352 {
9353 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9354 return;
9355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009356 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9357 {
9358 pRoamInfo = &roamInfo;
9359 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309360 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9361 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9363 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9364 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9365 }
9366 }
9367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 case eWNI_SME_MIC_FAILURE_IND:
9370 {
9371 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9372 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9373 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009374
9375 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9376 if( HAL_STATUS_SUCCESS( status ) )
9377 {
9378 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9379 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9380 pRoamInfo = &roamInfo;
9381 if(pMicInd->info.multicast)
9382 {
9383 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9384 }
9385 else
9386 {
9387 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9388 }
9389 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9390 }
9391
Jeff Johnson295189b2012-06-20 16:38:30 -07009392#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9393 {
lukez3c809222013-05-03 10:23:02 -07009394 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009396 if(!pSession)
9397 {
9398 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9399 return;
9400 }
lukez3c809222013-05-03 10:23:02 -07009401
Kiet Lam64c1b492013-07-12 13:56:44 +05309402 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9404 secEvent.encryptionModeMulticast =
9405 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9406 secEvent.encryptionModeUnicast =
9407 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9408 secEvent.authMode =
9409 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309410 vos_mem_copy(secEvent.bssid,
9411 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9413 }
9414#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 }
9416 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9418 {
9419 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9420 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009421 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009422
9423 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9424 if( HAL_STATUS_SUCCESS( status ) )
9425 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309426 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9428 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9429 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9430 }
9431 }
9432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009433
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9435 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9436 switch( pStatusChangeMsg->statusChangeCode )
9437 {
9438 case eSIR_SME_IBSS_ACTIVE:
9439 sessionId = csrFindIbssSession( pMac );
9440 if( CSR_SESSION_ID_INVALID != sessionId )
9441 {
9442 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009443 if(!pSession)
9444 {
9445 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9446 return;
9447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9449 if(pSession->pConnectBssDesc)
9450 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309451 vos_mem_copy(&roamInfo.bssid,
9452 pSession->pConnectBssDesc->bssId,
9453 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9455 pRoamInfo = &roamInfo;
9456 }
9457 else
9458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009459 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 }
9461 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9462 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9463 }
9464 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 case eSIR_SME_IBSS_INACTIVE:
9466 sessionId = csrFindIbssSession( pMac );
9467 if( CSR_SESSION_ID_INVALID != sessionId )
9468 {
9469 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009470 if(!pSession)
9471 {
9472 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9473 return;
9474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9476 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9477 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9478 }
9479 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9481 sessionId = csrFindIbssSession( pMac );
9482 if( CSR_SESSION_ID_INVALID != sessionId )
9483 {
9484 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009485 if(!pSession)
9486 {
9487 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9488 return;
9489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 // update the connection state information
9491 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009492#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9493 {
9494 vos_log_ibss_pkt_type *pIbssLog;
9495 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9497 if(pIbssLog)
9498 {
9499 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9500 if(pNewBss)
9501 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309502 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 if(pNewBss->ssId.length)
9504 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309505 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9506 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 }
9508 pIbssLog->operatingChannel = pNewBss->channelNumber;
9509 }
9510 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9511 {
9512 //***U8 is not enough for beacon interval
9513 pIbssLog->beaconInterval = (v_U8_t)bi;
9514 }
9515 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9516 }
9517 }
9518#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009520
9521 if ((eCSR_ENCRYPT_TYPE_NONE ==
9522 pSession->connectedProfile.EncryptionType ))
9523 {
9524 csrRoamIssueSetContextReq( pMac, sessionId,
9525 pSession->connectedProfile.EncryptionType,
9526 pSession->pConnectBssDesc,
9527 &Broadcastaddr,
9528 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9531 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309532 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9533 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 pRoamInfo = &roamInfo;
9535 //This BSSID is th ereal BSSID, let's save it
9536 if(pSession->pConnectBssDesc)
9537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309538 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9539 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009542 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 // detection by LIM that the capabilities of the associated AP have changed.
9545 case eSIR_SME_AP_CAPS_CHANGED:
9546 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009547 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9549 if( HAL_STATUS_SUCCESS( status ) )
9550 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009551 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9552 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309553 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009554 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9555 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9556 )
9557 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309558 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9559 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009560 }
9561 else
9562 {
9563 smsLog(pMac, LOGW,
9564 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009565 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009566 pMac->roam.curState[sessionId],
9567 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309568 /* We ignore the caps change event if CSR is not in full connected state.
9569 * Send one event to PE to reset limSentCapsChangeNtf
9570 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9571 * otherwise lim cannot send any CAPS change events to SME */
9572 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 }
9575 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309576
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 default:
9578 roamStatus = eCSR_ROAM_FAILED;
9579 result = eCSR_ROAM_RESULT_NONE;
9580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 } // end switch on statusChangeCode
9582 if(eCSR_ROAM_RESULT_NONE != result)
9583 {
9584 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9585 }
9586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 case eWNI_SME_IBSS_NEW_PEER_IND:
9588 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009589#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9590 {
9591 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9593 if(pIbssLog)
9594 {
9595 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309596 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9598 }
9599 }
9600#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 sessionId = csrFindIbssSession( pMac );
9602 if( CSR_SESSION_ID_INVALID != sessionId )
9603 {
9604 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009605
9606 if(!pSession)
9607 {
9608 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9609 return;
9610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9612 if(pSession->pConnectBssDesc)
9613 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309614 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9615 sizeof(tCsrBssid));
9616 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9617 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9619 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309620 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9621 - sizeof(tSmeIbssPeerInd)));
9622 if ( NULL == roamInfo.pbFrames )
9623 status = eHAL_STATUS_FAILURE;
9624 else
9625 status = eHAL_STATUS_SUCCESS;
9626 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 {
9628 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309629 vos_mem_copy(roamInfo.pbFrames,
9630 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9631 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 }
9633 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9634 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9635 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309636 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9637 if ( NULL == roamInfo.pBssDesc )
9638 status = eHAL_STATUS_FAILURE;
9639 else
9640 status = eHAL_STATUS_SUCCESS;
9641 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309643 vos_mem_copy(roamInfo.pBssDesc,
9644 pSession->pConnectBssDesc,
9645 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 }
9647 if(HAL_STATUS_SUCCESS(status))
9648 {
9649 pRoamInfo = &roamInfo;
9650 }
9651 else
9652 {
9653 if(roamInfo.pbFrames)
9654 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309655 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 }
9657 if(roamInfo.pBssDesc)
9658 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309659 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 }
9661 }
9662 }
9663 else
9664 {
9665 pRoamInfo = &roamInfo;
9666 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009667 if ((eCSR_ENCRYPT_TYPE_NONE ==
9668 pSession->connectedProfile.EncryptionType ))
9669 {
9670 csrRoamIssueSetContextReq( pMac, sessionId,
9671 pSession->connectedProfile.EncryptionType,
9672 pSession->pConnectBssDesc,
9673 &(pIbssPeerInd->peerAddr),
9674 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 }
9677 else
9678 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009679 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 }
9681 //send up the sec type for the new peer
9682 if (pRoamInfo)
9683 {
9684 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9685 }
9686 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9687 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9688 if(pRoamInfo)
9689 {
9690 if(roamInfo.pbFrames)
9691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309692 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 }
9694 if(roamInfo.pBssDesc)
9695 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309696 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 }
9698 }
9699 }
9700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9702 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9703 sessionId = csrFindIbssSession( pMac );
9704 if( CSR_SESSION_ID_INVALID != sessionId )
9705 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009706#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9707 {
9708 vos_log_ibss_pkt_type *pIbssLog;
9709
9710 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9711 if(pIbssLog)
9712 {
9713 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9714 if(pIbssPeerInd)
9715 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309716 vos_mem_copy(pIbssLog->peerMacAddr,
9717 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 }
9719 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9720 }
9721 }
9722#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009723 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9725 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9726 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309727 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9728 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009729 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9730 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9731 }
9732 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 case eWNI_SME_SETCONTEXT_RSP:
9734 {
9735 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9736 tListElem *pEntry;
9737 tSmeCmd *pCommand;
9738
9739 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9740 if ( pEntry )
9741 {
9742 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9743 if ( eSmeCommandSetKey == pCommand->command )
9744 {
9745 sessionId = pCommand->sessionId;
9746 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009747
9748 if(!pSession)
9749 {
9750 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9751 return;
9752 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009753
9754#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9755 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9756 {
9757 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309758 vos_mem_set(&setKeyEvent,
9759 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 if( pRsp->peerMacAddr[0] & 0x01 )
9761 {
9762 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9763 }
9764 else
9765 {
9766 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9767 }
9768 setKeyEvent.encryptionModeMulticast =
9769 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9770 setKeyEvent.encryptionModeUnicast =
9771 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309772 vos_mem_copy(setKeyEvent.bssid,
9773 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 setKeyEvent.authMode =
9775 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009776 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 {
9778 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9779 }
9780 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9781 }
9782#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9783 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9784 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009785 csrRoamStopWaitForKeyTimer( pMac );
9786
Jeff Johnson295189b2012-06-20 16:38:30 -07009787 //We are done with authentication, whethere succeed or not
9788 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009789 //We do it here because this linkup function is not called after association
9790 //when a key needs to be set.
9791 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9792 {
9793 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9794 }
9795 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009796 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309798 vos_mem_copy(&roamInfo.peerMac,
9799 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009800 //Make sure we install the GTK before indicating to HDD as authenticated
9801 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309802 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9803 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009804 {
Yathish9f22e662012-12-10 14:21:35 -08009805#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9806 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9807 {
9808 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309809 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009810 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9811 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9812 pMsg->seesionId = sessionId;
9813 status = palSendMBMessage(pMac->hHdd, pMsg );
9814 }
9815#endif
9816 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009817 }
9818 else
9819 {
9820 result = eCSR_ROAM_RESULT_NONE;
9821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 pRoamInfo = &roamInfo;
9823 }
9824 else
9825 {
9826 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009827 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9829 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9830 }
9831 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9832 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9834 // can go ahead and initiate the TSPEC if any are pending
9835 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009836#ifdef FEATURE_WLAN_CCX
9837 //Send Adjacent AP repot to new AP.
9838 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9839 pSession->isPrevApInfoValid &&
9840 pSession->connectedProfile.isCCXAssoc)
9841 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009842#ifdef FEATURE_WLAN_CCX_UPLOAD
9843 csrSendCcxAdjacentApRepInd(pMac, pSession);
9844#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009845 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9846#endif
9847 pSession->isPrevApInfoValid = FALSE;
9848 }
9849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009850 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9851 {
9852 csrReleaseCommandSetKey( pMac, pCommand );
9853 }
9854 }
9855 else
9856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009857 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 }
9859 }
9860 else
9861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009862 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009864 smeProcessPendingQueue( pMac );
9865 }
9866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 case eWNI_SME_REMOVEKEY_RSP:
9868 {
9869 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9870 tListElem *pEntry;
9871 tSmeCmd *pCommand;
9872
9873 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9874 if ( pEntry )
9875 {
9876 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9877 if ( eSmeCommandRemoveKey == pCommand->command )
9878 {
9879 sessionId = pCommand->sessionId;
9880 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009881
9882 if(!pSession)
9883 {
9884 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9885 return;
9886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009887#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9888 {
9889 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309890 vos_mem_set(&removeKeyEvent,
9891 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9893 removeKeyEvent.encryptionModeMulticast =
9894 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9895 removeKeyEvent.encryptionModeUnicast =
9896 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309897 vos_mem_copy( removeKeyEvent.bssid,
9898 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 removeKeyEvent.authMode =
9900 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009901 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 {
9903 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9904 }
9905 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9906 }
9907#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009908 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309910 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9911 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 result = eCSR_ROAM_RESULT_NONE;
9913 pRoamInfo = &roamInfo;
9914 }
9915 else
9916 {
9917 result = eCSR_ROAM_RESULT_FAILURE;
9918 }
9919 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9920 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9921 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9922 {
9923 csrReleaseCommandRemoveKey( pMac, pCommand );
9924 }
9925 }
9926 else
9927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009928 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 }
9930 }
9931 else
9932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009933 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 smeProcessPendingQueue( pMac );
9936 }
9937 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009939 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 csrRoamStatsRspProcessor( pMac, pSirMsg );
9941 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009942#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9943 case eWNI_SME_GET_ROAM_RSSI_RSP:
9944 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9945 csrRoamRssiRspProcessor( pMac, pSirMsg );
9946 break;
9947#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009948#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9949 case eWNI_SME_GET_TSM_STATS_RSP:
9950 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
9951 csrTsmStatsRspProcessor( pMac, pSirMsg );
9952 break;
9953#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009955 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 csrUpdateRssi( pMac, pSirMsg );
9957 break;
9958
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309959 case eWNI_SME_GET_SNR_REQ:
9960 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9961 csrUpdateSnr(pMac, pSirMsg);
9962 break;
9963
Jeff Johnson295189b2012-06-20 16:38:30 -07009964#ifdef WLAN_FEATURE_VOWIFI_11R
9965 case eWNI_SME_FT_PRE_AUTH_RSP:
9966 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9967 break;
9968#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9970 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009971 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 -07009972 sessionId = pSmeMaxAssocInd->sessionId;
9973 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309974 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
9975 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9977 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9978 break;
9979
9980 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009981 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 btampEstablishLogLinkHdlr( pSirMsg );
9983 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009984 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009985 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009986 csrRoamRssiIndHdlr( pMac, pSirMsg );
9987 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009988#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9989 case eWNI_SME_CANDIDATE_FOUND_IND:
9990 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9991 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9992 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009993 case eWNI_SME_HANDOFF_REQ:
9994 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9995 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9996 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009997#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009998
9999 default:
10000 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010002}
10003
Jeff Johnson295189b2012-06-20 16:38:30 -070010004void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10005 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10006{
10007 if(pSession)
10008 {
10009 if(pSession->bRefAssocStartCnt)
10010 {
10011 pSession->bRefAssocStartCnt--;
10012 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10013 //Need to call association_completion because there is an assoc_start pending.
10014 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10015 eCSR_ROAM_ASSOCIATION_COMPLETION,
10016 eCSR_ROAM_RESULT_FAILURE);
10017 }
10018 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10019 }
10020 else
10021 {
10022 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10023 }
10024}
10025
10026
10027eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10028{
10029 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010030 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10031 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10032 {
10033 status = csrScanRequestLostLink1( pMac, sessionId );
10034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 return(status);
10036}
10037
Jeff Johnson295189b2012-06-20 16:38:30 -070010038//return a boolean to indicate whether roaming completed or continue.
10039tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10040 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10041{
10042 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10043 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10044 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010046 if(!pSession)
10047 {
10048 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10049 return eANI_BOOLEAN_FALSE;
10050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 //Check whether time is up
10052 if(pSession->fCancelRoaming || fForce ||
10053 ((curTime - pSession->roamingStartTime) > roamTime) ||
10054 eCsrReassocRoaming == pSession->roamingReason ||
10055 eCsrDynamicRoaming == pSession->roamingReason)
10056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010057 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10059 {
10060 //roaming is cancelled, tell HDD to indicate disconnect
10061 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10062 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10063 //to be eSIR_BEACON_MISSED
10064 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10065 {
10066 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10067 }
10068 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10069 {
10070 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10071 }
10072 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10073 {
10074 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10075 }
10076 else
10077 {
10078 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10079 }
10080 }
10081 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10082 pSession->roamingReason = eCsrNotRoaming;
10083 }
10084 else
10085 {
10086 pSession->roamResult = roamResult;
10087 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10088 {
10089 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10090 pSession->roamingReason = eCsrNotRoaming;
10091 }
10092 else
10093 {
10094 fCompleted = eANI_BOOLEAN_FALSE;
10095 }
10096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 return(fCompleted);
10098}
10099
Jeff Johnson295189b2012-06-20 16:38:30 -070010100void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10101{
10102 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010103
10104 if(!pSession)
10105 {
10106 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10107 return;
10108 }
10109
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 if(CSR_IS_ROAMING(pSession))
10111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010112 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10114 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10115 {
10116 //No need to do anything in here because the handler takes care of it
10117 }
10118 else
10119 {
10120 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10121 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10122 //Roaming is stopped after here
10123 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10124 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010125 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 csrRoamStopRoamingTimer(pMac, sessionId);
10127 }
10128 }
10129}
10130
Jeff Johnson295189b2012-06-20 16:38:30 -070010131void csrRoamRoamingTimerHandler(void *pv)
10132{
10133 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10134 tpAniSirGlobal pMac = pInfo->pMac;
10135 tANI_U32 sessionId = pInfo->sessionId;
10136 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010137
10138 if(!pSession)
10139 {
10140 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10141 return;
10142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010143
10144 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10145 {
10146 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10147 {
10148 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10149 pSession->roamingReason = eCsrNotRoaming;
10150 }
10151 }
10152}
10153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10155{
10156 eHalStatus status;
10157 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010158
10159 if(!pSession)
10160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010161 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010162 return eHAL_STATUS_FAILURE;
10163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010164
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010165 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010167 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010168
10169 return (status);
10170}
10171
Jeff Johnson295189b2012-06-20 16:38:30 -070010172eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10173{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010174 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010175}
10176
Jeff Johnson295189b2012-06-20 16:38:30 -070010177void csrRoamWaitForKeyTimeOutHandler(void *pv)
10178{
10179 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10180 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
10182
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010183 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010184 pMac->roam.neighborRoamInfo.neighborRoamState,
10185 pMac->roam.curSubState[pInfo->sessionId]);
10186
Jeff Johnson295189b2012-06-20 16:38:30 -070010187 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10188 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010189#ifdef FEATURE_WLAN_LFR
10190 if (csrNeighborRoamIsHandoffInProgress(pMac))
10191 {
10192 /*
10193 * Enable heartbeat timer when hand-off is in progress
10194 * and Key Wait timer expired.
10195 */
10196 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010197 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010198 pMac->roam.configParam.HeartbeatThresh24);
10199 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10200 pMac->roam.configParam.HeartbeatThresh24,
10201 NULL, eANI_BOOLEAN_FALSE);
10202 }
10203#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010204 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010205
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010207 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10208 {
10209 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10210 pInfo->sessionId);
10211 }
10212
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010213 if (pSession)
10214 {
10215 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10216 {
10217 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10218 smeProcessPendingQueue(pMac);
10219 }
10220 else
10221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010222 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010223 __func__);
10224 }
10225 }
10226 else
10227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010228 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 }
10231
10232}
10233
Jeff Johnson295189b2012-06-20 16:38:30 -070010234eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10235{
10236 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010237#ifdef FEATURE_WLAN_LFR
10238 if (csrNeighborRoamIsHandoffInProgress(pMac))
10239 {
10240 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010241 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010242 __func__,
10243 pMac->roam.neighborRoamInfo.neighborRoamState,
10244 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10245 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10246 }
10247#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010248 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010249 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010250
10251 return (status);
10252}
10253
Jeff Johnson295189b2012-06-20 16:38:30 -070010254eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10255{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010256 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010257 pMac->roam.neighborRoamInfo.neighborRoamState,
10258 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10259#ifdef FEATURE_WLAN_LFR
10260 if (csrNeighborRoamIsHandoffInProgress(pMac))
10261 {
10262 /*
10263 * Enable heartbeat timer when hand-off is in progress
10264 * and Key Wait timer got stopped for some reason
10265 */
10266 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010267 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010268 pMac->roam.configParam.HeartbeatThresh24);
10269 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10270 pMac->roam.configParam.HeartbeatThresh24,
10271 NULL, eANI_BOOLEAN_FALSE);
10272 }
10273#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010274 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010275}
10276
Jeff Johnson295189b2012-06-20 16:38:30 -070010277void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10278 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10279{
10280 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10281 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010282 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10283 /* To silence the KW tool Null chaeck is added */
10284 if(!pSession)
10285 {
10286 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10287 return;
10288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010289
10290 if(pCommand)
10291 {
10292 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10296 {
10297 //if success, force roaming completion
10298 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10299 }
10300 else
10301 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010302 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010303 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10305 }
10306}
10307
Jeff Johnson295189b2012-06-20 16:38:30 -070010308eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10309{
10310 eHalStatus status = eHAL_STATUS_SUCCESS;
10311 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10312 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10313 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10314 tCsrRoamInfo *pRoamInfo = NULL;
10315 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010316 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010318 /* To silence the KW tool Null chaeck is added */
10319 if(!pSession)
10320 {
10321 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10322 return eHAL_STATUS_FAILURE;
10323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010325 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10327 if ( eWNI_SME_DISASSOC_IND == type )
10328 {
10329 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10330 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10331 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010332 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 }
10334 else if ( eWNI_SME_DEAUTH_IND == type )
10335 {
10336 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10337 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10338 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010339 /* Convert into proper reason code */
10340 pSession->joinFailStatusCode.reasonCode =
10341 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010342 0 : pDeauthIndMsg->reasonCode;
10343 /* cfg layer expects 0 as reason code if
10344 the driver dosent know the reason code
10345 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 }
10347 else
10348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010349 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010351 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 }
10353
10354 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010355 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 {
10357 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10358 }
10359
10360 if ( eWNI_SME_DISASSOC_IND == type )
10361 {
10362 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10363 }
10364 else if ( eWNI_SME_DEAUTH_IND == type )
10365 {
10366 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 if(!HAL_STATUS_SUCCESS(status))
10369 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010370 //If fail to send confirmation to PE, not to trigger roaming
10371 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010372 }
10373
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010374 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010375 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10377 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 if( eWNI_SME_DISASSOC_IND == type)
10379 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010380 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010381 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10382 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010383 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 else if( eWNI_SME_DEAUTH_IND == type )
10386 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010387 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010388 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10389 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010390 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10391 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010392 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010393
10394 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10395 that we are roaming. But if we cannot possibly roam, or if we are unable to
10396 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010397 if(fToRoam)
10398 {
10399 //Only remove the connected BSS in infrastructure mode
10400 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10401 //Not to do anying for lostlink with WDS
10402 if( pMac->roam.configParam.nRoamingTime )
10403 {
10404 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10405 ( eWNI_SME_DEAUTH_IND == type ) ?
10406 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10407 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010408 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 //For IBSS, we need to give some more info to HDD
10410 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10411 {
10412 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10413 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10414 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10415 }
10416 else
10417 {
10418 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10419 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010420 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010421 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10422 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10423 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10424 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10425 }
10426 else
10427 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010428 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 fToRoam = eANI_BOOLEAN_FALSE;
10430 }
10431 }
10432 else
10433 {
10434 //We are told not to roam, indicate lostlink
10435 fToRoam = eANI_BOOLEAN_FALSE;
10436 }
10437 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010438 if(!fToRoam)
10439 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010440 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010441 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010442 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010443 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10444 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10445 * csrRoamCheckForLinkStatusChange API.
10446 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010447 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10448 }
10449
10450 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 Still enable idle scan for polling in case concurrent sessions are running */
10452 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10453 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010454 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 }
10456 }
10457
10458 return (status);
10459}
10460
Jeff Johnson295189b2012-06-20 16:38:30 -070010461eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10462{
10463 eHalStatus status = eHAL_STATUS_SUCCESS;
10464 tListElem *pEntry = NULL;
10465 tSmeCmd *pCommand = NULL;
10466 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010467
10468 if(!pSession)
10469 {
10470 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10471 return eHAL_STATUS_FAILURE;
10472 }
10473
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 //Only remove the connected BSS in infrastructure mode
10476 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10477 if(pMac->roam.configParam.nRoamingTime)
10478 {
10479 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10480 {
10481 //before starting the lost link logic release the roam command for handoff
10482 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10483 if(pEntry)
10484 {
10485 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10486 }
10487 if(pCommand)
10488 {
10489 if (( eSmeCommandRoam == pCommand->command ) &&
10490 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10491 {
10492 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10493 {
10494 csrReleaseCommandRoam( pMac, pCommand );
10495 }
10496 }
10497 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010498 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 }
10500 }
10501 else
10502 {
10503 //We are told not to roam, indicate lostlink
10504 status = eHAL_STATUS_FAILURE;
10505 }
10506
10507 return (status);
10508}
Jeff Johnson295189b2012-06-20 16:38:30 -070010509void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10510{
10511 tListElem *pEntry;
10512 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010513 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10514 if ( pEntry )
10515 {
10516 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10517 if ( eSmeCommandWmStatusChange == pCommand->command )
10518 {
10519 // Nothing to process in a Lost Link completion.... It just kicks off a
10520 // roaming sequence.
10521 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10522 {
10523 csrReleaseCommandWmStatusChange( pMac, pCommand );
10524 }
10525 else
10526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010527 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 }
10529
10530 }
10531 else
10532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010533 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 }
10535 }
10536 else
10537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010538 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 smeProcessPendingQueue( pMac );
10541}
10542
Jeff Johnson295189b2012-06-20 16:38:30 -070010543void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10544{
10545 eHalStatus status = eHAL_STATUS_FAILURE;
10546 tSirSmeRsp *pSirSmeMsg;
10547 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010548
10549 if(!pSession)
10550 {
10551 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10552 return;
10553 }
10554
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 switch ( pCommand->u.wmStatusChangeCmd.Type )
10556 {
10557 case eCsrDisassociated:
10558 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10559 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10560 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 case eCsrDeauthenticated:
10562 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10563 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10564 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010566 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 break;
10568 }
10569 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10570 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10571 {
10572 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10573 {
10574 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010575 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 }
10577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10579 // command here since there is nothing else to do.
10580 csrRoamWmStatusChangeComplete( pMac );
10581}
10582
Jeff Johnson295189b2012-06-20 16:38:30 -070010583//This function returns band and mode information.
10584//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10585//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010586static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10587 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010588{
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10590 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10591 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010593
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 //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 -070010595 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10596 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10597 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10598 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 {
10600 switch( pMac->roam.configParam.uCfgDot11Mode )
10601 {
10602 case eCSR_CFG_DOT11_MODE_11A:
10603 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10604 eBand = eCSR_BAND_5G;
10605 break;
10606 case eCSR_CFG_DOT11_MODE_11B:
10607 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10608 eBand = eCSR_BAND_24;
10609 break;
10610 case eCSR_CFG_DOT11_MODE_11G:
10611 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10612 eBand = eCSR_BAND_24;
10613 break;
10614 case eCSR_CFG_DOT11_MODE_11N:
10615 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010616 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10617 break;
10618#ifdef WLAN_FEATURE_11AC
10619 case eCSR_CFG_DOT11_MODE_11AC:
10620 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10621 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010622 /* If the operating channel is in 2.4 GHz band, check for
10623 * INI item to disable VHT operation in 2.4 GHz band
10624 */
10625 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10626 !pMac->roam.configParam.enableVhtFor24GHz)
10627 {
10628 /* Disable 11AC operation */
10629 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10630 }
10631 else
10632 {
10633 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10634 }
10635 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010636 }
10637 else
10638 {
10639 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10640 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10641 }
10642 break;
10643 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10644 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10645 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010646 /* If the operating channel is in 2.4 GHz band, check for
10647 * INI item to disable VHT operation in 2.4 GHz band
10648 */
10649 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10650 !pMac->roam.configParam.enableVhtFor24GHz)
10651 {
10652 /* Disable 11AC operation */
10653 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10654 }
10655 else
10656 {
10657 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10658 }
10659 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010660 }
10661 else
10662 {
10663 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10664 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10665 }
10666 break;
10667#endif
10668 case eCSR_CFG_DOT11_MODE_AUTO:
10669 eBand = pMac->roam.configParam.eBand;
10670 if (eCSR_BAND_24 == eBand)
10671 {
10672 // WiFi tests require IBSS networks to start in 11b mode
10673 // without any change to the default parameter settings
10674 // on the adapter. We use ACU to start an IBSS through
10675 // creation of a startIBSS profile. This startIBSS profile
10676 // has Auto MACProtocol and the adapter property setting
10677 // for dot11Mode is also AUTO. So in this case, let's
10678 // start the IBSS network in 11b mode instead of 11g mode.
10679 // So this is for Auto=profile->MacProtocol && Auto=Global.
10680 // dot11Mode && profile->channel is < 14, then start the IBSS
10681 // in b mode.
10682 //
10683 // Note: we used to have this start as an 11g IBSS for best
10684 // performance... now to specify that the user will have to
10685 // set the do11Mode in the property page to 11g to force it.
10686 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10687 }
10688 else
10689 {
10690#ifdef WLAN_FEATURE_11AC
10691 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10692 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010693 /* If the operating channel is in 2.4 GHz band, check for
10694 * INI item to disable VHT operation in 2.4 GHz band
10695 */
10696 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10697 !pMac->roam.configParam.enableVhtFor24GHz)
10698 {
10699 /* Disable 11AC operation */
10700 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10701 }
10702 else
10703 {
10704 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10705 }
10706 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010707 }
10708 else
10709 {
10710 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10711 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10712 }
10713#else
10714 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10715 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10716#endif
10717 }
10718 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 default:
10720 // Global dot11 Mode setting is 11a/b/g.
10721 // use the channel number to determine the Mode setting.
10722 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10723 {
10724 eBand = pMac->roam.configParam.eBand;
10725 if(eCSR_BAND_24 == eBand)
10726 {
10727 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10728 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10729 }
10730 else
10731 {
10732 //prefer 5GHz
10733 eBand = eCSR_BAND_5G;
10734 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10735 }
10736 }
10737 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10738 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010739 // WiFi tests require IBSS networks to start in 11b mode
10740 // without any change to the default parameter settings
10741 // on the adapter. We use ACU to start an IBSS through
10742 // creation of a startIBSS profile. This startIBSS profile
10743 // has Auto MACProtocol and the adapter property setting
10744 // for dot11Mode is also AUTO. So in this case, let's
10745 // start the IBSS network in 11b mode instead of 11g mode.
10746 // So this is for Auto=profile->MacProtocol && Auto=Global.
10747 // dot11Mode && profile->channel is < 14, then start the IBSS
10748 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010750 // Note: we used to have this start as an 11g IBSS for best
10751 // performance... now to specify that the user will have to
10752 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10754 eBand = eCSR_BAND_24;
10755 }
10756 else
10757 {
10758 // else, it's a 5.0GHz channel. Set mode to 11a.
10759 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10760 eBand = eCSR_BAND_5G;
10761 }
10762 break;
10763 }//switch
10764 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10765 else
10766 {
10767 //dot11 mode is set, lets pick the band
10768 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10769 {
10770 // channel is Auto also.
10771 eBand = pMac->roam.configParam.eBand;
10772 if(eCSR_BAND_ALL == eBand)
10773 {
10774 //prefer 5GHz
10775 eBand = eCSR_BAND_5G;
10776 }
10777 }
10778 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10779 {
10780 eBand = eCSR_BAND_24;
10781 }
10782 else
10783 {
10784 eBand = eCSR_BAND_5G;
10785 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 if(pBand)
10788 {
10789 *pBand = eBand;
10790 }
10791
10792 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010793 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010794 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10795 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010796
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010797 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10798 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 -070010799 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010800#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010801 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010802#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010803 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10804 {
10805 //We cannot do 11n here
10806 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10807 {
10808 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10809 }
10810 else
10811 {
10812 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10813 }
10814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 return( cfgDot11Mode );
10816}
10817
Jeff Johnson295189b2012-06-20 16:38:30 -070010818eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10819{
10820 eHalStatus status;
10821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010822
10823 if(!pSession)
10824 {
10825 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10826 return eHAL_STATUS_FAILURE;
10827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010828
10829#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10830 {
10831 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10833 if(pIbssLog)
10834 {
10835 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10836 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10837 }
10838 }
10839#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010840 // Set the roaming substate to 'stop Bss request'...
10841 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10842
10843 // attempt to stop the Bss (reason code is ignored...)
10844 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010845 if(!HAL_STATUS_SUCCESS(status))
10846 {
10847 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10848 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010849 return (status);
10850}
10851
Jeff Johnson295189b2012-06-20 16:38:30 -070010852//pNumChan is a caller allocated space with the sizeof pChannels
10853eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10854{
10855
10856 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10857 (tANI_U8 *)pChannels,
10858 pNumChan));
10859}
10860
Kiran4a17ebe2013-01-31 10:43:43 -080010861tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10862{
10863 tANI_U32 cfgLength = 0;
10864 tANI_U16 cfgId = 0;
10865 tPowerdBm maxTxPwr = 0;
10866 tANI_U8 *pCountryInfo = NULL;
10867 eHalStatus status;
10868 tANI_U8 count = 0;
10869 tANI_U8 firstChannel;
10870 tANI_U8 maxChannels;
10871
10872 if (CSR_IS_CHANNEL_5GHZ(channel))
10873 {
10874 cfgId = WNI_CFG_MAX_TX_POWER_5;
10875 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10876 }
10877 else if (CSR_IS_CHANNEL_24GHZ(channel))
10878 {
10879 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10880 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10881 }
10882 else
10883 return maxTxPwr;
10884
Kiet Lam64c1b492013-07-12 13:56:44 +053010885 pCountryInfo = vos_mem_malloc(cfgLength);
10886 if ( NULL == pCountryInfo )
10887 status = eHAL_STATUS_FAILURE;
10888 else
10889 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010890 if (status != eHAL_STATUS_SUCCESS)
10891 {
10892 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010893 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010894 __FUNCTION__, status);
10895 goto error;
10896 }
10897 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10898 if (status != eHAL_STATUS_SUCCESS)
10899 {
10900 goto error;
10901 }
10902 /* Identify the channel and maxtxpower */
10903 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10904 {
10905 firstChannel = pCountryInfo[count++];
10906 maxChannels = pCountryInfo[count++];
10907 maxTxPwr = pCountryInfo[count++];
10908
10909 if ((channel >= firstChannel) &&
10910 (channel < (firstChannel + maxChannels)))
10911 {
10912 break;
10913 }
10914 }
10915
10916error:
10917 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010918 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010919
10920 return maxTxPwr;
10921}
10922
10923
Jeff Johnson295189b2012-06-20 16:38:30 -070010924tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10925{
10926 tANI_BOOLEAN fValid = FALSE;
10927 tANI_U32 idxValidChannels;
10928 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10929
10930 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10931 {
10932 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10933 {
10934 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10935 {
10936 fValid = TRUE;
10937 break;
10938 }
10939 }
10940 }
10941 pMac->roam.numValidChannels = len;
10942 return fValid;
10943}
10944
Jeff Johnson295189b2012-06-20 16:38:30 -070010945tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10946{
10947 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10948 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10950 {
10951 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10952 {
10953 fValid = eANI_BOOLEAN_TRUE;
10954 break;
10955 }
10956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 return (fValid);
10958}
10959
Jeff Johnson295189b2012-06-20 16:38:30 -070010960//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010961 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010962{
Jeff Johnsone7245742012-09-05 17:12:55 -070010963 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 tANI_U8 centerChn;
10965 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10967 {
10968 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10969 }
10970 else
10971 {
10972 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10973 }
10974 //Figure what the other side's CB mode
10975 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10976 {
10977 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10978 {
10979 if(pIes->HTInfo.present)
10980 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010981 /* This is called during INFRA STA/CLIENT and should use the merged value of
10982 * supported channel width and recommended tx width as per standard
10983 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010984 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010985 pIes->HTCaps.supportedChannelWidthSet,
10986 pIes->HTInfo.recommendedTxWidthSet,
10987 pIes->HTInfo.secondaryChannelOffset);
10988
10989 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10990 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010991 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010992 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10993 switch (eRet) {
10994 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10995 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10996 break;
10997 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10998 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10999 break;
11000 case PHY_SINGLE_CHANNEL_CENTERED:
11001 default:
11002 centerChn = primaryChn;
11003 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011005 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011007 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011008 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011009 }
11010 }
11011 }
11012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011013 return eRet;
11014}
Jeff Johnson295189b2012-06-20 16:38:30 -070011015tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11016{
11017 tANI_BOOLEAN fFound = FALSE;
11018 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11020 {
11021 if( pCipherList->encryptionType[idx] == encryptionType )
11022 {
11023 fFound = TRUE;
11024 break;
11025 }
11026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011027 return fFound;
11028}
Jeff Johnson295189b2012-06-20 16:38:30 -070011029tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11030{
11031 tANI_BOOLEAN fFound = FALSE;
11032 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11034 {
11035 if( pAuthList->authType[idx] == authType )
11036 {
11037 fFound = TRUE;
11038 break;
11039 }
11040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 return fFound;
11042}
Jeff Johnson295189b2012-06-20 16:38:30 -070011043tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11044{
11045 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11046 tCsrScanResultFilter *pScanFilter = NULL;
11047 eHalStatus status = eHAL_STATUS_SUCCESS;
11048
11049 if(pProfile1 && pProfile2)
11050 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011051 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11052 if ( NULL == pScanFilter )
11053 status = eHAL_STATUS_FAILURE;
11054 else
11055 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011056 if(HAL_STATUS_SUCCESS(status))
11057 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011058 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011059 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11060 if(HAL_STATUS_SUCCESS(status))
11061 {
11062 fCheck = eANI_BOOLEAN_FALSE;
11063 do
11064 {
11065 tANI_U32 i;
11066 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11067 {
11068 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11069 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11070 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11071 if ( fCheck ) break;
11072 }
11073 if(!fCheck)
11074 {
11075 break;
11076 }
11077 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11078 || pProfile2->BSSType != pProfile1->BSSType
11079 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11080 )
11081 {
11082 fCheck = eANI_BOOLEAN_FALSE;
11083 break;
11084 }
11085#ifdef WLAN_FEATURE_VOWIFI_11R
11086 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11087 {
11088 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11089 {
11090 fCheck = eANI_BOOLEAN_FALSE;
11091 break;
11092 }
11093 }
11094#endif
11095 //Match found
11096 fCheck = eANI_BOOLEAN_TRUE;
11097 }while(0);
11098 csrFreeScanFilter(pMac, pScanFilter);
11099 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011100 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 }
11102 }
11103
11104 return (fCheck);
11105}
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11108{
11109 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11110 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011111 do
11112 {
11113 //Only check for static WEP
11114 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11115 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11116 {
11117 fCheck = eANI_BOOLEAN_TRUE;
11118 break;
11119 }
11120 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11121 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11122 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11123 {
11124 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011125 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11126 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011127 {
11128 break;
11129 }
11130 }
11131 if( i == CSR_MAX_NUM_KEY)
11132 {
11133 fCheck = eANI_BOOLEAN_TRUE;
11134 }
11135 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011136 return (fCheck);
11137}
11138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139//IBSS
11140
Jeff Johnson295189b2012-06-20 16:38:30 -070011141tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11142{
11143 tANI_U8 channel = 0;
11144 tANI_U32 idx;
11145 tANI_U32 idxValidChannels;
11146 tANI_BOOLEAN fFound = FALSE;
11147 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11148
11149 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11150 {
11151 channel = pMac->roam.configParam.AdHocChannel5G;
11152 if(!csrRoamIsChannelValid(pMac, channel))
11153 {
11154 channel = 0;
11155 }
11156 }
11157 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11158 {
11159 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11160 {
11161 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11162 {
11163 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11164 {
11165 fFound = TRUE;
11166 channel = csrStartIbssChannels50[ idx ];
11167 }
11168 }
11169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11171 if (!fFound)
11172 {
11173 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11174 {
11175 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11176 {
11177 channel = csrStartIbssChannels50[ idx ];
11178 break;
11179 }
11180 }
11181 }
11182 }//if
11183
11184 return( channel );
11185}
11186
Jeff Johnson295189b2012-06-20 16:38:30 -070011187tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11188{
11189 tANI_U8 channel = 1;
11190 tANI_U32 idx;
11191 tANI_U32 idxValidChannels;
11192 tANI_BOOLEAN fFound = FALSE;
11193 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11194
11195 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11196 {
11197 channel = pMac->roam.configParam.AdHocChannel24;
11198 if(!csrRoamIsChannelValid(pMac, channel))
11199 {
11200 channel = 0;
11201 }
11202 }
11203
11204 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11205 {
11206 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11207 {
11208 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11209 {
11210 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11211 {
11212 fFound = TRUE;
11213 channel = csrStartIbssChannels24[ idx ];
11214 }
11215 }
11216 }
11217 }
11218
11219 return( channel );
11220}
11221
Jeff Johnson295189b2012-06-20 16:38:30 -070011222static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11223 tCsrRoamStartBssParams *pParam )
11224{
11225 eCsrCfgDot11Mode cfgDot11Mode;
11226 eCsrBand eBand;
11227 tANI_U8 channel = 0;
11228 tSirNwType nwType;
11229 tANI_U8 operationChannel = 0;
11230
11231 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11232 {
11233 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11234 }
11235
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011237
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11239 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11240 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11241 )
11242 {
11243 /* This should never happen */
11244 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011245 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 pProfile->csrPersona);
11247 VOS_ASSERT(0);
11248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 switch( cfgDot11Mode )
11250 {
11251 case eCSR_CFG_DOT11_MODE_11G:
11252 nwType = eSIR_11G_NW_TYPE;
11253 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 case eCSR_CFG_DOT11_MODE_11B:
11255 nwType = eSIR_11B_NW_TYPE;
11256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 case eCSR_CFG_DOT11_MODE_11A:
11258 nwType = eSIR_11A_NW_TYPE;
11259 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 default:
11261 case eCSR_CFG_DOT11_MODE_11N:
11262 case eCSR_CFG_DOT11_MODE_TAURUS:
11263 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11264 if(eCSR_BAND_24 == eBand)
11265 {
11266 nwType = eSIR_11G_NW_TYPE;
11267 }
11268 else
11269 {
11270 nwType = eSIR_11A_NW_TYPE;
11271 }
11272 break;
11273 }
11274
11275 pParam->extendedRateSet.numRates = 0;
11276
11277 switch ( nwType )
11278 {
11279 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011280 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 case eSIR_11A_NW_TYPE:
11282
11283 pParam->operationalRateSet.numRates = 8;
11284
11285 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11286 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11287 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11288 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11289 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11290 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11291 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11292 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11293
11294 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11295 {
11296 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11297 if( 0 == channel &&
11298 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11299 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11300 )
11301 {
11302 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11303 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11304 nwType = eSIR_11B_NW_TYPE;
11305 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11306 pParam->operationalRateSet.numRates = 4;
11307 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11308 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11309 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11310 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11311 }
11312 }
11313 else
11314 {
11315 channel = operationChannel;
11316 }
11317 break;
11318
11319 case eSIR_11B_NW_TYPE:
11320 pParam->operationalRateSet.numRates = 4;
11321 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11322 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11323 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11324 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11326 {
11327 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11328 }
11329 else
11330 {
11331 channel = operationChannel;
11332 }
11333
11334 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011336 /* For P2P Client and P2P GO, disable 11b rates */
11337 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11338 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11339 )
11340 {
11341 pParam->operationalRateSet.numRates = 8;
11342
11343 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11344 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11345 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11346 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11347 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11348 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11349 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11350 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11351 }
11352 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 {
11354 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011355 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11356 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11357 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11358 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11359
11360 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011361 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11362 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11363 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11364 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11365 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11366 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11367 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11368 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11369 }
11370
11371 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11372 {
11373 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11374 }
11375 else
11376 {
11377 channel = operationChannel;
11378 }
11379
11380 break;
11381 }
11382 pParam->operationChn = channel;
11383 pParam->sirNwType = nwType;
11384}
11385
Jeff Johnson295189b2012-06-20 16:38:30 -070011386static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11387 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11388{
11389
11390 if( pParam )
11391 {
11392 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011393 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011395 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011396
11397 if( pIes )
11398 {
11399 if(pIes->SuppRates.present)
11400 {
11401 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11402 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011404 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 -070011405 pIes->SuppRates.num_rates);
11406 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11407 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011408 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11409 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011411 if (pIes->ExtSuppRates.present)
11412 {
11413 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11414 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11415 {
11416 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11417 SIR_MAC_RATESET_EID_MAX, resetting to \
11418 SIR_MAC_RATESET_EID_MAX"),
11419 pIes->ExtSuppRates.num_rates);
11420 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11421 }
11422 palCopyMemory(pMac->hHdd, pParam->extendedRateSet.rate,
11423 pIes->ExtSuppRates.rates,
11424 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 if( pIes->SSID.present )
11427 {
11428 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011429 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11430 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 }
11432 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 }
11434 else
11435 {
11436 pParam->ssId.length = 0;
11437 pParam->operationalRateSet.numRates = 0;
11438 }
11439 }
11440}
11441
Jeff Johnson295189b2012-06-20 16:38:30 -070011442static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11443{
11444 tANI_U8 MaxRate = 0;
11445 tANI_U32 i;
11446 tANI_U8 *pRate;
11447
11448 pRate = pSirRateSet->rate;
11449 for ( i = 0; i < pSirRateSet->numRates; i++ )
11450 {
11451 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11452 }
11453
11454 // Save the max rate in the connected state information...
11455
11456 // modify LastRates variable as well
11457
11458 return;
11459}
11460
Jeff Johnson295189b2012-06-20 16:38:30 -070011461eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11462 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11463{
11464 eHalStatus status = eHAL_STATUS_SUCCESS;
11465 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 // Set the roaming substate to 'Start BSS attempt'...
11467 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011468#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11469 //Need to figure out whether we need to log WDS???
11470 if( CSR_IS_IBSS( pProfile ) )
11471 {
11472 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11474 if(pIbssLog)
11475 {
11476 if(pBssDesc)
11477 {
11478 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011479 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 }
11481 else
11482 {
11483 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11484 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011485 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 if(pProfile->ChannelInfo.numOfChannels == 0)
11487 {
11488 pIbssLog->channelSetting = AUTO_PICK;
11489 }
11490 else
11491 {
11492 pIbssLog->channelSetting = SPECIFIED;
11493 }
11494 pIbssLog->operatingChannel = pParam->operationChn;
11495 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11496 }
11497 }
11498#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11499 //Put RSN information in for Starting BSS
11500 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11501 pParam->pRSNIE = pProfile->pRSNReqIE;
11502
Jeff Johnson295189b2012-06-20 16:38:30 -070011503 pParam->privacy = pProfile->privacy;
11504 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11505 pParam->authType = pProfile->csr80211AuthType;
11506 pParam->beaconInterval = pProfile->beaconInterval;
11507 pParam->dtimPeriod = pProfile->dtimPeriod;
11508 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11509 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11510 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11511 {
11512 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11513 {
11514 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11515 }
11516 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 pParam->protEnabled = pProfile->protEnabled;
11518 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11519 pParam->ht_protection = pProfile->cfg_protection;
11520 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011521
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11523 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 pParam->bssPersona = pProfile->csrPersona;
11525 // When starting an IBSS, start on the channel from the Profile.
11526 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 return (status);
11528}
11529
Jeff Johnson295189b2012-06-20 16:38:30 -070011530static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011531 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011532{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011533 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011534 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011536
11537 if(!pSession)
11538 {
11539 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11540 return;
11541 }
11542
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 if( pBssDesc )
11544 {
11545 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11546 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11547 //The following code has to be do after that.
11548 //For WDS station, use selfMac as the self BSSID
11549 if( CSR_IS_WDS_STA( pProfile ) )
11550 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011551 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11552 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011553 }
11554 }
11555 else
11556 {
11557 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 //Use the first SSID
11559 if(pProfile->SSIDs.numOfSSIDs)
11560 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011561 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11562 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011563 }
11564 //For WDS station, use selfMac as the self BSSID
11565 if( CSR_IS_WDS_STA( pProfile ) )
11566 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011567 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11568 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 }
11570 //Use the first BSSID
11571 else if( pProfile->BSSIDs.numOfBSSIDs )
11572 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011573 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11574 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 }
11576 else
11577 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011578 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011579 }
11580 }
11581 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 //Set operating channel in pProfile which will be used
11583 //in csrRoamSetBssConfigCfg() to determine channel bonding
11584 //mode and will be configured in CFG later
11585 pProfile->operationChannel = Channel;
11586
11587 if(Channel == 0)
11588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011589 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 }
11591 else
11592 {
11593
11594 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011595 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011596 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011597 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011598 {
11599 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11600 }
11601 else
11602 {
11603 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11604 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011605 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011606 pBssConfig->cbMode = cbMode;
11607 pSession->bssParams.cbMode = cbMode;
11608 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011609 }
11610}
11611
Jeff Johnson295189b2012-06-20 16:38:30 -070011612static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11613 tANI_BOOLEAN *pfSameIbss )
11614{
11615 eHalStatus status = eHAL_STATUS_SUCCESS;
11616 tANI_BOOLEAN fSameIbss = FALSE;
11617
11618 if ( csrIsConnStateIbss( pMac, sessionId ) )
11619 {
11620 // Check if any profile parameter has changed ? If any profile parameter
11621 // has changed then stop old BSS and start a new one with new parameters
11622 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11623 {
11624 fSameIbss = TRUE;
11625 }
11626 else
11627 {
11628 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11629 }
11630 }
11631 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11632 {
11633 // Disassociate from the connected Infrastructure network...
11634 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11635 }
11636 else
11637 {
11638 tBssConfigParam *pBssConfig;
11639
Kiet Lam64c1b492013-07-12 13:56:44 +053011640 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11641 if ( NULL == pBssConfig )
11642 status = eHAL_STATUS_FAILURE;
11643 else
11644 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 if(HAL_STATUS_SUCCESS(status))
11646 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011647 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011648 // there is no Bss description before we start an IBSS so we need to adopt
11649 // all Bss configuration parameters from the Profile.
11650 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11651 if(HAL_STATUS_SUCCESS(status))
11652 {
11653 //save dotMode
11654 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11655 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011656 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011657 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11658 NULL, pBssConfig,
11659 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011661
11662 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011663 }//Allocate memory
11664 }
11665
11666 if(pfSameIbss)
11667 {
11668 *pfSameIbss = fSameIbss;
11669 }
11670 return( status );
11671}
11672
Jeff Johnson295189b2012-06-20 16:38:30 -070011673static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11674 tSirSmeNewBssInfo *pNewBss )
11675{
11676 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011677
11678 if(!pSession)
11679 {
11680 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11681 return;
11682 }
11683
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 if( pNewBss )
11685 {
11686 // Set the operating channel.
11687 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11688 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011689 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11690 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 return;
11693}
11694
Jeff Johnson295189b2012-06-20 16:38:30 -070011695#ifdef FEATURE_WLAN_WAPI
11696eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11697 tANI_U32 numItems )
11698{
11699 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11700 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011703 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011704 return status;
11705 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011706 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 pSession = CSR_GET_SESSION( pMac, sessionId );
11708 if(numItems <= CSR_MAX_BKID_ALLOWED)
11709 {
11710 status = eHAL_STATUS_SUCCESS;
11711 //numItems may be 0 to clear the cache
11712 pSession->NumBkidCache = (tANI_U16)numItems;
11713 if(numItems && pBKIDCache)
11714 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011715 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11716 sizeof(tBkidCacheInfo) * numItems);
11717 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 }
11719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 return (status);
11721}
Jeff Johnson295189b2012-06-20 16:38:30 -070011722eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11723 tBkidCacheInfo *pBkidCache)
11724{
11725 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11726 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011729 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011730 return status;
11731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 pSession = CSR_GET_SESSION( pMac, sessionId );
11733 if(pNum && pBkidCache)
11734 {
11735 if(pSession->NumBkidCache == 0)
11736 {
11737 *pNum = 0;
11738 status = eHAL_STATUS_SUCCESS;
11739 }
11740 else if(*pNum >= pSession->NumBkidCache)
11741 {
11742 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011744 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 -070011745 pSession->NumBkidCache);
11746 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11747 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011748 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11749 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 *pNum = pSession->NumBkidCache;
11751 status = eHAL_STATUS_SUCCESS;
11752 }
11753 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011755}
Jeff Johnson295189b2012-06-20 16:38:30 -070011756tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11757{
11758 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011759}
11760#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011761eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11762 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11763{
11764 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11765 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011766
11767 if(!pSession)
11768 {
11769 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11770 return eHAL_STATUS_FAILURE;
11771 }
11772
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011773 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11775 {
11776#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11777 {
11778 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011779 vos_mem_set(&secEvent,
11780 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11782 secEvent.encryptionModeMulticast =
11783 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11784 secEvent.encryptionModeUnicast =
11785 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011786 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 secEvent.authMode =
11788 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11789 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11790 }
11791#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 status = eHAL_STATUS_SUCCESS;
11793 //numItems may be 0 to clear the cache
11794 pSession->NumPmkidCache = (tANI_U16)numItems;
11795 if(numItems && pPMKIDCache)
11796 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011797 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11798 sizeof(tPmkidCacheInfo) * numItems);
11799 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 }
11801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 return (status);
11803}
11804
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011805eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11806 tANI_U8 *pBSSId )
11807{
11808 eHalStatus status = eHAL_STATUS_FAILURE;
11809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11810 tANI_BOOLEAN fMatchFound = FALSE;
11811 tANI_U32 Index;
11812 if(!pSession)
11813 {
11814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11815 return eHAL_STATUS_FAILURE;
11816 }
11817 do
11818 {
11819 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11820 {
11821 smsLog(pMac, LOGW, "Delete PMKID for %02X-%02X-%02X-%02X-%02X-%02X ",
11822 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
11823 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
11824 {
11825 fMatchFound = TRUE;
11826 break;
11827 }
11828 }
11829 if( !fMatchFound ) break;
11830 palZeroMemory( pMac->hHdd, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo));
11831 status = eHAL_STATUS_SUCCESS;
11832 }
11833 while( 0 );
11834 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11835 fMatchFound, status);
11836 return status;
11837}
Jeff Johnson295189b2012-06-20 16:38:30 -070011838tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11839{
11840 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11841}
11842
Jeff Johnson295189b2012-06-20 16:38:30 -070011843eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11844{
11845 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11846 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011847
11848 if(!pSession)
11849 {
11850 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11851 return eHAL_STATUS_FAILURE;
11852 }
11853
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 if(pNum && pPmkidCache)
11855 {
11856 if(pSession->NumPmkidCache == 0)
11857 {
11858 *pNum = 0;
11859 status = eHAL_STATUS_SUCCESS;
11860 }
11861 else if(*pNum >= pSession->NumPmkidCache)
11862 {
11863 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11864 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011865 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 -070011866 pSession->NumPmkidCache);
11867 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11868 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011869 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11870 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 *pNum = pSession->NumPmkidCache;
11872 status = eHAL_STATUS_SUCCESS;
11873 }
11874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011875 return (status);
11876}
11877
Jeff Johnson295189b2012-06-20 16:38:30 -070011878eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11879{
11880 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11881 tANI_U32 len;
11882 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011883
11884 if(!pSession)
11885 {
11886 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11887 return eHAL_STATUS_FAILURE;
11888 }
11889
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 if(pLen)
11891 {
11892 len = *pLen;
11893 *pLen = pSession->nWpaRsnReqIeLength;
11894 if(pBuf)
11895 {
11896 if(len >= pSession->nWpaRsnReqIeLength)
11897 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011898 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11899 pSession->nWpaRsnReqIeLength);
11900 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011901 }
11902 }
11903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 return (status);
11905}
11906
Jeff Johnson295189b2012-06-20 16:38:30 -070011907eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11908{
11909 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11910 tANI_U32 len;
11911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011912
11913 if(!pSession)
11914 {
11915 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11916 return eHAL_STATUS_FAILURE;
11917 }
11918
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 if(pLen)
11920 {
11921 len = *pLen;
11922 *pLen = pSession->nWpaRsnRspIeLength;
11923 if(pBuf)
11924 {
11925 if(len >= pSession->nWpaRsnRspIeLength)
11926 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011927 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11928 pSession->nWpaRsnRspIeLength);
11929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 }
11931 }
11932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 return (status);
11934}
Jeff Johnson295189b2012-06-20 16:38:30 -070011935#ifdef FEATURE_WLAN_WAPI
11936eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11937{
11938 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11939 tANI_U32 len;
11940 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011941
11942 if(!pSession)
11943 {
11944 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11945 return eHAL_STATUS_FAILURE;
11946 }
11947
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 if(pLen)
11949 {
11950 len = *pLen;
11951 *pLen = pSession->nWapiReqIeLength;
11952 if(pBuf)
11953 {
11954 if(len >= pSession->nWapiReqIeLength)
11955 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011956 vos_mem_copy(pBuf, pSession->pWapiReqIE,
11957 pSession->nWapiReqIeLength);
11958 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011959 }
11960 }
11961 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 return (status);
11963}
Jeff Johnson295189b2012-06-20 16:38:30 -070011964eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11965{
11966 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11967 tANI_U32 len;
11968 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011969
11970 if(!pSession)
11971 {
11972 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11973 return eHAL_STATUS_FAILURE;
11974 }
11975
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 if(pLen)
11977 {
11978 len = *pLen;
11979 *pLen = pSession->nWapiRspIeLength;
11980 if(pBuf)
11981 {
11982 if(len >= pSession->nWapiRspIeLength)
11983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011984 vos_mem_copy(pBuf, pSession->pWapiRspIE,
11985 pSession->nWapiRspIeLength);
11986 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 }
11988 }
11989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011990 return (status);
11991}
11992#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011993eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11994{
11995 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11996 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011997
11998 if(!pSession)
11999 {
12000 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12001 return (retStatus);
12002 }
12003
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 if(CSR_IS_ROAMING(pSession))
12005 {
12006 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12007 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 return (retStatus);
12010}
12011
Jeff Johnson295189b2012-06-20 16:38:30 -070012012//This function remove the connected BSS from te cached scan result
12013eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12014 tCsrRoamConnectedProfile *pConnProfile)
12015{
12016 eHalStatus status = eHAL_STATUS_FAILURE;
12017 tCsrScanResultFilter *pScanFilter = NULL;
12018 tListElem *pEntry;
12019 tCsrScanResult *pResult;
12020 tDot11fBeaconIEs *pIes;
12021 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012022 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12023 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12024 {
12025 do
12026 {
12027 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012028 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12029 if ( NULL == pScanFilter )
12030 status = eHAL_STATUS_FAILURE;
12031 else
12032 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012034 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12035 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12036 if ( NULL == pScanFilter->BSSIDs.bssid )
12037 status = eHAL_STATUS_FAILURE;
12038 else
12039 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012041 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12042 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12044 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12045 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012046 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12047 if ( NULL == pScanFilter->SSIDs.SSIDList )
12048 status = eHAL_STATUS_FAILURE;
12049 else
12050 status = eHAL_STATUS_SUCCESS;
12051 if (!HAL_STATUS_SUCCESS(status)) break;
12052 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12053 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 }
12055 pScanFilter->authType.numEntries = 1;
12056 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12057 pScanFilter->BSSType = pConnProfile->BSSType;
12058 pScanFilter->EncryptionType.numEntries = 1;
12059 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12060 pScanFilter->mcEncryptionType.numEntries = 1;
12061 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12062 //We ignore the channel for now, BSSID should be enough
12063 pScanFilter->ChannelInfo.numOfChannels = 0;
12064 //Also ignore the following fields
12065 pScanFilter->uapsd_mask = 0;
12066 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12067 pScanFilter->countryCode[0] = 0;
12068 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 csrLLLock(&pMac->scan.scanResultList);
12070 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12071 while( pEntry )
12072 {
12073 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12074 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12075 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12076 pScanFilter, NULL, NULL, NULL, &pIes);
12077 //Release the IEs allocated by csrMatchBSS is needed
12078 if( !pResult->Result.pvIes )
12079 {
12080 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012081 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 }
12083 if(fMatch)
12084 {
12085 //We found the one
12086 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12087 {
12088 //Free the memory
12089 csrFreeScanResultEntry( pMac, pResult );
12090 }
12091 break;
12092 }
12093 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12094 }//while
12095 csrLLUnlock(&pMac->scan.scanResultList);
12096 }while(0);
12097 if(pScanFilter)
12098 {
12099 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012100 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 }
12102 }
12103 return (status);
12104}
12105
Jeff Johnson295189b2012-06-20 16:38:30 -070012106//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012107eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12108{
12109 eHalStatus status = eHAL_STATUS_SUCCESS;
12110 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12112 {
12113 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12114 {
12115 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12116 {
12117 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012118 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 status = eHAL_STATUS_CSR_WRONG_STATE;
12120 break;
12121 }
12122 if( csrIsConnStateInfra( pMac, sessionId ) )
12123 {
12124 if( chnId &&
12125 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012127 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12129 status = eHAL_STATUS_CSR_WRONG_STATE;
12130 break;
12131 }
12132 }
12133 }
12134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 return ( status );
12136}
12137
Jeff Johnson295189b2012-06-20 16:38:30 -070012138static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12139{
12140 eHalStatus status = eHAL_STATUS_SUCCESS;
12141 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12142 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012143
12144 if(!pSession)
12145 {
12146 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12147 return eHAL_STATUS_FAILURE;
12148 }
12149
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 if ( csrIsConnStateIbss( pMac, sessionId ) )
12151 {
12152 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12153 }
12154 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12155 {
12156 // Disassociate from the connected Infrastructure network...
12157 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12158 }
12159 else
12160 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12162 //Otherwise we need to add code to handle the
12163 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12164 //send stop_bss to PE, before we can continue.
12165 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012166 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012168 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12169 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 // there is no Bss description before we start an WDS so we need
12171 // to adopt all Bss configuration parameters from the Profile.
12172 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12173 if(HAL_STATUS_SUCCESS(status))
12174 {
12175 //Save profile for late use
12176 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012177 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12178 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012180 vos_mem_set(pSession->pCurRoamProfile,
12181 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012182 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012185 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012186 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12187 NULL, &bssConfig,
12188 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 }
12190 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012191
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 return( status );
12193}
12194
Jeff Johnson295189b2012-06-20 16:38:30 -070012195////////////////////Mail box
12196
Jeff Johnson295189b2012-06-20 16:38:30 -070012197//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12198//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012199static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12200 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12202{
12203 tCsrChannelSet channelGroup;
12204 tSirMacCapabilityInfo *pAP_capabilityInfo;
12205 tAniBool fTmp;
12206 tANI_BOOLEAN found = FALSE;
12207 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012208 tANI_S8 pwrLimit = 0;
12209 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012210 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12211 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12212 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12213 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 // 802.11h
12215 //We can do this because it is in HOST CPU order for now.
12216 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012217 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12218 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12219 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 fTmp = (tAniBool)pal_cpu_to_be32(1);
12221 }
12222 else
12223 fTmp = (tAniBool)0;
12224
12225 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012226 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 pBuf += sizeof(tAniBool);
12228 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012229 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012230 // This is required for 11k test VoWiFi Ent: Test 2.
12231 // We need the power capabilities for Assoc Req.
12232 // This macro is provided by the halPhyCfg.h. We pick our
12233 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012234 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12235 if (0 != pwrLimit)
12236 {
12237 *pBuf++ = pwrLimit;
12238 }
12239 else
12240 {
12241 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 size = sizeof(pMac->roam.validChannelList);
12244 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12245 {
12246 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12247 for ( i = 0; i < size; i++)
12248 {
12249 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12250
12251 }
12252 }
12253 else
12254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012255 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 *pBuf++ = 0; //tSirSupChnl->numChnl
12257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 //Check whether it is ok to enter UAPSD
12259#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12260 if( btcIsReadyForUapsd(pMac) )
12261#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12262 {
12263 *pBuf++ = uapsdMask;
12264 }
12265#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12266 else
12267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012268 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 *pBuf++ = 0;
12270 }
12271#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12272
Jeff Johnson295189b2012-06-20 16:38:30 -070012273 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012274 vos_mem_copy(pBuf, pBssDescription,
12275 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12277}
12278
Jeff Johnson295189b2012-06-20 16:38:30 -070012279/*
12280 * The communication between HDD and LIM is thru mailbox (MB).
12281 * Both sides will access the data structure "tSirSmeJoinReq".
12282 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12283 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12284 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12285 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12286 */
12287eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012288 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012289{
12290 eHalStatus status = eHAL_STATUS_SUCCESS;
12291 tSirSmeJoinReq *pMsg;
12292 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012293 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 tANI_U16 msgLen, wTmp, ieLen;
12295 tSirMacRateSet OpRateSet;
12296 tSirMacRateSet ExRateSet;
12297 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12298 tANI_U32 dwTmp;
12299 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012300 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012301
12302 if(!pSession)
12303 {
12304 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12305 return eHAL_STATUS_FAILURE;
12306 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012307 /* To satisfy klockworks */
12308 if (NULL == pBssDescription)
12309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012310 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012311 return eHAL_STATUS_FAILURE;
12312 }
12313
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 do {
12315 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12316 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012317 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12319 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12320 // IE fields, but the length field in the bssDescription needs to be interpreted to
12321 // determine length of the IE fields.
12322 //
12323 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12324 // add in the length from the bssDescription (then add the size of the 'length' field
12325 // itself because that is NOT included in the length field).
12326 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12327 pBssDescription->length + sizeof( pBssDescription->length ) +
12328 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 +053012329 pMsg = vos_mem_malloc(msgLen);
12330 if (NULL == pMsg)
12331 status = eHAL_STATUS_FAILURE;
12332 else
12333 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012335 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012336 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 pMsg->length = pal_cpu_to_be16(msgLen);
12338 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 // sessionId
12340 *pBuf = (tANI_U8)sessionId;
12341 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 // transactionId
12343 *pBuf = 0;
12344 *( pBuf + 1 ) = 0;
12345 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 // ssId
12347 if( pIes->SSID.present && pIes->SSID.num_ssid )
12348 {
12349 // ssId len
12350 *pBuf = pIes->SSID.num_ssid;
12351 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012352 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 pBuf += pIes->SSID.num_ssid;
12354 }
12355 else
12356 {
12357 *pBuf = 0;
12358 pBuf++;
12359 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012360 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012361 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12362 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 pBuf += sizeof(tSirMacAddr);
12364 // bsstype
12365 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12366 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012367 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 pBuf += sizeof(tSirBssType);
12369 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012370 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12371 if (pBssDescription->channelId <= 14 &&
12372 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12373 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12374 {
12375 //Need to disable VHT operation in 2.4 GHz band
12376 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12377 }
12378 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012379 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 //Persona
12381 *pBuf = (tANI_U8)pProfile->csrPersona;
12382 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012383 //CBMode
12384 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12385 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012386
12387 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012388 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12389
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 // uapsdPerAcBitmask
12391 *pBuf = pProfile->uapsd_mask;
12392 pBuf++;
12393
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012394
12395
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012397 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 {
12399 // OperationalRateSet
12400 if (OpRateSet.numRates) {
12401 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012402 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 pBuf += OpRateSet.numRates;
12404 } else *pBuf++ = 0;
12405 // ExtendedRateSet
12406 if (ExRateSet.numRates) {
12407 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012408 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 pBuf += ExRateSet.numRates;
12410 } else *pBuf++ = 0;
12411 }
12412 else
12413 {
12414 *pBuf++ = 0;
12415 *pBuf++ = 0;
12416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 // rsnIE
12418 if ( csrIsProfileWpa( pProfile ) )
12419 {
12420 // Insert the Wpa IE into the join request
12421 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12422 (tCsrWpaIe *)( wpaRsnIE ) );
12423 }
12424 else if( csrIsProfileRSN( pProfile ) )
12425 {
12426 // Insert the RSN IE into the join request
12427 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12428 (tCsrRSNIe *)( wpaRsnIE ) );
12429 }
12430#ifdef FEATURE_WLAN_WAPI
12431 else if( csrIsProfileWapi( pProfile ) )
12432 {
12433 // Insert the WAPI IE into the join request
12434 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12435 (tCsrWapiIe *)( wpaRsnIE ) );
12436 }
12437#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 else
12439 {
12440 ieLen = 0;
12441 }
12442 //remember the IE for future use
12443 if( ieLen )
12444 {
12445 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012447 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 -070012448 ieLen = DOT11F_IE_RSN_MAX_LEN;
12449 }
12450#ifdef FEATURE_WLAN_WAPI
12451 if( csrIsProfileWapi( pProfile ) )
12452 {
12453 //Check whether we need to allocate more memory
12454 if(ieLen > pSession->nWapiReqIeLength)
12455 {
12456 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12457 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012458 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012460 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12461 if (NULL == pSession->pWapiReqIE)
12462 status = eHAL_STATUS_FAILURE;
12463 else
12464 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 if(!HAL_STATUS_SUCCESS(status)) break;
12466 }
12467 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012468 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012470 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012472 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 pBuf += ieLen;
12474 }
12475 else//should be WPA/WPA2 otherwise
12476#endif /* FEATURE_WLAN_WAPI */
12477 {
12478 //Check whether we need to allocate more memory
12479 if(ieLen > pSession->nWpaRsnReqIeLength)
12480 {
12481 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12482 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012483 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012484 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012485 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12486 if (NULL == pSession->pWpaRsnReqIE)
12487 status = eHAL_STATUS_FAILURE;
12488 else
12489 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 if(!HAL_STATUS_SUCCESS(status)) break;
12491 }
12492 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012493 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012494 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012495 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012497 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 pBuf += ieLen;
12499 }
12500 }
12501 else
12502 {
12503 //free whatever old info
12504 pSession->nWpaRsnReqIeLength = 0;
12505 if(pSession->pWpaRsnReqIE)
12506 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012507 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012508 pSession->pWpaRsnReqIE = NULL;
12509 }
12510#ifdef FEATURE_WLAN_WAPI
12511 pSession->nWapiReqIeLength = 0;
12512 if(pSession->pWapiReqIE)
12513 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012514 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 pSession->pWapiReqIE = NULL;
12516 }
12517#endif /* FEATURE_WLAN_WAPI */
12518 //length is two bytes
12519 *pBuf = 0;
12520 *(pBuf + 1) = 0;
12521 pBuf += 2;
12522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012523#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012524 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012525 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012526 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 //length is two bytes
12528 *pBuf = 0;
12529 *(pBuf + 1) = 0;
12530 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012531 }
12532 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012534 // cckmIE
12535 if( csrIsProfileCCX( pProfile ) )
12536 {
12537 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012538#ifdef FEATURE_WLAN_CCX_UPLOAD
12539 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12540 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12541 pSession->suppCckmIeInfo.cckmIe, ieLen);
12542#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012543 ieLen = csrConstructCcxCckmIe( pMac,
12544 pSession,
12545 pProfile,
12546 pBssDescription,
12547 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012548 pSession->nWpaRsnReqIeLength,
12549 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012550#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012551 }
12552 else
12553 {
12554 ieLen = 0;
12555 }
12556 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12557 if( ieLen )
12558 {
12559 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12560 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012561 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012562 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012563 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012564 pBuf += ieLen;
12565 }
12566 else
12567 {
12568 //Indicate you have no CCKM IE
12569 //length is two bytes
12570 *pBuf = 0;
12571 *(pBuf + 1) = 0;
12572 pBuf += 2;
12573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 }
12575#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 // addIEScan
12577 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12578 {
12579 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 if(ieLen > pSession->nAddIEScanLength)
12581 {
12582 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12583 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012584 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012586 pSession->pAddIEScan = vos_mem_malloc(ieLen);
12587 if (NULL == pSession->pAddIEScan)
12588 status = eHAL_STATUS_FAILURE;
12589 else
12590 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 if(!HAL_STATUS_SUCCESS(status)) break;
12592 }
12593 pSession->nAddIEScanLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012594 vos_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012595 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012596 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012598 vos_mem_copy(pBuf, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 pBuf += ieLen;
12600 }
12601 else
12602 {
12603 pSession->nAddIEScanLength = 0;
12604 if(pSession->pAddIEScan)
12605 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012606 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 pSession->pAddIEScan = NULL;
12608 }
12609 *pBuf = 0;
12610 *(pBuf + 1) = 0;
12611 pBuf += 2;
12612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 // addIEAssoc
12614 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12615 {
12616 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 if(ieLen > pSession->nAddIEAssocLength)
12618 {
12619 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012620 {
12621 vos_mem_free(pSession->pAddIEAssoc);
12622 }
12623 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12624 if (NULL == pSession->pAddIEAssoc)
12625 status = eHAL_STATUS_FAILURE;
12626 else
12627 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012629 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012631 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012633 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012635 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 pBuf += ieLen;
12637 }
12638 else
12639 {
12640 pSession->nAddIEAssocLength = 0;
12641 if(pSession->pAddIEAssoc)
12642 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012643 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 pSession->pAddIEAssoc = NULL;
12645 }
12646 *pBuf = 0;
12647 *(pBuf + 1) = 0;
12648 pBuf += 2;
12649 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012650
12651 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012653 //Unmask any AC in reassoc that is ACM-set
12654 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12655 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012657 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12658 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012659#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012660 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012661#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012662 uapsd_mask &= ~(acm_mask);
12663 }
12664 else
12665 {
12666 uapsd_mask = 0;
12667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 }
12669 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012670
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012672 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012673 pBuf += sizeof(tANI_U32);
12674
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012676 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012677 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012678#ifdef WLAN_FEATURE_11W
12679 //MgmtEncryption
12680 if (pProfile->MFPEnabled)
12681 {
12682 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12683 }
12684 else
12685 {
12686 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12687 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012688 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012689 pBuf += sizeof(tANI_U32);
12690#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012691#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012692 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012693 if (csrIsProfile11r( pProfile )
12694#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012695 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12696 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012697#endif
12698 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012699 {
12700 // is11Rconnection;
12701 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012702 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012703 pBuf += sizeof(tAniBool);
12704 }
12705 else
12706 {
12707 // is11Rconnection;
12708 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012709 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012710 pBuf += sizeof(tAniBool);
12711 }
12712#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012713#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012714
12715 // isCCXFeatureIniEnabled
12716 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12717 {
12718 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012719 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012720 pBuf += sizeof(tAniBool);
12721 }
12722 else
12723 {
12724 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012725 vos_mem_copy(pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012726 pBuf += sizeof(tAniBool);
12727 }
12728
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012729 /* A profile can not be both CCX and 11R. But an 802.11R AP
12730 * may be advertising support for CCX as well. So if we are
12731 * associating Open or explicitly CCX then we will get CCX.
12732 * If we are associating explictly 11R only then we will get
12733 * 11R.
12734 */
12735 if ((csrIsProfileCCX(pProfile) ||
12736 ((pIes->CCXVersion.present)
12737 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012738 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12739 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12740 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012741#ifdef WLAN_FEATURE_11W
12742 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12743#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012744 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012745 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12746 {
12747 // isCCXconnection;
12748 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012749 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012750 pBuf += sizeof(tAniBool);
12751 }
12752 else
12753 {
12754 //isCCXconnection;
12755 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012756 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012757 pBuf += sizeof(tAniBool);
12758 }
12759
12760 if (eWNI_SME_JOIN_REQ == messageType)
12761 {
12762 tCCXTspecInfo ccxTspec;
12763 // CCX-Tspec IEs in the ASSOC request is presently not supported
12764 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012765 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12766 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012767 pBuf += sizeof(tCCXTspecInfo);
12768 }
12769 else if (eWNI_SME_REASSOC_REQ == messageType)
12770 {
12771 if ((csrIsProfileCCX(pProfile) ||
12772 ((pIes->CCXVersion.present)
12773 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012774 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12775 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12776 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012777#ifdef WLAN_FEATURE_11W
12778 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12779#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012780 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012781 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 {
12783 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012785 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12787 *pBuf = ccxTspec.numTspecs;
12788 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 // Copy the TSPEC information only if present
12790 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012791 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12792 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 }
12794 pBuf += sizeof(ccxTspec.tspec);
12795 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012796 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012798 tCCXTspecInfo ccxTspec;
12799 // CCX-Tspec IEs in the ASSOC request is presently not supported
12800 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012801 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12802 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 pBuf += sizeof(tCCXTspecInfo);
12804 }
12805 }
12806#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012807#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012809 if (pMac->roam.configParam.isFastTransitionEnabled
12810#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012811 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012812#endif
12813 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012814 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012815 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012816 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012817 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012818 }
12819 else
12820 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012821 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012822 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012823 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 }
12825#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012826#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012827 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012828 {
12829 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012830 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012831 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012832 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012833 }
12834 else
12835 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012836 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012837 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012838 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012839 }
12840#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012841
12842 // txLdpcIniFeatureEnabled
12843 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12844 pBuf++;
12845
Kiran4a17ebe2013-01-31 10:43:43 -080012846 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12847 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12848 {
12849 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12850 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12851 csrApplyPower2Current(pMac);
12852 }
12853
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012854#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012855 // txBFIniFeatureEnabled
12856 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12857 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012858
12859 // txBFCsnValue
12860 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12861 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012862#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012863 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12864 pBuf++;
12865
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012866 //BssDesc
12867 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12868 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012869
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012870 status = palSendMBMessage(pMac->hHdd, pMsg );
12871 if(!HAL_STATUS_SUCCESS(status))
12872 {
12873 break;
12874 }
12875 else
12876 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012877#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012878 if (eWNI_SME_JOIN_REQ == messageType)
12879 {
12880 //Tush-QoS: notify QoS module that join happening
12881 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12882 }
12883 else if (eWNI_SME_REASSOC_REQ == messageType)
12884 {
12885 //Tush-QoS: notify QoS module that reassoc happening
12886 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012888#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012889 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012892}
12893
Jeff Johnson295189b2012-06-20 16:38:30 -070012894//
12895eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12896{
12897 eHalStatus status = eHAL_STATUS_SUCCESS;
12898 tSirSmeDisassocReq *pMsg;
12899 tANI_U8 *pBuf;
12900 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12902 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12903 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012905 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12906 if (NULL == pMsg)
12907 status = eHAL_STATUS_FAILURE;
12908 else
12909 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012911 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12913 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 pBuf = &pMsg->sessionId;
12915 // sessionId
12916 *pBuf++ = (tANI_U8)sessionId;
12917 // transactionId
12918 *pBuf = 0;
12919 *( pBuf + 1 ) = 0;
12920 pBuf += sizeof(tANI_U16);
12921
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012922 if ( (pSession->pCurRoamProfile != NULL) &&
12923 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12924 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 {
12926 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012927 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12928 sizeof( tSirMacAddr ));
12929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012932 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12933 //perMacAddr is passed as bssId for softAP
12934 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012935 pBuf = pBuf + sizeof ( tSirMacAddr );
12936 }
12937 else
12938 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012940 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12941 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053012943 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
12944 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 if(!HAL_STATUS_SUCCESS(status))
12948 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012949 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 break;
12951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 // reasonCode
12953 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053012954 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
12955 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 if(!HAL_STATUS_SUCCESS(status))
12957 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012958 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 break;
12960 }
12961 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012962 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12963 Here we should not send the disassoc over the air to the AP */
12964 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12965#ifdef WLAN_FEATURE_VOWIFI_11R
12966 && csrRoamIs11rAssoc(pMac)
12967#endif
12968 )
12969 {
12970 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12971 }
12972 pBuf += sizeof(tANI_U8);
12973 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012975 return( status );
12976}
Jeff Johnson295189b2012-06-20 16:38:30 -070012977eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12978{
12979 eHalStatus status = eHAL_STATUS_SUCCESS;
12980 tSirSmeTkipCntrMeasReq *pMsg;
12981 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 do
12983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012984 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
12985 if ( NULL == pMsg )
12986 status = eHAL_STATUS_FAILURE;
12987 else
12988 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012990 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12992 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 pBuf = &pMsg->sessionId;
12994 // sessionId
12995 *pBuf++ = (tANI_U8)sessionId;
12996 // transactionId
12997 *pBuf = 0;
12998 *( pBuf + 1 ) = 0;
12999 pBuf += sizeof(tANI_U16);
13000 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013001 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13002 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 pBuf = pBuf + sizeof ( tSirMacAddr );
13004 // bEnable
13005 *pBuf = (tANI_BOOLEAN)bEnable;
13006 if(!HAL_STATUS_SUCCESS(status))
13007 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013008 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 break;
13010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 return( status );
13014}
Jeff Johnson295189b2012-06-20 16:38:30 -070013015eHalStatus
13016csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13017 VOS_MODULE_ID modId, tSirMacAddr bssId,
13018 void *pUsrContext, void *pfnSapEventCallback,
13019 tANI_U8 *pAssocStasBuf )
13020{
13021 eHalStatus status = eHAL_STATUS_SUCCESS;
13022 tSirSmeGetAssocSTAsReq *pMsg;
13023 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13024 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 do
13026 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013027 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13028 if ( NULL == pMsg )
13029 status = eHAL_STATUS_FAILURE;
13030 else
13031 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013032 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013033 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 pBuf = (tANI_U8 *)&pMsg->bssId;
13036 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013038 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 // modId
13041 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013042 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 // pUsrContext
13045 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013046 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 // pfnSapEventCallback
13049 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013050 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 // pAssocStasBuf
13053 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013054 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 status = palSendMBMessage( pMac->hHdd, pMsg );
13058 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 return( status );
13060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013061eHalStatus
13062csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13063 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13064 {
13065 eHalStatus status = eHAL_STATUS_SUCCESS;
13066 tSirSmeGetWPSPBCSessionsReq *pMsg;
13067 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13068 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 do
13070 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013071 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13072 if ( NULL == pMsg )
13073 status = eHAL_STATUS_FAILURE;
13074 else
13075 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013077 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013080 VOS_ASSERT(pBuf);
13081
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 // pUsrContext
13084 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013085 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 // pSapEventCallback
13088 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013089 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013092 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013095 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 return( status );
13101}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013102
13103eHalStatus
13104csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13105{
13106 tpSirChangeBIParams pMsg;
13107 tANI_U16 len = 0;
13108 eHalStatus status = eHAL_STATUS_SUCCESS;
13109 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13110
13111 if(!pSession)
13112 {
13113 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13114 return eHAL_STATUS_FAILURE;
13115 }
13116
13117 //NO need to update the Beacon Params if update beacon parameter flag is not set
13118 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13119 return eHAL_STATUS_SUCCESS;
13120
13121 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13122
13123 /* Create the message and send to lim */
13124 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013125 pMsg = vos_mem_malloc(len);
13126 if ( NULL == pMsg )
13127 status = eHAL_STATUS_FAILURE;
13128 else
13129 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013130 if(HAL_STATUS_SUCCESS(status))
13131 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013132 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013133 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13134 pMsg->length = len;
13135
13136 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013137 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13138 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013139 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13140 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013141 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013142 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013143 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13144 status = palSendMBMessage(pMac->hHdd, pMsg);
13145 }
13146 return status;
13147}
13148
Jeff Johnson295189b2012-06-20 16:38:30 -070013149eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13150{
13151 eHalStatus status = eHAL_STATUS_SUCCESS;
13152 tSirSmeDeauthReq *pMsg;
13153 tANI_U8 *pBuf;
13154 tANI_U16 wTmp;
13155 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13156 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13157 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013159 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13160 if ( NULL == pMsg )
13161 status = eHAL_STATUS_FAILURE;
13162 else
13163 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013165 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13167 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13168 //sessionId
13169 pBuf = &pMsg->sessionId;
13170 *pBuf++ = (tANI_U8)sessionId;
13171
13172 //tansactionId
13173 *pBuf = 0;
13174 *(pBuf + 1 ) = 0;
13175 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13179 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013180 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13181 sizeof( pMsg->peerMacAddr ) );
13182 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 pBuf = pBuf + sizeof(tSirMacAddr);
13184 }
13185 else
13186 {
13187 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013188 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13189 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 }
13192 if(!HAL_STATUS_SUCCESS(status))
13193 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013194 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 break;
13196 }
13197 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013198 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13199 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 pBuf = pBuf + sizeof(tSirMacAddr);
13201 if(!HAL_STATUS_SUCCESS(status))
13202 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013203 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013204 break;
13205 }
13206 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013207 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13208 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 if(!HAL_STATUS_SUCCESS(status))
13210 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013211 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 break;
13213 }
13214 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 return( status );
13217}
13218
Jeff Johnson295189b2012-06-20 16:38:30 -070013219eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13220{
13221 eHalStatus status = eHAL_STATUS_SUCCESS;
13222 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013224 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13225 if ( NULL == pMsg )
13226 status = eHAL_STATUS_FAILURE;
13227 else
13228 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013230 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13232 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13233 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013234 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13235 sizeof(pMsg->peerMacAddr));
13236 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 if(!HAL_STATUS_SUCCESS(status))
13238 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013239 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 break;
13241 }
13242//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013243 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13244 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 if(!HAL_STATUS_SUCCESS(status))
13246 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013247 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 break;
13249 }
13250//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 return( status );
13254}
13255
Jeff Johnson295189b2012-06-20 16:38:30 -070013256eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13257{
13258 eHalStatus status = eHAL_STATUS_SUCCESS;
13259 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013261 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13262 if ( NULL == pMsg )
13263 status = eHAL_STATUS_FAILURE;
13264 else
13265 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013267 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13269 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13270 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013271 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13272 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 if(!HAL_STATUS_SUCCESS(status))
13274 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013275 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 break;
13277 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013278 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13279 sizeof(pMsg->peerMacAddr));
13280 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 if(!HAL_STATUS_SUCCESS(status))
13282 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013283 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 break;
13285 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013288 return( status );
13289}
Jeff Johnson295189b2012-06-20 16:38:30 -070013290eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13291{
13292 eHalStatus status = eHAL_STATUS_SUCCESS;
13293 tSirSmeAssocCnf *pMsg;
13294 tANI_U8 *pBuf;
13295 tSirResultCodes statusCode;
13296 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013298 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13299 if ( NULL == pMsg )
13300 status = eHAL_STATUS_FAILURE;
13301 else
13302 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013304 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13306 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 pBuf = (tANI_U8 *)&pMsg->statusCode;
13308 if(HAL_STATUS_SUCCESS(Halstatus))
13309 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13310 else
13311 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013312 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 pBuf += sizeof(tSirResultCodes);
13314 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013315 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13316 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013317 pBuf += sizeof (tSirMacAddr);
13318 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013319 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13320 sizeof(tSirMacAddr));
13321 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 pBuf += sizeof (tSirMacAddr);
13323 // aid
13324 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 pBuf += sizeof (tANI_U16);
13327 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013328 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pBuf += sizeof (tSirMacAddr);
13331 // alternateChannelId
13332 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 status = palSendMBMessage( pMac->hHdd, pMsg );
13334 if(!HAL_STATUS_SUCCESS(status))
13335 {
13336 //pMsg is freed by palSendMBMessage
13337 break;
13338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 return( status );
13341}
Jeff Johnson295189b2012-06-20 16:38:30 -070013342eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13343 tpSirSmeAssocInd pAssocInd,
13344 eHalStatus Halstatus,
13345 tANI_U8 sessionId)
13346{
13347 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13349 tANI_U8 *pBuf;
13350 tSirResultCodes statusCode;
13351 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013353 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13354 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13355 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013356
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13358 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13359
13360 pMsg->sessionId = sessionId;
13361
13362 pBuf = (tANI_U8 *)&pMsg->statusCode;
13363 if(HAL_STATUS_SUCCESS(Halstatus))
13364 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13365 else
13366 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013367 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 pBuf += sizeof(tSirResultCodes);
13369 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013370 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 pBuf += sizeof (tSirMacAddr);
13372 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013373 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13374 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 pBuf += sizeof (tSirMacAddr);
13376 // StaId
13377 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013378 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 pBuf += sizeof (tANI_U16);
13380 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 pBuf += sizeof (tSirMacAddr);
13383 // alternateChannelId
13384 *pBuf = 11;
13385 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013386 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 //Wmm
13388 *pBuf = pAssocInd->wmmEnabledSta;
13389 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013391 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013394 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 //reassocReq
13397 *pBuf = pAssocInd->reassocReq;
13398 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13400 msgQ.bodyptr = pMsg;
13401 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013404 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013405}
Jeff Johnson295189b2012-06-20 16:38:30 -070013406
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013407eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13409 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13410 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13411 tANI_U8 *pKeyRsc )
13412{
13413 tSirSmeSetContextReq *pMsg;
13414 tANI_U16 msgLen;
13415 eHalStatus status = eHAL_STATUS_FAILURE;
13416 tAniEdType tmpEdType;
13417 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013418 tANI_U8 *pBuf = NULL;
13419 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013421 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13424 // key set. Since we only support upto one key, we always allocate memory for 1 key
13425 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13426 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13427 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13428 ( sizeof( pMsg->keyMaterial.key ) );
13429
Kiet Lam64c1b492013-07-12 13:56:44 +053013430 pMsg = vos_mem_malloc(msgLen);
13431 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13432 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13434 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 //sessionId
13436 pBuf = &pMsg->sessionId;
13437 *pBuf = (tANI_U8)sessionId;
13438 pBuf++;
13439 // transactionId
13440 *pBuf = 0;
13441 *(pBuf + 1) = 0;
13442 pBuf += sizeof(tANI_U16);
13443 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013444 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013445
13446 pBuf += sizeof(tSirMacAddr);
13447
13448 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013449 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13450 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013451
13452 pBuf += sizeof(tSirMacAddr);
13453
13454 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13456 // in the tSirKeyMaterial keyMaterial; field).
13457 //
13458 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13459 // shorter than this max size. Is LIM interpreting this ok ?
13460 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 -070013461 // set pMsg->keyMaterial.edType
13462 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013463 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 // set the pMsg->keyMaterial.numKeys field
13466 *p = numKeys;
13467 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 // set pSirKey->keyId = keyId;
13469 *p = keyId;
13470 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 // set pSirKey->unicast = (tANI_U8)fUnicast;
13472 *p = (tANI_U8)fUnicast;
13473 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 // set pSirKey->keyDirection = aniKeyDirection;
13475 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013476 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 p += sizeof(tAniKeyDirection);
13478 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013479 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 // set pSirKey->paeRole
13482 *p = paeRole; // 0 is Supplicant
13483 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 // set pSirKey->keyLength = keyLength;
13485 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 if ( keyLength && pKey )
13487 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013488 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 if(keyLength == 16)
13490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013491 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 -070013492 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13493 pKey[5], pKey[6], pKey[7], pKey[8],
13494 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13495 }
13496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013499 return( status );
13500}
13501
Jeff Johnson295189b2012-06-20 16:38:30 -070013502eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13503 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13504{
13505 eHalStatus status;
13506 tSirSmeStartBssReq *pMsg;
13507 tANI_U8 *pBuf = NULL;
13508 tANI_U8 *wTmpBuf = NULL;
13509 tANI_U16 msgLen, wTmp;
13510 tANI_U32 dwTmp;
13511 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013512 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013515
13516 if(!pSession)
13517 {
13518 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13519 return eHAL_STATUS_FAILURE;
13520 }
13521
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 do {
13523 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13524 pSession->joinFailStatusCode.reasonCode = 0;
13525 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013526 pMsg = vos_mem_malloc(msgLen);
13527 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13528 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 //sessionId
13533 *pBuf = (tANI_U8)sessionId;
13534 pBuf++;
13535 // transactionId
13536 *pBuf = 0;
13537 *(pBuf + 1) = 0;
13538 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013540 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 pBuf += sizeof(tSirMacAddr);
13542 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013543 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 pBuf += sizeof(tSirMacAddr);
13545 // beaconInterval
13546 if( pBssDesc && pBssDesc->beaconInterval )
13547 {
13548 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 else if(pParam->beaconInterval)
13551 {
13552 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 else
13555 {
13556 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13557 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013558 if(csrIsconcurrentsessionValid (pMac, sessionId,
13559 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013560 == eHAL_STATUS_SUCCESS )
13561 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013562 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013563 pParam->bssPersona);
13564 //Update the beacon Interval
13565 pParam->beaconInterval = wTmp;
13566 }
13567 else
13568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013569 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013570 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013571 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013572 return status;
13573 }
13574
Kiet Lam64c1b492013-07-12 13:56:44 +053013575 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pBuf += sizeof(tANI_U16);
13577 // dot11mode
13578 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13579 pBuf += 1;
13580 // bssType
13581 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013582 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 pBuf += sizeof(tSirBssType);
13584 // ssId
13585 if( pParam->ssId.length )
13586 {
13587 // ssId len
13588 *pBuf = pParam->ssId.length;
13589 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013590 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pBuf += pParam->ssId.length;
13592 }
13593 else
13594 {
13595 *pBuf = 0;
13596 pBuf++;
13597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 // set the channel Id
13599 *pBuf = pParam->operationChn;
13600 pBuf++;
13601 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013602 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013603 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013604 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013605
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 // Set privacy
13607 *pBuf = pParam->privacy;
13608 pBuf++;
13609
13610 //Set Uapsd
13611 *pBuf = pParam->ApUapsdEnable;
13612 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 //Set SSID hidden
13614 *pBuf = pParam->ssidHidden;
13615 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13617 pBuf++;
13618
13619 //Ht protection Enable/Disable
13620 *pBuf = (tANI_U8)pParam->protEnabled;
13621 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 //Enable Beacons to Receive for OBSS protection Enable/Disable
13623 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13624 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 //set cfg related to protection
13626 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013627 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 // Set Auth type
13630 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 // Set DTIM
13634 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013635 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 // Set wps_state
13638 *pBuf = pParam->wps_state;
13639 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013640 // set isCoalesingInIBSSAllowed
13641 *pBuf = pMac->isCoalesingInIBSSAllowed;
13642 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 //Persona
13644 *pBuf = (tANI_U8)pParam->bssPersona;
13645 pBuf++;
13646
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013647 //txLdpcIniFeatureEnabled
13648 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13649 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013650
krunal soni4f087d22013-07-29 16:32:26 -070013651 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13653 {
13654 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013655 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 break;
13657 }
13658 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013659 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 pBuf += sizeof(tANI_U16);
13661 if( wTmp )
13662 {
13663 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013664 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 pBuf += wTmp;
13666 }
13667 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013668 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13671 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013672 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13673 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 pBuf += pParam->operationalRateSet.numRates ;
13675 *pBuf++ = pParam->extendedRateSet.numRates;
13676 if(0 != pParam->extendedRateSet.numRates)
13677 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013678 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13679 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 pBuf += pParam->extendedRateSet.numRates;
13681 }
krunal sonie9002db2013-11-25 14:24:17 -080013682
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13684 pMsg->length = pal_cpu_to_be16(msgLen);
13685
13686 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 return( status );
13689}
13690
Jeff Johnson295189b2012-06-20 16:38:30 -070013691eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13692{
13693 eHalStatus status = eHAL_STATUS_FAILURE;
13694 tSirSmeStopBssReq *pMsg;
13695 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13696 tANI_U8 *pBuf;
13697 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013698
13699 if(!pSession)
13700 {
13701 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13702 return eHAL_STATUS_FAILURE;
13703 }
13704
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013706 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13707 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13708 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13710 pBuf = &pMsg->sessionId;
13711 //sessionId
13712 *pBuf = (tANI_U8)sessionId;
13713 pBuf++;
13714 // transactionId
13715 *pBuf = 0;
13716 pBuf += sizeof(tANI_U16);
13717 //reason code
13718 *pBuf = 0;
13719 pBuf += sizeof(tSirResultCodes);
13720 // bssid
13721 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13722 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13723 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013724 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13725 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 }
13727 else
13728 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13730 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 }
13732 pBuf += sizeof(tSirMacAddr);
13733 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13734 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 status = palSendMBMessage( pMac->hHdd, pMsg );
13736#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013737 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13738 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13739 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13741 pMsg->reasonCode = 0;
13742 // bssid
13743 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13744 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13745 {
13746 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13747 }
13748 else
13749 {
13750 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13751 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013752 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 pMsg->transactionId = 0;
13754 pMsg->sessionId = (tANI_U8)sessionId;
13755 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13756 status = palSendMBMessage( pMac->hHdd, pMsg );
13757#endif
13758 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 return( status );
13760}
13761
Jeff Johnson295189b2012-06-20 16:38:30 -070013762eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13763 tCsrRoamModifyProfileFields *pModProfileFields,
13764 tANI_U32 *pRoamId, v_BOOL_t fForce)
13765{
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 eHalStatus status = eHAL_STATUS_FAILURE;
13767 tANI_U32 roamId = 0;
13768 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013770 (fForce || (!vos_mem_compare( &pModProfileFields,
13771 &pSession->connectedProfile.modifyProfileFields,
13772 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 {
13774 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13775 if(pRoamId)
13776 {
13777 *pRoamId = roamId;
13778 }
13779
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13781 eCsrSmeIssuedReassocToSameAP, roamId,
13782 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 return status;
13785}
Jeff Johnson295189b2012-06-20 16:38:30 -070013786static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13787{
13788 eHalStatus status = eHAL_STATUS_SUCCESS;
13789 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013790 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13792 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13793 return (status);
13794}
Jeff Johnson295189b2012-06-20 16:38:30 -070013795eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13796{
13797 eHalStatus status = eHAL_STATUS_SUCCESS;
13798 tListElem *pEntry = NULL;
13799 tSmeCmd *pCommand = NULL;
13800 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 do
13802 {
13803 if(pMsg == NULL)
13804 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013805 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 status = eHAL_STATUS_FAILURE;
13807 break;
13808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13810 if(pEntry)
13811 {
13812 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13813 if(eSmeCommandAddStaSession == pCommand->command)
13814 {
13815 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013816 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 //Remove this command out of the active list
13820 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13821 {
13822 //Now put this command back on the avilable command list
13823 csrReleaseCommand(pMac, pCommand);
13824 }
13825 smeProcessPendingQueue( pMac );
13826 }
13827 else
13828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013829 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 -070013830 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 status = eHAL_STATUS_FAILURE;
13832 break;
13833 }
13834 }
13835 else
13836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013837 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 -070013838 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 status = eHAL_STATUS_FAILURE;
13840 break;
13841 }
13842 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013844}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013845eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13846 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013847{
13848 tSirSmeAddStaSelfReq *pMsg;
13849 tANI_U16 msgLen;
13850 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013852 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 pMsg = vos_mem_malloc(msgLen);
13854 if ( NULL == pMsg ) break;
13855 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13857 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013859 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013860 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13861
13862 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13863
Arif Hussain24bafea2013-11-15 15:10:03 -080013864 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
13865 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 return( status );
13869}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013870eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13871 tANI_U32 sessionId,
13872 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013873{
13874 eHalStatus status = eHAL_STATUS_SUCCESS;
13875 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 pCommand = csrGetCommandBuffer(pMac);
13877 if(NULL == pCommand)
13878 {
13879 status = eHAL_STATUS_RESOURCES;
13880 }
13881 else
13882 {
13883 pCommand->command = eSmeCommandAddStaSession;
13884 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013885 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13886 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013887 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13889 if( !HAL_STATUS_SUCCESS( status ) )
13890 {
13891 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013892 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 }
13894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 return (status);
13896}
Jeff Johnson295189b2012-06-20 16:38:30 -070013897eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13898{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013899 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013900}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013901eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13902 csrRoamCompleteCallback callback,
13903 void *pContext, tANI_U8 *pSelfMacAddr,
13904 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013905{
13906 eHalStatus status = eHAL_STATUS_SUCCESS;
13907 tANI_U32 i;
13908 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 *pbSessionId = CSR_SESSION_ID_INVALID;
13910 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13911 {
13912 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13913 {
13914 pSession = CSR_GET_SESSION( pMac, i );
13915 status = eHAL_STATUS_SUCCESS;
13916 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13917 pSession->sessionId = (tANI_U8)i;
13918 pSession->callback = callback;
13919 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013920 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013922 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13923 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013925 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013927 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 break;
13929 }
13930#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013931 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13932 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013934 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013936 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013937 break;
13938 }
13939#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013940 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 break;
13942 }
13943 }
13944 if( CSR_ROAM_SESSION_MAX == i )
13945 {
13946 //No session is available
13947 status = eHAL_STATUS_RESOURCES;
13948 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 return ( status );
13950}
Jeff Johnson295189b2012-06-20 16:38:30 -070013951eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13952{
13953 eHalStatus status = eHAL_STATUS_SUCCESS;
13954 tListElem *pEntry = NULL;
13955 tSmeCmd *pCommand = NULL;
13956 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 do
13958 {
13959 if(pMsg == NULL)
13960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013961 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 status = eHAL_STATUS_FAILURE;
13963 break;
13964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13966 if(pEntry)
13967 {
13968 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13969 if(eSmeCommandDelStaSession == pCommand->command)
13970 {
13971 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013973 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 //This session is done.
13975 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 if(pCommand->u.delStaSessionCmd.callback)
13977 {
13978
13979 status = sme_ReleaseGlobalLock( &pMac->sme );
13980 if ( HAL_STATUS_SUCCESS( status ) )
13981 {
13982 pCommand->u.delStaSessionCmd.callback(
13983 pCommand->u.delStaSessionCmd.pContext);
13984 status = sme_AcquireGlobalLock( &pMac->sme );
13985 if (! HAL_STATUS_SUCCESS( status ) )
13986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013987 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 return status;
13989 }
13990 }
13991 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013992 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 }
13994 }
13995
13996 //Remove this command out of the active list
13997 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13998 {
13999 //Now put this command back on the avilable command list
14000 csrReleaseCommand(pMac, pCommand);
14001 }
14002 smeProcessPendingQueue( pMac );
14003 }
14004 else
14005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014006 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 -070014007 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 status = eHAL_STATUS_FAILURE;
14009 break;
14010 }
14011 }
14012 else
14013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014014 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 -070014015 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 status = eHAL_STATUS_FAILURE;
14017 break;
14018 }
14019 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014021}
Jeff Johnson295189b2012-06-20 16:38:30 -070014022eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14023{
14024 tSirSmeDelStaSelfReq *pMsg;
14025 tANI_U16 msgLen;
14026 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14029 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014030 pMsg = vos_mem_malloc(msgLen);
14031 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14032 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14034 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014036 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14037 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 return( status );
14041}
Jeff Johnson295189b2012-06-20 16:38:30 -070014042eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14043 tSirMacAddr sessionMacAddr,
14044 csrRoamSessionCloseCallback callback,
14045 void *pContext)
14046{
14047 eHalStatus status = eHAL_STATUS_SUCCESS;
14048 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 pCommand = csrGetCommandBuffer(pMac);
14050 if(NULL == pCommand)
14051 {
14052 status = eHAL_STATUS_RESOURCES;
14053 }
14054 else
14055 {
14056 pCommand->command = eSmeCommandDelStaSession;
14057 pCommand->sessionId = (tANI_U8)sessionId;
14058 pCommand->u.delStaSessionCmd.callback = callback;
14059 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014060 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14061 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014062 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14063 if( !HAL_STATUS_SUCCESS( status ) )
14064 {
14065 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014066 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 }
14068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 return (status);
14070}
Jeff Johnson295189b2012-06-20 16:38:30 -070014071eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14072{
14073 return csrSendMBDelSelfStaReqMsg( pMac,
14074 pCommand->u.delStaSessionCmd.selfMacAddr );
14075}
Jeff Johnson295189b2012-06-20 16:38:30 -070014076static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14077{
14078 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14079 tListElem *pEntry, *pNext;
14080 tSmeCmd *pCommand;
14081 tDblLinkList localList;
14082
14083 vos_mem_zero(&localList, sizeof(tDblLinkList));
14084 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14085 {
14086 smsLog(pMac, LOGE, FL(" failed to open list"));
14087 return;
14088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 csrLLLock(pList);
14090 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14091 while(pEntry != NULL)
14092 {
14093 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14094 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14095 if(pCommand->sessionId == sessionId)
14096 {
14097 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14098 {
14099 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14100 }
14101 }
14102 pEntry = pNext;
14103 }
14104 csrLLUnlock(pList);
14105
14106 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14107 {
14108 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14109 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14110 }
14111 csrLLClose(&localList);
14112}
14113
Jeff Johnson295189b2012-06-20 16:38:30 -070014114void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14115{
14116 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14117 {
14118 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 csrRoamStop(pMac, sessionId);
14120 csrFreeConnectBssDesc(pMac, sessionId);
14121 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14122 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014123 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014124#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014125 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014126#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014127 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14128 if (pMac->fScanOffload)
14129 {
14130 purgeSmeSessionCmdList(pMac, sessionId,
14131 &pMac->sme.smeScanCmdPendingList);
14132 }
14133
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 purgeCsrSessionCmdList(pMac, sessionId);
14135 csrInitSession(pMac, sessionId);
14136 }
14137}
14138
Jeff Johnson295189b2012-06-20 16:38:30 -070014139eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14140 tANI_BOOLEAN fSync,
14141 csrRoamSessionCloseCallback callback,
14142 void *pContext )
14143{
14144 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14146 {
14147 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14148 if(fSync)
14149 {
14150 csrCleanupSession(pMac, sessionId);
14151 }
14152 else
14153 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014154 purgeSmeSessionCmdList(pMac, sessionId,
14155 &pMac->sme.smeCmdPendingList);
14156 if (pMac->fScanOffload)
14157 {
14158 purgeSmeSessionCmdList(pMac, sessionId,
14159 &pMac->sme.smeScanCmdPendingList);
14160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 purgeCsrSessionCmdList(pMac, sessionId);
14162 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14163 pSession->selfMacAddr, callback, pContext);
14164 }
14165 }
14166 else
14167 {
14168 status = eHAL_STATUS_INVALID_PARAMETER;
14169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 return ( status );
14171}
14172
Jeff Johnson295189b2012-06-20 16:38:30 -070014173static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14174{
14175 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014176
14177 if(!pSession)
14178 {
14179 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14180 return;
14181 }
14182
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14184 pSession->sessionId = CSR_SESSION_ID_INVALID;
14185 pSession->callback = NULL;
14186 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014187 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14188 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14189 csrFreeRoamProfile( pMac, sessionId );
14190 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14191 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14192 csrFreeConnectBssDesc(pMac, sessionId);
14193 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014194 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14195 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014197 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014198 pSession->pWpaRsnReqIE = NULL;
14199 }
14200 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014201 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014203 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 pSession->pWpaRsnRspIE = NULL;
14205 }
14206 pSession->nWpaRsnRspIeLength = 0;
14207#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014208 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014210 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 pSession->pWapiReqIE = NULL;
14212 }
14213 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014214 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014215 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014216 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 pSession->pWapiRspIE = NULL;
14218 }
14219 pSession->nWapiRspIeLength = 0;
14220#endif /* FEATURE_WLAN_WAPI */
Kiet Lam64c1b492013-07-12 13:56:44 +053014221 if (pSession->pAddIEScan)
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014223 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 pSession->pAddIEScan = NULL;
14225 }
14226 pSession->nAddIEScanLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014227 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014229 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014233}
14234
Jeff Johnson295189b2012-06-20 16:38:30 -070014235eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14236{
14237 eHalStatus status = eHAL_STATUS_FAILURE;
14238 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14240 {
14241 if( CSR_IS_SESSION_VALID( pMac, i ) )
14242 {
14243 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14244 {
14245 //Found it
14246 status = eHAL_STATUS_SUCCESS;
14247 *pSessionId = i;
14248 break;
14249 }
14250 }
14251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 return( status );
14253}
14254
Jeff Johnson295189b2012-06-20 16:38:30 -070014255//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14256//session because for IBSS, the bssid changes.
14257static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14258{
14259 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14260 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14262 {
14263 if( CSR_IS_SESSION_VALID( pMac, i ) )
14264 {
14265 pSession = CSR_GET_SESSION( pMac, i );
14266 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14267 {
14268 //Found it
14269 nRet = i;
14270 break;
14271 }
14272 }
14273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 return (nRet);
14275}
Jeff Johnson295189b2012-06-20 16:38:30 -070014276static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14277{
14278 /* Update the current BSS info in ho control block based on connected
14279 profile info from pmac global structure */
14280
Arif Hussain24bafea2013-11-15 15:10:03 -080014281 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14282 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 /* Check for user misconfig of RSSI trigger threshold */
14284 pMac->roam.configParam.vccRssiThreshold =
14285 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14286 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14287 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 /* Check for user misconfig of UL MAC Loss trigger threshold */
14289 pMac->roam.configParam.vccUlMacLossThreshold =
14290 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14291 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014292#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14293 {
14294 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 /* Indicate the neighbor roal algorithm about the connect indication */
14296 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14297 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14298 }
14299#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014300}
14301
Jeff Johnson295189b2012-06-20 16:38:30 -070014302static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14303{
14304 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014305
14306 if(!pSession)
14307 {
14308 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14309 return;
14310 }
14311
Jeff Johnson295189b2012-06-20 16:38:30 -070014312 //Only to handle the case for Handover on infra link
14313 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14314 {
14315 return;
14316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14318 csrRoamDeregStatisticsReq(pMac);
14319 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14320#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14321 /* Indicate the neighbor roal algorithm about the disconnect indication */
14322 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14323#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014324
14325 //Remove this code once SLM_Sessionization is supported
14326 //BMPS_WORKAROUND_NOT_NEEDED
14327 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014328 csrIsInfraApStarted( pMac ) &&
14329 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014330 {
14331 pMac->roam.configParam.doBMPSWorkaround = 0;
14332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014333}
14334
Jeff Johnson295189b2012-06-20 16:38:30 -070014335void csrRoamTlStatsTimerHandler(void *pv)
14336{
14337 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14338 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14340
Jeff Johnsone7245742012-09-05 17:12:55 -070014341 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14342
Jeff Johnson295189b2012-06-20 16:38:30 -070014343#if 0
14344 // TODO Persession .???
14345 //req TL for stats
14346 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014348 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 }
14350 else
14351 {
14352 //save in SME
14353 csrRoamSaveStatsFromTl(pMac, tlStats);
14354 }
14355#endif
14356 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14357 {
14358 if(pMac->roam.tlStatsReqInfo.periodicity)
14359 {
14360 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014361 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14362 pMac->roam.tlStatsReqInfo.periodicity);
14363 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014365 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 return;
14367 }
14368 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14369 }
14370 }
14371}
Jeff Johnson295189b2012-06-20 16:38:30 -070014372void csrRoamPeStatsTimerHandler(void *pv)
14373{
14374 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14375 eHalStatus status;
14376 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14377 VOS_STATUS vosStatus;
14378 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 pPeStatsReqListEntry->timerRunning = FALSE;
14380 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14381 {
14382 // If we entered here, meaning the timer could not be successfully
14383 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14384
14385 /* Destroy the timer */
14386 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14387 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014389 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 }
14391
14392 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014393 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 pPeStatsReqListEntry = NULL;
14395 }
14396 else
14397 {
14398 if(!pPeStatsReqListEntry->rspPending)
14399 {
14400 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14401 pPeStatsReqListEntry->staId);
14402 if(!HAL_STATUS_SUCCESS(status))
14403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014404 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 }
14406 else
14407 {
14408 pPeStatsReqListEntry->rspPending = TRUE;
14409 }
14410 }
14411
14412 //send down a req
14413 if(pPeStatsReqListEntry->periodicity &&
14414 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14415 {
14416 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14417 if(ePMC_FULL_POWER == powerState)
14418 {
14419 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14420 {
14421 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14422 }
14423 }
14424 else
14425 {
14426 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14427 {
14428 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14429 }
14430 }
14431 //start timer
14432 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14433 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014435 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 return;
14437 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014438 pPeStatsReqListEntry->timerRunning = TRUE;
14439
14440 }
14441
14442 }
14443}
Jeff Johnson295189b2012-06-20 16:38:30 -070014444void csrRoamStatsClientTimerHandler(void *pv)
14445{
14446 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14448 {
14449#if 0
14450 // TODO Stats fix for multisession
14451 //start the timer
14452 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14453
14454 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014456 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 }
14458#endif
14459 }
14460#if 0
14461 //send up the stats report
14462 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14463 pStaEntry->staId, pStaEntry->pContext);
14464#endif
14465}
14466
14467
14468
Jeff Johnson295189b2012-06-20 16:38:30 -070014469eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14470{
14471 tAniGetPEStatsReq *pMsg;
14472 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014473 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14474 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014476 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014477 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 }
14479 // need to initiate a stats request to PE
14480 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14481 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14482 pMsg->staId = staId;
14483 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 if(!HAL_STATUS_SUCCESS(status))
14486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014487 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014489 return status;
14490}
Jeff Johnson295189b2012-06-20 16:38:30 -070014491void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14492{
14493 tAniGetPEStatsRsp *pSmeStatsRsp;
14494 eHalStatus status = eHAL_STATUS_FAILURE;
14495 tListElem *pEntry = NULL;
14496 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14497 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14498 tANI_U32 tempMask = 0;
14499 tANI_U8 counter = 0;
14500 tANI_U8 *pStats = NULL;
14501 tANI_U32 length = 0;
14502 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014503 v_S7_t rssi = 0, snr = 0;
14504 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014505 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14507 if(pSmeStatsRsp->rc)
14508 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014509 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 goto post_update;
14511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 tempMask = pSmeStatsRsp->statsMask;
14513 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 /* subtract all statistics from this length, and after processing the entire
14515 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14516 * in this 'stats' message.
14517 */
14518 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 //new stats info from PE, fill up the stats strucutres in PMAC
14520 while(tempMask)
14521 {
14522 if(tempMask & 1)
14523 {
14524 switch(counter)
14525 {
14526 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014527 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014528 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14529 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 pStats += sizeof(tCsrSummaryStatsInfo);
14531 length -= sizeof(tCsrSummaryStatsInfo);
14532 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014534 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014535 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14536 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14538 length -= sizeof(tCsrGlobalClassAStatsInfo);
14539 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014541 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014542 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14543 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14545 length -= sizeof(tCsrGlobalClassBStatsInfo);
14546 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014548 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014549 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14550 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14552 length -= sizeof(tCsrGlobalClassCStatsInfo);
14553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014555 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014556 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14557 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014558 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14559 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 }
14561 else
14562 {
14563 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014564 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 VOS_ASSERT( 0 );
14566 }
14567 if(!HAL_STATUS_SUCCESS(status))
14568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014569 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014570 }
14571 pStats += sizeof(tCsrPerStaStatsInfo);
14572 length -= sizeof(tCsrPerStaStatsInfo);
14573 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014575 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 }
14578 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 tempMask >>=1;
14580 counter++;
14581 }
14582 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14583 if (length != 0)
14584 {
14585 pRssi = (tANI_U32*)pStats;
14586 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014587 pStats += sizeof(tANI_U32);
14588 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 }
14590 else
14591 {
14592 /* If riva is not sending rssi, continue to use the hack */
14593 rssi = RSSI_HACK_BMPS;
14594 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014595
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014597
14598 if (length != 0)
14599 {
14600 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014601 pStats += sizeof(tANI_U32);
14602 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014603 }
14604 else
14605 {
14606 linkCapacity = 0;
14607 }
14608
14609 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014610
14611 if (length != 0)
14612 {
14613 pSnr = (tANI_U32*)pStats;
14614 snr = (v_S7_t)*pSnr;
14615 }
14616 else
14617 {
14618 snr = SNR_HACK_BMPS;
14619 }
14620
14621 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014622post_update:
14623 //make sure to update the pe stats req list
14624 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14625 if(pEntry)
14626 {
14627 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14628 pPeStaEntry->rspPending = FALSE;
14629
14630 }
14631 //check the one timer cases
14632 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14633 if(pEntry)
14634 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014635 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 if(pTempStaEntry->timerExpired)
14637 {
14638 //send up the stats report
14639 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14640 pTempStaEntry->staId, pTempStaEntry->pContext);
14641 //also remove from the client list
14642 csrRoamRemoveStatListEntry(pMac, pEntry);
14643 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 }
14645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014646}
Jeff Johnson295189b2012-06-20 16:38:30 -070014647tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14648{
14649 tListElem *pEntry = NULL;
14650 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014652 if(!pEntry)
14653 {
14654 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014655 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014656 return NULL;
14657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 while( pEntry )
14659 {
14660 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014661 if(pTempStaEntry->statsMask == statsMask)
14662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014663 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014664 break;
14665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 return pEntry;
14669}
14670
Jeff Johnson295189b2012-06-20 16:38:30 -070014671tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14672 tANI_BOOLEAN update)
14673{
14674 tListElem *pEntry;
14675 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014677 if(!pEntry)
14678 {
14679 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014680 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014681 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014682 return NULL;
14683 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 while( pEntry )
14685 {
14686 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14688 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014690 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 if(update)
14692 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014693 pTempStaEntry->periodicity = pStaEntry->periodicity;
14694 pTempStaEntry->callback = pStaEntry->callback;
14695 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 }
14697 break;
14698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014701 return pEntry;
14702}
Jeff Johnson295189b2012-06-20 16:38:30 -070014703tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14704{
14705 tListElem *pEntry;
14706 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 if(!pEntry)
14709 {
14710 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014711 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014712 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 return NULL;
14714 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014715 while( pEntry )
14716 {
14717 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014718 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014720 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 break;
14722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 return pEntry;
14726}
Jeff Johnson295189b2012-06-20 16:38:30 -070014727eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14728 csrRoamLinkQualityIndCallback callback,
14729 void *pContext)
14730{
14731 pMac->roam.linkQualityIndInfo.callback = callback;
14732 pMac->roam.linkQualityIndInfo.context = pContext;
14733 if( NULL == callback )
14734 {
14735 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14736 }
14737 else
14738 {
14739 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014740 /* do we need to invoke the callback to notify client of initial value ?? */
14741 }
14742 return eHAL_STATUS_SUCCESS;
14743}
Jeff Johnson295189b2012-06-20 16:38:30 -070014744void csrRoamVccTrigger(tpAniSirGlobal pMac)
14745{
14746 eCsrRoamLinkQualityInd newVccLinkQuality;
14747 tANI_U32 ul_mac_loss = 0;
14748 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14750 /*-------------------------------------------------------------------------
14751 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 Check for a change in link quality and notify client if necessary
14753 -------------------------------------------------------------------------*/
14754 ul_mac_loss_trigger_threshold =
14755 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014757 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014759 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014761 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14763 }
14764 else
14765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014766 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14770 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014773 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014776 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 newVccLinkQuality );
14778
14779 /* we now invoke the callback once to notify client of initial value */
14780 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14781 pMac->roam.linkQualityIndInfo.context );
14782 //event: EVENT_WLAN_VCC
14783 }
14784 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014785 pMac->roam.vccLinkQuality = newVccLinkQuality;
14786
Jeff Johnson295189b2012-06-20 16:38:30 -070014787}
Jeff Johnson295189b2012-06-20 16:38:30 -070014788VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14789 v_U8_t rssiNotification,
14790 void * context)
14791{
14792 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14793 eCsrRoamLinkQualityInd newVccLinkQuality;
14794 // TODO : Session info unavailable
14795 tANI_U32 sessionId = 0;
14796 VOS_STATUS status = VOS_STATUS_SUCCESS;
14797 /*-------------------------------------------------------------------------
14798 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 Check for a change in link quality and notify client if necessary
14800 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014801 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 pMac->roam.configParam.vccRssiThreshold);
14803 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14804 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014805 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 return VOS_STATUS_SUCCESS;
14807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014808 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014810 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14812 }
14813 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014815 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14817 }
14818 else
14819 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014820 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 //Set to this so the code below won't do anything
14822 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 VOS_ASSERT(0);
14824 }
14825
Jeff Johnson295189b2012-06-20 16:38:30 -070014826 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014831 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 /* we now invoke the callback once to notify client of initial value */
14834 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14835 pMac->roam.linkQualityIndInfo.context );
14836 //event: EVENT_WLAN_VCC
14837 }
14838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 return status;
14841}
Jeff Johnson295189b2012-06-20 16:38:30 -070014842tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14843 tDblLinkList *pStaList,
14844 tCsrStatsClientReqInfo *pStaEntry)
14845{
14846 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 //if same entity requested for same set of stats with different periodicity &
14848 // callback update it
14849 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14850 {
14851
Kiet Lam64c1b492013-07-12 13:56:44 +053014852 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14853 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 {
14855 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014856 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 return NULL;
14858 }
14859
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 pNewStaEntry->callback = pStaEntry->callback;
14861 pNewStaEntry->pContext = pStaEntry->pContext;
14862 pNewStaEntry->periodicity = pStaEntry->periodicity;
14863 pNewStaEntry->requesterId = pStaEntry->requesterId;
14864 pNewStaEntry->statsMask = pStaEntry->statsMask;
14865 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14866 pNewStaEntry->pMac = pStaEntry->pMac;
14867 pNewStaEntry->staId = pStaEntry->staId;
14868 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14869
14870 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14871 }
14872 return pNewStaEntry;
14873}
14874
Jeff Johnson295189b2012-06-20 16:38:30 -070014875tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14876 tDblLinkList *pStaList,
14877 tCsrPeStatsReqInfo *pStaEntry)
14878{
14879 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014880 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14881 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 {
14883 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014884 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 return NULL;
14886 }
14887
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14889 pNewStaEntry->numClient = pStaEntry->numClient;
14890 pNewStaEntry->periodicity = pStaEntry->periodicity;
14891 pNewStaEntry->statsMask = pStaEntry->statsMask;
14892 pNewStaEntry->pMac = pStaEntry->pMac;
14893 pNewStaEntry->staId = pStaEntry->staId;
14894 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14895 pNewStaEntry->rspPending = pStaEntry->rspPending;
14896
14897 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014898 return pNewStaEntry;
14899}
Jeff Johnson295189b2012-06-20 16:38:30 -070014900eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14901 tCsrRssiCallback callback,
14902 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14903{
14904 eHalStatus status = eHAL_STATUS_SUCCESS;
14905 vos_msg_t msg;
14906 tANI_U32 sessionId;
14907
14908 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014909 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014910 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14911 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014913 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014914 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14917
14918 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14919 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14920 pMsg->sessionId = sessionId;
14921 pMsg->staId = staId;
14922 pMsg->rssiCallback = callback;
14923 pMsg->pDevContext = pContext;
14924 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 msg.type = eWNI_SME_GET_RSSI_REQ;
14926 msg.bodyptr = pMsg;
14927 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014930 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014931 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 status = eHAL_STATUS_FAILURE;
14933 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014934 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 return status;
14936}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014937
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014938eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14939 tCsrSnrCallback callback,
14940 tANI_U8 staId, tCsrBssid bssId,
14941 void *pContext)
14942{
14943 eHalStatus status = eHAL_STATUS_SUCCESS;
14944 vos_msg_t msg;
14945 tANI_U32 sessionId;
14946
14947 tAniGetSnrReq *pMsg;
14948
14949 smsLog(pMac, LOG2, FL("called"));
14950
14951 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14952 if (NULL == pMsg )
14953 {
14954 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14955 return status;
14956 }
14957
14958 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14959
14960 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14961 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14962 pMsg->sessionId = sessionId;
14963 pMsg->staId = staId;
14964 pMsg->snrCallback = callback;
14965 pMsg->pDevContext = pContext;
14966 msg.type = eWNI_SME_GET_SNR_REQ;
14967 msg.bodyptr = pMsg;
14968 msg.reserved = 0;
14969
14970 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14971 {
14972 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14973 vos_mem_free((v_VOID_t *)pMsg);
14974 status = eHAL_STATUS_FAILURE;
14975 }
14976
14977 smsLog(pMac, LOG2, FL("returned"));
14978 return status;
14979}
14980
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014981#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14982eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14983 tCsrRssiCallback callback,
14984 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14985{
14986 eHalStatus status = eHAL_STATUS_SUCCESS;
14987 tAniGetRssiReq *pMsg;
14988
Kiet Lam64c1b492013-07-12 13:56:44 +053014989 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14990 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014991 {
14992 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053014993 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014994 }
14995 // need to initiate a stats request to PE
14996 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14997 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14998 pMsg->staId = staId;
14999 pMsg->rssiCallback = callback;
15000 pMsg->pDevContext = pContext;
15001 pMsg->pVosContext = pVosContext;
15002 status = palSendMBMessage(pMac->hHdd, pMsg );
15003 if(!HAL_STATUS_SUCCESS(status))
15004 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015005 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15006 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015007 status = eHAL_STATUS_FAILURE;
15008 }
15009 return status;
15010}
15011#endif
15012
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015013
15014
15015#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15016eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15017 tCsrTsmStatsCallback callback,
15018 tANI_U8 staId,
15019 tCsrBssid bssId,
15020 void *pContext,
15021 void* pVosContext,
15022 tANI_U8 tid)
15023{
15024 eHalStatus status = eHAL_STATUS_SUCCESS;
15025 tAniGetTsmStatsReq *pMsg = NULL;
15026
15027 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15028 if ( !HAL_STATUS_SUCCESS(status) )
15029 {
15030 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15031 return status;
15032 }
15033 // need to initiate a stats request to PE
15034 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15035 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15036 pMsg->staId = staId;
15037 pMsg->tid = tid;
15038 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15039 pMsg->tsmStatsCallback = callback;
15040 pMsg->pDevContext = pContext;
15041 pMsg->pVosContext = pVosContext;
15042 status = palSendMBMessage(pMac->hHdd, pMsg );
15043 if(!HAL_STATUS_SUCCESS(status))
15044 {
15045 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15046 //pMsg is freed by palSendMBMessage
15047 status = eHAL_STATUS_FAILURE;
15048 }
15049 return status;
15050}
15051#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15052
15053
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015054/* ---------------------------------------------------------------------------
15055 \fn csrGetTLSTAState
15056 \helper function to get teh TL STA State whenever the function is called.
15057
15058 \param staId - The staID to be passed to the TL
15059 to get the relevant TL STA State
15060 \return the state as tANI_U16
15061 ---------------------------------------------------------------------------*/
15062tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15063{
15064 WLANTL_STAStateType tlSTAState;
15065 tlSTAState = WLANTL_STA_INIT;
15066
15067 //request TL for STA State
15068 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15069 {
15070 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15071 }
15072
15073 return tlSTAState;
15074}
15075
Jeff Johnson295189b2012-06-20 16:38:30 -070015076eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15077 tANI_U32 statsMask,
15078 tCsrStatsCallback callback,
15079 tANI_U32 periodicity, tANI_BOOLEAN cache,
15080 tANI_U8 staId, void *pContext)
15081{
15082 tCsrStatsClientReqInfo staEntry;
15083 tCsrStatsClientReqInfo *pStaEntry = NULL;
15084 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15085 tListElem *pEntry = NULL;
15086 tANI_BOOLEAN found = FALSE;
15087 eHalStatus status = eHAL_STATUS_SUCCESS;
15088 tANI_BOOLEAN insertInClientList = FALSE;
15089 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015090 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015091
15092 if( csrIsAllSessionDisconnected(pMac) )
15093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015094 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 return eHAL_STATUS_FAILURE;
15096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 if((!statsMask) && (!callback))
15098 {
15099 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015100 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 return eHAL_STATUS_FAILURE;
15102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 //for the search list method for deregister
15104 staEntry.requesterId = requesterId;
15105 staEntry.statsMask = statsMask;
15106 //requester wants to deregister or just an error
15107 if((statsMask) && (!callback))
15108 {
15109 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15110 if(!pEntry)
15111 {
15112 //msg
15113 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015114 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015115 return eHAL_STATUS_FAILURE;
15116 }
15117 else
15118 {
15119 //clean up & return
15120 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015121 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015123 pStaEntry->pPeStaEntry->numClient--;
15124 //check if we need to delete the entry from peStatsReqList too
15125 if(!pStaEntry->pPeStaEntry->numClient)
15126 {
15127 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15128 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015130
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 //check if we need to stop the tl stats timer too
15132 pMac->roam.tlStatsReqInfo.numClient--;
15133 if(!pMac->roam.tlStatsReqInfo.numClient)
15134 {
15135 if(pMac->roam.tlStatsReqInfo.timerRunning)
15136 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015137 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15138 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015139 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015140 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 return eHAL_STATUS_FAILURE;
15142 }
15143 }
15144 pMac->roam.tlStatsReqInfo.periodicity = 0;
15145 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15146 }
15147 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 // Destroy the vos timer...
15149 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15150 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015152 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 csrRoamRemoveStatListEntry(pMac, pEntry);
15155 pStaEntry = NULL;
15156 return eHAL_STATUS_SUCCESS;
15157 }
15158 }
15159
15160 if(cache && !periodicity)
15161 {
15162 //return the cached stats
15163 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15164 }
15165 else
15166 {
15167 //add the request in the client req list
15168 staEntry.callback = callback;
15169 staEntry.pContext = pContext;
15170 staEntry.periodicity = periodicity;
15171 staEntry.pPeStaEntry = NULL;
15172 staEntry.staId = staId;
15173 staEntry.pMac = pMac;
15174 staEntry.timerExpired = FALSE;
15175
15176
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 //if periodic report requested with non cached result from PE/TL
15178 if(periodicity)
15179 {
15180
15181 //if looking for stats from PE
15182 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15183 {
15184
15185 //check if same request made already & waiting for rsp
15186 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15187 periodicity, &found, staId);
15188 if(!pPeStaEntry)
15189 {
15190 //bail out, maxed out on number of req for PE
15191 return eHAL_STATUS_FAILURE;
15192 }
15193 else
15194 {
15195 staEntry.pPeStaEntry = pPeStaEntry;
15196 }
15197
15198 }
15199 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15200 if(statsMask & (1 << eCsrGlobalClassDStats))
15201 {
15202 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015204 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 }
15206 else
15207 {
15208
15209 //update periodicity
15210 if(pMac->roam.tlStatsReqInfo.periodicity)
15211 {
15212 pMac->roam.tlStatsReqInfo.periodicity =
15213 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15214 }
15215 else
15216 {
15217 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15218 }
15219 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15220 {
15221 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15222 }
15223
15224 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15225 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015226 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015227 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015229 //req TL for class D stats
15230 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015232 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015233 }
15234 else
15235 {
15236 //save in SME
15237 csrRoamSaveStatsFromTl(pMac, pTlStats);
15238 }
15239 vos_mem_free(pTlStats);
15240 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 }
15242 else
15243 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015244 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015245 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015246
Jeff Johnson295189b2012-06-20 16:38:30 -070015247 if(pMac->roam.tlStatsReqInfo.periodicity)
15248 {
15249 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015250 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15251 pMac->roam.tlStatsReqInfo.periodicity);
15252 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015254 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 return eHAL_STATUS_FAILURE;
15256 }
15257 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15258 }
15259 }
15260 }
15261 pMac->roam.tlStatsReqInfo.numClient++;
15262 }
15263
15264 insertInClientList = TRUE;
15265 }
15266 //if one time report requested with non cached result from PE/TL
15267 else if(!cache && !periodicity)
15268 {
15269 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15270 {
15271 //send down a req
15272 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15273 if(!HAL_STATUS_SUCCESS(status))
15274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015275 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015276 }
15277 //so that when the stats rsp comes back from PE we respond to upper layer
15278 //right away
15279 staEntry.timerExpired = TRUE;
15280 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 }
15282 if(statsMask & (1 << eCsrGlobalClassDStats))
15283 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015284 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015285 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015287 //req TL for class D stats
15288 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015290 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015291 }
15292 else
15293 {
15294 //save in SME
15295 csrRoamSaveStatsFromTl(pMac, pTlStats);
15296 }
15297 vos_mem_free(pTlStats);
15298 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 }
15300 else
15301 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015302 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015304
15305 }
15306 //if looking for stats from TL only
15307 if(!insertInClientList)
15308 {
15309 //return the stats
15310 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 if(insertInClientList)
15314 {
15315 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15316 if(!pStaEntry)
15317 {
15318 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015319 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 return eHAL_STATUS_FAILURE;
15321 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015322 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 //Init & start timer if needed
15324 if(periodicity)
15325 {
15326 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15327 csrRoamStatsClientTimerHandler, pStaEntry );
15328 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015330 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 return eHAL_STATUS_FAILURE;
15332 }
15333 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15334 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015336 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 return eHAL_STATUS_FAILURE;
15338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 }
15342 return eHAL_STATUS_SUCCESS;
15343}
15344
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015345#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15346
15347static tSirRetStatus
15348csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15349 tANI_U8* pBD,
15350 tANI_U8 type,
15351 tANI_U8 subType,
15352 tSirMacAddr peerAddr,
15353 tSirMacAddr selfMacAddr)
15354{
15355 tSirRetStatus statusCode = eSIR_SUCCESS;
15356 tpSirMacMgmtHdr pMacHdr;
15357
15358 /* Prepare MAC management header */
15359 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15360
15361 /* Prepare FC */
15362 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15363 pMacHdr->fc.type = type;
15364 pMacHdr->fc.subType = subType;
15365
15366 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015367 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15368 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015369
15370 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15371
15372 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015373 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15374 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015375 return statusCode;
15376} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15377
15378static tSirRetStatus
15379csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15380 tANI_U8 nChannelNum,
15381 tANI_U32 dot11mode,
15382 tSirMacAddr selfMacAddr,
15383 tANI_U8 *pFrame,
15384 tANI_U16 *pusLen)
15385{
15386 tDot11fProbeRequest pr;
15387 tANI_U32 nStatus, nBytes, nPayload;
15388 tSirRetStatus nSirStatus;
15389 /*Bcast tx*/
15390 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15391 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15392
15393
Kiet Lam64c1b492013-07-12 13:56:44 +053015394 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015395
15396 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15397
15398 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15399 {
15400 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15401 }
15402
15403
15404 if (IS_DOT11_MODE_HT(dot11mode))
15405 {
15406 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15407 }
15408
15409
15410 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15411 if ( DOT11F_FAILED( nStatus ) )
15412 {
15413 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15414 "Failed to calculate the packed size f"
15415 "or a Probe Request (0x%08x).\n", nStatus );
15416
15417
15418 nPayload = sizeof( tDot11fProbeRequest );
15419 }
15420 else if ( DOT11F_WARNED( nStatus ) )
15421 {
15422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15423 "There were warnings while calculating"
15424 "the packed size for a Probe Request ("
15425 "0x%08x).\n", nStatus );
15426 }
15427
15428 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15429
15430 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015431 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015432
15433
15434 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015435 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015436
15437 if ( eSIR_SUCCESS != nSirStatus )
15438 {
15439 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15440 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15441 nSirStatus );
15442 return nSirStatus;
15443 }
15444
15445
15446 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15447 sizeof( tSirMacMgmtHdr ),
15448 nPayload, &nPayload );
15449 if ( DOT11F_FAILED( nStatus ) )
15450 {
15451 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15452 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15453 return eSIR_FAILURE;
15454 }
15455 else if ( DOT11F_WARNED( nStatus ) )
15456 {
15457 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015458 "There were warnings while packing a Probe Request (0x%08x).\n",
15459 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015460 }
15461
15462 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15463 return eSIR_SUCCESS;
15464}
15465
15466eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15467{
15468 vos_msg_t msg;
15469 tSirRoamOffloadScanReq *pRequestBuf;
15470 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15471 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015472 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015473 tANI_U8 *ChannelList = NULL;
15474 tANI_U32 sessionId;
15475 eHalStatus status = eHAL_STATUS_SUCCESS;
15476 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015477 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015478 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015479 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15480
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015481 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015482 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015483 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015484 return eHAL_STATUS_FAILURE;
15485 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015486
15487 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15488 {
15489 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15490 return eHAL_STATUS_FAILURE;
15491 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015492 status = csrRoamGetSessionIdFromBSSID(pMac,
15493 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15494 &sessionId);
15495 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15496 * It is important to ensure that the command is passed down to the FW only
15497 * if the Infra Station is in a connected state.A connected station could also be
15498 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15499 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15500 * irrespective of whichever state we are in.*/
15501 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15502 (command != ROAM_SCAN_OFFLOAD_STOP))
15503 {
15504 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15505 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15506 return eHAL_STATUS_FAILURE;
15507 }
15508
15509 if ( !HAL_STATUS_SUCCESS( status ) )
15510 {
15511 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15512 return eHAL_STATUS_FAILURE;
15513 }
15514 pSession = CSR_GET_SESSION( pMac, sessionId );
15515 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15516 if (NULL == pRequestBuf)
15517 {
15518 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15519 return eHAL_STATUS_FAILED_ALLOC;
15520 }
15521
Kiet Lam64c1b492013-07-12 13:56:44 +053015522 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015523 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15524 * host driver reloads, but Riva still up and running*/
15525 if(command == ROAM_SCAN_OFFLOAD_STOP)
15526 pRequestBuf->RoamScanOffloadEnabled = 0;
15527 else
15528 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015529 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15530 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015531 sizeof(tCsrBssid));
15532 pRequestBuf->ConnectedNetwork.ssId.length =
15533 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15534 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15535 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15536 pRequestBuf->ConnectedNetwork.ssId.length);
15537 pRequestBuf->ConnectedNetwork.authentication =
15538 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15539 pRequestBuf->ConnectedNetwork.encryption =
15540 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15541 pRequestBuf->ConnectedNetwork.mcencryption =
15542 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15543 pRequestBuf->LookupThreshold =
15544 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15545 pRequestBuf->RoamRssiDiff =
15546 pMac->roam.configParam.RoamRssiDiff;
15547 pRequestBuf->Command = command;
15548 pRequestBuf->StartScanReason = reason;
15549 pRequestBuf->NeighborScanTimerPeriod =
15550 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15551 pRequestBuf->NeighborRoamScanRefreshPeriod =
15552 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15553 pRequestBuf->NeighborScanChannelMinTime =
15554 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15555 pRequestBuf->NeighborScanChannelMaxTime =
15556 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15557 pRequestBuf->EmptyRefreshScanPeriod =
15558 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015559 /* MAWC feature */
15560 pRequestBuf->MAWCEnabled =
15561 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015562#ifdef FEATURE_WLAN_CCX
15563 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15564#endif
15565 if (
15566#ifdef FEATURE_WLAN_CCX
15567 ((pNeighborRoamInfo->isCCXAssoc) &&
15568 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15569 eANI_BOOLEAN_FALSE)) ||
15570 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15571#endif // CCX
15572 currChannelListInfo->numOfChannels == 0)
15573 {
15574
15575 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
15576 * Give Preference to INI Channels.*/
15577 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15578 {
15579 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15580 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
15581 {
15582 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15583 {
15584 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15585 }
15586 ChannelList++;
15587 }
15588 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15589 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15590 }
15591 else{
15592 ChannelList = pMac->scan.occupiedChannels.channelList;
15593 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15594 {
15595 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15596 {
15597 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15598 }
15599 ChannelList++;
15600 }
15601 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15602 /* If the profile changes as to what it was earlier, inform the FW through
15603 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15604 * for the earlier profile and try to learn them afresh.*/
15605 if (reason == REASON_FLUSH_CHANNEL_LIST)
15606 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15607 else {
15608 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15609 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15610 else
15611 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15612 }
15613 }
15614 }
15615#ifdef FEATURE_WLAN_CCX
15616 else
15617 {
15618 /* If CCX is enabled, and a neighbor Report is received,then
15619 * Ignore the INI Channels or the Occupied Channel List. Consider
15620 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015621 if (currChannelListInfo->numOfChannels != 0)
15622 {
15623 ChannelList = currChannelListInfo->ChannelList;
15624 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015625 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015626 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15627 {
15628 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15629 }
15630 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015631 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015632 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15633 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15634 }
15635 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015636#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015637 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15638 {
15639 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15640 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15641 }
15642 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15643 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15644 pRequestBuf->ChannelCacheType,
15645 pRequestBuf->ConnectedNetwork.ChannelCount,
15646 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015647 num_channels = 0;
15648 ChannelList = NULL;
15649
15650 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015651 host_channels = sizeof(pMac->roam.validChannelList);
15652 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015653 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015654 ChannelList = pMac->roam.validChannelList;
15655 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015656 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015657 else
15658 {
15659 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15660 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015661 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015662 return eHAL_STATUS_FAILURE;
15663 }
15664 for(i=0; i<pMac->roam.numValidChannels; i++)
15665 {
15666 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15667 {
15668 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15669 }
15670 ChannelList++;
15671 }
15672 pRequestBuf->ValidChannelCount = num_channels;
15673
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015674 pRequestBuf->MDID.mdiePresent =
15675 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15676 pRequestBuf->MDID.mobilityDomain =
15677 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015678 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15679
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015680 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015681
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015682 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15683 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15684 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15685 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15686 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15687
15688 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15689 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015690 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015691 msg.reserved = 0;
15692 msg.bodyptr = pRequestBuf;
15693 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15694 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015695 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15696 vos_mem_free(pRequestBuf);
15697 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015698 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015699 else
15700 {
15701 if (ROAM_SCAN_OFFLOAD_START == command)
15702 bRoamScanOffloadStarted = VOS_TRUE;
15703 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15704 bRoamScanOffloadStarted = VOS_FALSE;
15705 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015706
15707 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15708 return status;
15709}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015710
15711eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15712{
15713 switch(reason)
15714 {
15715 case 0:
15716 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15717 break;
15718 case REASON_OS_REQUESTED_ROAMING_NOW:
15719 csrNeighborRoamProceedWithHandoffReq(pMac);
15720 break;
15721 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015722 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 -070015723 }
15724 return eHAL_STATUS_SUCCESS;
15725}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015726#endif
15727
Jeff Johnson295189b2012-06-20 16:38:30 -070015728tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15729 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15730{
15731 tANI_BOOLEAN found = FALSE;
15732 eHalStatus status = eHAL_STATUS_SUCCESS;
15733 tCsrPeStatsReqInfo staEntry;
15734 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15735 tListElem *pStaEntry = NULL;
15736 VOS_STATUS vosStatus;
15737 tPmcPowerState powerState;
15738 *pFound = FALSE;
15739
15740 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15741 if(pStaEntry)
15742 {
15743 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15744 if(pTempStaEntry->periodicity)
15745 {
15746 pTempStaEntry->periodicity =
15747 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15748 }
15749 else
15750 {
15751 pTempStaEntry->periodicity = periodicity;
15752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015753 pTempStaEntry->numClient++;
15754 found = TRUE;
15755 }
15756 else
15757 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015758 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015759 staEntry.numClient = 1;
15760 staEntry.periodicity = periodicity;
15761 staEntry.pMac = pMac;
15762 staEntry.rspPending = FALSE;
15763 staEntry.staId = staId;
15764 staEntry.statsMask = statsMask;
15765 staEntry.timerRunning = FALSE;
15766 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15767 if(!pTempStaEntry)
15768 {
15769 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015770 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015771 return NULL;
15772 }
15773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015774 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15775 if(ePMC_FULL_POWER == powerState)
15776 {
15777 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15778 {
15779 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15780 }
15781 }
15782 else
15783 {
15784 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15785 {
15786 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15787 }
15788 }
15789 if(!pTempStaEntry->timerRunning)
15790 {
15791 //send down a req in case of one time req, for periodic ones wait for timer to expire
15792 if(!pTempStaEntry->rspPending &&
15793 !pTempStaEntry->periodicity)
15794 {
15795 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15796 if(!HAL_STATUS_SUCCESS(status))
15797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015798 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 }
15800 else
15801 {
15802 pTempStaEntry->rspPending = TRUE;
15803 }
15804 }
15805 if(pTempStaEntry->periodicity)
15806 {
15807 if(!found)
15808 {
15809
15810 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15811 csrRoamPeStatsTimerHandler, pTempStaEntry );
15812 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015814 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015815 return NULL;
15816 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015817 }
15818 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015819 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15821 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015823 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 return NULL;
15825 }
15826 pTempStaEntry->timerRunning = TRUE;
15827 }
15828 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015829 *pFound = found;
15830 return pTempStaEntry;
15831}
15832
Jeff Johnson295189b2012-06-20 16:38:30 -070015833/*
15834 pStaEntry is no longer invalid upon the return of this function.
15835*/
15836static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15837{
15838 if(pEntry)
15839 {
15840 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15841 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015842 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 }
15845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015846
15847void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15848{
15849 tListElem *pEntry;
15850 tCsrPeStatsReqInfo *pTempStaEntry;
15851 VOS_STATUS vosStatus;
15852 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015853 if(!pEntry)
15854 {
15855 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015856 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 return;
15858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 while( pEntry )
15860 {
15861 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015862 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015864 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015865 if(pTempStaEntry->timerRunning)
15866 {
15867 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15868 /* If we are not able to stop the timer here, just remove
15869 * the entry from the linked list. Destroy the timer object
15870 * and free the memory in the timer CB
15871 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015872 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 {
15874 /* the timer is successfully stopped */
15875 pTempStaEntry->timerRunning = FALSE;
15876
15877 /* Destroy the timer */
15878 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15879 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015881 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015882 }
15883 }
15884 else
15885 {
15886 // the timer could not be stopped. Hence destroy and free the
15887 // memory for the PE stat entry in the timer CB.
15888 pTempStaEntry->timerStopFailed = TRUE;
15889 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015891
15892 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15893 {
15894 // Only free the memory if we could stop the timer successfully
15895 if(!pTempStaEntry->timerStopFailed)
15896 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015897 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015898 pTempStaEntry = NULL;
15899 }
15900 break;
15901 }
15902
15903 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15904 }
15905 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015906 return;
15907}
15908
15909
Jeff Johnsone7245742012-09-05 17:12:55 -070015910void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015911{
15912
Jeff Johnsone7245742012-09-05 17:12:55 -070015913 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15914 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15915 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15916 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15917 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15918 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15919 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015920 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015921 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15922 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15923 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15924 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15925 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15926 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015927 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015928 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15929 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015930
15931}
15932
Jeff Johnson295189b2012-06-20 16:38:30 -070015933void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15934 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15935{
15936 tANI_U8 stats[500];
15937 tANI_U8 *pStats = NULL;
15938 tANI_U32 tempMask = 0;
15939 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015940 if(!callback)
15941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015942 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 return;
15944 }
15945 if(!statsMask)
15946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015947 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015948 return;
15949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015950 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015951 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015952 while(tempMask)
15953 {
15954 if(tempMask & 1)
15955 {
15956 //new stats info from PE, fill up the stats strucutres in PMAC
15957 switch(counter)
15958 {
15959 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015960 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015961 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15962 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015963 pStats += sizeof(tCsrSummaryStatsInfo);
15964 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015966 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015967 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15968 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015970 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015971 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015972 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015973 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15974 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015975 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015976 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015978 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015979 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15980 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015981 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015983 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015984 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015985 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15986 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015987 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015990 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015991 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15992 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015994 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015996 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 }
15999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016000 tempMask >>=1;
16001 counter++;
16002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016003 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016004}
16005
Jeff Johnson295189b2012-06-20 16:38:30 -070016006eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16007{
16008 tListElem *pEntry = NULL;
16009 tListElem *pPrevEntry = NULL;
16010 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16011 eHalStatus status = eHAL_STATUS_SUCCESS;
16012 VOS_STATUS vosStatus;
16013 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016014 if(!pEntry)
16015 {
16016 //list empty
16017 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016018 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 return status;
16020 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016021 while( pEntry )
16022 {
16023 if(pPrevEntry)
16024 {
16025 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16026 //send up the stats report
16027 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16028 pTempStaEntry->staId, pTempStaEntry->pContext);
16029 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016031 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016032 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16033 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016034 pTempStaEntry->pPeStaEntry->numClient--;
16035 //check if we need to delete the entry from peStatsReqList too
16036 if(!pTempStaEntry->pPeStaEntry->numClient)
16037 {
16038 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 //check if we need to stop the tl stats timer too
16042 pMac->roam.tlStatsReqInfo.numClient--;
16043 if(!pMac->roam.tlStatsReqInfo.numClient)
16044 {
16045 if(pMac->roam.tlStatsReqInfo.timerRunning)
16046 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016047 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16048 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016050 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 //we will continue
16052 }
16053 }
16054 pMac->roam.tlStatsReqInfo.periodicity = 0;
16055 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016057 if (pTempStaEntry->periodicity)
16058 {
16059 //While creating StaEntry in csrGetStatistics,
16060 //Initializing and starting timer only when periodicity is set.
16061 //So Stop and Destroy timer only when periodicity is set.
16062
Jeff Johnsone7245742012-09-05 17:12:55 -070016063 vos_timer_stop( &pTempStaEntry->timer );
16064 // Destroy the vos timer...
16065 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16066 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016068 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016069 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016071
Jeff Johnson295189b2012-06-20 16:38:30 -070016072
16073 pPrevEntry = pEntry;
16074 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16075 }
16076 //the last one
16077 if(pPrevEntry)
16078 {
16079 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16080 //send up the stats report
16081 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16082 pTempStaEntry->staId, pTempStaEntry->pContext);
16083 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016085 return status;
16086
16087}
16088
Jeff Johnson295189b2012-06-20 16:38:30 -070016089eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16090 tRequestFullPowerReason *pReason,
16091 tANI_BOOLEAN *pfNeedPower )
16092{
16093 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16094 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16095 tPmcState pmcState;
16096 eHalStatus status = eHAL_STATUS_SUCCESS;
16097 // TODO : Session info unavailable
16098 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016099 if( pfNeedPower )
16100 {
16101 *pfNeedPower = eANI_BOOLEAN_FALSE;
16102 }
16103 //We only handle CSR commands
16104 if( !(eSmeCsrCommandMask & pCommand->command) )
16105 {
16106 return eHAL_STATUS_SUCCESS;
16107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016108 //Check PMC state first
16109 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016110 switch( pmcState )
16111 {
16112 case REQUEST_IMPS:
16113 case IMPS:
16114 if( eSmeCommandScan == pCommand->command )
16115 {
16116 switch( pCommand->u.scanCmd.reason )
16117 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016118#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16119 case eCsrScanGetLfrResult:
16120#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016121 case eCsrScanGetResult:
16122 case eCsrScanBGScanAbort:
16123 case eCsrScanBGScanEnable:
16124 case eCsrScanGetScanChnInfo:
16125 //Internal process, no need for full power
16126 fNeedFullPower = eANI_BOOLEAN_FALSE;
16127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016128 default:
16129 //Other scans are real scan, ask for power
16130 fNeedFullPower = eANI_BOOLEAN_TRUE;
16131 break;
16132 } //switch
16133 }
16134 else
16135 {
16136 //ask for power for roam and status change
16137 fNeedFullPower = eANI_BOOLEAN_TRUE;
16138 }
16139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016140 case REQUEST_BMPS:
16141 case BMPS:
16142 case REQUEST_START_UAPSD:
16143 case UAPSD:
16144 //We treat WOWL same as BMPS
16145 case REQUEST_ENTER_WOWL:
16146 case WOWL:
16147 if( eSmeCommandRoam == pCommand->command )
16148 {
16149 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16150 tCsrScanResult *pScanResult;
16151 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016152 switch ( pCommand->u.roamCmd.roamReason )
16153 {
16154 case eCsrForcedDisassoc:
16155 case eCsrForcedDisassocMICFailure:
16156 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16157 fNeedFullPower = eANI_BOOLEAN_TRUE;
16158 break;
16159 case eCsrSmeIssuedDisassocForHandoff:
16160 case eCsrForcedDeauth:
16161 case eCsrHddIssuedReassocToSameAP:
16162 case eCsrSmeIssuedReassocToSameAP:
16163 fNeedFullPower = eANI_BOOLEAN_TRUE;
16164 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 case eCsrCapsChange:
16166 fNeedFullPower = eANI_BOOLEAN_TRUE;
16167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016168 default:
16169 //Check whether the profile is already connected. If so, no need for full power
16170 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16171 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16172 {
16173 //Only need to check the first one
16174 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16175 if( pEntry )
16176 {
16177 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16178#if 0
16179 // TODO : Session Specific info pConnectBssDesc
16180 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16181 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16182 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16183 {
16184 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16185 // with Authenticating first. To force this, stop the current association (Disassociate) and
16186 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16187 // a new Association.
16188 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16189 {
16190 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16191 {
16192 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16193 //No need for full power
16194 //Set the flag so the code later can avoid to do the above
16195 //check again.
16196 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16197 break;
16198 }
16199 }
16200 }
16201#endif
16202 }
16203 }
16204 //If we are here, full power is needed
16205 fNeedFullPower = eANI_BOOLEAN_TRUE;
16206 break;
16207 }
16208 }
16209 else if( eSmeCommandWmStatusChange == pCommand->command )
16210 {
16211 //need full power for all
16212 fNeedFullPower = eANI_BOOLEAN_TRUE;
16213 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16214 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016215#ifdef FEATURE_WLAN_TDLS
16216 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16217 {
16218 //TDLS link is getting established. need full power
16219 fNeedFullPower = eANI_BOOLEAN_TRUE;
16220 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16221 }
16222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016223 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016224 case REQUEST_STOP_UAPSD:
16225 case REQUEST_EXIT_WOWL:
16226 if( eSmeCommandRoam == pCommand->command )
16227 {
16228 fNeedFullPower = eANI_BOOLEAN_TRUE;
16229 switch ( pCommand->u.roamCmd.roamReason )
16230 {
16231 case eCsrForcedDisassoc:
16232 case eCsrForcedDisassocMICFailure:
16233 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16234 break;
16235 default:
16236 break;
16237 }
16238 }
16239 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016240 case STOPPED:
16241 case REQUEST_STANDBY:
16242 case STANDBY:
16243 case LOW_POWER:
16244 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016245 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016246 status = eHAL_STATUS_FAILURE;
16247 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016248 case FULL_POWER:
16249 case REQUEST_FULL_POWER:
16250 default:
16251 //No need to ask for full power. This has to be FULL_POWER state
16252 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016253 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016254 if( pReason )
16255 {
16256 *pReason = reason;
16257 }
16258 if( pfNeedPower )
16259 {
16260 *pfNeedPower = fNeedFullPower;
16261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016262 return ( status );
16263}
16264
Jeff Johnson295189b2012-06-20 16:38:30 -070016265static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16266{
16267 eHalStatus status = eHAL_STATUS_SUCCESS;
16268 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16269 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016270 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016271 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16272 {
16273 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016275 return ( status );
16276}
16277
Jeff Johnson295189b2012-06-20 16:38:30 -070016278tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16279{
16280 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 if( pCmd )
16282 {
16283 pMac->roam.sPendingCommands++;
16284 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016285 return ( pCmd );
16286}
16287
Jeff Johnson295189b2012-06-20 16:38:30 -070016288void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16289{
16290 if (pMac->roam.sPendingCommands > 0)
16291 {
16292 //All command allocated through csrGetCommandBuffer need to
16293 //decrement the pending count when releasing.
16294 pMac->roam.sPendingCommands--;
16295 smeReleaseCommand( pMac, pCommand );
16296 }
16297 else
16298 {
16299 smsLog(pMac, LOGE, FL( "no pending commands"));
16300 VOS_ASSERT(0);
16301 }
16302}
16303
Jeff Johnson295189b2012-06-20 16:38:30 -070016304//Return SUCCESS is the command is queued, failed
16305eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16306{
16307 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016308 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16309 {
16310 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16311 pCommand->u.scanCmd.reason);
16312 return eHAL_STATUS_CSR_WRONG_STATE;
16313 }
16314
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016315 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16316 {
16317 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16318 &pCommand->Link, LL_ACCESS_LOCK);
16319 // process the command queue...
16320 smeProcessPendingQueue(pMac);
16321 status = eHAL_STATUS_SUCCESS;
16322 goto end;
16323 }
16324
Jeff Johnson295189b2012-06-20 16:38:30 -070016325 //We can call request full power first before putting the command into pending Q
16326 //because we are holding SME lock at this point.
16327 status = csrRequestFullPower( pMac, pCommand );
16328 if( HAL_STATUS_SUCCESS( status ) )
16329 {
16330 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 //make sure roamCmdPendingList is not empty first
16332 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16333 if( fNoCmdPending )
16334 {
16335 smePushCommand( pMac, pCommand, fHighPriority );
16336 }
16337 else
16338 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016339 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016340 //no list lock is needed since SME lock is held
16341 if( !fHighPriority )
16342 {
16343 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16344 }
16345 else {
16346 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16347 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 }
16350 else if( eHAL_STATUS_PMC_PENDING == status )
16351 {
16352 //no list lock is needed since SME lock is held
16353 if( !fHighPriority )
16354 {
16355 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16356 }
16357 else {
16358 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16359 }
16360 //Let caller know the command is queue
16361 status = eHAL_STATUS_SUCCESS;
16362 }
16363 else
16364 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016365 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016366 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016367 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016368 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016369end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016370 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016371}
Jeff Johnson295189b2012-06-20 16:38:30 -070016372eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16373{
16374 eHalStatus status = eHAL_STATUS_SUCCESS;
16375 tSirUpdateAPWPSIEsReq *pMsg;
16376 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16377
16378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16379 if (NULL == pSession)
16380 {
16381 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16382 return eHAL_STATUS_FAILURE;
16383 }
16384
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 do
16386 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016387 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16388 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16389 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016390 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16391
16392 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016393 VOS_ASSERT(pBuf);
16394
Jeff Johnson295189b2012-06-20 16:38:30 -070016395 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016396 // transactionId
16397 *pBuf = 0;
16398 *( pBuf + 1 ) = 0;
16399 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016400 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016401 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16402 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016404 //sessionId
16405 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016407 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016410 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016411 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016412 return ( status );
16413}
Jeff Johnson295189b2012-06-20 16:38:30 -070016414eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16415{
16416 eHalStatus status = eHAL_STATUS_SUCCESS;
16417 tSirUpdateAPWPARSNIEsReq *pMsg;
16418 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016419 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16420 if (NULL == pSession)
16421 {
16422 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16423 return eHAL_STATUS_FAILURE;
16424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 do
16426 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016427 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16428 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16429 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016430 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016431 pBuf = (tANI_U8 *)&pMsg->transactionId;
16432 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016433 // transactionId
16434 *pBuf = 0;
16435 *( pBuf + 1 ) = 0;
16436 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016437 VOS_ASSERT(pBuf);
16438
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016440 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16441 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016442 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 // sessionId
16444 *pBuf++ = (tANI_U8)sessionId;
16445
16446 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016447 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016451 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 return ( status );
16453}
Jeff Johnson295189b2012-06-20 16:38:30 -070016454
16455#ifdef WLAN_FEATURE_VOWIFI_11R
16456//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16457eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16458{
16459 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16460 tpSirFTPreAuthReq pftPreAuthReq;
16461 tANI_U16 auth_req_len = 0;
16462 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 auth_req_len = sizeof(tSirFTPreAuthReq);
16464 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016465 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016466 {
16467 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16468 return eHAL_STATUS_RESOURCES;
16469 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016470 // Save the SME Session ID here. We need it while processing the preauth response
16471 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 vos_mem_zero(pftPreAuthReq, auth_req_len);
16473
16474 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16475 sizeof(pBssDescription->length) + pBssDescription->length);
16476
16477 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16478
16479 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16480
Kiet Lam64c1b492013-07-12 13:56:44 +053016481 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16482 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16483 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16484 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016485
Jeff Johnson295189b2012-06-20 16:38:30 -070016486#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016487 if (csrRoamIs11rAssoc(pMac) &&
16488 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 {
16490 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016491 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16492 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016493 }
16494 else
16495#endif
16496 {
16497 pftPreAuthReq->ft_ies_length = 0;
16498 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016499 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16500 sizeof(pBssDescription->length) + pBssDescription->length);
16501 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016502 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16503}
Jeff Johnson295189b2012-06-20 16:38:30 -070016504/*--------------------------------------------------------------------------
16505 * This will receive and process the FT Pre Auth Rsp from the current
16506 * associated ap.
16507 *
16508 * This will invoke the hdd call back. This is so that hdd can now
16509 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16510 ------------------------------------------------------------------------*/
16511void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16512{
16513 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16514 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016515#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016516 tCsrRoamInfo roamInfo;
16517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016518
16519#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016520 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016521#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016522#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016523 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016524 if (status != eHAL_STATUS_SUCCESS) {
16525 /*
16526 * Bail out if pre-auth was not even processed.
16527 */
16528 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16529 return;
16530 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016532 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16533 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16534 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 // Implies a success
16536 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016537 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16538 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016539 /* No need to notify qos module if this is a non 11r roam*/
16540 if (csrRoamIs11rAssoc(pMac))
16541 {
16542 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16545 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016546 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16547 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016548 if (eHAL_STATUS_SUCCESS != status)
16549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016550 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016551 return;
16552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016553 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016554 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16555 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016556 if (csrRoamIs11rAssoc(pMac))
16557 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16558 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16559
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016560#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16561 if (csrRoamIsCCXAssoc(pMac))
16562 {
16563 /* read TSF */
16564 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16565
16566 // Save the bssid from the received response
16567 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16568 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16569 }
16570#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016571#ifdef FEATURE_WLAN_LFR
16572 // If Legacy Fast Roaming is enabled, signal the supplicant
16573 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016574 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016575 {
16576 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016577 vos_mem_copy((void *)&roamInfo.bssid,
16578 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016579 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16580 }
16581
16582#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016583
16584 // Done with it, init it.
16585 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16586}
16587#endif
16588#ifdef FEATURE_WLAN_BTAMP_UT_RF
16589void csrRoamJoinRetryTimerHandler(void *pv)
16590{
16591 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16592 tpAniSirGlobal pMac = pInfo->pMac;
16593 tANI_U32 sessionId = pInfo->sessionId;
16594 tCsrRoamSession *pSession;
16595
16596 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016598 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016599 pSession = CSR_GET_SESSION( pMac, sessionId );
16600 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16601 {
16602 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016604 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 }
16606 }
16607 }
16608}
Jeff Johnson295189b2012-06-20 16:38:30 -070016609eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16610{
16611 eHalStatus status = eHAL_STATUS_FAILURE;
16612 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16613
16614 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016616 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016617 pSession->maxRetryCount--;
16618 pSession->joinRetryTimerInfo.pMac = pMac;
16619 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016620 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16621 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016623 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016624 }
16625 }
16626 else
16627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016628 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016629 pSession->maxRetryCount);
16630 }
16631
16632 return (status);
16633}
Jeff Johnson295189b2012-06-20 16:38:30 -070016634eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16635{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016636 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016637 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16638 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016639 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016640 }
16641
16642 return eHAL_STATUS_SUCCESS;
16643}
16644#endif
16645
16646
16647/*
16648 pBuf points to the beginning of the message
16649 LIM packs disassoc rsp as below,
16650 messageType - 2 bytes
16651 messageLength - 2 bytes
16652 sessionId - 1 byte
16653 transactionId - 2 bytes (tANI_U16)
16654 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16655 peerMacAddr - 6 bytes
16656 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16657*/
16658static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16659{
16660 if(pBuf && pRsp)
16661 {
16662 pBuf += 4; //skip type and length
16663 pRsp->sessionId = *pBuf++;
16664 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16665 pBuf += 2;
16666 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16667 pBuf += 4;
16668 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16669 }
16670}
16671
Jeff Johnsond13512a2012-07-17 11:42:19 -070016672eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16673{
16674 static uNvTables nvTables;
16675 eHalStatus status = eHAL_STATUS_SUCCESS;
16676 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16677
16678 /* read the country code from NV and use it */
16679 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16680 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016681 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16682 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016683 return status;
16684 }
16685 else
16686 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016687 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016688 status = eHAL_STATUS_FAILURE;
16689 return status;
16690 }
16691}
16692
16693eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16694{
Kiet Lam64c1b492013-07-12 13:56:44 +053016695 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016696 return eHAL_STATUS_SUCCESS;
16697}
schang86c22c42013-03-13 18:41:24 -070016698
16699eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16700{
16701 tSirSetTxPowerReq *pMsg = NULL;
16702 eHalStatus status = eHAL_STATUS_SUCCESS;
16703 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16704
16705 if (!pSession)
16706 {
16707 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16708 return eHAL_STATUS_FAILURE;
16709 }
16710
Kiet Lam64c1b492013-07-12 13:56:44 +053016711 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16712 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16713 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16714 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16715 pMsg->length = sizeof(tSirSetTxPowerReq);
16716 pMsg->mwPower = mW;
16717 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16718 sizeof(tSirMacAddr));
16719 status = palSendMBMessage(pMac->hHdd, pMsg);
16720 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016721 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016722 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16723 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016724 }
16725 return status;
16726}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016727
16728/* Returns whether a session is in VOS_STA_MODE...or not */
16729tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16730{
16731 tCsrRoamSession *pSession = NULL;
16732 pSession = CSR_GET_SESSION ( pMac, sessionId );
16733 if(!pSession)
16734 {
16735 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16736 return eANI_BOOLEAN_FALSE;
16737 }
16738 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16739 {
16740 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16741 return eANI_BOOLEAN_FALSE;
16742 }
16743 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16744 {
16745 return eANI_BOOLEAN_FALSE;
16746 }
16747 /* There is a possibility that the above check may fail,because
16748 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16749 * when it is connected.So,we may sneak through the above check even
16750 * if we are not a STA mode INFRA station. So, if we sneak through
16751 * the above condition, we can use the following check if we are
16752 * really in STA Mode.*/
16753
16754 if ( NULL != pSession->pCurRoamProfile )
16755 {
16756 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16757 {
16758 return eANI_BOOLEAN_TRUE;
16759 } else {
16760 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16761 return eANI_BOOLEAN_FALSE;
16762 }
16763 }
16764
16765 return eANI_BOOLEAN_FALSE;
16766}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016767
16768#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16769eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16770 tCsrHandoffRequest *pHandoffInfo)
16771{
16772 eHalStatus status = eHAL_STATUS_SUCCESS;
16773 vos_msg_t msg;
16774
16775 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016776 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16777 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016778 {
16779 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016780 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016781 }
16782 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16783 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16784 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16785 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016786 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016787 pHandoffInfo->bssid,
16788 6);
16789 msg.type = eWNI_SME_HANDOFF_REQ;
16790 msg.bodyptr = pMsg;
16791 msg.reserved = 0;
16792 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16793 {
16794 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016795 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016796 status = eHAL_STATUS_FAILURE;
16797 }
16798 return status;
16799}
16800#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016801
16802#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16803/* ---------------------------------------------------------------------------
16804 \fn csrSetCCKMIe
16805 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16806 data structure and this IE will be packed inside reassociation request
16807 \param pMac - pMac global structure
16808 \param sessionId - Current session id
16809 \param pCckmIe - pointer to CCKM IE data
16810 \param ccKmIeLen - length of the CCKM IE
16811 \- return Success or failure
16812 -------------------------------------------------------------------------*/
16813VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16814 const tANI_U8 *pCckmIe,
16815 const tANI_U8 ccKmIeLen)
16816{
16817 eHalStatus status = eHAL_STATUS_SUCCESS;
16818 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16819
16820 if (!pSession)
16821 {
16822 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16823 return eHAL_STATUS_FAILURE;
16824 }
16825 palCopyMemory(pMac->hHdd, pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
16826 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16827 return status;
16828}
16829
16830/* ---------------------------------------------------------------------------
16831 \fn csrRoamReadTSF
16832 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16833 probe response reception from the hand off AP to arrive at the latest TSF value.
16834 \param pMac - pMac global structure
16835 \param pTimestamp - output TSF timestamp
16836 \- return Success or failure
16837 -------------------------------------------------------------------------*/
16838VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16839{
16840 eHalStatus status = eHAL_STATUS_SUCCESS;
16841 tCsrNeighborRoamBSSInfo handoffNode;
16842 tANI_U32 timer_diff = 0;
16843 tANI_U32 timeStamp[2];
16844 tpSirBssDescription pBssDescription = NULL;
16845
16846 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16847 pBssDescription = handoffNode.pBssDescription;
16848
16849 // Get the time diff in milli seconds
16850 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16851 // Convert msec to micro sec timer
16852 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16853
16854 timeStamp[0] = pBssDescription->timeStamp[0];
16855 timeStamp[1] = pBssDescription->timeStamp[1];
16856
16857 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16858
16859 palCopyMemory(pMac->hHdd, pTimestamp, (void *) &timeStamp[0],
16860 sizeof (tANI_U32) * 2);
16861 return status;
16862}
16863
16864#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16865