blob: 17ca2ccc96bd81e252fd14e89ebcc5fdcc420a23 [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 }
Abhishek Singha306a442013-11-07 18:39:01 +0530351 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 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 }
Abhishek Singha306a442013-11-07 18:39:01 +0530394 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 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);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301308 vos_mem_copy(ChannelList,
1309 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001310 }
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 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301331 vos_mem_copy(currChannelListInfo->ChannelList,
1332 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001333 }
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)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001369 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1370 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001371#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 status = csrInitGetChannels( pMac );
1373 if (eHAL_STATUS_SUCCESS == status)
1374 csrInitChannelList( hHal );
1375 return status;
1376}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001377
1378
Jeff Johnsone7245742012-09-05 17:12:55 -07001379/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1380 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1381 * Ideally we should have kept the ini value and enum value same and representing the same
1382 * cb values as in 11n standard i.e.
1383 * Set to 1 (SCA) if the secondary channel is above the primary channel
1384 * Set to 3 (SCB) if the secondary channel is below the primary channel
1385 * Set to 0 (SCN) if no secondary channel is present
1386 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1387 * 0 - secondary none
1388 * 1 - secondary LOW
1389 * 2 - secondary HIGH
1390 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1391 * The enum values are as follows:
1392 * PHY_SINGLE_CHANNEL_CENTERED = 0
1393 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1394 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1395 */
1396ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1397{
1398
1399 ePhyChanBondState phyCbState;
1400 switch (cbIniValue) {
1401 // secondary none
1402 case 0:
1403 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1404 break;
1405 // secondary LOW
1406 case 1:
1407 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1408 break;
1409 // secondary HIGH
1410 case 2:
1411 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1412 break;
1413#ifdef WLAN_FEATURE_11AC
1414 case 3:
1415 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1416 break;
1417 case 4:
1418 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1419 break;
1420 case 5:
1421 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1422 break;
1423 case 6:
1424 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1425 break;
1426 case 7:
1427 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1428 break;
1429 case 8:
1430 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1431 break;
1432 case 9:
1433 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1434 break;
1435#endif
1436 default:
1437 // If an invalid value is passed, disable CHANNEL BONDING
1438 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1439 break;
1440 }
1441 return phyCbState;
1442}
1443
1444v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1445{
1446
1447 v_U32_t cbIniValue;
1448 switch (phyCbState) {
1449 // secondary none
1450 case PHY_SINGLE_CHANNEL_CENTERED:
1451 cbIniValue = 0;
1452 break;
1453 // secondary LOW
1454 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1455 cbIniValue = 1;
1456 break;
1457 // secondary HIGH
1458 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1459 cbIniValue = 2;
1460 break;
1461#ifdef WLAN_FEATURE_11AC
1462 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1463 cbIniValue = 3;
1464 break;
1465 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1466 cbIniValue = 4;
1467 break;
1468 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1469 cbIniValue = 5;
1470 break;
1471 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1472 cbIniValue = 6;
1473 break;
1474 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1475 cbIniValue = 7;
1476 break;
1477 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1478 cbIniValue = 8;
1479 break;
1480 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1481 cbIniValue = 9;
1482 break;
1483#endif
1484 default:
1485 // return some invalid value
1486 cbIniValue = 10;
1487 break;
1488 }
1489 return cbIniValue;
1490}
Jeff Johnson295189b2012-06-20 16:38:30 -07001491
1492eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1493{
1494 eHalStatus status = eHAL_STATUS_SUCCESS;
1495
1496 if(pParam)
1497 {
1498 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1499 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1500 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1501 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1502 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1503 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1504
1505 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001506 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1507
Jeff Johnsone7245742012-09-05 17:12:55 -07001508 /* channelBondingMode5GHz plays a dual role right now
1509 * 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
1510 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1511 */
1512 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001514 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001515 }
1516 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1517 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001519 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001520 }
1521 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1523 pMac->roam.configParam.phyMode = pParam->phyMode;
1524 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1525 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1526 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1527 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1528 pMac->roam.configParam.TxRate = pParam->TxRate;
1529 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1530 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1531 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1532 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1533 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001534 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 //if HDD passed down non zero values then only update,
1536 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001537 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 {
1539 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1540 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001541 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 {
1543 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1544 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001545 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 {
1547 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1548 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001549 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
1551 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1552 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001553 if (pParam->nActiveMaxChnTimeBtc)
1554 {
1555 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1556 }
1557 if (pParam->nActiveMinChnTimeBtc)
1558 {
1559 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1560 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001561#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001562 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001563 {
1564 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1565 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001566 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001567 {
1568 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1569 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001570 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001571 {
1572 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1573 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001574 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001575 {
1576 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1577 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001578 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001579 {
1580 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1581 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001582 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001583 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001584 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1585 }
1586 if (pParam->nNumP2PChanCombinedConc)
1587 {
1588 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001589 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001590#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001592 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 {
1594 //Change the unit from second to microsecond
1595 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1597 {
1598 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1599 }
1600 else
1601 {
1602 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1603 }
1604 }
1605 else
1606 {
1607 pMac->roam.configParam.impsSleepTime = 0;
1608 }
1609 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1611 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 //if HDD passed down non zero values for age params, then only update,
1613 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001614 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 {
1616 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 if(pParam->scanAgeTimeNCNPS)
1619 {
1620 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 if(pParam->scanAgeTimeNCPS)
1623 {
1624 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 if(pParam->scanAgeTimeCNPS)
1627 {
1628 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1629 }
1630 if(pParam->scanAgeTimeCPS)
1631 {
1632 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1633 }
1634
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001635 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1637 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1638 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1639 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1640 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1642 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1644 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1645 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1646 //Assign this before calling CsrInit11dInfo
1647 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 if( csrIs11dSupported( pMac ) )
1649 {
1650 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1651 }
1652 else
1653 {
1654 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1655 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001656
1657 /* Initialize the power + channel information if 11h is enabled.
1658 If 11d is enabled this information has already been initialized */
1659 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1660 {
1661 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1662 }
1663
1664
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301665#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301666 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1667 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001668 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001669#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001670#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001672 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001673 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001674 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001675 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001676 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001677 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001678 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001679 pMac->roam.configParam.nProbes = pParam->nProbes;
1680 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001681#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001682#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1683 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001684 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001685#endif
1686#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001687 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001688 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001689#endif
1690
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301691#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1693#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001694#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301695 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1696 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001697 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1698 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1699 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1700 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1701 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1702 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1703 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1704 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 {
1706 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001707 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 -07001708 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1709 {
1710 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 }
1713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1715 pMac->scan.fValidateList = pParam->fValidateList;
1716 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1717 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001718 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001720 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1721 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1722 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1723 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1724 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1725 * single session
1726 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001727 //Remove this code once SLM_Sessionization is supported
1728 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001729 pMac->roam.configParam.doBMPSWorkaround = 0;
1730
Jeff Johnsone7245742012-09-05 17:12:55 -07001731#ifdef WLAN_FEATURE_11AC
1732 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001733 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001734 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001735 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001736#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001737 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001738
1739 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001740 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001741 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1742 pParam->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 }
1744
1745 return status;
1746}
1747
Jeff Johnson295189b2012-06-20 16:38:30 -07001748eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1749{
1750 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 if(pParam)
1752 {
1753 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1754 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1755 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1756 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1757 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1758 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001759 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1760 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1762 pParam->phyMode = pMac->roam.configParam.phyMode;
1763 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1764 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1765 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1766 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1767 pParam->TxRate = pMac->roam.configParam.TxRate;
1768 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1769 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1770 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1771 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1772 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1774 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1775 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1776 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001777 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1778 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1779 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001780#ifdef WLAN_AP_STA_CONCURRENCY
1781 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1782 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1783 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1784 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1785 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001786 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1787 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001788#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 //Change the unit from microsecond to second
1790 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1791 pParam->eBand = pMac->roam.configParam.eBand;
1792 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1793 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1794 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1795 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1796 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1797 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1798 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1799 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1800 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1801 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1802 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1803 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1804 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1806 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1807 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1808 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1810 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1811 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1812 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1813 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001814 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001815 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001816 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001817 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001818
1819#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301820 vos_mem_copy(&pParam->neighborRoamConfig,
1821 &pMac->roam.configParam.neighborRoamConfig,
1822 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001823#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001824#ifdef WLAN_FEATURE_11AC
1825 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001826 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001827 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001828 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001829#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001830#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301831 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1832 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001833#endif
1834#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1835 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1836 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1837 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1838 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1839 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001840 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001841 pParam->nProbes = pMac->roam.configParam.nProbes;
1842 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001843#endif
1844#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1845 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1846 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1847#endif
1848#ifdef FEATURE_WLAN_LFR
1849 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1850#endif
1851
1852#ifdef FEATURE_WLAN_CCX
1853 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1854#endif
1855#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301856 vos_mem_copy(&pParam->neighborRoamConfig,
1857 &pMac->roam.configParam.neighborRoamConfig,
1858 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001859 {
1860 int i;
1861 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1862 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1863 {
1864 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1865 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001866 }
1867#endif
1868
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001869 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001870
krunal soni5afa96c2013-09-06 22:19:02 -07001871 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001872 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001873
krunal sonie9002db2013-11-25 14:24:17 -08001874 pParam->isCoalesingInIBSSAllowed =
1875 pMac->roam.configParam.isCoalesingInIBSSAllowed;
1876
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 csrSetChannels(pMac, pParam);
1878
1879 status = eHAL_STATUS_SUCCESS;
1880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 return (status);
1882}
1883
Jeff Johnson295189b2012-06-20 16:38:30 -07001884eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1885{
1886 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1887 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1888 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1889 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 do
1891 {
1892 if(eCSR_BAND_24 == eBand)
1893 {
1894 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1895 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1896 }
1897 if(eCSR_BAND_5G == eBand)
1898 {
1899 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1900 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1901 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1902 )
1903 {
1904 break;
1905 }
1906 }
1907 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1908 {
1909 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1910 }
1911 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1912 {
1913 newPhyMode = eCSR_DOT11_MODE_AUTO;
1914 }
1915 else
1916 {
1917 //Check for dual band and higher capability first
1918 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1919 {
1920 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1921 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1922 }
1923 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1924 {
1925 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1926 if(eCSR_BAND_24 == eBand) break;
1927 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1928 eBand = eCSR_BAND_5G;
1929 }
1930 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1931 {
1932 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1933 if(eCSR_BAND_5G == eBand) break;
1934 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1935 eBand = eCSR_BAND_24;
1936 }
1937 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1938 {
1939 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1940 if(eCSR_BAND_5G == eBand) break;
1941 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1942 eBand = eCSR_BAND_24;
1943 }
1944 else if(eCSR_DOT11_MODE_11n & phyMode)
1945 {
1946 newPhyMode = eCSR_DOT11_MODE_11n;
1947 }
1948 else if(eCSR_DOT11_MODE_abg & phyMode)
1949 {
1950 newPhyMode = eCSR_DOT11_MODE_abg;
1951 }
1952 else if(eCSR_DOT11_MODE_11a & phyMode)
1953 {
1954 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1955 {
1956 if(eCSR_BAND_ALL == eBand)
1957 {
1958 newPhyMode = eCSR_DOT11_MODE_abg;
1959 }
1960 else
1961 {
1962 //bad setting
1963 break;
1964 }
1965 }
1966 else
1967 {
1968 newPhyMode = eCSR_DOT11_MODE_11a;
1969 eBand = eCSR_BAND_5G;
1970 }
1971 }
1972 else if(eCSR_DOT11_MODE_11g & phyMode)
1973 {
1974 newPhyMode = eCSR_DOT11_MODE_11g;
1975 eBand = eCSR_BAND_24;
1976 }
1977 else if(eCSR_DOT11_MODE_11b & phyMode)
1978 {
1979 newPhyMode = eCSR_DOT11_MODE_11b;
1980 eBand = eCSR_BAND_24;
1981 }
1982 else
1983 {
1984 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001985 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 newPhyMode = eCSR_DOT11_MODE_AUTO;
1987 }
1988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 //Done validating
1990 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 //Now we need to check whether a restart is needed.
1992 if(eBand != pMac->roam.configParam.eBand)
1993 {
1994 fRestartNeeded = eANI_BOOLEAN_TRUE;
1995 break;
1996 }
1997 if(newPhyMode != pMac->roam.configParam.phyMode)
1998 {
1999 fRestartNeeded = eANI_BOOLEAN_TRUE;
2000 break;
2001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 if(HAL_STATUS_SUCCESS(status))
2004 {
2005 pMac->roam.configParam.eBand = eBand;
2006 pMac->roam.configParam.phyMode = newPhyMode;
2007 if(pfRestartNeeded)
2008 {
2009 *pfRestartNeeded = fRestartNeeded;
2010 }
2011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 return (status);
2013}
2014
Jeff Johnson295189b2012-06-20 16:38:30 -07002015void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2016{
2017 tANI_U8 Index;
2018 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 // for dual band NICs, don't need to trim the channel list....
2020 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2021 {
2022 // 2.4 GHz band operation requires the channel list to be trimmed to
2023 // the 2.4 GHz channels only...
2024 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2025 {
2026 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2027 Index++ )
2028 {
2029 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2030 {
2031 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2032 cChannels++;
2033 }
2034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2036 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2037 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2038 // only if we need to.
2039 //
2040 // The amount of memory to clear is the number of channesl that we trimmed
2041 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2042
2043 if ( pChannelList->numChannels > cChannels )
2044 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302045 vos_mem_set(&pChannelList->channelList[ cChannels ],
2046 sizeof( pChannelList->channelList[ 0 ] ) *
2047 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 }
2049
2050 pChannelList->numChannels = cChannels;
2051 }
2052 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2053 {
2054 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2055 {
2056 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2057 {
2058 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2059 cChannels++;
2060 }
2061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2063 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2064 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2065 // only if we need to.
2066 //
2067 // The amount of memory to clear is the number of channesl that we trimmed
2068 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2069 if ( pChannelList->numChannels > cChannels )
2070 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302071 vos_mem_set(&pChannelList->channelList[ cChannels ],
2072 sizeof( pChannelList->channelList[ 0 ] ) *
2073 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 }
2075
2076 pChannelList->numChannels = cChannels;
2077 }
2078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002079}
Jeff Johnson295189b2012-06-20 16:38:30 -07002080#define INFRA_AP_DEFAULT_CHANNEL 6
2081eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2082{
2083 tANI_U8 index= 0;
2084 eHalStatus status = eHAL_STATUS_FAILURE;
2085 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2086 {
2087 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2088 status = eHAL_STATUS_SUCCESS;
2089 break;
2090 }
2091 }
2092 return status;
2093}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002094
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2097{
2098 eHalStatus status = eHAL_STATUS_SUCCESS;
2099 tANI_U8 num20MHzChannelsFound = 0;
2100 VOS_STATUS vosStatus;
2101 tANI_U8 Index = 0;
2102 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002103
Jeff Johnson295189b2012-06-20 16:38:30 -07002104
2105 //TODO: this interface changed to include the 40MHz channel list
2106 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2107 // Read the scan channel list (including the power limit) from EEPROM
2108 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2109 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2110 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002112 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 status = eHAL_STATUS_FAILURE;
2114 }
2115 else
2116 {
2117 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2118 {
2119 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2120 }
2121 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2122 // Move the channel list to the global data
2123 // structure -- this will be used as the scan list
2124 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2125 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 }
2128 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2129 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2130 {
2131 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2132 }
2133 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2134 {
2135 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2136 }
2137 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 return (status);
2140}
2141
Jeff Johnson295189b2012-06-20 16:38:30 -07002142eHalStatus csrInitChannelList( tHalHandle hHal )
2143{
2144 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2145 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2147 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002148 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2149 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002151 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002152
2153 return (status);
2154}
Jeff Johnson295189b2012-06-20 16:38:30 -07002155eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2156 tCsrUpdateConfigParam *pUpdateConfigParam)
2157{
2158 eHalStatus status = eHAL_STATUS_FAILURE;
2159 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2161 status = CsrInit11dInfo(pMac, ps11dinfo);
2162 return status;
2163}
2164
Jeff Johnson295189b2012-06-20 16:38:30 -07002165static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2166{
2167 eHalStatus status = eHAL_STATUS_FAILURE;
2168 tANI_U8 index;
2169 tANI_U32 count=0;
2170 tSirMacChanInfo *pChanInfo;
2171 tSirMacChanInfo *pChanInfoStart;
2172 tANI_BOOLEAN applyConfig = TRUE;
2173
2174 if(!ps11dinfo)
2175 {
2176 return (status);
2177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2179 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302180 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2181 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2182 ps11dinfo->Channels.channelList,
2183 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 }
2185 else
2186 {
2187 //No change
2188 return (eHAL_STATUS_SUCCESS);
2189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302191
2192 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2193 WNI_CFG_COUNTRY_CODE_LEN);
2194
2195
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 //Tush: at csropen get this initialized with default, during csr reset if this
2197 // already set with some value no need initilaize with default again
2198 if(0 == pMac->scan.countryCodeCurrent[0])
2199 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302200 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2201 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302204 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2205 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302207 vos_mem_set(pChanInfo,
2208 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2209 0);
2210
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002212 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2213 {
2214 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2215 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2216 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2217 pChanInfo++;
2218 count++;
2219 }
2220 if(count)
2221 {
2222 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2223 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302224 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002225 }
2226 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2227 if( HAL_STATUS_SUCCESS(status) )
2228 {
2229 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2230 {
2231 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2232 {
2233 applyConfig = FALSE;
2234 }
2235 }
2236
2237 if(TRUE == applyConfig)
2238 {
2239 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002240 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002241 }
2242
2243 }
2244 return (status);
2245}
2246/* Initialize the Channel + Power List in the local cache and in the CFG */
2247eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2248{
2249 tANI_U8 index;
2250 tANI_U32 count=0;
2251 tSirMacChanInfo *pChanInfo;
2252 tSirMacChanInfo *pChanInfoStart;
2253
2254 if(!ps11dinfo || !pMac)
2255 {
2256 return eHAL_STATUS_FAILURE;
2257 }
2258
Kiet Lam64c1b492013-07-12 13:56:44 +05302259 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2260 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002261 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302262 vos_mem_set(pChanInfo,
2263 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2264 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002265 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002266
2267 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2268 {
2269 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2270 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2271 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2272 pChanInfo++;
2273 count++;
2274 }
2275 if(count)
2276 {
2277 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2278 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302279 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 }
2281
Jeff Johnsone7245742012-09-05 17:12:55 -07002282 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002283}
2284
2285//pCommand may be NULL
2286//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2287void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2288{
2289 tListElem *pEntry, *pNextEntry;
2290 tSmeCmd *pDupCommand;
2291 tDblLinkList localList;
2292
2293 vos_mem_zero(&localList, sizeof(tDblLinkList));
2294 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2295 {
2296 smsLog(pMac, LOGE, FL(" failed to open list"));
2297 return;
2298 }
2299 csrLLLock( &pMac->sme.smeCmdPendingList );
2300 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2301 while( pEntry )
2302 {
2303 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2304 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 // Remove the previous command if..
2306 // - the new roam command is for the same RoamReason...
2307 // - the new roam command is a NewProfileList.
2308 // - the new roam command is a Forced Dissoc
2309 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2310 if (
2311 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2312 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002313 /* This peermac check is requried for Softap/GO scenarios
2314 * For STA scenario below OR check will suffice as pCommand will
2315 * always be NULL for STA scenarios
2316 */
2317 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2319 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2320 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2321 ||
2322 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002323 ( (sessionId == pDupCommand->sessionId) &&
2324 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 ((eCsrForcedDisassoc == eRoamReason) ||
2326 (eCsrHddIssued == eRoamReason))
2327 )
2328 )
2329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002330 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 // Remove the 'stale' roam command from the pending list...
2332 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2333 {
2334 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2335 }
2336 }
2337 pEntry = pNextEntry;
2338 }
2339 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2340
2341 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2342 {
2343 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2344 //Tell caller that the command is cancelled
2345 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2346 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2347 csrReleaseCommandRoam(pMac, pDupCommand);
2348 }
2349 csrLLClose(&localList);
2350}
Jeff Johnson295189b2012-06-20 16:38:30 -07002351eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2352 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2353{
2354 eHalStatus status = eHAL_STATUS_SUCCESS;
2355#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2356 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2357#endif
2358 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2360 {
2361 pSession = CSR_GET_SESSION( pMac, sessionId );
2362 }
2363 else
2364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002365 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 VOS_ASSERT(0);
2367 return eHAL_STATUS_FAILURE;
2368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002371 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002373 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2374 /*
2375 * Decrement bRefAssocStartCnt for FT reassoc failure.
2376 * Reason: For FT reassoc failures, we first call
2377 * csrRoamCallCallback before notifying a failed roam
2378 * completion through csrRoamComplete. The latter in
2379 * turn calls csrRoamProcessResults which tries to
2380 * once again call csrRoamCallCallback if bRefAssocStartCnt
2381 * is non-zero. Since this is redundant for FT reassoc
2382 * failure, decrement bRefAssocStartCnt.
2383 */
2384 pSession->bRefAssocStartCnt--;
2385 }
2386
Jeff Johnson295189b2012-06-20 16:38:30 -07002387 if ( (pSession == NULL) ||
2388 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002390 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 return eHAL_STATUS_FAILURE;
2392 }
2393
2394 if(NULL != pSession->callback)
2395 {
2396 if( pRoamInfo )
2397 {
2398 pRoamInfo->sessionId = (tANI_U8)sessionId;
2399 }
2400
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302401 /* avoid holding the global lock when making the roaming callback, original change came
2402 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2403 is possible on other OS ports where the callback may need to take locks to protect
2404 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2406 that may actually depend on the lock being held */
2407 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2408 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2409 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2410 }
2411 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2412 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2413#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302414 vos_mem_set(&connectionStatus,
2415 sizeof(vos_event_wlan_status_payload_type), 0);
2416
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2418 {
2419 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2420 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2421 if(NULL != pRoamInfo->pBssDesc)
2422 {
2423 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2424 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2427 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2428 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302429 vos_mem_copy(connectionStatus.ssid,
2430 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2431
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2433 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2436 {
2437 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2438 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2439 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 if(eCSR_ROAM_RESULT_FORCED == u2)
2442 {
2443 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2444 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2445 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2448 {
2449 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2450 connectionStatus.reason = eCSR_REASON_DISASSOC;
2451 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2454 {
2455 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2456 connectionStatus.reason = eCSR_REASON_DEAUTH;
2457 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002459#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2460
2461 return (status);
2462}
Jeff Johnson295189b2012-06-20 16:38:30 -07002463// Returns whether handoff is currently in progress or not
2464tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2465{
2466#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2467 return csrNeighborRoamIsHandoffInProgress(pMac);
2468#else
2469 return eANI_BOOLEAN_FALSE;
2470#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002471}
Jeff Johnson295189b2012-06-20 16:38:30 -07002472eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2473 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2474{
2475 eHalStatus status = eHAL_STATUS_SUCCESS;
2476 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2477 tANI_U16 reasonCode;
2478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002479
2480 if(!pSession)
2481 {
2482 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2483 return eHAL_STATUS_FAILURE;
2484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002485
2486 //Restore AC weight in case we change it
2487 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2488 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002489 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 -07002490 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2491 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2492 }
2493
2494 if ( fMICFailure )
2495 {
2496 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2497 }
2498 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2499 {
2500 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002501 }
2502 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 {
2504 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002506#ifdef WLAN_FEATURE_VOWIFI_11R
2507 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2508 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2509 {
2510 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302511 vos_mem_copy(&bssId,
2512 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2513 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002514 }
2515 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002516#endif
2517 if(pSession->pConnectBssDesc)
2518 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302519 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002521
Jeff Johnson295189b2012-06-20 16:38:30 -07002522
Arif Hussain24bafea2013-11-15 15:10:03 -08002523 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2524 " subState = %d reason=%d",
2525 MAC_ADDR_ARRAY(bssId), NewSubstate, reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002526
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2528
2529 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2530
2531 if(HAL_STATUS_SUCCESS(status))
2532 {
2533 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002534#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2535 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2536 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2537 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002538 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2540 }
2541#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002542 }
2543 else
2544 {
2545 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2546 }
2547
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 return (status);
2549}
Jeff Johnson295189b2012-06-20 16:38:30 -07002550
Jeff Johnson295189b2012-06-20 16:38:30 -07002551/* ---------------------------------------------------------------------------
2552 \fn csrRoamIssueDisassociateStaCmd
2553 \brief csr function that HDD calls to disassociate a associated station
2554 \param sessionId - session Id for Soft AP
2555 \param pPeerMacAddr - MAC of associated station to delete
2556 \param reason - reason code, be one of the tSirMacReasonCodes
2557 \return eHalStatus
2558 ---------------------------------------------------------------------------*/
2559eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2560 tANI_U32 sessionId,
2561 tANI_U8 *pPeerMacAddr,
2562 tANI_U32 reason)
2563{
2564 eHalStatus status = eHAL_STATUS_SUCCESS;
2565 tSmeCmd *pCommand;
2566
2567 do
2568 {
2569 pCommand = csrGetCommandBuffer( pMac );
2570 if ( !pCommand )
2571 {
2572 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2573 status = eHAL_STATUS_RESOURCES;
2574 break;
2575 }
2576 pCommand->command = eSmeCommandRoam;
2577 pCommand->sessionId = (tANI_U8)sessionId;
2578 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2579 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2580 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2581 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2582 if( !HAL_STATUS_SUCCESS( status ) )
2583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002584 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 csrReleaseCommandRoam( pMac, pCommand );
2586 }
2587 }while(0);
2588
2589 return status;
2590}
2591
2592
Jeff Johnson295189b2012-06-20 16:38:30 -07002593/* ---------------------------------------------------------------------------
2594 \fn csrRoamIssueDeauthSta
2595 \brief csr function that HDD calls to delete a associated station
2596 \param sessionId - session Id for Soft AP
2597 \param pPeerMacAddr - MAC of associated station to delete
2598 \param reason - reason code, be one of the tSirMacReasonCodes
2599 \return eHalStatus
2600 ---------------------------------------------------------------------------*/
2601eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2602 tANI_U32 sessionId,
2603 tANI_U8 *pPeerMacAddr,
2604 tANI_U32 reason)
2605{
2606 eHalStatus status = eHAL_STATUS_SUCCESS;
2607 tSmeCmd *pCommand;
2608
2609 do
2610 {
2611 pCommand = csrGetCommandBuffer( pMac );
2612 if ( !pCommand )
2613 {
2614 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2615 status = eHAL_STATUS_RESOURCES;
2616 break;
2617 }
2618 pCommand->command = eSmeCommandRoam;
2619 pCommand->sessionId = (tANI_U8)sessionId;
2620 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2621 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2622 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2623 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2624 if( !HAL_STATUS_SUCCESS( status ) )
2625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002626 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 csrReleaseCommandRoam( pMac, pCommand );
2628 }
2629 }while(0);
2630
2631 return status;
2632}
Jeff Johnson295189b2012-06-20 16:38:30 -07002633eHalStatus
2634csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2635 tANI_BOOLEAN bEnable )
2636{
2637 eHalStatus status = eHAL_STATUS_FAILURE;
2638 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2639 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 if (!pSession)
2641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002642 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 return (status);
2644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 if (pSession->pConnectBssDesc)
2646 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302647 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 }
2649 else
2650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002651 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 return (status);
2653 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002654 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2655 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2657 return (status);
2658}
Jeff Johnson295189b2012-06-20 16:38:30 -07002659eHalStatus
2660csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2661 VOS_MODULE_ID modId, void *pUsrContext,
2662 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2663{
2664 eHalStatus status = eHAL_STATUS_SUCCESS;
2665 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2666 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 if (!pSession)
2668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002669 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 return (status);
2671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 if(pSession->pConnectBssDesc)
2673 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302674 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 }
2676 else
2677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002678 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 return (status);
2680 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002681 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2682 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2684 return (status);
2685}
Jeff Johnson295189b2012-06-20 16:38:30 -07002686eHalStatus
2687csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2688 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2689{
2690 eHalStatus status = eHAL_STATUS_SUCCESS;
2691 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2692 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2693
2694 if (!pSession)
2695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002696 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 return (status);
2698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 if(pSession->pConnectBssDesc)
2700 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302701 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 }
2703 else
2704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002705 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 return (status);
2707 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002708 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2709 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002710
2711 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2712
2713 return (status);
2714}
Jeff Johnson295189b2012-06-20 16:38:30 -07002715eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2716{
2717 eHalStatus status = eHAL_STATUS_SUCCESS;
2718 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2719 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002720
2721 if (!pSession)
2722 {
2723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2724 return eHAL_STATUS_FAILURE;
2725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002726
2727 if(pSession->pConnectBssDesc)
2728 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302729 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002731 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2732 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2734
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302735 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002736 if(!HAL_STATUS_SUCCESS(status))
2737 {
2738 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2739 }
2740
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 return (status);
2742}
2743
Jeff Johnson295189b2012-06-20 16:38:30 -07002744eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2745{
2746 eHalStatus status = eHAL_STATUS_SUCCESS;
2747 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2748 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002749
2750 if(!pSession)
2751 {
2752 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2753 return eHAL_STATUS_FAILURE;
2754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002755
2756 // If no BSS description was found in this connection (happens with start IBSS), then
2757 // nix the BSS description that we keep around for the connected BSS) and get out...
2758 if(NULL == pBssDesc)
2759 {
2760 csrFreeConnectBssDesc(pMac, sessionId);
2761 }
2762 else
2763 {
2764 size = pBssDesc->length + sizeof( pBssDesc->length );
2765 if(NULL != pSession->pConnectBssDesc)
2766 {
2767 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2768 {
2769 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2770 csrFreeConnectBssDesc(pMac, sessionId);
2771 }
2772 }
2773 if(NULL == pSession->pConnectBssDesc)
2774 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302775 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302777 if (NULL == pSession->pConnectBssDesc)
2778 status = eHAL_STATUS_FAILURE;
2779 else
2780 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 return (status);
2783}
2784
Jeff Johnson295189b2012-06-20 16:38:30 -07002785eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2786 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2787 tDot11fBeaconIEs *pIes)
2788{
2789 eHalStatus status = eHAL_STATUS_SUCCESS;
2790 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302792 if (pIes == NULL)
2793 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002794
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 do
2796 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302797 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2798 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 //get qos
2800 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2801 //get SSID
2802 if(pIes->SSID.present)
2803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302804 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2806 }
2807 else
2808 pBssConfig->SSID.length = 0;
2809 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002811 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 //Return failed if profile doesn't have an SSID either.
2813 if(pProfile->SSIDs.numOfSSIDs == 0)
2814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002815 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 status = eHAL_STATUS_FAILURE;
2817 break;
2818 }
2819 }
2820 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2821 {
2822 pBssConfig->eBand = eCSR_BAND_5G;
2823 }
2824 else
2825 {
2826 pBssConfig->eBand = eCSR_BAND_24;
2827 }
2828 //phymode
2829 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2830 {
2831 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2832 }
2833 else
2834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002835 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 //force it
2837 if(eCSR_BAND_24 == pBssConfig->eBand)
2838 {
2839 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2840 }
2841 else
2842 {
2843 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2844 }
2845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 //Qos
2847 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2848 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2849 {
2850 //Joining BSS is not 11n capable and WMM is disabled on client.
2851 //Disable QoS and WMM
2852 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2853 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302854
2855 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302856 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302857 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2858 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2859 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2860 {
2861 //Joining BSS is 11n capable and WMM is disabled on AP.
2862 //Assume all HT AP's are QOS AP's and enable WMM
2863 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2864 }
2865
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 //auth type
2867 switch( pProfile->negotiatedAuthType )
2868 {
2869 default:
2870 case eCSR_AUTH_TYPE_WPA:
2871 case eCSR_AUTH_TYPE_WPA_PSK:
2872 case eCSR_AUTH_TYPE_WPA_NONE:
2873 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2874 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2875 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 case eCSR_AUTH_TYPE_SHARED_KEY:
2877 pBssConfig->authType = eSIR_SHARED_KEY;
2878 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 case eCSR_AUTH_TYPE_AUTOSWITCH:
2880 pBssConfig->authType = eSIR_AUTO_SWITCH;
2881 break;
2882 }
2883 //short slot time
2884 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2885 {
2886 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2887 }
2888 else
2889 {
2890 pBssConfig->uShortSlotTime = 0;
2891 }
2892 if(pBssConfig->BssCap.ibss)
2893 {
2894 //We don't support 11h on IBSS
2895 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2896 }
2897 else
2898 {
2899 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2900 }
2901 //power constraint
2902 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2903 //heartbeat
2904 if ( CSR_IS_11A_BSS( pBssDesc ) )
2905 {
2906 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2907 }
2908 else
2909 {
2910 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2911 }
2912 //Join timeout
2913 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002914 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 if ( pBssDesc->beaconInterval )
2916 {
2917 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002918 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 }
2920 else
2921 {
2922 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2923 }
2924 //validate CB
2925 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2926 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 return (status);
2928}
2929
Jeff Johnson295189b2012-06-20 16:38:30 -07002930static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2931 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2932{
2933 eHalStatus status = eHAL_STATUS_SUCCESS;
2934 tANI_U8 operationChannel = 0;
2935 tANI_U8 qAPisEnabled = FALSE;
2936 //SSID
2937 pBssConfig->SSID.length = 0;
2938 if(pProfile->SSIDs.numOfSSIDs)
2939 {
2940 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05302941 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
2942 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 }
2944 else
2945 {
2946 //SSID must present
2947 return eHAL_STATUS_FAILURE;
2948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 //Settomg up the capabilities
2950 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2951 {
2952 pBssConfig->BssCap.ibss = 1;
2953 }
2954 else
2955 {
2956 pBssConfig->BssCap.ess = 1;
2957 }
2958 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2959 {
2960 pBssConfig->BssCap.privacy = 1;
2961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 pBssConfig->eBand = pMac->roam.configParam.eBand;
2963 //phymode
2964 if(pProfile->ChannelInfo.ChannelList)
2965 {
2966 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2969 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 //QOS
2971 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 if ( pBssConfig->BssCap.ess == 1 )
2973 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 /*For Softap case enable WMM*/
2975 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2976 qAPisEnabled = TRUE;
2977 }
2978 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2980 qAPisEnabled = TRUE;
2981 } else {
2982 qAPisEnabled = FALSE;
2983 }
2984 } else {
2985 qAPisEnabled = TRUE;
2986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2988 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2989 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2990 )
2991 {
2992 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2993 } else {
2994 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2995 }
2996
2997 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002998 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 {
3000 default:
3001 case eCSR_AUTH_TYPE_WPA:
3002 case eCSR_AUTH_TYPE_WPA_PSK:
3003 case eCSR_AUTH_TYPE_WPA_NONE:
3004 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3005 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3006 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 case eCSR_AUTH_TYPE_SHARED_KEY:
3008 pBssConfig->authType = eSIR_SHARED_KEY;
3009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 case eCSR_AUTH_TYPE_AUTOSWITCH:
3011 pBssConfig->authType = eSIR_AUTO_SWITCH;
3012 break;
3013 }
3014 //short slot time
3015 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3016 {
3017 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3018 }
3019 else
3020 {
3021 pBssConfig->uShortSlotTime = 0;
3022 }
3023 //power constraint. We don't support 11h on IBSS
3024 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3025 pBssConfig->uPowerLimit = 0;
3026 //heartbeat
3027 if ( eCSR_BAND_5G == pBssConfig->eBand )
3028 {
3029 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3030 }
3031 else
3032 {
3033 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3034 }
3035 //Join timeout
3036 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003037
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 return (status);
3039}
Jeff Johnson295189b2012-06-20 16:38:30 -07003040static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3041{
3042 eHalStatus status = eHAL_STATUS_FAILURE;
3043 tDot11fBeaconIEs *pIes = NULL;
3044
3045 do
3046 {
3047 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3048 {
3049 //err msg
3050 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003051 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 break;
3053 }
3054 //check if the AP is QAP & it supports APSD
3055 if( CSR_IS_QOS_BSS(pIes) )
3056 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303057 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 }
3059 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303060
3061 if (NULL != pIes)
3062 {
3063 vos_mem_free(pIes);
3064 }
3065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 return status;
3067}
3068
Jeff Johnson295189b2012-06-20 16:38:30 -07003069void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3070{
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3072 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3073 // See !!Note: below in this function...
3074 tANI_U32 PrivacyEnabled = 0;
3075 tANI_U32 RsnEnabled = 0;
3076 tANI_U32 WepDefaultKeyId = 0;
3077 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3078 tANI_U32 Key0Length = 0;
3079 tANI_U32 Key1Length = 0;
3080 tANI_U32 Key2Length = 0;
3081 tANI_U32 Key3Length = 0;
3082
3083 // Reserve for the biggest key
3084 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3085 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3086 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3087 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3088
3089 switch ( pProfile->negotiatedUCEncryptionType )
3090 {
3091 case eCSR_ENCRYPT_TYPE_NONE:
3092
3093 // for NO encryption, turn off Privacy and Rsn.
3094 PrivacyEnabled = 0;
3095 RsnEnabled = 0;
3096
3097 // WEP key length and Wep Default Key ID don't matter in this case....
3098
3099 // clear out the WEP keys that may be hanging around.
3100 Key0Length = 0;
3101 Key1Length = 0;
3102 Key2Length = 0;
3103 Key3Length = 0;
3104
3105 break;
3106
3107 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303108 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003109
3110 // Privacy is ON. NO RSN for Wep40 static key.
3111 PrivacyEnabled = 1;
3112 RsnEnabled = 0;
3113
3114 // Set the Wep default key ID.
3115 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 // Wep key size if 5 bytes (40 bits).
3117 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3118
3119 // set encryption keys in the CFG database or clear those that are not present in this profile.
3120 if ( pProfile->Keys.KeyLength[0] )
3121 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303122 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3123 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3125 }
3126 else
3127 {
3128 Key0Length = 0;
3129 }
3130
3131 if ( pProfile->Keys.KeyLength[1] )
3132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303133 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3134 WNI_CFG_WEP_KEY_LENGTH_5);
3135 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 }
3137 else
3138 {
3139 Key1Length = 0;
3140 }
3141
3142 if ( pProfile->Keys.KeyLength[2] )
3143 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303144 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3145 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3147 }
3148 else
3149 {
3150 Key2Length = 0;
3151 }
3152
3153 if ( pProfile->Keys.KeyLength[3] )
3154 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303155 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3156 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3158 }
3159 else
3160 {
3161 Key3Length = 0;
3162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 break;
3164
3165 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303166 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003167
3168 // Privacy is ON. NO RSN for Wep40 static key.
3169 PrivacyEnabled = 1;
3170 RsnEnabled = 0;
3171
3172 // Set the Wep default key ID.
3173 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3174
3175 // Wep key size if 13 bytes (104 bits).
3176 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3177
3178 // set encryption keys in the CFG database or clear those that are not present in this profile.
3179 if ( pProfile->Keys.KeyLength[0] )
3180 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303181 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3182 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3184 }
3185 else
3186 {
3187 Key0Length = 0;
3188 }
3189
3190 if ( pProfile->Keys.KeyLength[1] )
3191 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303192 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3193 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3195 }
3196 else
3197 {
3198 Key1Length = 0;
3199 }
3200
3201 if ( pProfile->Keys.KeyLength[2] )
3202 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303203 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3204 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3206 }
3207 else
3208 {
3209 Key2Length = 0;
3210 }
3211
3212 if ( pProfile->Keys.KeyLength[3] )
3213 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303214 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3215 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3217 }
3218 else
3219 {
3220 Key3Length = 0;
3221 }
3222
3223 break;
3224
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 case eCSR_ENCRYPT_TYPE_TKIP:
3226 case eCSR_ENCRYPT_TYPE_AES:
3227#ifdef FEATURE_WLAN_WAPI
3228 case eCSR_ENCRYPT_TYPE_WPI:
3229#endif /* FEATURE_WLAN_WAPI */
3230 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3231 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3232 PrivacyEnabled = (0 != fPrivacy);
3233
3234 // turn on RSN enabled for WPA associations
3235 RsnEnabled = 1;
3236
3237 // WEP key length and Wep Default Key ID don't matter in this case....
3238
3239 // clear out the static WEP keys that may be hanging around.
3240 Key0Length = 0;
3241 Key1Length = 0;
3242 Key2Length = 0;
3243 Key3Length = 0;
3244
3245 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 default:
3247 PrivacyEnabled = 0;
3248 RsnEnabled = 0;
3249 break;
3250 }
3251
3252 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3253 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3254 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3255 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3256 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3257 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3258 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3259 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3260}
3261
Jeff Johnson295189b2012-06-20 16:38:30 -07003262static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3263{
3264 tANI_U32 len = 0;
3265 if(pSSID->length <= WNI_CFG_SSID_LEN)
3266 {
3267 len = pSSID->length;
3268 }
3269 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3270}
3271
Jeff Johnson295189b2012-06-20 16:38:30 -07003272eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3273{
3274 eHalStatus status = eHAL_STATUS_SUCCESS;
3275 tANI_U32 QoSEnabled;
3276 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 // set the CFG enable/disable variables based on the qosType being configured...
3278 switch( qosType )
3279 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3281 QoSEnabled = FALSE;
3282 WmeEnabled = TRUE;
3283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3285 QoSEnabled = FALSE;
3286 WmeEnabled = TRUE;
3287 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3289 QoSEnabled = FALSE;
3290 WmeEnabled = TRUE;
3291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3293 QoSEnabled = TRUE;
3294 WmeEnabled = FALSE;
3295 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 case eCSR_MEDIUM_ACCESS_11e_HCF:
3297 QoSEnabled = TRUE;
3298 WmeEnabled = FALSE;
3299 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 default:
3301 case eCSR_MEDIUM_ACCESS_DCF:
3302 QoSEnabled = FALSE;
3303 WmeEnabled = FALSE;
3304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 }
3306 //save the WMM setting for later use
3307 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303308 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
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
Kiet Lamf2f201e2013-11-16 21:24:16 +05303729 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003730 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 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307239 /* While switching between two AP, csr will reissue roam command again
7240 to the nextbss if it was interrupted by the dissconnect req for the
7241 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7242 so reset the bRefAssocStartCnt.
7243 */
7244 if(pSession->bRefAssocStartCnt > 0)
7245 {
7246 pSession->bRefAssocStartCnt--;
7247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 if( pCommand->u.roamCmd.fStopWds )
7249 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307250 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7252 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7253 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7256 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7257 eCSR_ROAM_WDS_IND,
7258 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7260 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7261 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7262 eCSR_ROAM_INFRA_IND,
7263 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7264 }
7265
Jeff Johnson295189b2012-06-20 16:38:30 -07007266
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007269 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7271 }
7272 }
7273 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007275 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7277 }
7278 }
7279 else
7280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007281 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007282 }
7283 }
7284 else
7285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007286 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 }
7288}
7289
Jeff Johnson295189b2012-06-20 16:38:30 -07007290tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7291{
7292 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7293 tListElem *pEntry;
7294 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 //alwasy lock active list before locking pending list
7296 csrLLLock( &pMac->sme.smeCmdActiveList );
7297 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7298 if(pEntry)
7299 {
7300 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7301 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7302 {
7303 fRet = eANI_BOOLEAN_TRUE;
7304 }
7305 }
7306 if(eANI_BOOLEAN_FALSE == fRet)
7307 {
7308 csrLLLock(&pMac->sme.smeCmdPendingList);
7309 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7310 while(pEntry)
7311 {
7312 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7313 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7314 {
7315 fRet = eANI_BOOLEAN_TRUE;
7316 break;
7317 }
7318 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7319 }
7320 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7321 }
7322 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007323 return (fRet);
7324}
7325
Jeff Johnson295189b2012-06-20 16:38:30 -07007326tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7327{
7328 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7329 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7331 {
7332 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7333 {
7334 break;
7335 }
7336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 return ( fRet );
7338}
7339
Jeff Johnson295189b2012-06-20 16:38:30 -07007340tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7341{
7342 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 //alwasy lock active list before locking pending list
7344 csrLLLock( &pMac->sme.smeCmdActiveList );
7345 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7346 if(eANI_BOOLEAN_FALSE == fRet)
7347 {
7348 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7349 }
7350 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 return (fRet);
7352}
7353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7355{
7356 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7357 tListElem *pEntry;
7358 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 //alwasy lock active list before locking pending list
7360 csrLLLock( &pMac->sme.smeCmdActiveList );
7361 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7362 if( pEntry )
7363 {
7364 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7365 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7366 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7367 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7368 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7369 {
7370 fRet = eANI_BOOLEAN_TRUE;
7371 }
7372 }
7373 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 return (fRet);
7375}
Jeff Johnson295189b2012-06-20 16:38:30 -07007376eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7377{
7378 eHalStatus status = eHAL_STATUS_SUCCESS;
7379 tSmeCmd *pCommand = NULL;
7380 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7381 tANI_BOOLEAN fRemoveCmd = FALSE;
7382 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 // Delete the old assoc command. All is setup for reassoc to be serialized
7384 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7385 if ( pEntry )
7386 {
7387 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7388 if ( !pCommand )
7389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007390 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 return eHAL_STATUS_RESOURCES;
7392 }
7393 if ( eSmeCommandRoam == pCommand->command )
7394 {
7395 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7396 {
7397 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7398 }
7399 else
7400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007401 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 }
7403 if (fRemoveCmd == FALSE)
7404 {
7405 // Implies we did not get the serialized assoc command we
7406 // were expecting
7407 pCommand = NULL;
7408 }
7409 }
7410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 if(NULL == pCommand)
7412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007413 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 return eHAL_STATUS_RESOURCES;
7415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 do
7417 {
7418 //Change the substate in case it is wait-for-key
7419 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7420 {
7421 csrRoamStopWaitForKeyTimer( pMac );
7422 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7423 }
7424 pCommand->command = eSmeCommandRoam;
7425 pCommand->sessionId = (tANI_U8)sessionId;
7426 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7428 if( !HAL_STATUS_SUCCESS( status ) )
7429 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007430 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 csrReleaseCommandRoam( pMac, pCommand );
7432 }
7433 } while( 0 );
7434
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 return( status );
7436}
7437static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7438{
7439 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7440 tCsrScanResult *pScanResult = NULL;
7441 tSirBssDescription *pBssDesc = NULL;
7442 tSmeCmd *pCommand = NULL;
7443 tANI_U32 sessionId;
7444 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 if(NULL == pEntry)
7446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007447 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 return;
7449 }
7450 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7451 sessionId = pCommand->sessionId;
7452 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007453
7454 if(!pSession)
7455 {
7456 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7457 return;
7458 }
7459
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7461 {
7462 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007463 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7465 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007466 /* If the roaming has stopped, not to continue the roaming command*/
7467 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7468 {
7469 //No need to complete roaming here as it already completes
7470 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7471 pCommand->u.roamCmd.roamReason);
7472 csrSetAbortRoamingCommand( pMac, pCommand );
7473 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 else
7476 {
7477 if ( CCM_IS_RESULT_SUCCESS(result) )
7478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007479 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 // Successfully set the configuration parameters for the new Bss. Attempt to
7481 // join the roaming Bss.
7482 if(pCommand->u.roamCmd.pRoamBssEntry)
7483 {
7484 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7485 pBssDesc = &pScanResult->Result.BssDescriptor;
7486 }
7487 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7488 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 )
7491 {
7492 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7493 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7494 pBssDesc, pCommand->u.roamCmd.roamId )))
7495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007496 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 //We need to complete the command
7498 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7499 }
7500 }
7501 else
7502 {
7503 if (!pCommand->u.roamCmd.pRoamBssEntry)
7504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007505 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 //We need to complete the command
7507 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7508 return;
7509 }
7510 // If we are roaming TO an Infrastructure BSS...
7511 VOS_ASSERT(pScanResult != NULL);
7512 if ( csrIsInfraBssDesc( pBssDesc ) )
7513 {
7514 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7516 {
7517 // ..and currently in an Infrastructure connection....
7518 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7519 {
7520 // ...and the SSIDs are equal, then we Reassoc.
7521 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7522 pIesLocal ) )
7523 // ..and currently in an infrastructure connection
7524 {
7525 // then issue a Reassoc.
7526 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7527 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7528 &pCommand->u.roamCmd.roamProfile );
7529 }
7530 else
7531 {
7532
7533 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7534 // previously associated AP.
7535 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7536 pIesLocal,
7537 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7538 {
7539 //try something else
7540 csrRoam( pMac, pCommand );
7541 }
7542 }
7543 }
7544 else
7545 {
7546 eHalStatus status = eHAL_STATUS_SUCCESS;
7547
7548 /* We need to come with other way to figure out that this is because of HO in BMP
7549 The below API will be only available for Android as it uses a different HO algorithm */
7550 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7551 * use join request */
7552#ifdef WLAN_FEATURE_VOWIFI_11R
7553 if (csrRoamIsHandoffInProgress(pMac) &&
7554 csrRoamIs11rAssoc(pMac))
7555 {
7556 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7557 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7558 }
7559 else
7560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007561#ifdef FEATURE_WLAN_CCX
7562 if (csrRoamIsHandoffInProgress(pMac) &&
7563 csrRoamIsCCXAssoc(pMac))
7564 {
7565 // Now serialize the reassoc command.
7566 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7567 }
7568 else
7569#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007570#ifdef FEATURE_WLAN_LFR
7571 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307572 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007573 {
7574 // Now serialize the reassoc command.
7575 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7576 }
7577 else
7578#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 // else we are not connected and attempting to Join. Issue the
7580 // Join request.
7581 {
7582 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7583 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7584 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7585 }
7586 if(!HAL_STATUS_SUCCESS(status))
7587 {
7588 //try something else
7589 csrRoam( pMac, pCommand );
7590 }
7591 }
7592 if( !pScanResult->Result.pvIes )
7593 {
7594 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307595 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 }
7597 }
7598 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7599 else
7600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007601 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 }
7603 }//else
7604 }//if ( WNI_CFG_SUCCESS == result )
7605 else
7606 {
7607 // In the event the configuration failed, for infra let the roam processor
7608 //attempt to join something else...
7609 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7610 {
7611 csrRoam(pMac, pCommand);
7612 }
7613 else
7614 {
7615 //We need to complete the command
7616 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7617 {
7618 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7619 }
7620 else
7621 {
7622 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7623 }
7624 }
7625 }
7626 }//we have active entry
7627}
7628
Jeff Johnson295189b2012-06-20 16:38:30 -07007629static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7630{
7631 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007632 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007635 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7637 // join the new one...
7638 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007639 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7640 }
7641 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007642 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 /***profHandleLostLinkAfterReset(pAdapter);
7644 // In the event the authenticate fails, let the roam processor attempt to join something else...
7645 roamRoam( pAdapter );***/
7646 }
7647}
7648
Jeff Johnson295189b2012-06-20 16:38:30 -07007649static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7650{
7651 eCsrRoamCompleteResult result;
7652 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7653 tCsrRoamInfo roamInfo;
7654 tANI_U32 roamId = 0;
7655
7656 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007658 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 /* Defeaturize this part later if needed */
7661#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7662 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7663 * we need the response contents while processing the result in csrRoamProcessResults() */
7664 if (csrRoamIsHandoffInProgress(pMac))
7665 {
7666 /* Need to dig more on indicating events to SME QoS module */
7667 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7668 csrRoamComplete( pMac, result, pSmeJoinRsp);
7669 }
7670 else
7671#endif
7672 {
7673 csrRoamComplete( pMac, result, NULL );
7674 }
7675 }
7676 /* Should we handle this similar to handling the join failure? Is it ok
7677 * to call csrRoamComplete() with state as CsrJoinFailure */
7678 else
7679 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007680 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 result = eCsrReassocFailure;
7682#ifdef WLAN_FEATURE_VOWIFI_11R
7683 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7684 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7685 {
7686 // Inform HDD to turn off FT flag in HDD
7687 if (pNeighborRoamInfo)
7688 {
7689 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7690 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7691 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007692 /*
7693 * Since the above callback sends a disconnect
7694 * to HDD, we should clean-up our state
7695 * machine as well to be in sync with the upper
7696 * layers. There is no need to send a disassoc
7697 * since: 1) we will never reassoc to the current
7698 * AP in LFR, and 2) there is no need to issue a
7699 * disassoc to the AP with which we were trying
7700 * to reassoc.
7701 */
7702 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7703 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 }
7705 }
7706#endif
7707 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7708 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7709 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7710 //The disassoc rsp message will remove the command from active list
7711 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7712 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7713 {
7714 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7715 }
7716 }
7717}
7718
Jeff Johnson295189b2012-06-20 16:38:30 -07007719static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7720{
Jeff Johnson295189b2012-06-20 16:38:30 -07007721#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7722 {
7723 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007724 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7725 if(pIbssLog)
7726 {
7727 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7728 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7729 {
7730 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7731 }
7732 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7733 }
7734 }
7735#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7737 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7738 {
7739 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7740 }
7741 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7742 {
7743 csrRoamReissueRoamCommand(pMac);
7744 }
7745}
7746
Jeff Johnson295189b2012-06-20 16:38:30 -07007747void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7748{
7749 tSirResultCodes statusCode;
7750#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7751 tScanResultHandle hBSSList;
7752 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7753 eHalStatus status;
7754 tCsrRoamInfo roamInfo;
7755 tCsrScanResultFilter *pScanFilter = NULL;
7756 tANI_U32 roamId = 0;
7757 tCsrRoamProfile *pCurRoamProfile = NULL;
7758 tListElem *pEntry = NULL;
7759 tSmeCmd *pCommand = NULL;
7760#endif
7761 tANI_U32 sessionId;
7762 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007763
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 tSirSmeDisassocRsp SmeDisassocRsp;
7765
7766 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7767 sessionId = SmeDisassocRsp.sessionId;
7768 statusCode = SmeDisassocRsp.statusCode;
7769
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007770 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007771
7772 if ( csrIsConnStateInfra( pMac, sessionId ) )
7773 {
7774 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007776 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007777
7778 if(!pSession)
7779 {
7780 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7781 return;
7782 }
7783
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7785 {
7786 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7787 }
7788 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7789 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7790 {
7791 if ( eSIR_SME_SUCCESS == statusCode )
7792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007793 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007794 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7795 }
7796 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007800 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007801#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007802 /*
7803 * First ensure if the roam profile is in the scan cache.
7804 * If not, post a reassoc failure and disconnect.
7805 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307806 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7807 if ( NULL == pScanFilter )
7808 status = eHAL_STATUS_FAILURE;
7809 else
7810 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007811 if(HAL_STATUS_SUCCESS(status))
7812 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307813 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007814 status = csrRoamPrepareFilterFromProfile(pMac,
7815 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7816 if(!HAL_STATUS_SUCCESS(status))
7817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007818 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007819 __func__, status);
7820 goto POST_ROAM_FAILURE;
7821 }
7822 else
7823 {
7824 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7825 if (!HAL_STATUS_SUCCESS(status))
7826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007827 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007828 __func__, status);
7829 goto POST_ROAM_FAILURE;
7830 }
7831 }
7832 }
7833 else
7834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007835 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007836 __func__, status);
7837 goto POST_ROAM_FAILURE;
7838 }
7839
7840 /*
7841 * After ensuring that the roam profile is in the scan result list,
7842 * dequeue the command from the active list.
7843 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007844 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7845 if ( pEntry )
7846 {
7847 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007848 /* If the head of the queue is Active and it is a ROAM command, remove
7849 * and put this on the Free queue.
7850 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 if ( eSmeCommandRoam == pCommand->command )
7852 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007853
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007854 /*
7855 * we need to process the result first before removing it from active list
7856 * because state changes still happening insides roamQProcessRoamResults so
7857 * no other roam command should be issued.
7858 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007859 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7860 if(pCommand->u.roamCmd.fReleaseProfile)
7861 {
7862 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7863 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 else
7868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007869 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007870 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 }
7872 }
7873 else
7874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007875 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007876 }
7877 }
7878 else
7879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007880 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007881 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007882
7883 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7885
Kiet Lam64c1b492013-07-12 13:56:44 +05307886 vos_mem_copy(roamInfo.bssid,
7887 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7888 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007889
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007890 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7891 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007892
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007893 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307894 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7895 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307897 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007898 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7899 //make sure to put it at the head of the cmd queue
7900 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7901 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7902 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7903
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 if(!HAL_STATUS_SUCCESS(status))
7905 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007906 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007907 __func__, status);
7908 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 }
7910
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007911 /* Notify sub-modules like QoS etc. that handoff happening */
7912 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007913 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307914 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007915 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307916 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007917 return;
7918 }
7919
7920POST_ROAM_FAILURE:
7921 if (pScanFilter)
7922 {
7923 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307924 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007925 }
7926 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05307927 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007928
7929 /* Inform the upper layers that the reassoc failed */
7930 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7931 csrRoamCallCallback(pMac, sessionId,
7932 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7933
7934 /*
7935 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7936 * Upon success, we would re-enter this routine after receiving the disassoc
7937 * response and will fall into the reassoc fail sub-state. And, eventually
7938 * call csrRoamComplete which would remove the roam command from SME active
7939 * queue.
7940 */
7941 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7942 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7943 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007944 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007945 __func__, status);
7946 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007948#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007949
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7951 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7952 {
7953 // Disassoc due to Reassoc failure falls into this codepath....
7954 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7955 }
7956 else
7957 {
7958 if ( eSIR_SME_SUCCESS == statusCode )
7959 {
7960 // Successfully disassociated from the 'old' Bss...
7961 //
7962 // We get Disassociate response in three conditions.
7963 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7964 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7965 // Infrastructure network.
7966 // - Third is where we are doing an Infra to Infra roam between networks with different
7967 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7968
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007969 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 }
7971 else
7972 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007973 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 }
7975 //We are not done yet. Get the data and continue roaming
7976 csrRoamReissueRoamCommand(pMac);
7977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007978}
7979
Jeff Johnson295189b2012-06-20 16:38:30 -07007980static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7981{
7982 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007983 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007984 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7986 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7987 {
7988 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7989 }
7990 else
7991 {
7992 if ( eSIR_SME_SUCCESS == statusCode )
7993 {
7994 // Successfully deauth from the 'old' Bss...
7995 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007996 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 }
7998 else
7999 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008000 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 }
8002 //We are not done yet. Get the data and continue roaming
8003 csrRoamReissueRoamCommand(pMac);
8004 }
8005}
8006
Jeff Johnson295189b2012-06-20 16:38:30 -07008007static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8008{
8009 eCsrRoamCompleteResult result;
8010
8011 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008013 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 result = eCsrStartBssSuccess;
8015 }
8016 else
8017 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008018 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 //Let csrRoamComplete decide what to do
8020 result = eCsrStartBssFailure;
8021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008022 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008023}
8024
Jeff Johnson295189b2012-06-20 16:38:30 -07008025/*
8026 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8027 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8028 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8029 For the messages where sender allocates memory for specific structures, then it can be
8030 cast accordingly.
8031*/
8032void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8033{
8034 tSirSmeRsp *pSmeRsp;
8035 tSmeIbssPeerInd *pIbssPeerInd;
8036 tCsrRoamInfo roamInfo;
8037 // TODO Session Id need to be acquired in this function
8038 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008040 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 pSmeRsp->messageType, pSmeRsp->messageType,
8042 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 pSmeRsp->messageType = (pSmeRsp->messageType);
8044 pSmeRsp->length = (pSmeRsp->length);
8045 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008046 switch (pSmeRsp->messageType)
8047 {
8048
8049 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8050 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8051 {
8052 //We sent a JOIN_REQ
8053 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8054 }
8055 break;
8056
8057 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8058 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8059 {
8060 //We sent a AUTH_REQ
8061 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8062 }
8063 break;
8064
8065 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8066 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8067 {
8068 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8069 }
8070 break;
8071
8072 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8073 {
8074 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8075 }
8076 break;
8077
8078 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8079 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8080 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8081 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8082 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8083 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8084//HO
8085 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008087 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8089 }
8090 break;
8091
8092 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8093 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8094 {
8095 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8096 }
8097 break;
8098
8099 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8100 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8101 {
8102 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8103 }
8104 break;
8105
8106 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8107 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8108 {
8109 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8113 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8114 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008115 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308116 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8117 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8119 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308120 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8121 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8123 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8124 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8125 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008127 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008128 pSmeRsp->messageType, pSmeRsp->messageType,
8129 pMac->roam.curSubState[pSmeRsp->sessionId] );
8130
8131 //If we are connected, check the link status change
8132 if(!csrIsConnStateDisconnected(pMac, sessionId))
8133 {
8134 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8135 }
8136 break;
8137 }
8138}
8139
Jeff Johnson295189b2012-06-20 16:38:30 -07008140void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8141{
8142 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 switch (pSirMsg->messageType)
8144 {
8145 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008146 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 csrRoamStatsRspProcessor( pMac, pSirMsg );
8148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8150 {
8151 tCsrRoamSession *pSession;
8152 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8153 tCsrRoamInfo roamInfo;
8154 tCsrRoamInfo *pRoamInfo = NULL;
8155 tANI_U32 sessionId;
8156 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008157 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308158 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8161 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8162 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008163
8164 if(!pSession)
8165 {
8166 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8167 return;
8168 }
8169
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8171 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8173 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8174 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8176 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308177 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8178 sizeof(tSirMacAddr));
8179 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8180 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8183 {
8184 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8185 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8186 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8187 }
8188 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8189 {
8190 vos_sleep( 100 );
8191 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8192 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8193 }
8194
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 }
8196 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008197 default:
8198 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8199 break;
8200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008201}
8202
Jeff Johnson295189b2012-06-20 16:38:30 -07008203eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8204 tSirBssDescription *pBssDescription,
8205 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8206 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8207 tANI_U8 keyId, tANI_U16 keyLength,
8208 tANI_U8 *pKey, tANI_U8 paeRole )
8209{
8210 eHalStatus status = eHAL_STATUS_SUCCESS;
8211 tAniEdType edType;
8212
8213 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8214 {
8215 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8216 }
8217
8218 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8219
8220 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8221 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8222 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8223 addKey )
8224 {
8225 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 setKey.encType = EncryptType;
8227 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308228 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 setKey.paeRole = paeRole; //0 for supplicant
8230 setKey.keyId = keyId; // Kye index
8231 setKey.keyLength = keyLength;
8232 if( keyLength )
8233 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308234 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 }
8236 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 return (status);
8239}
8240
Jeff Johnson295189b2012-06-20 16:38:30 -07008241static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8242 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8243{
8244 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8245 tSmeCmd *pCommand = NULL;
8246#ifdef FEATURE_WLAN_CCX
8247 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8248#endif /* FEATURE_WLAN_CCX */
8249
8250 do
8251 {
8252 pCommand = csrGetCommandBuffer(pMac);
8253 if(NULL == pCommand)
8254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008255 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 status = eHAL_STATUS_RESOURCES;
8257 break;
8258 }
8259 pCommand->command = eSmeCommandSetKey;
8260 pCommand->sessionId = (tANI_U8)sessionId;
8261 // validate the key length, Adjust if too long...
8262 // for static WEP the keys are not set thru' SetContextReq
8263 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8264 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8265 {
8266 //KeyLength maybe 0 for static WEP
8267 if( pSetKey->keyLength )
8268 {
8269 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008271 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 break;
8273 }
8274
8275 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308276 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8277 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 }
8279 }
8280 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8281 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8282 {
8283 //KeyLength maybe 0 for static WEP
8284 if( pSetKey->keyLength )
8285 {
8286 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008288 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 break;
8290 }
8291
8292 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308293 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8294 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 }
8296 }
8297 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8298 {
8299 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008301 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 break;
8303 }
8304 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308305 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8306 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 }
8308 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8309 {
8310 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8311 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008312 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 break;
8314 }
8315 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308316 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8317 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 }
8319#ifdef FEATURE_WLAN_WAPI
8320 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8321 {
8322 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008324 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 break;
8326 }
8327 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308328 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8329 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 }
8331#endif /* FEATURE_WLAN_WAPI */
8332#ifdef FEATURE_WLAN_CCX
8333 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8334 {
8335 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008337 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 break;
8339 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308340 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8341 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 pSession->ccxCckmInfo.reassoc_req_num=1;
8343 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8344 status = eHAL_STATUS_SUCCESS;
8345 break;
8346 }
8347#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008348
Jeff Johnson295189b2012-06-20 16:38:30 -07008349#ifdef WLAN_FEATURE_11W
8350 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008351 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008353 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008355 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 break;
8357 }
8358 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308359 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 }
8361#endif
8362 status = eHAL_STATUS_SUCCESS;
8363 pCommand->u.setKeyCmd.roamId = roamId;
8364 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8365 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308366 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8367 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8369 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308370 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008371 //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
8372
8373 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8374 if( !HAL_STATUS_SUCCESS( status ) )
8375 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008376 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 }
8378 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 // Free the command if there has been a failure, or it is a
8380 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008381 if ( ( NULL != pCommand ) &&
8382 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008383#ifdef FEATURE_WLAN_CCX
8384 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8385#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008386 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 {
8388 csrReleaseCommandSetKey( pMac, pCommand );
8389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 return( status );
8391}
8392
Jeff Johnson295189b2012-06-20 16:38:30 -07008393eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8394 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8395{
8396 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8397 tSmeCmd *pCommand = NULL;
8398 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 do
8400 {
8401 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8402 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008403 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 status = eHAL_STATUS_CSR_WRONG_STATE;
8405 break;
8406 }
8407 pCommand = csrGetCommandBuffer(pMac);
8408 if(NULL == pCommand)
8409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008410 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 status = eHAL_STATUS_RESOURCES;
8412 break;
8413 }
8414 pCommand->command = eSmeCommandRemoveKey;
8415 pCommand->sessionId = (tANI_U8)sessionId;
8416 pCommand->u.removeKeyCmd.roamId = roamId;
8417 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308418 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8419 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8421 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8422 {
8423 //in this case, put it to the end of the Q incase there is a set key pending.
8424 fImediate = eANI_BOOLEAN_FALSE;
8425 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008426 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008428 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8430 if( !HAL_STATUS_SUCCESS( status ) )
8431 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008432 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008433 break;
8434 }
8435 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8437 {
8438 csrReleaseCommandRemoveKey( pMac, pCommand );
8439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 return (status );
8441}
8442
Jeff Johnson295189b2012-06-20 16:38:30 -07008443eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8444{
8445 eHalStatus status;
8446 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8447 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8448 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8449 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008450#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8451 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8452 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008453 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308455 vos_mem_set(&setKeyEvent,
8456 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8458 {
8459 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8460 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8461 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8462 }
8463 else
8464 {
8465 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8466 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8467 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8468 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308469 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008470 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 {
8472 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 //It has to be static WEP here
8474 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8475 {
8476 setKeyEvent.keyId = (v_U8_t)defKeyId;
8477 }
8478 }
8479 else
8480 {
8481 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8482 }
8483 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8484 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8485 }
8486#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 if( csrIsSetKeyAllowed(pMac, sessionId) )
8488 {
8489 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8490 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8491 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8492 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8493 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8494 pCommand->u.setKeyCmd.keyRsc);
8495 }
8496 else
8497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008498 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 //Set this status so the error handling take care of the case.
8500 status = eHAL_STATUS_CSR_WRONG_STATE;
8501 }
8502 if( !HAL_STATUS_SUCCESS(status) )
8503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008504 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008506#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008507 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 {
8509 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8510 {
8511 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8512 }
8513 else
8514 {
8515 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8516 }
8517 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8518 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8519 }
8520#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 return ( status );
8523}
8524
Jeff Johnson295189b2012-06-20 16:38:30 -07008525eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8526{
8527 eHalStatus status;
8528 tpSirSmeRemoveKeyReq pMsg = NULL;
8529 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8530 tANI_U8 *p;
8531 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008532#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8534 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308535 vos_mem_set(&removeKeyEvent,
8536 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8538 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8539 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308540 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8542 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8543 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8544#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 if( csrIsSetKeyAllowed(pMac, sessionId) )
8546 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308547 pMsg = vos_mem_malloc(wMsgLen);
8548 if ( NULL == pMsg )
8549 status = eHAL_STATUS_FAILURE;
8550 else
8551 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 }
8553 else
8554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008555 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 //Set the error status so error handling kicks in below
8557 status = eHAL_STATUS_CSR_WRONG_STATE;
8558 }
8559 if( HAL_STATUS_SUCCESS( status ) )
8560 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308561 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8563 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 pMsg->sessionId = (tANI_U8)sessionId;
8565 pMsg->transactionId = 0;
8566 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8567 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8568 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308569 vos_mem_copy(p,
8570 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8571 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 p += sizeof(tSirMacAddr);
8573 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308574 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 p += sizeof(tSirMacAddr);
8576 // edType
8577 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8578 p++;
8579 // weptype
8580 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8581 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8582 {
8583 *p = (tANI_U8)eSIR_WEP_STATIC;
8584 }
8585 else
8586 {
8587 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8588 }
8589 p++;
8590 //keyid
8591 *p = pCommand->u.removeKeyCmd.keyId;
8592 p++;
8593 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 status = palSendMBMessage(pMac->hHdd, pMsg);
8595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 if( !HAL_STATUS_SUCCESS( status ) )
8597 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008598 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008599#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8600 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008601 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8603#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008604 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 return ( status );
8607}
8608
Jeff Johnson295189b2012-06-20 16:38:30 -07008609eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8610{
8611 eHalStatus status;
8612
8613 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8614 {
8615 status = eHAL_STATUS_CSR_WRONG_STATE;
8616 }
8617 else
8618 {
8619 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 return ( status );
8622}
8623
Jeff Johnson295189b2012-06-20 16:38:30 -07008624/*
8625 Prepare a filter base on a profile for parsing the scan results.
8626 Upon successful return, caller MUST call csrFreeScanFilter on
8627 pScanFilter when it is done with the filter.
8628*/
8629eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8630 tCsrScanResultFilter *pScanFilter)
8631{
8632 eHalStatus status = eHAL_STATUS_SUCCESS;
8633 tANI_U32 size = 0;
8634 tANI_U8 index = 0;
8635
8636 do
8637 {
8638 if(pProfile->BSSIDs.numOfBSSIDs)
8639 {
8640 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308641 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8642 if ( NULL == pScanFilter->BSSIDs.bssid )
8643 status = eHAL_STATUS_FAILURE;
8644 else
8645 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 if(!HAL_STATUS_SUCCESS(status))
8647 {
8648 break;
8649 }
8650 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308651 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 }
8653 if(pProfile->SSIDs.numOfSSIDs)
8654 {
8655 if( !CSR_IS_WDS_STA( pProfile ) )
8656 {
8657 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8658 }
8659 else
8660 {
8661 //For WDS station
8662 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8663 pScanFilter->SSIDs.numOfSSIDs = 1;
8664 }
8665 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308666 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8667 if ( NULL == pScanFilter->SSIDs.SSIDList )
8668 status = eHAL_STATUS_FAILURE;
8669 else
8670 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 if(!HAL_STATUS_SUCCESS(status))
8672 {
8673 break;
8674 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308675 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8676 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 }
8678 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8679 {
8680 pScanFilter->ChannelInfo.numOfChannels = 0;
8681 pScanFilter->ChannelInfo.ChannelList = NULL;
8682 }
8683 else if(pProfile->ChannelInfo.numOfChannels)
8684 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308685 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8686 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8687 pProfile->ChannelInfo.numOfChannels);
8688 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8689 status = eHAL_STATUS_FAILURE;
8690 else
8691 status = eHAL_STATUS_SUCCESS;
8692
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 pScanFilter->ChannelInfo.numOfChannels = 0;
8694 if(HAL_STATUS_SUCCESS(status))
8695 {
8696 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8697 {
8698 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8699 {
8700 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8701 = pProfile->ChannelInfo.ChannelList[index];
8702 pScanFilter->ChannelInfo.numOfChannels++;
8703 }
8704 else
8705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008706 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 }
8709 }
8710 else
8711 {
8712 break;
8713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 }
8715 else
8716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008717 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 status = eHAL_STATUS_FAILURE;
8719 break;
8720 }
8721 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8722 pScanFilter->authType = pProfile->AuthType;
8723 pScanFilter->EncryptionType = pProfile->EncryptionType;
8724 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8725 pScanFilter->BSSType = pProfile->BSSType;
8726 pScanFilter->phyMode = pProfile->phyMode;
8727#ifdef FEATURE_WLAN_WAPI
8728 //check if user asked for WAPI with 11n or auto mode, in that case modify
8729 //the phymode to 11g
8730 if(csrIsProfileWapi(pProfile))
8731 {
8732 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8733 {
8734 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8735 }
8736 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8737 {
8738 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8739 }
8740 if(!pScanFilter->phyMode)
8741 {
8742 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8743 }
8744 }
8745#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 /*Save the WPS info*/
8747 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008748 if( pProfile->countryCode[0] )
8749 {
8750 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308751 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8752 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 }
8754#ifdef WLAN_FEATURE_VOWIFI_11R
8755 if (pProfile->MDID.mdiePresent)
8756 {
8757 pScanFilter->MDID.mdiePresent = 1;
8758 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8759 }
8760#endif
8761
8762 }while(0);
8763
8764 if(!HAL_STATUS_SUCCESS(status))
8765 {
8766 csrFreeScanFilter(pMac, pScanFilter);
8767 }
8768
8769 return(status);
8770}
8771
Jeff Johnson295189b2012-06-20 16:38:30 -07008772tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8773 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8774{
8775 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8776 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 do
8778 {
8779 // Validate the type is ok...
8780 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8781 pCommand = csrGetCommandBuffer( pMac );
8782 if ( !pCommand )
8783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008784 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 break;
8786 }
8787 //Change the substate in case it is waiting for key
8788 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8789 {
8790 csrRoamStopWaitForKeyTimer( pMac );
8791 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8792 }
8793 pCommand->command = eSmeCommandWmStatusChange;
8794 pCommand->sessionId = (tANI_U8)sessionId;
8795 pCommand->u.wmStatusChangeCmd.Type = Type;
8796 if ( eCsrDisassociated == Type )
8797 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308798 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8799 pSmeRsp,
8800 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 }
8802 else
8803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308804 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8805 pSmeRsp,
8806 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 }
8808 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8809 {
8810 fCommandQueued = eANI_BOOLEAN_TRUE;
8811 }
8812 else
8813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008814 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 csrReleaseCommandWmStatusChange( pMac, pCommand );
8816 }
8817
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8819 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008821 return( fCommandQueued );
8822}
8823
Jeff Johnson295189b2012-06-20 16:38:30 -07008824static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8825{
8826 v_S7_t rssi = 0;
8827 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8828 if(pGetRssiReq)
8829 {
8830 if(NULL != pGetRssiReq->pVosContext)
8831 {
8832 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8833 }
8834 else
8835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008836 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 return;
8838 }
8839
8840 if(NULL != pGetRssiReq->rssiCallback)
8841 {
8842 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8843 }
8844 else
8845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008846 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 return;
8848 }
8849 }
8850 else
8851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008852 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 }
8854 return;
8855}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308856
8857static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8858{
8859 tANI_S8 snr = 0;
8860 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8861
8862 if (pGetSnrReq)
8863 {
8864 if (VOS_STATUS_SUCCESS !=
8865 WDA_GetSnr(pGetSnrReq->staId, &snr))
8866 {
8867 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8868 return;
8869 }
8870
8871 if (pGetSnrReq->snrCallback)
8872 {
8873 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8874 pGetSnrReq->pDevContext);
8875 }
8876 else
8877 {
8878 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8879 return;
8880 }
8881 }
8882 else
8883 {
8884 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8885 }
8886 return;
8887}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008888#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8889void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8890{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008891 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8892
Jeff Johnson36d483b2013-04-08 11:08:53 -07008893 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008894 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008895 /* Get roam Rssi request is backed up and passed back to the response,
8896 Extract the request message to fetch callback */
8897 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8898 v_S7_t rssi = pRoamRssiRsp->rssi;
8899
8900 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008901 {
8902 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8903 reqBkp->rssiCallback = NULL;
8904 vos_mem_free(reqBkp);
8905 }
8906 else
8907 {
8908 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8909 if (NULL != reqBkp)
8910 {
8911 vos_mem_free(reqBkp);
8912 }
8913 }
8914 }
8915 else
8916 {
8917 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8918 }
8919 return;
8920}
8921#endif
8922
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008923
8924#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8925void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8926{
8927 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
8928
8929 if (NULL != pTsmStatsRsp)
8930 {
8931 /* Get roam Rssi request is backed up and passed back to the response,
8932 Extract the request message to fetch callback */
8933 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
8934
8935 if (NULL != reqBkp)
8936 {
8937 if (NULL != reqBkp->tsmStatsCallback)
8938 {
8939 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
8940 pTsmStatsRsp->staId, reqBkp->pDevContext);
8941 reqBkp->tsmStatsCallback = NULL;
8942 }
8943 vos_mem_free(reqBkp);
8944 }
8945 else
8946 {
8947 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
8948 if (NULL != reqBkp)
8949 {
8950 vos_mem_free(reqBkp);
8951 }
8952 }
8953 }
8954 else
8955 {
8956 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
8957 }
8958 return;
8959}
8960
8961void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
8962{
8963 tANI_U32 roamTS2 = 0;
8964 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008965 tpPESession pSessionEntry = NULL;
8966 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008967
8968 if (NULL == pSession)
8969 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008970 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008971 return;
8972 }
8973
8974 roamTS2 = vos_timer_get_system_time();
8975 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08008976 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
8977 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008978 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008979
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008980 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
8981 if (NULL == pSessionEntry)
8982 {
8983 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
8984 return;
8985 }
8986 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008987 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
8988 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
8989}
8990#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
8991
Jeff Johnsone7245742012-09-05 17:12:55 -07008992static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8993{
8994 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8995 if(pTlRssiInd)
8996 {
8997 if(NULL != pTlRssiInd->tlCallback)
8998 {
8999 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009000 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009001 }
9002 else
9003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009004 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009005 }
9006 }
9007 else
9008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009009 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009010 }
9011 return;
9012}
Jeff Johnson295189b2012-06-20 16:38:30 -07009013
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309014eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9015{
9016 tpSirResetAPCapsChange pMsg;
9017 tANI_U16 len;
9018 eHalStatus status = eHAL_STATUS_SUCCESS;
9019
9020 /* Create the message and send to lim */
9021 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309022 pMsg = vos_mem_malloc(len);
9023 if ( NULL == pMsg )
9024 status = eHAL_STATUS_FAILURE;
9025 else
9026 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309027 if (HAL_STATUS_SUCCESS(status))
9028 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309029 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309030 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9031 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309032 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009033 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9034 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309035 status = palSendMBMessage(pMac->hHdd, pMsg);
9036 }
9037 else
9038 {
9039 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9040 }
9041 return status;
9042}
9043
Jeff Johnson295189b2012-06-20 16:38:30 -07009044void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9045{
9046 tSirSmeAssocInd *pAssocInd;
9047 tSirSmeDisassocInd *pDisassocInd;
9048 tSirSmeDeauthInd *pDeauthInd;
9049 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9050 tSirSmeNewBssInfo *pNewBss;
9051 tSmeIbssPeerInd *pIbssPeerInd;
9052 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9053 tSirSmeApNewCaps *pApNewCaps;
9054 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9055 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9056 tCsrRoamInfo *pRoamInfo = NULL;
9057 tCsrRoamInfo roamInfo;
9058 eHalStatus status;
9059 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9060 tCsrRoamSession *pSession = NULL;
9061 tpSirSmeSwitchChannelInd pSwitchChnInd;
9062 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009063 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009064 pSirMsg->messageType = (pSirMsg->messageType);
9065 pSirMsg->length = (pSirMsg->length);
9066 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309067 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009068 switch( pSirMsg->messageType )
9069 {
9070 case eWNI_SME_ASSOC_IND:
9071 {
9072 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009073 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9075 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9076 if( HAL_STATUS_SUCCESS( status ) )
9077 {
9078 pSession = CSR_GET_SESSION(pMac, sessionId);
9079
Jeff Johnson32d95a32012-09-10 13:15:23 -07009080 if(!pSession)
9081 {
9082 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9083 return;
9084 }
9085
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 pRoamInfo = &roamInfo;
9087
9088 // Required for indicating the frames to upper layer
9089 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9090 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9091
9092 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9093 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9094 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9095 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9096
9097 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9098 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9099 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9100
9101 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9102 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309103 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9104 sizeof(tSirMacAddr));
9105 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9106 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9108 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9111 {
9112 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9113 {
9114 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9115 pSession->pConnectBssDesc,
9116 &(pRoamInfo->peerMac),
9117 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9118 pRoamInfo->fAuthRequired = FALSE;
9119 }
9120 else
9121 {
9122 pRoamInfo->fAuthRequired = TRUE;
9123 }
9124 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9125 if (!HAL_STATUS_SUCCESS(status))
9126 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 /* Send Association completion message to PE */
9129 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9130
9131 /* send a message to CSR itself just to avoid the EAPOL frames going
9132 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9134 {
9135 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009137 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9138 {
9139 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9140 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9141 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 }
9144 }
9145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 // Check if AP dis-associated us because of MIC failure. If so,
9148 // then we need to take action immediately and not wait till the
9149 // the WmStatusChange requests is pushed and processed
9150 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9151 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9152 if( HAL_STATUS_SUCCESS( status ) )
9153 {
Kiet Lam82004c62013-11-11 13:24:28 +05309154 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC for session %d "), sessionId);
9155 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer =" MAC_ADDRESS_STR " "
9156 " reason = %d status = %d "),
9157 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9158 pDisassocInd->reasonCode, pDisassocInd->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 // If we are in neighbor preauth done state then on receiving
9160 // disassoc or deauth we dont roam instead we just disassoc
9161 // from current ap and then go to disconnected state
9162 // This happens for CCX and 11r FT connections ONLY.
9163#ifdef WLAN_FEATURE_VOWIFI_11R
9164 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9165 {
9166 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9167 }
9168#endif
9169#ifdef FEATURE_WLAN_CCX
9170 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9171 {
9172 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9173 }
9174#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009175#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309176 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009177 {
9178 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9179 }
9180#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009181 pSession = CSR_GET_SESSION( pMac, sessionId );
9182
Jeff Johnson32d95a32012-09-10 13:15:23 -07009183 if(!pSession)
9184 {
9185 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9186 return;
9187 }
9188
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 if ( csrIsConnStateInfra( pMac, sessionId ) )
9190 {
9191 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009193#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9194 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9195#endif
9196 csrRoamLinkDown(pMac, sessionId);
9197 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9199 {
9200
9201 pRoamInfo = &roamInfo;
9202
9203 pRoamInfo->statusCode = pDisassocInd->statusCode;
9204 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9205
9206 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
9207
Kiet Lam64c1b492013-07-12 13:56:44 +05309208 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9209 sizeof(tSirMacAddr));
9210 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9211 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009212
9213 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009214
9215 /*
9216 * STA/P2P client got disassociated so remove any pending deauth
9217 * commands in sme pending list
9218 */
9219 pCommand.command = eSmeCommandRoam;
9220 pCommand.sessionId = (tANI_U8)sessionId;
9221 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Kiet Lam64c1b492013-07-12 13:56:44 +05309222 vos_mem_copy(pCommand.u.roamCmd.peerMac,
9223 pDisassocInd->peerMacAddr,
9224 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009225 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 }
Kiet Lam82004c62013-11-11 13:24:28 +05309228 else
9229 {
9230 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9231 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009235 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9237 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9238 if( HAL_STATUS_SUCCESS( status ) )
9239 {
9240 // If we are in neighbor preauth done state then on receiving
9241 // disassoc or deauth we dont roam instead we just disassoc
9242 // from current ap and then go to disconnected state
9243 // This happens for CCX and 11r FT connections ONLY.
9244#ifdef WLAN_FEATURE_VOWIFI_11R
9245 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9246 {
9247 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9248 }
9249#endif
9250#ifdef FEATURE_WLAN_CCX
9251 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9252 {
9253 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9254 }
9255#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009256#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309257 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009258 {
9259 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9260 }
9261#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 pSession = CSR_GET_SESSION( pMac, sessionId );
9263
Jeff Johnson32d95a32012-09-10 13:15:23 -07009264 if(!pSession)
9265 {
9266 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9267 return;
9268 }
9269
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 if ( csrIsConnStateInfra( pMac, sessionId ) )
9271 {
9272 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009274#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9275 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9276#endif
9277 csrRoamLinkDown(pMac, sessionId);
9278 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009279 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9280 {
9281
9282 pRoamInfo = &roamInfo;
9283
9284 pRoamInfo->statusCode = pDeauthInd->statusCode;
9285 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9286
9287 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9288
Kiet Lam64c1b492013-07-12 13:56:44 +05309289 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9290 sizeof(tSirMacAddr));
9291 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9292 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009293
9294 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 }
9297 break;
9298
9299 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 -08009300 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9302 //Update with the new channel id.
9303 //The channel id is hidden in the statusCode.
9304 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9305 if( HAL_STATUS_SUCCESS( status ) )
9306 {
9307 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009308 if(!pSession)
9309 {
9310 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9311 return;
9312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9314 if(pSession->pConnectBssDesc)
9315 {
9316 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9317 }
9318 }
9319 break;
9320
9321 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009322 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009323 {
9324 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9325 sessionId = pDeauthRsp->sessionId;
9326 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9327 {
9328 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009329 if(!pSession)
9330 {
9331 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9332 return;
9333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9335 {
9336 pRoamInfo = &roamInfo;
9337 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309338 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9339 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9341 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9342 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9343 }
9344 }
9345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009346 break;
9347
9348 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009349 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009350 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 {
9352 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9353 sessionId = pDisassocRsp->sessionId;
9354 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9355 {
9356 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009357 if(!pSession)
9358 {
9359 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9360 return;
9361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9363 {
9364 pRoamInfo = &roamInfo;
9365 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309366 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9367 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9369 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9370 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9371 }
9372 }
9373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 case eWNI_SME_MIC_FAILURE_IND:
9376 {
9377 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9378 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9379 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009380
9381 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9382 if( HAL_STATUS_SUCCESS( status ) )
9383 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309384 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009385 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9386 pRoamInfo = &roamInfo;
9387 if(pMicInd->info.multicast)
9388 {
9389 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9390 }
9391 else
9392 {
9393 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9394 }
9395 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9396 }
9397
Jeff Johnson295189b2012-06-20 16:38:30 -07009398#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9399 {
lukez3c809222013-05-03 10:23:02 -07009400 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009401 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009402 if(!pSession)
9403 {
9404 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9405 return;
9406 }
lukez3c809222013-05-03 10:23:02 -07009407
Kiet Lam64c1b492013-07-12 13:56:44 +05309408 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9410 secEvent.encryptionModeMulticast =
9411 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9412 secEvent.encryptionModeUnicast =
9413 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9414 secEvent.authMode =
9415 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309416 vos_mem_copy(secEvent.bssid,
9417 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9419 }
9420#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 }
9422 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9424 {
9425 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9426 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009427 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009428
9429 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9430 if( HAL_STATUS_SUCCESS( status ) )
9431 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309432 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9434 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9435 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9436 }
9437 }
9438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9441 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9442 switch( pStatusChangeMsg->statusChangeCode )
9443 {
9444 case eSIR_SME_IBSS_ACTIVE:
9445 sessionId = csrFindIbssSession( pMac );
9446 if( CSR_SESSION_ID_INVALID != sessionId )
9447 {
9448 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009449 if(!pSession)
9450 {
9451 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9452 return;
9453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9455 if(pSession->pConnectBssDesc)
9456 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309457 vos_mem_copy(&roamInfo.bssid,
9458 pSession->pConnectBssDesc->bssId,
9459 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9461 pRoamInfo = &roamInfo;
9462 }
9463 else
9464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009465 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 }
9467 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9468 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9469 }
9470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009471 case eSIR_SME_IBSS_INACTIVE:
9472 sessionId = csrFindIbssSession( pMac );
9473 if( CSR_SESSION_ID_INVALID != sessionId )
9474 {
9475 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009476 if(!pSession)
9477 {
9478 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9479 return;
9480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9482 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9483 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9484 }
9485 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9487 sessionId = csrFindIbssSession( pMac );
9488 if( CSR_SESSION_ID_INVALID != sessionId )
9489 {
9490 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009491 if(!pSession)
9492 {
9493 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9494 return;
9495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 // update the connection state information
9497 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009498#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9499 {
9500 vos_log_ibss_pkt_type *pIbssLog;
9501 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9503 if(pIbssLog)
9504 {
9505 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9506 if(pNewBss)
9507 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309508 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 if(pNewBss->ssId.length)
9510 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309511 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9512 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 }
9514 pIbssLog->operatingChannel = pNewBss->channelNumber;
9515 }
9516 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9517 {
9518 //***U8 is not enough for beacon interval
9519 pIbssLog->beaconInterval = (v_U8_t)bi;
9520 }
9521 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9522 }
9523 }
9524#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009526
9527 if ((eCSR_ENCRYPT_TYPE_NONE ==
9528 pSession->connectedProfile.EncryptionType ))
9529 {
9530 csrRoamIssueSetContextReq( pMac, sessionId,
9531 pSession->connectedProfile.EncryptionType,
9532 pSession->pConnectBssDesc,
9533 &Broadcastaddr,
9534 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9537 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309538 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9539 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 pRoamInfo = &roamInfo;
9541 //This BSSID is th ereal BSSID, let's save it
9542 if(pSession->pConnectBssDesc)
9543 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309544 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9545 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009548 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 // detection by LIM that the capabilities of the associated AP have changed.
9551 case eSIR_SME_AP_CAPS_CHANGED:
9552 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009553 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9555 if( HAL_STATUS_SUCCESS( status ) )
9556 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009557 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9558 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309559 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009560 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9561 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9562 )
9563 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309564 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9565 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009566 }
9567 else
9568 {
9569 smsLog(pMac, LOGW,
9570 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009571 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009572 pMac->roam.curState[sessionId],
9573 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309574 /* We ignore the caps change event if CSR is not in full connected state.
9575 * Send one event to PE to reset limSentCapsChangeNtf
9576 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9577 * otherwise lim cannot send any CAPS change events to SME */
9578 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 }
9581 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309582
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 default:
9584 roamStatus = eCSR_ROAM_FAILED;
9585 result = eCSR_ROAM_RESULT_NONE;
9586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 } // end switch on statusChangeCode
9588 if(eCSR_ROAM_RESULT_NONE != result)
9589 {
9590 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9591 }
9592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 case eWNI_SME_IBSS_NEW_PEER_IND:
9594 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009595#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9596 {
9597 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9599 if(pIbssLog)
9600 {
9601 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309602 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9604 }
9605 }
9606#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 sessionId = csrFindIbssSession( pMac );
9608 if( CSR_SESSION_ID_INVALID != sessionId )
9609 {
9610 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009611
9612 if(!pSession)
9613 {
9614 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9615 return;
9616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9618 if(pSession->pConnectBssDesc)
9619 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309620 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9621 sizeof(tCsrBssid));
9622 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9623 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9625 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309626 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9627 - sizeof(tSmeIbssPeerInd)));
9628 if ( NULL == roamInfo.pbFrames )
9629 status = eHAL_STATUS_FAILURE;
9630 else
9631 status = eHAL_STATUS_SUCCESS;
9632 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 {
9634 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309635 vos_mem_copy(roamInfo.pbFrames,
9636 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9637 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 }
9639 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9640 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9641 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309642 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9643 if ( NULL == roamInfo.pBssDesc )
9644 status = eHAL_STATUS_FAILURE;
9645 else
9646 status = eHAL_STATUS_SUCCESS;
9647 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309649 vos_mem_copy(roamInfo.pBssDesc,
9650 pSession->pConnectBssDesc,
9651 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 }
9653 if(HAL_STATUS_SUCCESS(status))
9654 {
9655 pRoamInfo = &roamInfo;
9656 }
9657 else
9658 {
9659 if(roamInfo.pbFrames)
9660 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309661 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 }
9663 if(roamInfo.pBssDesc)
9664 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309665 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 }
9667 }
9668 }
9669 else
9670 {
9671 pRoamInfo = &roamInfo;
9672 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009673 if ((eCSR_ENCRYPT_TYPE_NONE ==
9674 pSession->connectedProfile.EncryptionType ))
9675 {
9676 csrRoamIssueSetContextReq( pMac, sessionId,
9677 pSession->connectedProfile.EncryptionType,
9678 pSession->pConnectBssDesc,
9679 &(pIbssPeerInd->peerAddr),
9680 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 }
9683 else
9684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009685 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 }
9687 //send up the sec type for the new peer
9688 if (pRoamInfo)
9689 {
9690 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9691 }
9692 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9693 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9694 if(pRoamInfo)
9695 {
9696 if(roamInfo.pbFrames)
9697 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309698 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 }
9700 if(roamInfo.pBssDesc)
9701 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309702 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 }
9704 }
9705 }
9706 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9708 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9709 sessionId = csrFindIbssSession( pMac );
9710 if( CSR_SESSION_ID_INVALID != sessionId )
9711 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009712#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9713 {
9714 vos_log_ibss_pkt_type *pIbssLog;
9715
9716 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9717 if(pIbssLog)
9718 {
9719 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9720 if(pIbssPeerInd)
9721 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309722 vos_mem_copy(pIbssLog->peerMacAddr,
9723 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 }
9725 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9726 }
9727 }
9728#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009729 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9731 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9732 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309733 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9734 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9736 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9737 }
9738 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 case eWNI_SME_SETCONTEXT_RSP:
9740 {
9741 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9742 tListElem *pEntry;
9743 tSmeCmd *pCommand;
9744
9745 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9746 if ( pEntry )
9747 {
9748 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9749 if ( eSmeCommandSetKey == pCommand->command )
9750 {
9751 sessionId = pCommand->sessionId;
9752 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009753
9754 if(!pSession)
9755 {
9756 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9757 return;
9758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009759
9760#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9761 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9762 {
9763 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309764 vos_mem_set(&setKeyEvent,
9765 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009766 if( pRsp->peerMacAddr[0] & 0x01 )
9767 {
9768 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9769 }
9770 else
9771 {
9772 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9773 }
9774 setKeyEvent.encryptionModeMulticast =
9775 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9776 setKeyEvent.encryptionModeUnicast =
9777 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309778 vos_mem_copy(setKeyEvent.bssid,
9779 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 setKeyEvent.authMode =
9781 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009782 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 {
9784 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9785 }
9786 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9787 }
9788#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9789 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9790 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009791 csrRoamStopWaitForKeyTimer( pMac );
9792
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 //We are done with authentication, whethere succeed or not
9794 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 //We do it here because this linkup function is not called after association
9796 //when a key needs to be set.
9797 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9798 {
9799 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9800 }
9801 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009802 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309804 vos_mem_copy(&roamInfo.peerMac,
9805 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009806 //Make sure we install the GTK before indicating to HDD as authenticated
9807 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309808 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9809 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009810 {
Yathish9f22e662012-12-10 14:21:35 -08009811#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9812 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9813 {
9814 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309815 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009816 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9817 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9818 pMsg->seesionId = sessionId;
9819 status = palSendMBMessage(pMac->hHdd, pMsg );
9820 }
9821#endif
9822 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009823 }
9824 else
9825 {
9826 result = eCSR_ROAM_RESULT_NONE;
9827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 pRoamInfo = &roamInfo;
9829 }
9830 else
9831 {
9832 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009833 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9834 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9835 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 }
9837 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9838 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9840 // can go ahead and initiate the TSPEC if any are pending
9841 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009842#ifdef FEATURE_WLAN_CCX
9843 //Send Adjacent AP repot to new AP.
9844 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9845 pSession->isPrevApInfoValid &&
9846 pSession->connectedProfile.isCCXAssoc)
9847 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009848#ifdef FEATURE_WLAN_CCX_UPLOAD
9849 csrSendCcxAdjacentApRepInd(pMac, pSession);
9850#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9852#endif
9853 pSession->isPrevApInfoValid = FALSE;
9854 }
9855#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009856 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9857 {
9858 csrReleaseCommandSetKey( pMac, pCommand );
9859 }
9860 }
9861 else
9862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009863 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009864 }
9865 }
9866 else
9867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009868 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 smeProcessPendingQueue( pMac );
9871 }
9872 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009873 case eWNI_SME_REMOVEKEY_RSP:
9874 {
9875 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9876 tListElem *pEntry;
9877 tSmeCmd *pCommand;
9878
9879 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9880 if ( pEntry )
9881 {
9882 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9883 if ( eSmeCommandRemoveKey == pCommand->command )
9884 {
9885 sessionId = pCommand->sessionId;
9886 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009887
9888 if(!pSession)
9889 {
9890 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9891 return;
9892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009893#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9894 {
9895 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309896 vos_mem_set(&removeKeyEvent,
9897 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009898 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9899 removeKeyEvent.encryptionModeMulticast =
9900 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9901 removeKeyEvent.encryptionModeUnicast =
9902 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309903 vos_mem_copy( removeKeyEvent.bssid,
9904 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 removeKeyEvent.authMode =
9906 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009907 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 {
9909 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9910 }
9911 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9912 }
9913#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009914 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309916 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9917 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 result = eCSR_ROAM_RESULT_NONE;
9919 pRoamInfo = &roamInfo;
9920 }
9921 else
9922 {
9923 result = eCSR_ROAM_RESULT_FAILURE;
9924 }
9925 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9926 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9927 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9928 {
9929 csrReleaseCommandRemoveKey( pMac, pCommand );
9930 }
9931 }
9932 else
9933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009934 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009935 }
9936 }
9937 else
9938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009939 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 smeProcessPendingQueue( pMac );
9942 }
9943 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009945 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 csrRoamStatsRspProcessor( pMac, pSirMsg );
9947 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009948#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9949 case eWNI_SME_GET_ROAM_RSSI_RSP:
9950 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9951 csrRoamRssiRspProcessor( pMac, pSirMsg );
9952 break;
9953#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009954#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9955 case eWNI_SME_GET_TSM_STATS_RSP:
9956 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
9957 csrTsmStatsRspProcessor( pMac, pSirMsg );
9958 break;
9959#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009960 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009961 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 csrUpdateRssi( pMac, pSirMsg );
9963 break;
9964
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309965 case eWNI_SME_GET_SNR_REQ:
9966 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9967 csrUpdateSnr(pMac, pSirMsg);
9968 break;
9969
Jeff Johnson295189b2012-06-20 16:38:30 -07009970#ifdef WLAN_FEATURE_VOWIFI_11R
9971 case eWNI_SME_FT_PRE_AUTH_RSP:
9972 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9973 break;
9974#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009975 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9976 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009977 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 -07009978 sessionId = pSmeMaxAssocInd->sessionId;
9979 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309980 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
9981 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9983 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9984 break;
9985
9986 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009987 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 btampEstablishLogLinkHdlr( pSirMsg );
9989 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009990 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009991 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009992 csrRoamRssiIndHdlr( pMac, pSirMsg );
9993 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009994#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9995 case eWNI_SME_CANDIDATE_FOUND_IND:
9996 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9997 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9998 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009999 case eWNI_SME_HANDOFF_REQ:
10000 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10001 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10002 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010003#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010004
10005 default:
10006 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010008}
10009
Jeff Johnson295189b2012-06-20 16:38:30 -070010010void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10011 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10012{
10013 if(pSession)
10014 {
10015 if(pSession->bRefAssocStartCnt)
10016 {
10017 pSession->bRefAssocStartCnt--;
10018 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10019 //Need to call association_completion because there is an assoc_start pending.
10020 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10021 eCSR_ROAM_ASSOCIATION_COMPLETION,
10022 eCSR_ROAM_RESULT_FAILURE);
10023 }
10024 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10025 }
10026 else
10027 {
10028 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10029 }
10030}
10031
10032
10033eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10034{
10035 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10037 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10038 {
10039 status = csrScanRequestLostLink1( pMac, sessionId );
10040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 return(status);
10042}
10043
Jeff Johnson295189b2012-06-20 16:38:30 -070010044//return a boolean to indicate whether roaming completed or continue.
10045tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10046 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10047{
10048 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10049 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10050 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10051 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010052 if(!pSession)
10053 {
10054 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10055 return eANI_BOOLEAN_FALSE;
10056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 //Check whether time is up
10058 if(pSession->fCancelRoaming || fForce ||
10059 ((curTime - pSession->roamingStartTime) > roamTime) ||
10060 eCsrReassocRoaming == pSession->roamingReason ||
10061 eCsrDynamicRoaming == pSession->roamingReason)
10062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010063 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10065 {
10066 //roaming is cancelled, tell HDD to indicate disconnect
10067 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10068 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10069 //to be eSIR_BEACON_MISSED
10070 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10071 {
10072 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10073 }
10074 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10075 {
10076 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10077 }
10078 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10079 {
10080 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10081 }
10082 else
10083 {
10084 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10085 }
10086 }
10087 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10088 pSession->roamingReason = eCsrNotRoaming;
10089 }
10090 else
10091 {
10092 pSession->roamResult = roamResult;
10093 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10094 {
10095 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10096 pSession->roamingReason = eCsrNotRoaming;
10097 }
10098 else
10099 {
10100 fCompleted = eANI_BOOLEAN_FALSE;
10101 }
10102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 return(fCompleted);
10104}
10105
Jeff Johnson295189b2012-06-20 16:38:30 -070010106void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10107{
10108 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010109
10110 if(!pSession)
10111 {
10112 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10113 return;
10114 }
10115
Jeff Johnson295189b2012-06-20 16:38:30 -070010116 if(CSR_IS_ROAMING(pSession))
10117 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010118 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10120 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10121 {
10122 //No need to do anything in here because the handler takes care of it
10123 }
10124 else
10125 {
10126 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10127 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10128 //Roaming is stopped after here
10129 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10130 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010131 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 csrRoamStopRoamingTimer(pMac, sessionId);
10133 }
10134 }
10135}
10136
Jeff Johnson295189b2012-06-20 16:38:30 -070010137void csrRoamRoamingTimerHandler(void *pv)
10138{
10139 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10140 tpAniSirGlobal pMac = pInfo->pMac;
10141 tANI_U32 sessionId = pInfo->sessionId;
10142 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010143
10144 if(!pSession)
10145 {
10146 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10147 return;
10148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010149
10150 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10151 {
10152 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10153 {
10154 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10155 pSession->roamingReason = eCsrNotRoaming;
10156 }
10157 }
10158}
10159
Jeff Johnson295189b2012-06-20 16:38:30 -070010160eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10161{
10162 eHalStatus status;
10163 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010164
10165 if(!pSession)
10166 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010167 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010168 return eHAL_STATUS_FAILURE;
10169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010170
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010171 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010172 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010173 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010174
10175 return (status);
10176}
10177
Jeff Johnson295189b2012-06-20 16:38:30 -070010178eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10179{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010180 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010181}
10182
Jeff Johnson295189b2012-06-20 16:38:30 -070010183void csrRoamWaitForKeyTimeOutHandler(void *pv)
10184{
10185 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10186 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
10188
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010189 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010190 pMac->roam.neighborRoamInfo.neighborRoamState,
10191 pMac->roam.curSubState[pInfo->sessionId]);
10192
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10194 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010195#ifdef FEATURE_WLAN_LFR
10196 if (csrNeighborRoamIsHandoffInProgress(pMac))
10197 {
10198 /*
10199 * Enable heartbeat timer when hand-off is in progress
10200 * and Key Wait timer expired.
10201 */
10202 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010203 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010204 pMac->roam.configParam.HeartbeatThresh24);
10205 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10206 pMac->roam.configParam.HeartbeatThresh24,
10207 NULL, eANI_BOOLEAN_FALSE);
10208 }
10209#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010210 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010211
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010213 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10214 {
10215 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10216 pInfo->sessionId);
10217 }
10218
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010219 if (pSession)
10220 {
10221 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10222 {
10223 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10224 smeProcessPendingQueue(pMac);
10225 }
10226 else
10227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010228 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010229 __func__);
10230 }
10231 }
10232 else
10233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010234 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010236 }
10237
10238}
10239
Jeff Johnson295189b2012-06-20 16:38:30 -070010240eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10241{
10242 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010243#ifdef FEATURE_WLAN_LFR
10244 if (csrNeighborRoamIsHandoffInProgress(pMac))
10245 {
10246 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010247 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010248 __func__,
10249 pMac->roam.neighborRoamInfo.neighborRoamState,
10250 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10251 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10252 }
10253#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010254 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010255 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010256
10257 return (status);
10258}
10259
Jeff Johnson295189b2012-06-20 16:38:30 -070010260eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10261{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010262 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010263 pMac->roam.neighborRoamInfo.neighborRoamState,
10264 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10265#ifdef FEATURE_WLAN_LFR
10266 if (csrNeighborRoamIsHandoffInProgress(pMac))
10267 {
10268 /*
10269 * Enable heartbeat timer when hand-off is in progress
10270 * and Key Wait timer got stopped for some reason
10271 */
10272 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010273 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010274 pMac->roam.configParam.HeartbeatThresh24);
10275 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10276 pMac->roam.configParam.HeartbeatThresh24,
10277 NULL, eANI_BOOLEAN_FALSE);
10278 }
10279#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010280 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010281}
10282
Jeff Johnson295189b2012-06-20 16:38:30 -070010283void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10284 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10285{
10286 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10287 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10289 /* To silence the KW tool Null chaeck is added */
10290 if(!pSession)
10291 {
10292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10293 return;
10294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010295
10296 if(pCommand)
10297 {
10298 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010299 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010301 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10302 {
10303 //if success, force roaming completion
10304 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10305 }
10306 else
10307 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010308 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010309 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010310 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10311 }
10312}
10313
Jeff Johnson295189b2012-06-20 16:38:30 -070010314eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10315{
10316 eHalStatus status = eHAL_STATUS_SUCCESS;
10317 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10318 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10319 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10320 tCsrRoamInfo *pRoamInfo = NULL;
10321 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010322 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010324 /* To silence the KW tool Null chaeck is added */
10325 if(!pSession)
10326 {
10327 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10328 return eHAL_STATUS_FAILURE;
10329 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010331 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10333 if ( eWNI_SME_DISASSOC_IND == type )
10334 {
10335 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10336 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10337 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010338 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 }
10340 else if ( eWNI_SME_DEAUTH_IND == type )
10341 {
10342 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10343 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10344 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010345 /* Convert into proper reason code */
10346 pSession->joinFailStatusCode.reasonCode =
10347 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010348 0 : pDeauthIndMsg->reasonCode;
10349 /* cfg layer expects 0 as reason code if
10350 the driver dosent know the reason code
10351 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 }
10353 else
10354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010355 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010357 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 }
10359
10360 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 {
10363 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10364 }
10365
10366 if ( eWNI_SME_DISASSOC_IND == type )
10367 {
10368 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10369 }
10370 else if ( eWNI_SME_DEAUTH_IND == type )
10371 {
10372 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010374 if(!HAL_STATUS_SUCCESS(status))
10375 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010376 //If fail to send confirmation to PE, not to trigger roaming
10377 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010378 }
10379
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010380 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010381 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010382 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10383 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 if( eWNI_SME_DISASSOC_IND == type)
10385 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010386 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010387 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10388 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010389 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 else if( eWNI_SME_DEAUTH_IND == type )
10392 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010393 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010394 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10395 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010396 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10397 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010398 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010399
10400 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10401 that we are roaming. But if we cannot possibly roam, or if we are unable to
10402 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 if(fToRoam)
10404 {
10405 //Only remove the connected BSS in infrastructure mode
10406 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10407 //Not to do anying for lostlink with WDS
10408 if( pMac->roam.configParam.nRoamingTime )
10409 {
10410 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10411 ( eWNI_SME_DEAUTH_IND == type ) ?
10412 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10413 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010414 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 //For IBSS, we need to give some more info to HDD
10416 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10417 {
10418 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10419 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10420 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10421 }
10422 else
10423 {
10424 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10425 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010426 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10428 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10429 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10430 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10431 }
10432 else
10433 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010434 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010435 fToRoam = eANI_BOOLEAN_FALSE;
10436 }
10437 }
10438 else
10439 {
10440 //We are told not to roam, indicate lostlink
10441 fToRoam = eANI_BOOLEAN_FALSE;
10442 }
10443 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010444 if(!fToRoam)
10445 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010446 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010447 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010448 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010449 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10450 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10451 * csrRoamCheckForLinkStatusChange API.
10452 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010453 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10454 }
10455
10456 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 Still enable idle scan for polling in case concurrent sessions are running */
10458 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10459 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010460 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 }
10462 }
10463
10464 return (status);
10465}
10466
Jeff Johnson295189b2012-06-20 16:38:30 -070010467eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10468{
10469 eHalStatus status = eHAL_STATUS_SUCCESS;
10470 tListElem *pEntry = NULL;
10471 tSmeCmd *pCommand = NULL;
10472 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010473
10474 if(!pSession)
10475 {
10476 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10477 return eHAL_STATUS_FAILURE;
10478 }
10479
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 //Only remove the connected BSS in infrastructure mode
10482 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10483 if(pMac->roam.configParam.nRoamingTime)
10484 {
10485 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10486 {
10487 //before starting the lost link logic release the roam command for handoff
10488 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10489 if(pEntry)
10490 {
10491 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10492 }
10493 if(pCommand)
10494 {
10495 if (( eSmeCommandRoam == pCommand->command ) &&
10496 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10497 {
10498 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10499 {
10500 csrReleaseCommandRoam( pMac, pCommand );
10501 }
10502 }
10503 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010504 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010505 }
10506 }
10507 else
10508 {
10509 //We are told not to roam, indicate lostlink
10510 status = eHAL_STATUS_FAILURE;
10511 }
10512
10513 return (status);
10514}
Jeff Johnson295189b2012-06-20 16:38:30 -070010515void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10516{
10517 tListElem *pEntry;
10518 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10520 if ( pEntry )
10521 {
10522 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10523 if ( eSmeCommandWmStatusChange == pCommand->command )
10524 {
10525 // Nothing to process in a Lost Link completion.... It just kicks off a
10526 // roaming sequence.
10527 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10528 {
10529 csrReleaseCommandWmStatusChange( pMac, pCommand );
10530 }
10531 else
10532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010533 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010534 }
10535
10536 }
10537 else
10538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010539 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 }
10541 }
10542 else
10543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010544 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 smeProcessPendingQueue( pMac );
10547}
10548
Jeff Johnson295189b2012-06-20 16:38:30 -070010549void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10550{
10551 eHalStatus status = eHAL_STATUS_FAILURE;
10552 tSirSmeRsp *pSirSmeMsg;
10553 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010554
10555 if(!pSession)
10556 {
10557 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10558 return;
10559 }
10560
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 switch ( pCommand->u.wmStatusChangeCmd.Type )
10562 {
10563 case eCsrDisassociated:
10564 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10565 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10566 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 case eCsrDeauthenticated:
10568 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10569 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10570 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010572 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 break;
10574 }
10575 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10576 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10577 {
10578 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10579 {
10580 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010581 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 }
10583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10585 // command here since there is nothing else to do.
10586 csrRoamWmStatusChangeComplete( pMac );
10587}
10588
Jeff Johnson295189b2012-06-20 16:38:30 -070010589//This function returns band and mode information.
10590//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10591//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010592static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10593 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010594{
Jeff Johnson295189b2012-06-20 16:38:30 -070010595 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10596 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10597 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010599
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 //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 -070010601 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10602 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10603 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10604 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 {
10606 switch( pMac->roam.configParam.uCfgDot11Mode )
10607 {
10608 case eCSR_CFG_DOT11_MODE_11A:
10609 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10610 eBand = eCSR_BAND_5G;
10611 break;
10612 case eCSR_CFG_DOT11_MODE_11B:
10613 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10614 eBand = eCSR_BAND_24;
10615 break;
10616 case eCSR_CFG_DOT11_MODE_11G:
10617 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10618 eBand = eCSR_BAND_24;
10619 break;
10620 case eCSR_CFG_DOT11_MODE_11N:
10621 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010622 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10623 break;
10624#ifdef WLAN_FEATURE_11AC
10625 case eCSR_CFG_DOT11_MODE_11AC:
10626 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10627 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010628 /* If the operating channel is in 2.4 GHz band, check for
10629 * INI item to disable VHT operation in 2.4 GHz band
10630 */
10631 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10632 !pMac->roam.configParam.enableVhtFor24GHz)
10633 {
10634 /* Disable 11AC operation */
10635 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10636 }
10637 else
10638 {
10639 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10640 }
10641 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010642 }
10643 else
10644 {
10645 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10646 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10647 }
10648 break;
10649 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10650 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10651 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010652 /* If the operating channel is in 2.4 GHz band, check for
10653 * INI item to disable VHT operation in 2.4 GHz band
10654 */
10655 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10656 !pMac->roam.configParam.enableVhtFor24GHz)
10657 {
10658 /* Disable 11AC operation */
10659 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10660 }
10661 else
10662 {
10663 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10664 }
10665 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010666 }
10667 else
10668 {
10669 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10670 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10671 }
10672 break;
10673#endif
10674 case eCSR_CFG_DOT11_MODE_AUTO:
10675 eBand = pMac->roam.configParam.eBand;
10676 if (eCSR_BAND_24 == eBand)
10677 {
10678 // WiFi tests require IBSS networks to start in 11b mode
10679 // without any change to the default parameter settings
10680 // on the adapter. We use ACU to start an IBSS through
10681 // creation of a startIBSS profile. This startIBSS profile
10682 // has Auto MACProtocol and the adapter property setting
10683 // for dot11Mode is also AUTO. So in this case, let's
10684 // start the IBSS network in 11b mode instead of 11g mode.
10685 // So this is for Auto=profile->MacProtocol && Auto=Global.
10686 // dot11Mode && profile->channel is < 14, then start the IBSS
10687 // in b mode.
10688 //
10689 // Note: we used to have this start as an 11g IBSS for best
10690 // performance... now to specify that the user will have to
10691 // set the do11Mode in the property page to 11g to force it.
10692 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10693 }
10694 else
10695 {
10696#ifdef WLAN_FEATURE_11AC
10697 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10698 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010699 /* If the operating channel is in 2.4 GHz band, check for
10700 * INI item to disable VHT operation in 2.4 GHz band
10701 */
10702 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10703 !pMac->roam.configParam.enableVhtFor24GHz)
10704 {
10705 /* Disable 11AC operation */
10706 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10707 }
10708 else
10709 {
10710 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10711 }
10712 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010713 }
10714 else
10715 {
10716 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10717 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10718 }
10719#else
10720 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10721 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10722#endif
10723 }
10724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 default:
10726 // Global dot11 Mode setting is 11a/b/g.
10727 // use the channel number to determine the Mode setting.
10728 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10729 {
10730 eBand = pMac->roam.configParam.eBand;
10731 if(eCSR_BAND_24 == eBand)
10732 {
10733 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10734 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10735 }
10736 else
10737 {
10738 //prefer 5GHz
10739 eBand = eCSR_BAND_5G;
10740 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10741 }
10742 }
10743 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10744 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010745 // WiFi tests require IBSS networks to start in 11b mode
10746 // without any change to the default parameter settings
10747 // on the adapter. We use ACU to start an IBSS through
10748 // creation of a startIBSS profile. This startIBSS profile
10749 // has Auto MACProtocol and the adapter property setting
10750 // for dot11Mode is also AUTO. So in this case, let's
10751 // start the IBSS network in 11b mode instead of 11g mode.
10752 // So this is for Auto=profile->MacProtocol && Auto=Global.
10753 // dot11Mode && profile->channel is < 14, then start the IBSS
10754 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010756 // Note: we used to have this start as an 11g IBSS for best
10757 // performance... now to specify that the user will have to
10758 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10760 eBand = eCSR_BAND_24;
10761 }
10762 else
10763 {
10764 // else, it's a 5.0GHz channel. Set mode to 11a.
10765 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10766 eBand = eCSR_BAND_5G;
10767 }
10768 break;
10769 }//switch
10770 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10771 else
10772 {
10773 //dot11 mode is set, lets pick the band
10774 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10775 {
10776 // channel is Auto also.
10777 eBand = pMac->roam.configParam.eBand;
10778 if(eCSR_BAND_ALL == eBand)
10779 {
10780 //prefer 5GHz
10781 eBand = eCSR_BAND_5G;
10782 }
10783 }
10784 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10785 {
10786 eBand = eCSR_BAND_24;
10787 }
10788 else
10789 {
10790 eBand = eCSR_BAND_5G;
10791 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 if(pBand)
10794 {
10795 *pBand = eBand;
10796 }
10797
10798 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010799 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10801 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010802
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010803 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10804 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 -070010805 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010806#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010807 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010808#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010809 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10810 {
10811 //We cannot do 11n here
10812 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10813 {
10814 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10815 }
10816 else
10817 {
10818 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10819 }
10820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 return( cfgDot11Mode );
10822}
10823
Jeff Johnson295189b2012-06-20 16:38:30 -070010824eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10825{
10826 eHalStatus status;
10827 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010828
10829 if(!pSession)
10830 {
10831 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10832 return eHAL_STATUS_FAILURE;
10833 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010834
10835#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10836 {
10837 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10839 if(pIbssLog)
10840 {
10841 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10842 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10843 }
10844 }
10845#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 // Set the roaming substate to 'stop Bss request'...
10847 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10848
10849 // attempt to stop the Bss (reason code is ignored...)
10850 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010851 if(!HAL_STATUS_SUCCESS(status))
10852 {
10853 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 return (status);
10856}
10857
Jeff Johnson295189b2012-06-20 16:38:30 -070010858//pNumChan is a caller allocated space with the sizeof pChannels
10859eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10860{
10861
10862 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10863 (tANI_U8 *)pChannels,
10864 pNumChan));
10865}
10866
Kiran4a17ebe2013-01-31 10:43:43 -080010867tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10868{
10869 tANI_U32 cfgLength = 0;
10870 tANI_U16 cfgId = 0;
10871 tPowerdBm maxTxPwr = 0;
10872 tANI_U8 *pCountryInfo = NULL;
10873 eHalStatus status;
10874 tANI_U8 count = 0;
10875 tANI_U8 firstChannel;
10876 tANI_U8 maxChannels;
10877
10878 if (CSR_IS_CHANNEL_5GHZ(channel))
10879 {
10880 cfgId = WNI_CFG_MAX_TX_POWER_5;
10881 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10882 }
10883 else if (CSR_IS_CHANNEL_24GHZ(channel))
10884 {
10885 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10886 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10887 }
10888 else
10889 return maxTxPwr;
10890
Kiet Lam64c1b492013-07-12 13:56:44 +053010891 pCountryInfo = vos_mem_malloc(cfgLength);
10892 if ( NULL == pCountryInfo )
10893 status = eHAL_STATUS_FAILURE;
10894 else
10895 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010896 if (status != eHAL_STATUS_SUCCESS)
10897 {
10898 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010899 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010900 __FUNCTION__, status);
10901 goto error;
10902 }
10903 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10904 if (status != eHAL_STATUS_SUCCESS)
10905 {
10906 goto error;
10907 }
10908 /* Identify the channel and maxtxpower */
10909 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10910 {
10911 firstChannel = pCountryInfo[count++];
10912 maxChannels = pCountryInfo[count++];
10913 maxTxPwr = pCountryInfo[count++];
10914
10915 if ((channel >= firstChannel) &&
10916 (channel < (firstChannel + maxChannels)))
10917 {
10918 break;
10919 }
10920 }
10921
10922error:
10923 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010924 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010925
10926 return maxTxPwr;
10927}
10928
10929
Jeff Johnson295189b2012-06-20 16:38:30 -070010930tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10931{
10932 tANI_BOOLEAN fValid = FALSE;
10933 tANI_U32 idxValidChannels;
10934 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10935
10936 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10937 {
10938 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10939 {
10940 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10941 {
10942 fValid = TRUE;
10943 break;
10944 }
10945 }
10946 }
10947 pMac->roam.numValidChannels = len;
10948 return fValid;
10949}
10950
Jeff Johnson295189b2012-06-20 16:38:30 -070010951tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10952{
10953 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10954 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10956 {
10957 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10958 {
10959 fValid = eANI_BOOLEAN_TRUE;
10960 break;
10961 }
10962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010963 return (fValid);
10964}
10965
Jeff Johnson295189b2012-06-20 16:38:30 -070010966//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010967 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010968{
Jeff Johnsone7245742012-09-05 17:12:55 -070010969 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010970 tANI_U8 centerChn;
10971 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10973 {
10974 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10975 }
10976 else
10977 {
10978 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10979 }
10980 //Figure what the other side's CB mode
10981 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10982 {
10983 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10984 {
10985 if(pIes->HTInfo.present)
10986 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010987 /* This is called during INFRA STA/CLIENT and should use the merged value of
10988 * supported channel width and recommended tx width as per standard
10989 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010990 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010991 pIes->HTCaps.supportedChannelWidthSet,
10992 pIes->HTInfo.recommendedTxWidthSet,
10993 pIes->HTInfo.secondaryChannelOffset);
10994
10995 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10996 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010997 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010998 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10999 switch (eRet) {
11000 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11001 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11002 break;
11003 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11004 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11005 break;
11006 case PHY_SINGLE_CHANNEL_CENTERED:
11007 default:
11008 centerChn = primaryChn;
11009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011011 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011013 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011014 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011015 }
11016 }
11017 }
11018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 return eRet;
11020}
Jeff Johnson295189b2012-06-20 16:38:30 -070011021tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11022{
11023 tANI_BOOLEAN fFound = FALSE;
11024 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011025 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11026 {
11027 if( pCipherList->encryptionType[idx] == encryptionType )
11028 {
11029 fFound = TRUE;
11030 break;
11031 }
11032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 return fFound;
11034}
Jeff Johnson295189b2012-06-20 16:38:30 -070011035tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11036{
11037 tANI_BOOLEAN fFound = FALSE;
11038 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11040 {
11041 if( pAuthList->authType[idx] == authType )
11042 {
11043 fFound = TRUE;
11044 break;
11045 }
11046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 return fFound;
11048}
Jeff Johnson295189b2012-06-20 16:38:30 -070011049tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11050{
11051 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11052 tCsrScanResultFilter *pScanFilter = NULL;
11053 eHalStatus status = eHAL_STATUS_SUCCESS;
11054
11055 if(pProfile1 && pProfile2)
11056 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011057 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11058 if ( NULL == pScanFilter )
11059 status = eHAL_STATUS_FAILURE;
11060 else
11061 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 if(HAL_STATUS_SUCCESS(status))
11063 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011064 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011065 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11066 if(HAL_STATUS_SUCCESS(status))
11067 {
11068 fCheck = eANI_BOOLEAN_FALSE;
11069 do
11070 {
11071 tANI_U32 i;
11072 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11073 {
11074 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11075 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11076 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11077 if ( fCheck ) break;
11078 }
11079 if(!fCheck)
11080 {
11081 break;
11082 }
11083 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11084 || pProfile2->BSSType != pProfile1->BSSType
11085 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11086 )
11087 {
11088 fCheck = eANI_BOOLEAN_FALSE;
11089 break;
11090 }
11091#ifdef WLAN_FEATURE_VOWIFI_11R
11092 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11093 {
11094 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11095 {
11096 fCheck = eANI_BOOLEAN_FALSE;
11097 break;
11098 }
11099 }
11100#endif
11101 //Match found
11102 fCheck = eANI_BOOLEAN_TRUE;
11103 }while(0);
11104 csrFreeScanFilter(pMac, pScanFilter);
11105 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011106 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 }
11108 }
11109
11110 return (fCheck);
11111}
11112
Jeff Johnson295189b2012-06-20 16:38:30 -070011113tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11114{
11115 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11116 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 do
11118 {
11119 //Only check for static WEP
11120 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11121 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11122 {
11123 fCheck = eANI_BOOLEAN_TRUE;
11124 break;
11125 }
11126 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11127 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11128 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11129 {
11130 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011131 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11132 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 {
11134 break;
11135 }
11136 }
11137 if( i == CSR_MAX_NUM_KEY)
11138 {
11139 fCheck = eANI_BOOLEAN_TRUE;
11140 }
11141 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011142 return (fCheck);
11143}
11144
Jeff Johnson295189b2012-06-20 16:38:30 -070011145//IBSS
11146
Jeff Johnson295189b2012-06-20 16:38:30 -070011147tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11148{
11149 tANI_U8 channel = 0;
11150 tANI_U32 idx;
11151 tANI_U32 idxValidChannels;
11152 tANI_BOOLEAN fFound = FALSE;
11153 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11154
11155 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11156 {
11157 channel = pMac->roam.configParam.AdHocChannel5G;
11158 if(!csrRoamIsChannelValid(pMac, channel))
11159 {
11160 channel = 0;
11161 }
11162 }
11163 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11164 {
11165 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11166 {
11167 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11168 {
11169 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11170 {
11171 fFound = TRUE;
11172 channel = csrStartIbssChannels50[ idx ];
11173 }
11174 }
11175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011176 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11177 if (!fFound)
11178 {
11179 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11180 {
11181 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11182 {
11183 channel = csrStartIbssChannels50[ idx ];
11184 break;
11185 }
11186 }
11187 }
11188 }//if
11189
11190 return( channel );
11191}
11192
Jeff Johnson295189b2012-06-20 16:38:30 -070011193tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11194{
11195 tANI_U8 channel = 1;
11196 tANI_U32 idx;
11197 tANI_U32 idxValidChannels;
11198 tANI_BOOLEAN fFound = FALSE;
11199 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11200
11201 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11202 {
11203 channel = pMac->roam.configParam.AdHocChannel24;
11204 if(!csrRoamIsChannelValid(pMac, channel))
11205 {
11206 channel = 0;
11207 }
11208 }
11209
11210 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11211 {
11212 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11213 {
11214 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11215 {
11216 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11217 {
11218 fFound = TRUE;
11219 channel = csrStartIbssChannels24[ idx ];
11220 }
11221 }
11222 }
11223 }
11224
11225 return( channel );
11226}
11227
Jeff Johnson295189b2012-06-20 16:38:30 -070011228static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11229 tCsrRoamStartBssParams *pParam )
11230{
11231 eCsrCfgDot11Mode cfgDot11Mode;
11232 eCsrBand eBand;
11233 tANI_U8 channel = 0;
11234 tSirNwType nwType;
11235 tANI_U8 operationChannel = 0;
11236
11237 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11238 {
11239 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11240 }
11241
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011243
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11245 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11246 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11247 )
11248 {
11249 /* This should never happen */
11250 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011251 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011252 pProfile->csrPersona);
11253 VOS_ASSERT(0);
11254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011255 switch( cfgDot11Mode )
11256 {
11257 case eCSR_CFG_DOT11_MODE_11G:
11258 nwType = eSIR_11G_NW_TYPE;
11259 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 case eCSR_CFG_DOT11_MODE_11B:
11261 nwType = eSIR_11B_NW_TYPE;
11262 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011263 case eCSR_CFG_DOT11_MODE_11A:
11264 nwType = eSIR_11A_NW_TYPE;
11265 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 default:
11267 case eCSR_CFG_DOT11_MODE_11N:
11268 case eCSR_CFG_DOT11_MODE_TAURUS:
11269 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11270 if(eCSR_BAND_24 == eBand)
11271 {
11272 nwType = eSIR_11G_NW_TYPE;
11273 }
11274 else
11275 {
11276 nwType = eSIR_11A_NW_TYPE;
11277 }
11278 break;
11279 }
11280
11281 pParam->extendedRateSet.numRates = 0;
11282
11283 switch ( nwType )
11284 {
11285 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011286 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 case eSIR_11A_NW_TYPE:
11288
11289 pParam->operationalRateSet.numRates = 8;
11290
11291 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11292 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11293 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11294 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11295 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11296 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11297 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11298 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11299
11300 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11301 {
11302 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11303 if( 0 == channel &&
11304 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11305 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11306 )
11307 {
11308 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11309 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11310 nwType = eSIR_11B_NW_TYPE;
11311 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11312 pParam->operationalRateSet.numRates = 4;
11313 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11314 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11315 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11316 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11317 }
11318 }
11319 else
11320 {
11321 channel = operationChannel;
11322 }
11323 break;
11324
11325 case eSIR_11B_NW_TYPE:
11326 pParam->operationalRateSet.numRates = 4;
11327 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11328 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11329 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11330 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11332 {
11333 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11334 }
11335 else
11336 {
11337 channel = operationChannel;
11338 }
11339
11340 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011341 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 /* For P2P Client and P2P GO, disable 11b rates */
11343 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11344 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11345 )
11346 {
11347 pParam->operationalRateSet.numRates = 8;
11348
11349 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11350 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11351 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11352 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11353 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11354 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11355 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11356 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11357 }
11358 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011359 {
11360 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011361 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11362 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11363 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11364 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11365
11366 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011367 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11368 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11369 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11370 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11371 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11372 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11373 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11374 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11375 }
11376
11377 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11378 {
11379 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11380 }
11381 else
11382 {
11383 channel = operationChannel;
11384 }
11385
11386 break;
11387 }
11388 pParam->operationChn = channel;
11389 pParam->sirNwType = nwType;
11390}
11391
Jeff Johnson295189b2012-06-20 16:38:30 -070011392static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11393 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11394{
11395
11396 if( pParam )
11397 {
11398 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011399 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011401 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011402
11403 if( pIes )
11404 {
11405 if(pIes->SuppRates.present)
11406 {
11407 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11408 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011410 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 -070011411 pIes->SuppRates.num_rates);
11412 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11413 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011414 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11415 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011416 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011417 if (pIes->ExtSuppRates.present)
11418 {
11419 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11420 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11421 {
11422 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11423 SIR_MAC_RATESET_EID_MAX, resetting to \
11424 SIR_MAC_RATESET_EID_MAX"),
11425 pIes->ExtSuppRates.num_rates);
11426 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11427 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011428 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011429 pIes->ExtSuppRates.rates,
11430 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 if( pIes->SSID.present )
11433 {
11434 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011435 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11436 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 }
11438 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 }
11440 else
11441 {
11442 pParam->ssId.length = 0;
11443 pParam->operationalRateSet.numRates = 0;
11444 }
11445 }
11446}
11447
Jeff Johnson295189b2012-06-20 16:38:30 -070011448static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11449{
11450 tANI_U8 MaxRate = 0;
11451 tANI_U32 i;
11452 tANI_U8 *pRate;
11453
11454 pRate = pSirRateSet->rate;
11455 for ( i = 0; i < pSirRateSet->numRates; i++ )
11456 {
11457 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11458 }
11459
11460 // Save the max rate in the connected state information...
11461
11462 // modify LastRates variable as well
11463
11464 return;
11465}
11466
Jeff Johnson295189b2012-06-20 16:38:30 -070011467eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11468 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11469{
11470 eHalStatus status = eHAL_STATUS_SUCCESS;
11471 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 // Set the roaming substate to 'Start BSS attempt'...
11473 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011474#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11475 //Need to figure out whether we need to log WDS???
11476 if( CSR_IS_IBSS( pProfile ) )
11477 {
11478 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11480 if(pIbssLog)
11481 {
11482 if(pBssDesc)
11483 {
11484 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011485 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 }
11487 else
11488 {
11489 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11490 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011491 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 if(pProfile->ChannelInfo.numOfChannels == 0)
11493 {
11494 pIbssLog->channelSetting = AUTO_PICK;
11495 }
11496 else
11497 {
11498 pIbssLog->channelSetting = SPECIFIED;
11499 }
11500 pIbssLog->operatingChannel = pParam->operationChn;
11501 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11502 }
11503 }
11504#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11505 //Put RSN information in for Starting BSS
11506 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11507 pParam->pRSNIE = pProfile->pRSNReqIE;
11508
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 pParam->privacy = pProfile->privacy;
11510 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11511 pParam->authType = pProfile->csr80211AuthType;
11512 pParam->beaconInterval = pProfile->beaconInterval;
11513 pParam->dtimPeriod = pProfile->dtimPeriod;
11514 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11515 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11516 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11517 {
11518 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11519 {
11520 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11521 }
11522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 pParam->protEnabled = pProfile->protEnabled;
11524 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11525 pParam->ht_protection = pProfile->cfg_protection;
11526 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011527
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11529 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 pParam->bssPersona = pProfile->csrPersona;
11531 // When starting an IBSS, start on the channel from the Profile.
11532 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 return (status);
11534}
11535
Jeff Johnson295189b2012-06-20 16:38:30 -070011536static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011537 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011538{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011539 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011540 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011542
11543 if(!pSession)
11544 {
11545 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11546 return;
11547 }
11548
Jeff Johnson295189b2012-06-20 16:38:30 -070011549 if( pBssDesc )
11550 {
11551 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11552 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11553 //The following code has to be do after that.
11554 //For WDS station, use selfMac as the self BSSID
11555 if( CSR_IS_WDS_STA( pProfile ) )
11556 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011557 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11558 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011559 }
11560 }
11561 else
11562 {
11563 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 //Use the first SSID
11565 if(pProfile->SSIDs.numOfSSIDs)
11566 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011567 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11568 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 }
11570 //For WDS station, use selfMac as the self BSSID
11571 if( CSR_IS_WDS_STA( pProfile ) )
11572 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011573 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11574 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 }
11576 //Use the first BSSID
11577 else if( pProfile->BSSIDs.numOfBSSIDs )
11578 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011579 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11580 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 }
11582 else
11583 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011584 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 }
11586 }
11587 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011588 //Set operating channel in pProfile which will be used
11589 //in csrRoamSetBssConfigCfg() to determine channel bonding
11590 //mode and will be configured in CFG later
11591 pProfile->operationChannel = Channel;
11592
11593 if(Channel == 0)
11594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011595 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 }
11597 else
11598 {
11599
11600 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011601 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011602 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011603 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011604 {
11605 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11606 }
11607 else
11608 {
11609 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11610 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011611 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011612 pBssConfig->cbMode = cbMode;
11613 pSession->bssParams.cbMode = cbMode;
11614 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 }
11616}
11617
Jeff Johnson295189b2012-06-20 16:38:30 -070011618static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11619 tANI_BOOLEAN *pfSameIbss )
11620{
11621 eHalStatus status = eHAL_STATUS_SUCCESS;
11622 tANI_BOOLEAN fSameIbss = FALSE;
11623
11624 if ( csrIsConnStateIbss( pMac, sessionId ) )
11625 {
11626 // Check if any profile parameter has changed ? If any profile parameter
11627 // has changed then stop old BSS and start a new one with new parameters
11628 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11629 {
11630 fSameIbss = TRUE;
11631 }
11632 else
11633 {
11634 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11635 }
11636 }
11637 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11638 {
11639 // Disassociate from the connected Infrastructure network...
11640 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11641 }
11642 else
11643 {
11644 tBssConfigParam *pBssConfig;
11645
Kiet Lam64c1b492013-07-12 13:56:44 +053011646 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11647 if ( NULL == pBssConfig )
11648 status = eHAL_STATUS_FAILURE;
11649 else
11650 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 if(HAL_STATUS_SUCCESS(status))
11652 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011653 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 // there is no Bss description before we start an IBSS so we need to adopt
11655 // all Bss configuration parameters from the Profile.
11656 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11657 if(HAL_STATUS_SUCCESS(status))
11658 {
11659 //save dotMode
11660 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11661 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011662 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011663 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11664 NULL, pBssConfig,
11665 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011666 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011667
11668 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 }//Allocate memory
11670 }
11671
11672 if(pfSameIbss)
11673 {
11674 *pfSameIbss = fSameIbss;
11675 }
11676 return( status );
11677}
11678
Jeff Johnson295189b2012-06-20 16:38:30 -070011679static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11680 tSirSmeNewBssInfo *pNewBss )
11681{
11682 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011683
11684 if(!pSession)
11685 {
11686 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11687 return;
11688 }
11689
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 if( pNewBss )
11691 {
11692 // Set the operating channel.
11693 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11694 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011695 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11696 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 return;
11699}
11700
Jeff Johnson295189b2012-06-20 16:38:30 -070011701#ifdef FEATURE_WLAN_WAPI
11702eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11703 tANI_U32 numItems )
11704{
11705 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11706 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11708 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011709 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 return status;
11711 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011712 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 pSession = CSR_GET_SESSION( pMac, sessionId );
11714 if(numItems <= CSR_MAX_BKID_ALLOWED)
11715 {
11716 status = eHAL_STATUS_SUCCESS;
11717 //numItems may be 0 to clear the cache
11718 pSession->NumBkidCache = (tANI_U16)numItems;
11719 if(numItems && pBKIDCache)
11720 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011721 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11722 sizeof(tBkidCacheInfo) * numItems);
11723 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 }
11725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011726 return (status);
11727}
Jeff Johnson295189b2012-06-20 16:38:30 -070011728eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11729 tBkidCacheInfo *pBkidCache)
11730{
11731 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11732 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11734 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011735 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 return status;
11737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 pSession = CSR_GET_SESSION( pMac, sessionId );
11739 if(pNum && pBkidCache)
11740 {
11741 if(pSession->NumBkidCache == 0)
11742 {
11743 *pNum = 0;
11744 status = eHAL_STATUS_SUCCESS;
11745 }
11746 else if(*pNum >= pSession->NumBkidCache)
11747 {
11748 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011750 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 -070011751 pSession->NumBkidCache);
11752 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11753 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011754 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11755 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 *pNum = pSession->NumBkidCache;
11757 status = eHAL_STATUS_SUCCESS;
11758 }
11759 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011761}
Jeff Johnson295189b2012-06-20 16:38:30 -070011762tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11763{
11764 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011765}
11766#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011767eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11768 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11769{
11770 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11771 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011772
11773 if(!pSession)
11774 {
11775 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11776 return eHAL_STATUS_FAILURE;
11777 }
11778
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011779 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11781 {
11782#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11783 {
11784 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011785 vos_mem_set(&secEvent,
11786 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11788 secEvent.encryptionModeMulticast =
11789 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11790 secEvent.encryptionModeUnicast =
11791 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011792 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011793 secEvent.authMode =
11794 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11795 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11796 }
11797#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 status = eHAL_STATUS_SUCCESS;
11799 //numItems may be 0 to clear the cache
11800 pSession->NumPmkidCache = (tANI_U16)numItems;
11801 if(numItems && pPMKIDCache)
11802 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011803 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11804 sizeof(tPmkidCacheInfo) * numItems);
11805 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011806 }
11807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 return (status);
11809}
11810
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011811eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11812 tANI_U8 *pBSSId )
11813{
11814 eHalStatus status = eHAL_STATUS_FAILURE;
11815 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11816 tANI_BOOLEAN fMatchFound = FALSE;
11817 tANI_U32 Index;
11818 if(!pSession)
11819 {
11820 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11821 return eHAL_STATUS_FAILURE;
11822 }
11823 do
11824 {
11825 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11826 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011827 smsLog(pMac, LOGW, "Delete PMKID for "
11828 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053011829 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011830 {
11831 fMatchFound = TRUE;
11832 break;
11833 }
11834 }
11835 if( !fMatchFound ) break;
Kiet Lamf2f201e2013-11-16 21:24:16 +053011836 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011837 status = eHAL_STATUS_SUCCESS;
11838 }
11839 while( 0 );
11840 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11841 fMatchFound, status);
11842 return status;
11843}
Jeff Johnson295189b2012-06-20 16:38:30 -070011844tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11845{
11846 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11847}
11848
Jeff Johnson295189b2012-06-20 16:38:30 -070011849eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11850{
11851 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11852 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011853
11854 if(!pSession)
11855 {
11856 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11857 return eHAL_STATUS_FAILURE;
11858 }
11859
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 if(pNum && pPmkidCache)
11861 {
11862 if(pSession->NumPmkidCache == 0)
11863 {
11864 *pNum = 0;
11865 status = eHAL_STATUS_SUCCESS;
11866 }
11867 else if(*pNum >= pSession->NumPmkidCache)
11868 {
11869 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011871 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 -070011872 pSession->NumPmkidCache);
11873 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11874 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011875 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11876 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011877 *pNum = pSession->NumPmkidCache;
11878 status = eHAL_STATUS_SUCCESS;
11879 }
11880 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011881 return (status);
11882}
11883
Jeff Johnson295189b2012-06-20 16:38:30 -070011884eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11885{
11886 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11887 tANI_U32 len;
11888 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011889
11890 if(!pSession)
11891 {
11892 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11893 return eHAL_STATUS_FAILURE;
11894 }
11895
Jeff Johnson295189b2012-06-20 16:38:30 -070011896 if(pLen)
11897 {
11898 len = *pLen;
11899 *pLen = pSession->nWpaRsnReqIeLength;
11900 if(pBuf)
11901 {
11902 if(len >= pSession->nWpaRsnReqIeLength)
11903 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011904 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11905 pSession->nWpaRsnReqIeLength);
11906 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 }
11908 }
11909 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011910 return (status);
11911}
11912
Jeff Johnson295189b2012-06-20 16:38:30 -070011913eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11914{
11915 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11916 tANI_U32 len;
11917 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011918
11919 if(!pSession)
11920 {
11921 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11922 return eHAL_STATUS_FAILURE;
11923 }
11924
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 if(pLen)
11926 {
11927 len = *pLen;
11928 *pLen = pSession->nWpaRsnRspIeLength;
11929 if(pBuf)
11930 {
11931 if(len >= pSession->nWpaRsnRspIeLength)
11932 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011933 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11934 pSession->nWpaRsnRspIeLength);
11935 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011936 }
11937 }
11938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 return (status);
11940}
Jeff Johnson295189b2012-06-20 16:38:30 -070011941#ifdef FEATURE_WLAN_WAPI
11942eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11943{
11944 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11945 tANI_U32 len;
11946 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011947
11948 if(!pSession)
11949 {
11950 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11951 return eHAL_STATUS_FAILURE;
11952 }
11953
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 if(pLen)
11955 {
11956 len = *pLen;
11957 *pLen = pSession->nWapiReqIeLength;
11958 if(pBuf)
11959 {
11960 if(len >= pSession->nWapiReqIeLength)
11961 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011962 vos_mem_copy(pBuf, pSession->pWapiReqIE,
11963 pSession->nWapiReqIeLength);
11964 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 }
11966 }
11967 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 return (status);
11969}
Jeff Johnson295189b2012-06-20 16:38:30 -070011970eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11971{
11972 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11973 tANI_U32 len;
11974 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011975
11976 if(!pSession)
11977 {
11978 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11979 return eHAL_STATUS_FAILURE;
11980 }
11981
Jeff Johnson295189b2012-06-20 16:38:30 -070011982 if(pLen)
11983 {
11984 len = *pLen;
11985 *pLen = pSession->nWapiRspIeLength;
11986 if(pBuf)
11987 {
11988 if(len >= pSession->nWapiRspIeLength)
11989 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011990 vos_mem_copy(pBuf, pSession->pWapiRspIE,
11991 pSession->nWapiRspIeLength);
11992 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 }
11994 }
11995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 return (status);
11997}
11998#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011999eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12000{
12001 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12002 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012003
12004 if(!pSession)
12005 {
12006 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12007 return (retStatus);
12008 }
12009
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 if(CSR_IS_ROAMING(pSession))
12011 {
12012 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12013 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12014 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 return (retStatus);
12016}
12017
Jeff Johnson295189b2012-06-20 16:38:30 -070012018//This function remove the connected BSS from te cached scan result
12019eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12020 tCsrRoamConnectedProfile *pConnProfile)
12021{
12022 eHalStatus status = eHAL_STATUS_FAILURE;
12023 tCsrScanResultFilter *pScanFilter = NULL;
12024 tListElem *pEntry;
12025 tCsrScanResult *pResult;
12026 tDot11fBeaconIEs *pIes;
12027 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12029 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12030 {
12031 do
12032 {
12033 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012034 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12035 if ( NULL == pScanFilter )
12036 status = eHAL_STATUS_FAILURE;
12037 else
12038 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012040 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12041 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12042 if ( NULL == pScanFilter->BSSIDs.bssid )
12043 status = eHAL_STATUS_FAILURE;
12044 else
12045 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012047 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12048 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12050 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12051 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012052 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12053 if ( NULL == pScanFilter->SSIDs.SSIDList )
12054 status = eHAL_STATUS_FAILURE;
12055 else
12056 status = eHAL_STATUS_SUCCESS;
12057 if (!HAL_STATUS_SUCCESS(status)) break;
12058 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12059 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 }
12061 pScanFilter->authType.numEntries = 1;
12062 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12063 pScanFilter->BSSType = pConnProfile->BSSType;
12064 pScanFilter->EncryptionType.numEntries = 1;
12065 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12066 pScanFilter->mcEncryptionType.numEntries = 1;
12067 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12068 //We ignore the channel for now, BSSID should be enough
12069 pScanFilter->ChannelInfo.numOfChannels = 0;
12070 //Also ignore the following fields
12071 pScanFilter->uapsd_mask = 0;
12072 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12073 pScanFilter->countryCode[0] = 0;
12074 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 csrLLLock(&pMac->scan.scanResultList);
12076 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12077 while( pEntry )
12078 {
12079 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12080 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12081 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12082 pScanFilter, NULL, NULL, NULL, &pIes);
12083 //Release the IEs allocated by csrMatchBSS is needed
12084 if( !pResult->Result.pvIes )
12085 {
12086 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012087 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 }
12089 if(fMatch)
12090 {
12091 //We found the one
12092 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12093 {
12094 //Free the memory
12095 csrFreeScanResultEntry( pMac, pResult );
12096 }
12097 break;
12098 }
12099 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12100 }//while
12101 csrLLUnlock(&pMac->scan.scanResultList);
12102 }while(0);
12103 if(pScanFilter)
12104 {
12105 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012106 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012107 }
12108 }
12109 return (status);
12110}
12111
Jeff Johnson295189b2012-06-20 16:38:30 -070012112//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012113eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12114{
12115 eHalStatus status = eHAL_STATUS_SUCCESS;
12116 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012117 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12118 {
12119 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12120 {
12121 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12122 {
12123 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012124 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012125 status = eHAL_STATUS_CSR_WRONG_STATE;
12126 break;
12127 }
12128 if( csrIsConnStateInfra( pMac, sessionId ) )
12129 {
12130 if( chnId &&
12131 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12132 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012133 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12135 status = eHAL_STATUS_CSR_WRONG_STATE;
12136 break;
12137 }
12138 }
12139 }
12140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012141 return ( status );
12142}
12143
Jeff Johnson295189b2012-06-20 16:38:30 -070012144static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12145{
12146 eHalStatus status = eHAL_STATUS_SUCCESS;
12147 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12148 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012149
12150 if(!pSession)
12151 {
12152 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12153 return eHAL_STATUS_FAILURE;
12154 }
12155
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 if ( csrIsConnStateIbss( pMac, sessionId ) )
12157 {
12158 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12159 }
12160 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12161 {
12162 // Disassociate from the connected Infrastructure network...
12163 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12164 }
12165 else
12166 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12168 //Otherwise we need to add code to handle the
12169 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12170 //send stop_bss to PE, before we can continue.
12171 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012172 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012174 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12175 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 // there is no Bss description before we start an WDS so we need
12177 // to adopt all Bss configuration parameters from the Profile.
12178 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12179 if(HAL_STATUS_SUCCESS(status))
12180 {
12181 //Save profile for late use
12182 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012183 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12184 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012186 vos_mem_set(pSession->pCurRoamProfile,
12187 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12189 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012191 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012192 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12193 NULL, &bssConfig,
12194 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 }
12196 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012197
Jeff Johnson295189b2012-06-20 16:38:30 -070012198 return( status );
12199}
12200
Jeff Johnson295189b2012-06-20 16:38:30 -070012201////////////////////Mail box
12202
Jeff Johnson295189b2012-06-20 16:38:30 -070012203//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12204//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012205static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12206 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12208{
12209 tCsrChannelSet channelGroup;
12210 tSirMacCapabilityInfo *pAP_capabilityInfo;
12211 tAniBool fTmp;
12212 tANI_BOOLEAN found = FALSE;
12213 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012214 tANI_S8 pwrLimit = 0;
12215 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12217 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12218 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12219 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 // 802.11h
12221 //We can do this because it is in HOST CPU order for now.
12222 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012223 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12224 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12225 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 fTmp = (tAniBool)pal_cpu_to_be32(1);
12227 }
12228 else
12229 fTmp = (tAniBool)0;
12230
12231 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012232 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 pBuf += sizeof(tAniBool);
12234 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012235 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012236 // This is required for 11k test VoWiFi Ent: Test 2.
12237 // We need the power capabilities for Assoc Req.
12238 // This macro is provided by the halPhyCfg.h. We pick our
12239 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012240 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12241 if (0 != pwrLimit)
12242 {
12243 *pBuf++ = pwrLimit;
12244 }
12245 else
12246 {
12247 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 size = sizeof(pMac->roam.validChannelList);
12250 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12251 {
12252 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12253 for ( i = 0; i < size; i++)
12254 {
12255 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12256
12257 }
12258 }
12259 else
12260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012261 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012262 *pBuf++ = 0; //tSirSupChnl->numChnl
12263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012264 //Check whether it is ok to enter UAPSD
12265#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12266 if( btcIsReadyForUapsd(pMac) )
12267#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12268 {
12269 *pBuf++ = uapsdMask;
12270 }
12271#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12272 else
12273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012274 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 *pBuf++ = 0;
12276 }
12277#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12278
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012280 vos_mem_copy(pBuf, pBssDescription,
12281 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012282 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12283}
12284
Jeff Johnson295189b2012-06-20 16:38:30 -070012285/*
12286 * The communication between HDD and LIM is thru mailbox (MB).
12287 * Both sides will access the data structure "tSirSmeJoinReq".
12288 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12289 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12290 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12291 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12292 */
12293eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012294 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012295{
12296 eHalStatus status = eHAL_STATUS_SUCCESS;
12297 tSirSmeJoinReq *pMsg;
12298 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012299 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 tANI_U16 msgLen, wTmp, ieLen;
12301 tSirMacRateSet OpRateSet;
12302 tSirMacRateSet ExRateSet;
12303 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12304 tANI_U32 dwTmp;
12305 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012306 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012307
12308 if(!pSession)
12309 {
12310 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12311 return eHAL_STATUS_FAILURE;
12312 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012313 /* To satisfy klockworks */
12314 if (NULL == pBssDescription)
12315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012316 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012317 return eHAL_STATUS_FAILURE;
12318 }
12319
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 do {
12321 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12322 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012323 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12325 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12326 // IE fields, but the length field in the bssDescription needs to be interpreted to
12327 // determine length of the IE fields.
12328 //
12329 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12330 // add in the length from the bssDescription (then add the size of the 'length' field
12331 // itself because that is NOT included in the length field).
12332 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12333 pBssDescription->length + sizeof( pBssDescription->length ) +
12334 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 +053012335 pMsg = vos_mem_malloc(msgLen);
12336 if (NULL == pMsg)
12337 status = eHAL_STATUS_FAILURE;
12338 else
12339 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012341 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012342 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 pMsg->length = pal_cpu_to_be16(msgLen);
12344 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 // sessionId
12346 *pBuf = (tANI_U8)sessionId;
12347 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012348 // transactionId
12349 *pBuf = 0;
12350 *( pBuf + 1 ) = 0;
12351 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 // ssId
12353 if( pIes->SSID.present && pIes->SSID.num_ssid )
12354 {
12355 // ssId len
12356 *pBuf = pIes->SSID.num_ssid;
12357 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012358 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012359 pBuf += pIes->SSID.num_ssid;
12360 }
12361 else
12362 {
12363 *pBuf = 0;
12364 pBuf++;
12365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012367 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12368 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012369 pBuf += sizeof(tSirMacAddr);
12370 // bsstype
12371 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12372 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012373 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 pBuf += sizeof(tSirBssType);
12375 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012376 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12377 if (pBssDescription->channelId <= 14 &&
12378 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12379 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12380 {
12381 //Need to disable VHT operation in 2.4 GHz band
12382 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12383 }
12384 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 //Persona
12387 *pBuf = (tANI_U8)pProfile->csrPersona;
12388 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012389 //CBMode
12390 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12391 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012392
12393 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012394 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12395
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 // uapsdPerAcBitmask
12397 *pBuf = pProfile->uapsd_mask;
12398 pBuf++;
12399
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012400
12401
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012403 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 {
12405 // OperationalRateSet
12406 if (OpRateSet.numRates) {
12407 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012408 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 pBuf += OpRateSet.numRates;
12410 } else *pBuf++ = 0;
12411 // ExtendedRateSet
12412 if (ExRateSet.numRates) {
12413 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012414 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 pBuf += ExRateSet.numRates;
12416 } else *pBuf++ = 0;
12417 }
12418 else
12419 {
12420 *pBuf++ = 0;
12421 *pBuf++ = 0;
12422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 // rsnIE
12424 if ( csrIsProfileWpa( pProfile ) )
12425 {
12426 // Insert the Wpa IE into the join request
12427 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12428 (tCsrWpaIe *)( wpaRsnIE ) );
12429 }
12430 else if( csrIsProfileRSN( pProfile ) )
12431 {
12432 // Insert the RSN IE into the join request
12433 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12434 (tCsrRSNIe *)( wpaRsnIE ) );
12435 }
12436#ifdef FEATURE_WLAN_WAPI
12437 else if( csrIsProfileWapi( pProfile ) )
12438 {
12439 // Insert the WAPI IE into the join request
12440 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12441 (tCsrWapiIe *)( wpaRsnIE ) );
12442 }
12443#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 else
12445 {
12446 ieLen = 0;
12447 }
12448 //remember the IE for future use
12449 if( ieLen )
12450 {
12451 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012453 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 -070012454 ieLen = DOT11F_IE_RSN_MAX_LEN;
12455 }
12456#ifdef FEATURE_WLAN_WAPI
12457 if( csrIsProfileWapi( pProfile ) )
12458 {
12459 //Check whether we need to allocate more memory
12460 if(ieLen > pSession->nWapiReqIeLength)
12461 {
12462 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12463 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012464 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012466 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12467 if (NULL == pSession->pWapiReqIE)
12468 status = eHAL_STATUS_FAILURE;
12469 else
12470 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 if(!HAL_STATUS_SUCCESS(status)) break;
12472 }
12473 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012474 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012476 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012478 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 pBuf += ieLen;
12480 }
12481 else//should be WPA/WPA2 otherwise
12482#endif /* FEATURE_WLAN_WAPI */
12483 {
12484 //Check whether we need to allocate more memory
12485 if(ieLen > pSession->nWpaRsnReqIeLength)
12486 {
12487 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12488 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012489 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012491 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12492 if (NULL == pSession->pWpaRsnReqIE)
12493 status = eHAL_STATUS_FAILURE;
12494 else
12495 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 if(!HAL_STATUS_SUCCESS(status)) break;
12497 }
12498 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012499 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012501 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012502 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012503 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 pBuf += ieLen;
12505 }
12506 }
12507 else
12508 {
12509 //free whatever old info
12510 pSession->nWpaRsnReqIeLength = 0;
12511 if(pSession->pWpaRsnReqIE)
12512 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012513 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 pSession->pWpaRsnReqIE = NULL;
12515 }
12516#ifdef FEATURE_WLAN_WAPI
12517 pSession->nWapiReqIeLength = 0;
12518 if(pSession->pWapiReqIE)
12519 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012520 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 pSession->pWapiReqIE = NULL;
12522 }
12523#endif /* FEATURE_WLAN_WAPI */
12524 //length is two bytes
12525 *pBuf = 0;
12526 *(pBuf + 1) = 0;
12527 pBuf += 2;
12528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012529#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012530 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012532 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 //length is two bytes
12534 *pBuf = 0;
12535 *(pBuf + 1) = 0;
12536 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012537 }
12538 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012540 // cckmIE
12541 if( csrIsProfileCCX( pProfile ) )
12542 {
12543 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012544#ifdef FEATURE_WLAN_CCX_UPLOAD
12545 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12546 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12547 pSession->suppCckmIeInfo.cckmIe, ieLen);
12548#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012549 ieLen = csrConstructCcxCckmIe( pMac,
12550 pSession,
12551 pProfile,
12552 pBssDescription,
12553 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012554 pSession->nWpaRsnReqIeLength,
12555 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012556#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012557 }
12558 else
12559 {
12560 ieLen = 0;
12561 }
12562 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12563 if( ieLen )
12564 {
12565 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12566 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012567 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012568 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012569 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012570 pBuf += ieLen;
12571 }
12572 else
12573 {
12574 //Indicate you have no CCKM IE
12575 //length is two bytes
12576 *pBuf = 0;
12577 *(pBuf + 1) = 0;
12578 pBuf += 2;
12579 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 }
12581#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 // addIEScan
12583 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12584 {
12585 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 if(ieLen > pSession->nAddIEScanLength)
12587 {
12588 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12589 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012590 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012592 pSession->pAddIEScan = vos_mem_malloc(ieLen);
12593 if (NULL == pSession->pAddIEScan)
12594 status = eHAL_STATUS_FAILURE;
12595 else
12596 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 if(!HAL_STATUS_SUCCESS(status)) break;
12598 }
12599 pSession->nAddIEScanLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012600 vos_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012602 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012604 vos_mem_copy(pBuf, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 pBuf += ieLen;
12606 }
12607 else
12608 {
12609 pSession->nAddIEScanLength = 0;
12610 if(pSession->pAddIEScan)
12611 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012612 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 pSession->pAddIEScan = NULL;
12614 }
12615 *pBuf = 0;
12616 *(pBuf + 1) = 0;
12617 pBuf += 2;
12618 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 // addIEAssoc
12620 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12621 {
12622 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012623 if(ieLen > pSession->nAddIEAssocLength)
12624 {
12625 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012626 {
12627 vos_mem_free(pSession->pAddIEAssoc);
12628 }
12629 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12630 if (NULL == pSession->pAddIEAssoc)
12631 status = eHAL_STATUS_FAILURE;
12632 else
12633 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012637 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012639 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012641 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 pBuf += ieLen;
12643 }
12644 else
12645 {
12646 pSession->nAddIEAssocLength = 0;
12647 if(pSession->pAddIEAssoc)
12648 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012649 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 pSession->pAddIEAssoc = NULL;
12651 }
12652 *pBuf = 0;
12653 *(pBuf + 1) = 0;
12654 pBuf += 2;
12655 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012656
12657 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012659 //Unmask any AC in reassoc that is ACM-set
12660 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12661 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012663 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12664 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012665#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012666 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012667#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012668 uapsd_mask &= ~(acm_mask);
12669 }
12670 else
12671 {
12672 uapsd_mask = 0;
12673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 }
12675 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012676
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012678 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012679 pBuf += sizeof(tANI_U32);
12680
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012682 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012683 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012684#ifdef WLAN_FEATURE_11W
12685 //MgmtEncryption
12686 if (pProfile->MFPEnabled)
12687 {
12688 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12689 }
12690 else
12691 {
12692 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12693 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012694 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012695 pBuf += sizeof(tANI_U32);
12696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012697#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012698 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012699 if (csrIsProfile11r( pProfile )
12700#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012701 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12702 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012703#endif
12704 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012705 {
12706 // is11Rconnection;
12707 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012708 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012709 pBuf += sizeof(tAniBool);
12710 }
12711 else
12712 {
12713 // is11Rconnection;
12714 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012715 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012716 pBuf += sizeof(tAniBool);
12717 }
12718#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012719#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012720
12721 // isCCXFeatureIniEnabled
12722 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12723 {
12724 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012725 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012726 pBuf += sizeof(tAniBool);
12727 }
12728 else
12729 {
12730 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012731 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012732 pBuf += sizeof(tAniBool);
12733 }
12734
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012735 /* A profile can not be both CCX and 11R. But an 802.11R AP
12736 * may be advertising support for CCX as well. So if we are
12737 * associating Open or explicitly CCX then we will get CCX.
12738 * If we are associating explictly 11R only then we will get
12739 * 11R.
12740 */
12741 if ((csrIsProfileCCX(pProfile) ||
12742 ((pIes->CCXVersion.present)
12743 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012744 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12745 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12746 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012747#ifdef WLAN_FEATURE_11W
12748 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12749#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012750 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012751 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12752 {
12753 // isCCXconnection;
12754 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012755 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012756 pBuf += sizeof(tAniBool);
12757 }
12758 else
12759 {
12760 //isCCXconnection;
12761 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012762 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012763 pBuf += sizeof(tAniBool);
12764 }
12765
12766 if (eWNI_SME_JOIN_REQ == messageType)
12767 {
12768 tCCXTspecInfo ccxTspec;
12769 // CCX-Tspec IEs in the ASSOC request is presently not supported
12770 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012771 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12772 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012773 pBuf += sizeof(tCCXTspecInfo);
12774 }
12775 else if (eWNI_SME_REASSOC_REQ == messageType)
12776 {
12777 if ((csrIsProfileCCX(pProfile) ||
12778 ((pIes->CCXVersion.present)
12779 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012780 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12781 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12782 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012783#ifdef WLAN_FEATURE_11W
12784 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12785#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012786 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012787 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 {
12789 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012791 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012792 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12793 *pBuf = ccxTspec.numTspecs;
12794 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012795 // Copy the TSPEC information only if present
12796 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012797 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12798 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 }
12800 pBuf += sizeof(ccxTspec.tspec);
12801 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012802 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 tCCXTspecInfo ccxTspec;
12805 // CCX-Tspec IEs in the ASSOC request is presently not supported
12806 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012807 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12808 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012809 pBuf += sizeof(tCCXTspecInfo);
12810 }
12811 }
12812#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012813#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012814 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012815 if (pMac->roam.configParam.isFastTransitionEnabled
12816#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012817 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012818#endif
12819 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012821 dwTmp = pal_cpu_to_be32(TRUE);
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 else
12826 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012827 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012828 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012829 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 }
12831#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012832#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012833 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012834 {
12835 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012836 dwTmp = pal_cpu_to_be32(TRUE);
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 else
12841 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012842 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012843 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012844 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012845 }
12846#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012847
12848 // txLdpcIniFeatureEnabled
12849 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12850 pBuf++;
12851
Kiran4a17ebe2013-01-31 10:43:43 -080012852 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12853 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12854 {
12855 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12856 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12857 csrApplyPower2Current(pMac);
12858 }
12859
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012860#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012861 // txBFIniFeatureEnabled
12862 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12863 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012864
12865 // txBFCsnValue
12866 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12867 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012868#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012869 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12870 pBuf++;
12871
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053012872 // WME
12873 if(pMac->roam.roamSession[sessionId].fWMMConnection)
12874 {
12875 //WME enabled
12876 dwTmp = pal_cpu_to_be32(TRUE);
12877 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12878 pBuf += sizeof(tAniBool);
12879 }
12880 else
12881 {
12882 dwTmp = pal_cpu_to_be32(FALSE);
12883 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12884 pBuf += sizeof(tAniBool);
12885 }
12886
12887 // QOS
12888 if(pMac->roam.roamSession[sessionId].fQOSConnection)
12889 {
12890 //QOS enabled
12891 dwTmp = pal_cpu_to_be32(TRUE);
12892 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12893 pBuf += sizeof(tAniBool);
12894 }
12895 else
12896 {
12897 dwTmp = pal_cpu_to_be32(FALSE);
12898 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12899 pBuf += sizeof(tAniBool);
12900 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012901 //BssDesc
12902 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12903 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012904
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012905 status = palSendMBMessage(pMac->hHdd, pMsg );
12906 if(!HAL_STATUS_SUCCESS(status))
12907 {
12908 break;
12909 }
12910 else
12911 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012912#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012913 if (eWNI_SME_JOIN_REQ == messageType)
12914 {
12915 //Tush-QoS: notify QoS module that join happening
12916 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12917 }
12918 else if (eWNI_SME_REASSOC_REQ == messageType)
12919 {
12920 //Tush-QoS: notify QoS module that reassoc happening
12921 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12922 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012923#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012925 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012927}
12928
Jeff Johnson295189b2012-06-20 16:38:30 -070012929//
12930eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12931{
12932 eHalStatus status = eHAL_STATUS_SUCCESS;
12933 tSirSmeDisassocReq *pMsg;
12934 tANI_U8 *pBuf;
12935 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12937 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12938 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012940 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12941 if (NULL == pMsg)
12942 status = eHAL_STATUS_FAILURE;
12943 else
12944 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012946 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12948 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 pBuf = &pMsg->sessionId;
12950 // sessionId
12951 *pBuf++ = (tANI_U8)sessionId;
12952 // transactionId
12953 *pBuf = 0;
12954 *( pBuf + 1 ) = 0;
12955 pBuf += sizeof(tANI_U16);
12956
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012957 if ( (pSession->pCurRoamProfile != NULL) &&
12958 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12959 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 {
12961 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012962 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12963 sizeof( tSirMacAddr ));
12964 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012965 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012967 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12968 //perMacAddr is passed as bssId for softAP
12969 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 pBuf = pBuf + sizeof ( tSirMacAddr );
12971 }
12972 else
12973 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012975 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12976 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053012978 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
12979 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 if(!HAL_STATUS_SUCCESS(status))
12983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012984 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 break;
12986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 // reasonCode
12988 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053012989 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
12990 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 if(!HAL_STATUS_SUCCESS(status))
12992 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012993 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 break;
12995 }
12996 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12998 Here we should not send the disassoc over the air to the AP */
12999 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13000#ifdef WLAN_FEATURE_VOWIFI_11R
13001 && csrRoamIs11rAssoc(pMac)
13002#endif
13003 )
13004 {
13005 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13006 }
13007 pBuf += sizeof(tANI_U8);
13008 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 return( status );
13011}
Jeff Johnson295189b2012-06-20 16:38:30 -070013012eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13013{
13014 eHalStatus status = eHAL_STATUS_SUCCESS;
13015 tSirSmeTkipCntrMeasReq *pMsg;
13016 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 do
13018 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013019 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13020 if ( NULL == pMsg )
13021 status = eHAL_STATUS_FAILURE;
13022 else
13023 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013025 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13027 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 pBuf = &pMsg->sessionId;
13029 // sessionId
13030 *pBuf++ = (tANI_U8)sessionId;
13031 // transactionId
13032 *pBuf = 0;
13033 *( pBuf + 1 ) = 0;
13034 pBuf += sizeof(tANI_U16);
13035 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013036 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13037 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 pBuf = pBuf + sizeof ( tSirMacAddr );
13039 // bEnable
13040 *pBuf = (tANI_BOOLEAN)bEnable;
13041 if(!HAL_STATUS_SUCCESS(status))
13042 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013043 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 break;
13045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 return( status );
13049}
Jeff Johnson295189b2012-06-20 16:38:30 -070013050eHalStatus
13051csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13052 VOS_MODULE_ID modId, tSirMacAddr bssId,
13053 void *pUsrContext, void *pfnSapEventCallback,
13054 tANI_U8 *pAssocStasBuf )
13055{
13056 eHalStatus status = eHAL_STATUS_SUCCESS;
13057 tSirSmeGetAssocSTAsReq *pMsg;
13058 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13059 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 do
13061 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013062 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13063 if ( NULL == pMsg )
13064 status = eHAL_STATUS_FAILURE;
13065 else
13066 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013068 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 pBuf = (tANI_U8 *)&pMsg->bssId;
13071 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013073 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 // modId
13076 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013077 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 // pUsrContext
13080 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013081 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 // pfnSapEventCallback
13084 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
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 // pAssocStasBuf
13088 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
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 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 status = palSendMBMessage( pMac->hHdd, pMsg );
13093 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 return( status );
13095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013096eHalStatus
13097csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13098 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13099 {
13100 eHalStatus status = eHAL_STATUS_SUCCESS;
13101 tSirSmeGetWPSPBCSessionsReq *pMsg;
13102 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13103 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 do
13105 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013106 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13107 if ( NULL == pMsg )
13108 status = eHAL_STATUS_FAILURE;
13109 else
13110 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013111 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013112 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013115 VOS_ASSERT(pBuf);
13116
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 // pUsrContext
13119 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013120 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013122 // pSapEventCallback
13123 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013124 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013127 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013130 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 return( status );
13136}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013137
13138eHalStatus
13139csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13140{
13141 tpSirChangeBIParams pMsg;
13142 tANI_U16 len = 0;
13143 eHalStatus status = eHAL_STATUS_SUCCESS;
13144 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13145
13146 if(!pSession)
13147 {
13148 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13149 return eHAL_STATUS_FAILURE;
13150 }
13151
13152 //NO need to update the Beacon Params if update beacon parameter flag is not set
13153 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13154 return eHAL_STATUS_SUCCESS;
13155
13156 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13157
13158 /* Create the message and send to lim */
13159 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013160 pMsg = vos_mem_malloc(len);
13161 if ( NULL == pMsg )
13162 status = eHAL_STATUS_FAILURE;
13163 else
13164 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013165 if(HAL_STATUS_SUCCESS(status))
13166 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013167 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013168 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13169 pMsg->length = len;
13170
13171 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013172 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13173 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013174 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13175 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013176 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013177 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013178 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13179 status = palSendMBMessage(pMac->hHdd, pMsg);
13180 }
13181 return status;
13182}
13183
Jeff Johnson295189b2012-06-20 16:38:30 -070013184eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13185{
13186 eHalStatus status = eHAL_STATUS_SUCCESS;
13187 tSirSmeDeauthReq *pMsg;
13188 tANI_U8 *pBuf;
13189 tANI_U16 wTmp;
13190 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13191 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13192 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013194 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13195 if ( NULL == pMsg )
13196 status = eHAL_STATUS_FAILURE;
13197 else
13198 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013200 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13202 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13203 //sessionId
13204 pBuf = &pMsg->sessionId;
13205 *pBuf++ = (tANI_U8)sessionId;
13206
13207 //tansactionId
13208 *pBuf = 0;
13209 *(pBuf + 1 ) = 0;
13210 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13214 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013215 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13216 sizeof( pMsg->peerMacAddr ) );
13217 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013218 pBuf = pBuf + sizeof(tSirMacAddr);
13219 }
13220 else
13221 {
13222 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013223 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13224 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 }
13227 if(!HAL_STATUS_SUCCESS(status))
13228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013229 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 break;
13231 }
13232 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013233 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13234 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 pBuf = pBuf + sizeof(tSirMacAddr);
13236 if(!HAL_STATUS_SUCCESS(status))
13237 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013238 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 break;
13240 }
13241 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013242 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13243 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 if(!HAL_STATUS_SUCCESS(status))
13245 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013246 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 break;
13248 }
13249 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 return( status );
13252}
13253
Jeff Johnson295189b2012-06-20 16:38:30 -070013254eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13255{
13256 eHalStatus status = eHAL_STATUS_SUCCESS;
13257 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013259 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13260 if ( NULL == pMsg )
13261 status = eHAL_STATUS_FAILURE;
13262 else
13263 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013264 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013265 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13267 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13268 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013269 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13270 sizeof(pMsg->peerMacAddr));
13271 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 if(!HAL_STATUS_SUCCESS(status))
13273 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013274 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 break;
13276 }
13277//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013278 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13279 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 if(!HAL_STATUS_SUCCESS(status))
13281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013282 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 break;
13284 }
13285//To test reconn ends
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}
13290
Jeff Johnson295189b2012-06-20 16:38:30 -070013291eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13292{
13293 eHalStatus status = eHAL_STATUS_SUCCESS;
13294 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013296 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13297 if ( NULL == pMsg )
13298 status = eHAL_STATUS_FAILURE;
13299 else
13300 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013302 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13304 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13305 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013306 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13307 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 if(!HAL_STATUS_SUCCESS(status))
13309 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013310 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 break;
13312 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013313 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13314 sizeof(pMsg->peerMacAddr));
13315 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 if(!HAL_STATUS_SUCCESS(status))
13317 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 break;
13320 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 return( status );
13324}
Jeff Johnson295189b2012-06-20 16:38:30 -070013325eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13326{
13327 eHalStatus status = eHAL_STATUS_SUCCESS;
13328 tSirSmeAssocCnf *pMsg;
13329 tANI_U8 *pBuf;
13330 tSirResultCodes statusCode;
13331 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13334 if ( NULL == pMsg )
13335 status = eHAL_STATUS_FAILURE;
13336 else
13337 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013339 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13341 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 pBuf = (tANI_U8 *)&pMsg->statusCode;
13343 if(HAL_STATUS_SUCCESS(Halstatus))
13344 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13345 else
13346 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013347 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 pBuf += sizeof(tSirResultCodes);
13349 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013350 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13351 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 pBuf += sizeof (tSirMacAddr);
13353 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013354 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13355 sizeof(tSirMacAddr));
13356 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 pBuf += sizeof (tSirMacAddr);
13358 // aid
13359 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013360 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 pBuf += sizeof (tANI_U16);
13362 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013363 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13364 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 pBuf += sizeof (tSirMacAddr);
13366 // alternateChannelId
13367 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 status = palSendMBMessage( pMac->hHdd, pMsg );
13369 if(!HAL_STATUS_SUCCESS(status))
13370 {
13371 //pMsg is freed by palSendMBMessage
13372 break;
13373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 return( status );
13376}
Jeff Johnson295189b2012-06-20 16:38:30 -070013377eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13378 tpSirSmeAssocInd pAssocInd,
13379 eHalStatus Halstatus,
13380 tANI_U8 sessionId)
13381{
13382 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13384 tANI_U8 *pBuf;
13385 tSirResultCodes statusCode;
13386 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013388 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13389 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13390 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013391
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13393 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13394
13395 pMsg->sessionId = sessionId;
13396
13397 pBuf = (tANI_U8 *)&pMsg->statusCode;
13398 if(HAL_STATUS_SUCCESS(Halstatus))
13399 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13400 else
13401 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013402 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 pBuf += sizeof(tSirResultCodes);
13404 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013405 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 pBuf += sizeof (tSirMacAddr);
13407 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013408 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13409 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 pBuf += sizeof (tSirMacAddr);
13411 // StaId
13412 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013413 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 pBuf += sizeof (tANI_U16);
13415 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013416 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 pBuf += sizeof (tSirMacAddr);
13418 // alternateChannelId
13419 *pBuf = 11;
13420 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013421 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 //Wmm
13423 *pBuf = pAssocInd->wmmEnabledSta;
13424 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013426 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013429 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 //reassocReq
13432 *pBuf = pAssocInd->reassocReq;
13433 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013434 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13435 msgQ.bodyptr = pMsg;
13436 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013439 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013440}
Jeff Johnson295189b2012-06-20 16:38:30 -070013441
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013442eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13444 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13445 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13446 tANI_U8 *pKeyRsc )
13447{
13448 tSirSmeSetContextReq *pMsg;
13449 tANI_U16 msgLen;
13450 eHalStatus status = eHAL_STATUS_FAILURE;
13451 tAniEdType tmpEdType;
13452 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013453 tANI_U8 *pBuf = NULL;
13454 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13459 // key set. Since we only support upto one key, we always allocate memory for 1 key
13460 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13461 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13462 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13463 ( sizeof( pMsg->keyMaterial.key ) );
13464
Kiet Lam64c1b492013-07-12 13:56:44 +053013465 pMsg = vos_mem_malloc(msgLen);
13466 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13467 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13469 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 //sessionId
13471 pBuf = &pMsg->sessionId;
13472 *pBuf = (tANI_U8)sessionId;
13473 pBuf++;
13474 // transactionId
13475 *pBuf = 0;
13476 *(pBuf + 1) = 0;
13477 pBuf += sizeof(tANI_U16);
13478 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013479 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013480
13481 pBuf += sizeof(tSirMacAddr);
13482
13483 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013484 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13485 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013486
13487 pBuf += sizeof(tSirMacAddr);
13488
13489 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13491 // in the tSirKeyMaterial keyMaterial; field).
13492 //
13493 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13494 // shorter than this max size. Is LIM interpreting this ok ?
13495 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 -070013496 // set pMsg->keyMaterial.edType
13497 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013498 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013499 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 // set the pMsg->keyMaterial.numKeys field
13501 *p = numKeys;
13502 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 // set pSirKey->keyId = keyId;
13504 *p = keyId;
13505 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 // set pSirKey->unicast = (tANI_U8)fUnicast;
13507 *p = (tANI_U8)fUnicast;
13508 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 // set pSirKey->keyDirection = aniKeyDirection;
13510 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013511 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 p += sizeof(tAniKeyDirection);
13513 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013514 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 // set pSirKey->paeRole
13517 *p = paeRole; // 0 is Supplicant
13518 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013519 // set pSirKey->keyLength = keyLength;
13520 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 if ( keyLength && pKey )
13522 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013523 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 if(keyLength == 16)
13525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013526 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 -070013527 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13528 pKey[5], pKey[6], pKey[7], pKey[8],
13529 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13530 }
13531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 return( status );
13535}
13536
Jeff Johnson295189b2012-06-20 16:38:30 -070013537eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13538 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13539{
13540 eHalStatus status;
13541 tSirSmeStartBssReq *pMsg;
13542 tANI_U8 *pBuf = NULL;
13543 tANI_U8 *wTmpBuf = NULL;
13544 tANI_U16 msgLen, wTmp;
13545 tANI_U32 dwTmp;
13546 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013547 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013550
13551 if(!pSession)
13552 {
13553 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13554 return eHAL_STATUS_FAILURE;
13555 }
13556
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 do {
13558 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13559 pSession->joinFailStatusCode.reasonCode = 0;
13560 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013561 pMsg = vos_mem_malloc(msgLen);
13562 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13563 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 //sessionId
13568 *pBuf = (tANI_U8)sessionId;
13569 pBuf++;
13570 // transactionId
13571 *pBuf = 0;
13572 *(pBuf + 1) = 0;
13573 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013575 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pBuf += sizeof(tSirMacAddr);
13577 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013578 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 pBuf += sizeof(tSirMacAddr);
13580 // beaconInterval
13581 if( pBssDesc && pBssDesc->beaconInterval )
13582 {
13583 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 else if(pParam->beaconInterval)
13586 {
13587 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 else
13590 {
13591 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13592 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013593 if(csrIsconcurrentsessionValid (pMac, sessionId,
13594 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013595 == eHAL_STATUS_SUCCESS )
13596 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013597 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013598 pParam->bssPersona);
13599 //Update the beacon Interval
13600 pParam->beaconInterval = wTmp;
13601 }
13602 else
13603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013604 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013605 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013606 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013607 return status;
13608 }
13609
Kiet Lam64c1b492013-07-12 13:56:44 +053013610 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 pBuf += sizeof(tANI_U16);
13612 // dot11mode
13613 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13614 pBuf += 1;
13615 // bssType
13616 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013617 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 pBuf += sizeof(tSirBssType);
13619 // ssId
13620 if( pParam->ssId.length )
13621 {
13622 // ssId len
13623 *pBuf = pParam->ssId.length;
13624 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013625 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pBuf += pParam->ssId.length;
13627 }
13628 else
13629 {
13630 *pBuf = 0;
13631 pBuf++;
13632 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 // set the channel Id
13634 *pBuf = pParam->operationChn;
13635 pBuf++;
13636 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013637 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013638 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013639 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013640
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 // Set privacy
13642 *pBuf = pParam->privacy;
13643 pBuf++;
13644
13645 //Set Uapsd
13646 *pBuf = pParam->ApUapsdEnable;
13647 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 //Set SSID hidden
13649 *pBuf = pParam->ssidHidden;
13650 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13652 pBuf++;
13653
13654 //Ht protection Enable/Disable
13655 *pBuf = (tANI_U8)pParam->protEnabled;
13656 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 //Enable Beacons to Receive for OBSS protection Enable/Disable
13658 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13659 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 //set cfg related to protection
13661 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013662 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 // Set Auth type
13665 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013666 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 // Set DTIM
13669 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013670 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 // Set wps_state
13673 *pBuf = pParam->wps_state;
13674 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013675 // set isCoalesingInIBSSAllowed
13676 *pBuf = pMac->isCoalesingInIBSSAllowed;
13677 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 //Persona
13679 *pBuf = (tANI_U8)pParam->bssPersona;
13680 pBuf++;
13681
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013682 //txLdpcIniFeatureEnabled
13683 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13684 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013685
krunal soni4f087d22013-07-29 16:32:26 -070013686 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13688 {
13689 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013690 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 break;
13692 }
13693 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013694 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 pBuf += sizeof(tANI_U16);
13696 if( wTmp )
13697 {
13698 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013699 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 pBuf += wTmp;
13701 }
13702 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013703 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13706 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013707 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13708 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 pBuf += pParam->operationalRateSet.numRates ;
13710 *pBuf++ = pParam->extendedRateSet.numRates;
13711 if(0 != pParam->extendedRateSet.numRates)
13712 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013713 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13714 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 pBuf += pParam->extendedRateSet.numRates;
13716 }
krunal sonie9002db2013-11-25 14:24:17 -080013717
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13719 pMsg->length = pal_cpu_to_be16(msgLen);
13720
13721 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 return( status );
13724}
13725
Jeff Johnson295189b2012-06-20 16:38:30 -070013726eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13727{
13728 eHalStatus status = eHAL_STATUS_FAILURE;
13729 tSirSmeStopBssReq *pMsg;
13730 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13731 tANI_U8 *pBuf;
13732 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013733
13734 if(!pSession)
13735 {
13736 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13737 return eHAL_STATUS_FAILURE;
13738 }
13739
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013741 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13742 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13743 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13745 pBuf = &pMsg->sessionId;
13746 //sessionId
13747 *pBuf = (tANI_U8)sessionId;
13748 pBuf++;
13749 // transactionId
13750 *pBuf = 0;
13751 pBuf += sizeof(tANI_U16);
13752 //reason code
13753 *pBuf = 0;
13754 pBuf += sizeof(tSirResultCodes);
13755 // bssid
13756 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13757 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13758 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013759 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13760 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 }
13762 else
13763 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013764 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13765 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 }
13767 pBuf += sizeof(tSirMacAddr);
13768 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13769 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 status = palSendMBMessage( pMac->hHdd, pMsg );
13771#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013772 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13773 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13774 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13776 pMsg->reasonCode = 0;
13777 // bssid
13778 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13779 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13780 {
13781 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13782 }
13783 else
13784 {
13785 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13786 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013787 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 pMsg->transactionId = 0;
13789 pMsg->sessionId = (tANI_U8)sessionId;
13790 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13791 status = palSendMBMessage( pMac->hHdd, pMsg );
13792#endif
13793 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 return( status );
13795}
13796
Jeff Johnson295189b2012-06-20 16:38:30 -070013797eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13798 tCsrRoamModifyProfileFields *pModProfileFields,
13799 tANI_U32 *pRoamId, v_BOOL_t fForce)
13800{
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 eHalStatus status = eHAL_STATUS_FAILURE;
13802 tANI_U32 roamId = 0;
13803 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013805 (fForce || (!vos_mem_compare( &pModProfileFields,
13806 &pSession->connectedProfile.modifyProfileFields,
13807 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 {
13809 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13810 if(pRoamId)
13811 {
13812 *pRoamId = roamId;
13813 }
13814
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13816 eCsrSmeIssuedReassocToSameAP, roamId,
13817 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 return status;
13820}
Jeff Johnson295189b2012-06-20 16:38:30 -070013821static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13822{
13823 eHalStatus status = eHAL_STATUS_SUCCESS;
13824 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013825 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13827 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13828 return (status);
13829}
Jeff Johnson295189b2012-06-20 16:38:30 -070013830eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13831{
13832 eHalStatus status = eHAL_STATUS_SUCCESS;
13833 tListElem *pEntry = NULL;
13834 tSmeCmd *pCommand = NULL;
13835 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 do
13837 {
13838 if(pMsg == NULL)
13839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013840 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 status = eHAL_STATUS_FAILURE;
13842 break;
13843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13845 if(pEntry)
13846 {
13847 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13848 if(eSmeCommandAddStaSession == pCommand->command)
13849 {
13850 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013851 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 //Remove this command out of the active list
13855 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13856 {
13857 //Now put this command back on the avilable command list
13858 csrReleaseCommand(pMac, pCommand);
13859 }
13860 smeProcessPendingQueue( pMac );
13861 }
13862 else
13863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013864 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 -070013865 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 status = eHAL_STATUS_FAILURE;
13867 break;
13868 }
13869 }
13870 else
13871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013872 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 -070013873 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 status = eHAL_STATUS_FAILURE;
13875 break;
13876 }
13877 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013879}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013880eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13881 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013882{
13883 tSirSmeAddStaSelfReq *pMsg;
13884 tANI_U16 msgLen;
13885 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013887 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013888 pMsg = vos_mem_malloc(msgLen);
13889 if ( NULL == pMsg ) break;
13890 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13892 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013894 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013895 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13896
13897 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13898
Arif Hussain24bafea2013-11-15 15:10:03 -080013899 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
13900 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 return( status );
13904}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013905eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13906 tANI_U32 sessionId,
13907 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013908{
13909 eHalStatus status = eHAL_STATUS_SUCCESS;
13910 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 pCommand = csrGetCommandBuffer(pMac);
13912 if(NULL == pCommand)
13913 {
13914 status = eHAL_STATUS_RESOURCES;
13915 }
13916 else
13917 {
13918 pCommand->command = eSmeCommandAddStaSession;
13919 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013920 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13921 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013922 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13924 if( !HAL_STATUS_SUCCESS( status ) )
13925 {
13926 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013927 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 }
13929 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 return (status);
13931}
Jeff Johnson295189b2012-06-20 16:38:30 -070013932eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13933{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013934 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013935}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013936eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13937 csrRoamCompleteCallback callback,
13938 void *pContext, tANI_U8 *pSelfMacAddr,
13939 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013940{
13941 eHalStatus status = eHAL_STATUS_SUCCESS;
13942 tANI_U32 i;
13943 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 *pbSessionId = CSR_SESSION_ID_INVALID;
13945 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13946 {
13947 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13948 {
13949 pSession = CSR_GET_SESSION( pMac, i );
13950 status = eHAL_STATUS_SUCCESS;
13951 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13952 pSession->sessionId = (tANI_U8)i;
13953 pSession->callback = callback;
13954 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013955 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013957 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13958 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013960 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013962 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 break;
13964 }
13965#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013966 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13967 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013969 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013971 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 break;
13973 }
13974#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013975 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 break;
13977 }
13978 }
13979 if( CSR_ROAM_SESSION_MAX == i )
13980 {
13981 //No session is available
13982 status = eHAL_STATUS_RESOURCES;
13983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 return ( status );
13985}
Jeff Johnson295189b2012-06-20 16:38:30 -070013986eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13987{
13988 eHalStatus status = eHAL_STATUS_SUCCESS;
13989 tListElem *pEntry = NULL;
13990 tSmeCmd *pCommand = NULL;
13991 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 do
13993 {
13994 if(pMsg == NULL)
13995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013996 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 status = eHAL_STATUS_FAILURE;
13998 break;
13999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14001 if(pEntry)
14002 {
14003 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14004 if(eSmeCommandDelStaSession == pCommand->command)
14005 {
14006 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014008 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 //This session is done.
14010 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 if(pCommand->u.delStaSessionCmd.callback)
14012 {
14013
14014 status = sme_ReleaseGlobalLock( &pMac->sme );
14015 if ( HAL_STATUS_SUCCESS( status ) )
14016 {
14017 pCommand->u.delStaSessionCmd.callback(
14018 pCommand->u.delStaSessionCmd.pContext);
14019 status = sme_AcquireGlobalLock( &pMac->sme );
14020 if (! HAL_STATUS_SUCCESS( status ) )
14021 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014022 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 return status;
14024 }
14025 }
14026 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014027 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 }
14029 }
14030
14031 //Remove this command out of the active list
14032 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14033 {
14034 //Now put this command back on the avilable command list
14035 csrReleaseCommand(pMac, pCommand);
14036 }
14037 smeProcessPendingQueue( pMac );
14038 }
14039 else
14040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014041 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 -070014042 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 status = eHAL_STATUS_FAILURE;
14044 break;
14045 }
14046 }
14047 else
14048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014049 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 -070014050 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 status = eHAL_STATUS_FAILURE;
14052 break;
14053 }
14054 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014056}
Jeff Johnson295189b2012-06-20 16:38:30 -070014057eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14058{
14059 tSirSmeDelStaSelfReq *pMsg;
14060 tANI_U16 msgLen;
14061 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014062 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14064 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014065 pMsg = vos_mem_malloc(msgLen);
14066 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14067 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14069 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014071 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14072 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 return( status );
14076}
Jeff Johnson295189b2012-06-20 16:38:30 -070014077eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14078 tSirMacAddr sessionMacAddr,
14079 csrRoamSessionCloseCallback callback,
14080 void *pContext)
14081{
14082 eHalStatus status = eHAL_STATUS_SUCCESS;
14083 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 pCommand = csrGetCommandBuffer(pMac);
14085 if(NULL == pCommand)
14086 {
14087 status = eHAL_STATUS_RESOURCES;
14088 }
14089 else
14090 {
14091 pCommand->command = eSmeCommandDelStaSession;
14092 pCommand->sessionId = (tANI_U8)sessionId;
14093 pCommand->u.delStaSessionCmd.callback = callback;
14094 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014095 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14096 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14098 if( !HAL_STATUS_SUCCESS( status ) )
14099 {
14100 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014101 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014102 }
14103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 return (status);
14105}
Jeff Johnson295189b2012-06-20 16:38:30 -070014106eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14107{
14108 return csrSendMBDelSelfStaReqMsg( pMac,
14109 pCommand->u.delStaSessionCmd.selfMacAddr );
14110}
Jeff Johnson295189b2012-06-20 16:38:30 -070014111static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14112{
14113 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14114 tListElem *pEntry, *pNext;
14115 tSmeCmd *pCommand;
14116 tDblLinkList localList;
14117
14118 vos_mem_zero(&localList, sizeof(tDblLinkList));
14119 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14120 {
14121 smsLog(pMac, LOGE, FL(" failed to open list"));
14122 return;
14123 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 csrLLLock(pList);
14125 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14126 while(pEntry != NULL)
14127 {
14128 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14129 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14130 if(pCommand->sessionId == sessionId)
14131 {
14132 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14133 {
14134 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14135 }
14136 }
14137 pEntry = pNext;
14138 }
14139 csrLLUnlock(pList);
14140
14141 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14142 {
14143 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14144 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14145 }
14146 csrLLClose(&localList);
14147}
14148
Jeff Johnson295189b2012-06-20 16:38:30 -070014149void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14150{
14151 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14152 {
14153 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 csrRoamStop(pMac, sessionId);
14155 csrFreeConnectBssDesc(pMac, sessionId);
14156 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14157 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014158 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014159#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014160 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014161#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014162 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14163 if (pMac->fScanOffload)
14164 {
14165 purgeSmeSessionCmdList(pMac, sessionId,
14166 &pMac->sme.smeScanCmdPendingList);
14167 }
14168
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 purgeCsrSessionCmdList(pMac, sessionId);
14170 csrInitSession(pMac, sessionId);
14171 }
14172}
14173
Jeff Johnson295189b2012-06-20 16:38:30 -070014174eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14175 tANI_BOOLEAN fSync,
14176 csrRoamSessionCloseCallback callback,
14177 void *pContext )
14178{
14179 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14181 {
14182 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14183 if(fSync)
14184 {
14185 csrCleanupSession(pMac, sessionId);
14186 }
14187 else
14188 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014189 purgeSmeSessionCmdList(pMac, sessionId,
14190 &pMac->sme.smeCmdPendingList);
14191 if (pMac->fScanOffload)
14192 {
14193 purgeSmeSessionCmdList(pMac, sessionId,
14194 &pMac->sme.smeScanCmdPendingList);
14195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 purgeCsrSessionCmdList(pMac, sessionId);
14197 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14198 pSession->selfMacAddr, callback, pContext);
14199 }
14200 }
14201 else
14202 {
14203 status = eHAL_STATUS_INVALID_PARAMETER;
14204 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 return ( status );
14206}
14207
Jeff Johnson295189b2012-06-20 16:38:30 -070014208static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14209{
14210 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014211
14212 if(!pSession)
14213 {
14214 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14215 return;
14216 }
14217
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14219 pSession->sessionId = CSR_SESSION_ID_INVALID;
14220 pSession->callback = NULL;
14221 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14223 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14224 csrFreeRoamProfile( pMac, sessionId );
14225 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14226 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14227 csrFreeConnectBssDesc(pMac, sessionId);
14228 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014229 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14230 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014232 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 pSession->pWpaRsnReqIE = NULL;
14234 }
14235 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014236 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014238 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 pSession->pWpaRsnRspIE = NULL;
14240 }
14241 pSession->nWpaRsnRspIeLength = 0;
14242#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014243 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014245 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 pSession->pWapiReqIE = NULL;
14247 }
14248 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014249 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014251 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 pSession->pWapiRspIE = NULL;
14253 }
14254 pSession->nWapiRspIeLength = 0;
14255#endif /* FEATURE_WLAN_WAPI */
Kiet Lam64c1b492013-07-12 13:56:44 +053014256 if (pSession->pAddIEScan)
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014258 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 pSession->pAddIEScan = NULL;
14260 }
14261 pSession->nAddIEScanLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014262 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014264 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014267 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014268}
14269
Jeff Johnson295189b2012-06-20 16:38:30 -070014270eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14271{
14272 eHalStatus status = eHAL_STATUS_FAILURE;
14273 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14275 {
14276 if( CSR_IS_SESSION_VALID( pMac, i ) )
14277 {
14278 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14279 {
14280 //Found it
14281 status = eHAL_STATUS_SUCCESS;
14282 *pSessionId = i;
14283 break;
14284 }
14285 }
14286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 return( status );
14288}
14289
Jeff Johnson295189b2012-06-20 16:38:30 -070014290//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14291//session because for IBSS, the bssid changes.
14292static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14293{
14294 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14295 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14297 {
14298 if( CSR_IS_SESSION_VALID( pMac, i ) )
14299 {
14300 pSession = CSR_GET_SESSION( pMac, i );
14301 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14302 {
14303 //Found it
14304 nRet = i;
14305 break;
14306 }
14307 }
14308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 return (nRet);
14310}
Jeff Johnson295189b2012-06-20 16:38:30 -070014311static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14312{
14313 /* Update the current BSS info in ho control block based on connected
14314 profile info from pmac global structure */
14315
Arif Hussain24bafea2013-11-15 15:10:03 -080014316 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14317 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 /* Check for user misconfig of RSSI trigger threshold */
14319 pMac->roam.configParam.vccRssiThreshold =
14320 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14321 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14322 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 /* Check for user misconfig of UL MAC Loss trigger threshold */
14324 pMac->roam.configParam.vccUlMacLossThreshold =
14325 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14326 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014327#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14328 {
14329 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 /* Indicate the neighbor roal algorithm about the connect indication */
14331 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14332 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14333 }
14334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014335}
14336
Jeff Johnson295189b2012-06-20 16:38:30 -070014337static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14338{
14339 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014340
14341 if(!pSession)
14342 {
14343 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14344 return;
14345 }
14346
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 //Only to handle the case for Handover on infra link
14348 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14349 {
14350 return;
14351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14353 csrRoamDeregStatisticsReq(pMac);
14354 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14355#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14356 /* Indicate the neighbor roal algorithm about the disconnect indication */
14357 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14358#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014359
14360 //Remove this code once SLM_Sessionization is supported
14361 //BMPS_WORKAROUND_NOT_NEEDED
14362 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014363 csrIsInfraApStarted( pMac ) &&
14364 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014365 {
14366 pMac->roam.configParam.doBMPSWorkaround = 0;
14367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014368}
14369
Jeff Johnson295189b2012-06-20 16:38:30 -070014370void csrRoamTlStatsTimerHandler(void *pv)
14371{
14372 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14373 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014374 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14375
Jeff Johnsone7245742012-09-05 17:12:55 -070014376 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14377
Jeff Johnson295189b2012-06-20 16:38:30 -070014378#if 0
14379 // TODO Persession .???
14380 //req TL for stats
14381 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014383 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 }
14385 else
14386 {
14387 //save in SME
14388 csrRoamSaveStatsFromTl(pMac, tlStats);
14389 }
14390#endif
14391 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14392 {
14393 if(pMac->roam.tlStatsReqInfo.periodicity)
14394 {
14395 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014396 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14397 pMac->roam.tlStatsReqInfo.periodicity);
14398 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014400 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 return;
14402 }
14403 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14404 }
14405 }
14406}
Jeff Johnson295189b2012-06-20 16:38:30 -070014407void csrRoamPeStatsTimerHandler(void *pv)
14408{
14409 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14410 eHalStatus status;
14411 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14412 VOS_STATUS vosStatus;
14413 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014414 pPeStatsReqListEntry->timerRunning = FALSE;
14415 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14416 {
14417 // If we entered here, meaning the timer could not be successfully
14418 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14419
14420 /* Destroy the timer */
14421 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14422 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014424 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014425 }
14426
14427 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014428 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014429 pPeStatsReqListEntry = NULL;
14430 }
14431 else
14432 {
14433 if(!pPeStatsReqListEntry->rspPending)
14434 {
14435 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14436 pPeStatsReqListEntry->staId);
14437 if(!HAL_STATUS_SUCCESS(status))
14438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014439 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 }
14441 else
14442 {
14443 pPeStatsReqListEntry->rspPending = TRUE;
14444 }
14445 }
14446
14447 //send down a req
14448 if(pPeStatsReqListEntry->periodicity &&
14449 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14450 {
14451 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14452 if(ePMC_FULL_POWER == powerState)
14453 {
14454 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14455 {
14456 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14457 }
14458 }
14459 else
14460 {
14461 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14462 {
14463 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14464 }
14465 }
14466 //start timer
14467 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14468 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014470 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014471 return;
14472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 pPeStatsReqListEntry->timerRunning = TRUE;
14474
14475 }
14476
14477 }
14478}
Jeff Johnson295189b2012-06-20 16:38:30 -070014479void csrRoamStatsClientTimerHandler(void *pv)
14480{
14481 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14483 {
14484#if 0
14485 // TODO Stats fix for multisession
14486 //start the timer
14487 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14488
14489 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014491 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 }
14493#endif
14494 }
14495#if 0
14496 //send up the stats report
14497 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14498 pStaEntry->staId, pStaEntry->pContext);
14499#endif
14500}
14501
14502
14503
Jeff Johnson295189b2012-06-20 16:38:30 -070014504eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14505{
14506 tAniGetPEStatsReq *pMsg;
14507 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014508 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14509 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014511 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014512 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 }
14514 // need to initiate a stats request to PE
14515 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14516 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14517 pMsg->staId = staId;
14518 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 if(!HAL_STATUS_SUCCESS(status))
14521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014522 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014524 return status;
14525}
Jeff Johnson295189b2012-06-20 16:38:30 -070014526void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14527{
14528 tAniGetPEStatsRsp *pSmeStatsRsp;
14529 eHalStatus status = eHAL_STATUS_FAILURE;
14530 tListElem *pEntry = NULL;
14531 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14532 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14533 tANI_U32 tempMask = 0;
14534 tANI_U8 counter = 0;
14535 tANI_U8 *pStats = NULL;
14536 tANI_U32 length = 0;
14537 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014538 v_S7_t rssi = 0, snr = 0;
14539 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014540 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14542 if(pSmeStatsRsp->rc)
14543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014544 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 goto post_update;
14546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 tempMask = pSmeStatsRsp->statsMask;
14548 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 /* subtract all statistics from this length, and after processing the entire
14550 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14551 * in this 'stats' message.
14552 */
14553 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 //new stats info from PE, fill up the stats strucutres in PMAC
14555 while(tempMask)
14556 {
14557 if(tempMask & 1)
14558 {
14559 switch(counter)
14560 {
14561 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014562 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014563 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14564 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 pStats += sizeof(tCsrSummaryStatsInfo);
14566 length -= sizeof(tCsrSummaryStatsInfo);
14567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014569 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014570 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14571 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14573 length -= sizeof(tCsrGlobalClassAStatsInfo);
14574 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014576 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014577 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14578 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14580 length -= sizeof(tCsrGlobalClassBStatsInfo);
14581 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014582 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014583 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014584 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14585 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14587 length -= sizeof(tCsrGlobalClassCStatsInfo);
14588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014590 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14592 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014593 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14594 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 }
14596 else
14597 {
14598 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014599 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 VOS_ASSERT( 0 );
14601 }
14602 if(!HAL_STATUS_SUCCESS(status))
14603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014604 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014605 }
14606 pStats += sizeof(tCsrPerStaStatsInfo);
14607 length -= sizeof(tCsrPerStaStatsInfo);
14608 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014610 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014612 }
14613 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014614 tempMask >>=1;
14615 counter++;
14616 }
14617 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14618 if (length != 0)
14619 {
14620 pRssi = (tANI_U32*)pStats;
14621 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014622 pStats += sizeof(tANI_U32);
14623 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014624 }
14625 else
14626 {
14627 /* If riva is not sending rssi, continue to use the hack */
14628 rssi = RSSI_HACK_BMPS;
14629 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014630
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014632
14633 if (length != 0)
14634 {
14635 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014636 pStats += sizeof(tANI_U32);
14637 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014638 }
14639 else
14640 {
14641 linkCapacity = 0;
14642 }
14643
14644 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014645
14646 if (length != 0)
14647 {
14648 pSnr = (tANI_U32*)pStats;
14649 snr = (v_S7_t)*pSnr;
14650 }
14651 else
14652 {
14653 snr = SNR_HACK_BMPS;
14654 }
14655
14656 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014657post_update:
14658 //make sure to update the pe stats req list
14659 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14660 if(pEntry)
14661 {
14662 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14663 pPeStaEntry->rspPending = FALSE;
14664
14665 }
14666 //check the one timer cases
14667 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14668 if(pEntry)
14669 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014670 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014671 if(pTempStaEntry->timerExpired)
14672 {
14673 //send up the stats report
14674 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14675 pTempStaEntry->staId, pTempStaEntry->pContext);
14676 //also remove from the client list
14677 csrRoamRemoveStatListEntry(pMac, pEntry);
14678 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014679 }
14680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014681}
Jeff Johnson295189b2012-06-20 16:38:30 -070014682tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14683{
14684 tListElem *pEntry = NULL;
14685 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 if(!pEntry)
14688 {
14689 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014690 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 return NULL;
14692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014693 while( pEntry )
14694 {
14695 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 if(pTempStaEntry->statsMask == statsMask)
14697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014698 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 break;
14700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014701 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 return pEntry;
14704}
14705
Jeff Johnson295189b2012-06-20 16:38:30 -070014706tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14707 tANI_BOOLEAN update)
14708{
14709 tListElem *pEntry;
14710 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 if(!pEntry)
14713 {
14714 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014715 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014716 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 return NULL;
14718 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014719 while( pEntry )
14720 {
14721 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14723 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014725 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 if(update)
14727 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014728 pTempStaEntry->periodicity = pStaEntry->periodicity;
14729 pTempStaEntry->callback = pStaEntry->callback;
14730 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014731 }
14732 break;
14733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 return pEntry;
14737}
Jeff Johnson295189b2012-06-20 16:38:30 -070014738tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14739{
14740 tListElem *pEntry;
14741 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 if(!pEntry)
14744 {
14745 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014746 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014747 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014748 return NULL;
14749 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 while( pEntry )
14751 {
14752 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014755 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 break;
14757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14759 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 return pEntry;
14761}
Jeff Johnson295189b2012-06-20 16:38:30 -070014762eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14763 csrRoamLinkQualityIndCallback callback,
14764 void *pContext)
14765{
14766 pMac->roam.linkQualityIndInfo.callback = callback;
14767 pMac->roam.linkQualityIndInfo.context = pContext;
14768 if( NULL == callback )
14769 {
14770 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14771 }
14772 else
14773 {
14774 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 /* do we need to invoke the callback to notify client of initial value ?? */
14776 }
14777 return eHAL_STATUS_SUCCESS;
14778}
Jeff Johnson295189b2012-06-20 16:38:30 -070014779void csrRoamVccTrigger(tpAniSirGlobal pMac)
14780{
14781 eCsrRoamLinkQualityInd newVccLinkQuality;
14782 tANI_U32 ul_mac_loss = 0;
14783 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14785 /*-------------------------------------------------------------------------
14786 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 Check for a change in link quality and notify client if necessary
14788 -------------------------------------------------------------------------*/
14789 ul_mac_loss_trigger_threshold =
14790 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014791 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014792 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014794 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014796 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14798 }
14799 else
14800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014801 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14805 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014808 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014811 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014812 newVccLinkQuality );
14813
14814 /* we now invoke the callback once to notify client of initial value */
14815 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14816 pMac->roam.linkQualityIndInfo.context );
14817 //event: EVENT_WLAN_VCC
14818 }
14819 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 pMac->roam.vccLinkQuality = newVccLinkQuality;
14821
Jeff Johnson295189b2012-06-20 16:38:30 -070014822}
Jeff Johnson295189b2012-06-20 16:38:30 -070014823VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14824 v_U8_t rssiNotification,
14825 void * context)
14826{
14827 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14828 eCsrRoamLinkQualityInd newVccLinkQuality;
14829 // TODO : Session info unavailable
14830 tANI_U32 sessionId = 0;
14831 VOS_STATUS status = VOS_STATUS_SUCCESS;
14832 /*-------------------------------------------------------------------------
14833 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 Check for a change in link quality and notify client if necessary
14835 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014836 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 pMac->roam.configParam.vccRssiThreshold);
14838 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014840 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 return VOS_STATUS_SUCCESS;
14842 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014843 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014845 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14847 }
14848 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014850 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14852 }
14853 else
14854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014855 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 //Set to this so the code below won't do anything
14857 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 VOS_ASSERT(0);
14859 }
14860
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014863 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014866 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 /* we now invoke the callback once to notify client of initial value */
14869 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14870 pMac->roam.linkQualityIndInfo.context );
14871 //event: EVENT_WLAN_VCC
14872 }
14873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 return status;
14876}
Jeff Johnson295189b2012-06-20 16:38:30 -070014877tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14878 tDblLinkList *pStaList,
14879 tCsrStatsClientReqInfo *pStaEntry)
14880{
14881 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 //if same entity requested for same set of stats with different periodicity &
14883 // callback update it
14884 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14885 {
14886
Kiet Lam64c1b492013-07-12 13:56:44 +053014887 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14888 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 {
14890 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014891 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 return NULL;
14893 }
14894
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 pNewStaEntry->callback = pStaEntry->callback;
14896 pNewStaEntry->pContext = pStaEntry->pContext;
14897 pNewStaEntry->periodicity = pStaEntry->periodicity;
14898 pNewStaEntry->requesterId = pStaEntry->requesterId;
14899 pNewStaEntry->statsMask = pStaEntry->statsMask;
14900 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14901 pNewStaEntry->pMac = pStaEntry->pMac;
14902 pNewStaEntry->staId = pStaEntry->staId;
14903 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14904
14905 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14906 }
14907 return pNewStaEntry;
14908}
14909
Jeff Johnson295189b2012-06-20 16:38:30 -070014910tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14911 tDblLinkList *pStaList,
14912 tCsrPeStatsReqInfo *pStaEntry)
14913{
14914 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014915 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14916 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 {
14918 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014919 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 return NULL;
14921 }
14922
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14924 pNewStaEntry->numClient = pStaEntry->numClient;
14925 pNewStaEntry->periodicity = pStaEntry->periodicity;
14926 pNewStaEntry->statsMask = pStaEntry->statsMask;
14927 pNewStaEntry->pMac = pStaEntry->pMac;
14928 pNewStaEntry->staId = pStaEntry->staId;
14929 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14930 pNewStaEntry->rspPending = pStaEntry->rspPending;
14931
14932 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 return pNewStaEntry;
14934}
Jeff Johnson295189b2012-06-20 16:38:30 -070014935eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14936 tCsrRssiCallback callback,
14937 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14938{
14939 eHalStatus status = eHAL_STATUS_SUCCESS;
14940 vos_msg_t msg;
14941 tANI_U32 sessionId;
14942
14943 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014944 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014945 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14946 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014948 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014949 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14952
14953 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14954 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14955 pMsg->sessionId = sessionId;
14956 pMsg->staId = staId;
14957 pMsg->rssiCallback = callback;
14958 pMsg->pDevContext = pContext;
14959 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 msg.type = eWNI_SME_GET_RSSI_REQ;
14961 msg.bodyptr = pMsg;
14962 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014965 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014966 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 status = eHAL_STATUS_FAILURE;
14968 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014969 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 return status;
14971}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014972
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014973eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14974 tCsrSnrCallback callback,
14975 tANI_U8 staId, tCsrBssid bssId,
14976 void *pContext)
14977{
14978 eHalStatus status = eHAL_STATUS_SUCCESS;
14979 vos_msg_t msg;
14980 tANI_U32 sessionId;
14981
14982 tAniGetSnrReq *pMsg;
14983
14984 smsLog(pMac, LOG2, FL("called"));
14985
14986 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14987 if (NULL == pMsg )
14988 {
14989 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14990 return status;
14991 }
14992
14993 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14994
14995 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14996 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14997 pMsg->sessionId = sessionId;
14998 pMsg->staId = staId;
14999 pMsg->snrCallback = callback;
15000 pMsg->pDevContext = pContext;
15001 msg.type = eWNI_SME_GET_SNR_REQ;
15002 msg.bodyptr = pMsg;
15003 msg.reserved = 0;
15004
15005 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15006 {
15007 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15008 vos_mem_free((v_VOID_t *)pMsg);
15009 status = eHAL_STATUS_FAILURE;
15010 }
15011
15012 smsLog(pMac, LOG2, FL("returned"));
15013 return status;
15014}
15015
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015016#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15017eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15018 tCsrRssiCallback callback,
15019 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15020{
15021 eHalStatus status = eHAL_STATUS_SUCCESS;
15022 tAniGetRssiReq *pMsg;
15023
Kiet Lam64c1b492013-07-12 13:56:44 +053015024 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15025 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015026 {
15027 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053015028 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015029 }
15030 // need to initiate a stats request to PE
15031 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15032 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15033 pMsg->staId = staId;
15034 pMsg->rssiCallback = callback;
15035 pMsg->pDevContext = pContext;
15036 pMsg->pVosContext = pVosContext;
15037 status = palSendMBMessage(pMac->hHdd, pMsg );
15038 if(!HAL_STATUS_SUCCESS(status))
15039 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015040 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15041 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015042 status = eHAL_STATUS_FAILURE;
15043 }
15044 return status;
15045}
15046#endif
15047
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015048
15049
15050#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15051eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15052 tCsrTsmStatsCallback callback,
15053 tANI_U8 staId,
15054 tCsrBssid bssId,
15055 void *pContext,
15056 void* pVosContext,
15057 tANI_U8 tid)
15058{
15059 eHalStatus status = eHAL_STATUS_SUCCESS;
15060 tAniGetTsmStatsReq *pMsg = NULL;
15061
15062 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15063 if ( !HAL_STATUS_SUCCESS(status) )
15064 {
15065 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15066 return status;
15067 }
15068 // need to initiate a stats request to PE
15069 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15070 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15071 pMsg->staId = staId;
15072 pMsg->tid = tid;
15073 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15074 pMsg->tsmStatsCallback = callback;
15075 pMsg->pDevContext = pContext;
15076 pMsg->pVosContext = pVosContext;
15077 status = palSendMBMessage(pMac->hHdd, pMsg );
15078 if(!HAL_STATUS_SUCCESS(status))
15079 {
15080 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15081 //pMsg is freed by palSendMBMessage
15082 status = eHAL_STATUS_FAILURE;
15083 }
15084 return status;
15085}
15086#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15087
15088
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015089/* ---------------------------------------------------------------------------
15090 \fn csrGetTLSTAState
15091 \helper function to get teh TL STA State whenever the function is called.
15092
15093 \param staId - The staID to be passed to the TL
15094 to get the relevant TL STA State
15095 \return the state as tANI_U16
15096 ---------------------------------------------------------------------------*/
15097tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15098{
15099 WLANTL_STAStateType tlSTAState;
15100 tlSTAState = WLANTL_STA_INIT;
15101
15102 //request TL for STA State
15103 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15104 {
15105 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15106 }
15107
15108 return tlSTAState;
15109}
15110
Jeff Johnson295189b2012-06-20 16:38:30 -070015111eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15112 tANI_U32 statsMask,
15113 tCsrStatsCallback callback,
15114 tANI_U32 periodicity, tANI_BOOLEAN cache,
15115 tANI_U8 staId, void *pContext)
15116{
15117 tCsrStatsClientReqInfo staEntry;
15118 tCsrStatsClientReqInfo *pStaEntry = NULL;
15119 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15120 tListElem *pEntry = NULL;
15121 tANI_BOOLEAN found = FALSE;
15122 eHalStatus status = eHAL_STATUS_SUCCESS;
15123 tANI_BOOLEAN insertInClientList = FALSE;
15124 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015125 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015126
15127 if( csrIsAllSessionDisconnected(pMac) )
15128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015129 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 return eHAL_STATUS_FAILURE;
15131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 if((!statsMask) && (!callback))
15133 {
15134 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015135 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 return eHAL_STATUS_FAILURE;
15137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015138 //for the search list method for deregister
15139 staEntry.requesterId = requesterId;
15140 staEntry.statsMask = statsMask;
15141 //requester wants to deregister or just an error
15142 if((statsMask) && (!callback))
15143 {
15144 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15145 if(!pEntry)
15146 {
15147 //msg
15148 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015149 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 return eHAL_STATUS_FAILURE;
15151 }
15152 else
15153 {
15154 //clean up & return
15155 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015156 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015158 pStaEntry->pPeStaEntry->numClient--;
15159 //check if we need to delete the entry from peStatsReqList too
15160 if(!pStaEntry->pPeStaEntry->numClient)
15161 {
15162 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015165
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 //check if we need to stop the tl stats timer too
15167 pMac->roam.tlStatsReqInfo.numClient--;
15168 if(!pMac->roam.tlStatsReqInfo.numClient)
15169 {
15170 if(pMac->roam.tlStatsReqInfo.timerRunning)
15171 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015172 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15173 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 return eHAL_STATUS_FAILURE;
15177 }
15178 }
15179 pMac->roam.tlStatsReqInfo.periodicity = 0;
15180 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15181 }
15182 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 // Destroy the vos timer...
15184 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15185 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015187 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015189 csrRoamRemoveStatListEntry(pMac, pEntry);
15190 pStaEntry = NULL;
15191 return eHAL_STATUS_SUCCESS;
15192 }
15193 }
15194
15195 if(cache && !periodicity)
15196 {
15197 //return the cached stats
15198 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15199 }
15200 else
15201 {
15202 //add the request in the client req list
15203 staEntry.callback = callback;
15204 staEntry.pContext = pContext;
15205 staEntry.periodicity = periodicity;
15206 staEntry.pPeStaEntry = NULL;
15207 staEntry.staId = staId;
15208 staEntry.pMac = pMac;
15209 staEntry.timerExpired = FALSE;
15210
15211
Jeff Johnson295189b2012-06-20 16:38:30 -070015212 //if periodic report requested with non cached result from PE/TL
15213 if(periodicity)
15214 {
15215
15216 //if looking for stats from PE
15217 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15218 {
15219
15220 //check if same request made already & waiting for rsp
15221 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15222 periodicity, &found, staId);
15223 if(!pPeStaEntry)
15224 {
15225 //bail out, maxed out on number of req for PE
15226 return eHAL_STATUS_FAILURE;
15227 }
15228 else
15229 {
15230 staEntry.pPeStaEntry = pPeStaEntry;
15231 }
15232
15233 }
15234 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15235 if(statsMask & (1 << eCsrGlobalClassDStats))
15236 {
15237 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015239 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015240 }
15241 else
15242 {
15243
15244 //update periodicity
15245 if(pMac->roam.tlStatsReqInfo.periodicity)
15246 {
15247 pMac->roam.tlStatsReqInfo.periodicity =
15248 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15249 }
15250 else
15251 {
15252 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15253 }
15254 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15255 {
15256 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15257 }
15258
15259 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15260 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015261 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015262 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015263 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015264 //req TL for class D stats
15265 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015267 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015268 }
15269 else
15270 {
15271 //save in SME
15272 csrRoamSaveStatsFromTl(pMac, pTlStats);
15273 }
15274 vos_mem_free(pTlStats);
15275 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015276 }
15277 else
15278 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015279 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015280 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015281
Jeff Johnson295189b2012-06-20 16:38:30 -070015282 if(pMac->roam.tlStatsReqInfo.periodicity)
15283 {
15284 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015285 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15286 pMac->roam.tlStatsReqInfo.periodicity);
15287 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015289 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 return eHAL_STATUS_FAILURE;
15291 }
15292 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15293 }
15294 }
15295 }
15296 pMac->roam.tlStatsReqInfo.numClient++;
15297 }
15298
15299 insertInClientList = TRUE;
15300 }
15301 //if one time report requested with non cached result from PE/TL
15302 else if(!cache && !periodicity)
15303 {
15304 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15305 {
15306 //send down a req
15307 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15308 if(!HAL_STATUS_SUCCESS(status))
15309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015310 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 }
15312 //so that when the stats rsp comes back from PE we respond to upper layer
15313 //right away
15314 staEntry.timerExpired = TRUE;
15315 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 }
15317 if(statsMask & (1 << eCsrGlobalClassDStats))
15318 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015319 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015320 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015322 //req TL for class D stats
15323 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015325 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015326 }
15327 else
15328 {
15329 //save in SME
15330 csrRoamSaveStatsFromTl(pMac, pTlStats);
15331 }
15332 vos_mem_free(pTlStats);
15333 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015334 }
15335 else
15336 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015337 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015339
15340 }
15341 //if looking for stats from TL only
15342 if(!insertInClientList)
15343 {
15344 //return the stats
15345 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 if(insertInClientList)
15349 {
15350 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15351 if(!pStaEntry)
15352 {
15353 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015354 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 return eHAL_STATUS_FAILURE;
15356 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015357 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015358 //Init & start timer if needed
15359 if(periodicity)
15360 {
15361 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15362 csrRoamStatsClientTimerHandler, pStaEntry );
15363 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015365 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 return eHAL_STATUS_FAILURE;
15367 }
15368 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15369 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015371 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 return eHAL_STATUS_FAILURE;
15373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 }
15377 return eHAL_STATUS_SUCCESS;
15378}
15379
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015380#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15381
15382static tSirRetStatus
15383csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15384 tANI_U8* pBD,
15385 tANI_U8 type,
15386 tANI_U8 subType,
15387 tSirMacAddr peerAddr,
15388 tSirMacAddr selfMacAddr)
15389{
15390 tSirRetStatus statusCode = eSIR_SUCCESS;
15391 tpSirMacMgmtHdr pMacHdr;
15392
15393 /* Prepare MAC management header */
15394 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15395
15396 /* Prepare FC */
15397 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15398 pMacHdr->fc.type = type;
15399 pMacHdr->fc.subType = subType;
15400
15401 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015402 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15403 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015404
15405 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15406
15407 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015408 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15409 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015410 return statusCode;
15411} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15412
15413static tSirRetStatus
15414csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15415 tANI_U8 nChannelNum,
15416 tANI_U32 dot11mode,
15417 tSirMacAddr selfMacAddr,
15418 tANI_U8 *pFrame,
15419 tANI_U16 *pusLen)
15420{
15421 tDot11fProbeRequest pr;
15422 tANI_U32 nStatus, nBytes, nPayload;
15423 tSirRetStatus nSirStatus;
15424 /*Bcast tx*/
15425 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15426 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15427
15428
Kiet Lam64c1b492013-07-12 13:56:44 +053015429 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015430
15431 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15432
15433 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15434 {
15435 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15436 }
15437
15438
15439 if (IS_DOT11_MODE_HT(dot11mode))
15440 {
15441 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15442 }
15443
15444
15445 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15446 if ( DOT11F_FAILED( nStatus ) )
15447 {
15448 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15449 "Failed to calculate the packed size f"
15450 "or a Probe Request (0x%08x).\n", nStatus );
15451
15452
15453 nPayload = sizeof( tDot11fProbeRequest );
15454 }
15455 else if ( DOT11F_WARNED( nStatus ) )
15456 {
15457 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15458 "There were warnings while calculating"
15459 "the packed size for a Probe Request ("
15460 "0x%08x).\n", nStatus );
15461 }
15462
15463 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15464
15465 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015466 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015467
15468
15469 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015470 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015471
15472 if ( eSIR_SUCCESS != nSirStatus )
15473 {
15474 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15475 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15476 nSirStatus );
15477 return nSirStatus;
15478 }
15479
15480
15481 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15482 sizeof( tSirMacMgmtHdr ),
15483 nPayload, &nPayload );
15484 if ( DOT11F_FAILED( nStatus ) )
15485 {
15486 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15487 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15488 return eSIR_FAILURE;
15489 }
15490 else if ( DOT11F_WARNED( nStatus ) )
15491 {
15492 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015493 "There were warnings while packing a Probe Request (0x%08x).\n",
15494 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015495 }
15496
15497 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15498 return eSIR_SUCCESS;
15499}
15500
15501eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15502{
15503 vos_msg_t msg;
15504 tSirRoamOffloadScanReq *pRequestBuf;
15505 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15506 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015507 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015508 tANI_U8 *ChannelList = NULL;
15509 tANI_U32 sessionId;
15510 eHalStatus status = eHAL_STATUS_SUCCESS;
15511 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015512 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015513 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015514 eCsrBand eBand;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015515 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15516
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015517 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015518 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015519 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015520 return eHAL_STATUS_FAILURE;
15521 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015522
15523 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15524 {
15525 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15526 return eHAL_STATUS_FAILURE;
15527 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015528 status = csrRoamGetSessionIdFromBSSID(pMac,
15529 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15530 &sessionId);
15531 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15532 * It is important to ensure that the command is passed down to the FW only
15533 * if the Infra Station is in a connected state.A connected station could also be
15534 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15535 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15536 * irrespective of whichever state we are in.*/
15537 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15538 (command != ROAM_SCAN_OFFLOAD_STOP))
15539 {
15540 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15541 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15542 return eHAL_STATUS_FAILURE;
15543 }
15544
15545 if ( !HAL_STATUS_SUCCESS( status ) )
15546 {
15547 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15548 return eHAL_STATUS_FAILURE;
15549 }
15550 pSession = CSR_GET_SESSION( pMac, sessionId );
15551 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15552 if (NULL == pRequestBuf)
15553 {
15554 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15555 return eHAL_STATUS_FAILED_ALLOC;
15556 }
15557
Kiet Lam64c1b492013-07-12 13:56:44 +053015558 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015559 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15560 * host driver reloads, but Riva still up and running*/
15561 if(command == ROAM_SCAN_OFFLOAD_STOP)
15562 pRequestBuf->RoamScanOffloadEnabled = 0;
15563 else
15564 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015565 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15566 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015567 sizeof(tCsrBssid));
15568 pRequestBuf->ConnectedNetwork.ssId.length =
15569 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15570 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15571 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15572 pRequestBuf->ConnectedNetwork.ssId.length);
15573 pRequestBuf->ConnectedNetwork.authentication =
15574 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15575 pRequestBuf->ConnectedNetwork.encryption =
15576 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15577 pRequestBuf->ConnectedNetwork.mcencryption =
15578 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15579 pRequestBuf->LookupThreshold =
15580 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15581 pRequestBuf->RoamRssiDiff =
15582 pMac->roam.configParam.RoamRssiDiff;
15583 pRequestBuf->Command = command;
15584 pRequestBuf->StartScanReason = reason;
15585 pRequestBuf->NeighborScanTimerPeriod =
15586 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15587 pRequestBuf->NeighborRoamScanRefreshPeriod =
15588 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15589 pRequestBuf->NeighborScanChannelMinTime =
15590 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15591 pRequestBuf->NeighborScanChannelMaxTime =
15592 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15593 pRequestBuf->EmptyRefreshScanPeriod =
15594 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015595 /* MAWC feature */
15596 pRequestBuf->MAWCEnabled =
15597 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015598#ifdef FEATURE_WLAN_CCX
15599 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15600#endif
15601 if (
15602#ifdef FEATURE_WLAN_CCX
15603 ((pNeighborRoamInfo->isCCXAssoc) &&
15604 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15605 eANI_BOOLEAN_FALSE)) ||
15606 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15607#endif // CCX
15608 currChannelListInfo->numOfChannels == 0)
15609 {
15610
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015611 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15612 * Give Preference to INI Channels.*/
15613 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15614 {
15615 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15616 /*The INI channels need to be filtered with respect to the current
15617 * band that is supported.*/
15618 eBand = pMac->roam.configParam.bandCapability;
15619 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015620 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015621 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15622 "Invalid band, No operation carried out (Band %d)", eBand);
15623 vos_mem_free(pRequestBuf);
15624 return eHAL_STATUS_FAILURE;
15625 }
15626 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15627 {
15628 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15629 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15630 (eCSR_BAND_ALL == eBand))
15631 {
15632 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15633 csrRoamIsChannelValid(pMac, *ChannelList) &&
15634 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15635 {
15636 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15637 }
15638 }
15639 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015640 }
15641 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15642 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015643 }
15644 else
15645 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015646 ChannelList = pMac->scan.occupiedChannels.channelList;
15647 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15648 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015649 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15650 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15651 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015652 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015653 }
15654 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015655 }
15656 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15657 /* If the profile changes as to what it was earlier, inform the FW through
15658 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15659 * for the earlier profile and try to learn them afresh.*/
15660 if (reason == REASON_FLUSH_CHANNEL_LIST)
15661 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15662 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015663 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15664 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15665 else
15666 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015667 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015668 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015669 }
15670#ifdef FEATURE_WLAN_CCX
15671 else
15672 {
15673 /* If CCX is enabled, and a neighbor Report is received,then
15674 * Ignore the INI Channels or the Occupied Channel List. Consider
15675 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015676 if (currChannelListInfo->numOfChannels != 0)
15677 {
15678 ChannelList = currChannelListInfo->ChannelList;
15679 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015680 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015681 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15682 {
15683 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15684 }
15685 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015686 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015687 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15688 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15689 }
15690 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015691#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015692 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15693 {
15694 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15695 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15696 }
15697 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15698 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15699 pRequestBuf->ChannelCacheType,
15700 pRequestBuf->ConnectedNetwork.ChannelCount,
15701 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015702 num_channels = 0;
15703 ChannelList = NULL;
15704
15705 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015706 host_channels = sizeof(pMac->roam.validChannelList);
15707 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015708 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015709 ChannelList = pMac->roam.validChannelList;
15710 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015711 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015712 else
15713 {
15714 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15715 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015716 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015717 return eHAL_STATUS_FAILURE;
15718 }
15719 for(i=0; i<pMac->roam.numValidChannels; i++)
15720 {
15721 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15722 {
15723 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15724 }
15725 ChannelList++;
15726 }
15727 pRequestBuf->ValidChannelCount = num_channels;
15728
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015729 pRequestBuf->MDID.mdiePresent =
15730 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15731 pRequestBuf->MDID.mobilityDomain =
15732 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015733 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15734
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015735 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015736 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
15737 * where RFS is the RF Switching time. It is twice RFS to consider the
15738 * time to go off channel and return to the home channel. */
15739 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
15740 {
15741 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
15742 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
15743 " Hence enforcing home away time to disable (0)",
15744 __func__, pRequestBuf->HomeAwayTime,
15745 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
15746 pRequestBuf->HomeAwayTime = 0;
15747 }
15748 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015749
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015750 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15751 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15752 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15753 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15754 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15755
15756 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15757 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015758 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015759 msg.reserved = 0;
15760 msg.bodyptr = pRequestBuf;
15761 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15762 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015763 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15764 vos_mem_free(pRequestBuf);
15765 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015766 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015767 else
15768 {
15769 if (ROAM_SCAN_OFFLOAD_START == command)
15770 bRoamScanOffloadStarted = VOS_TRUE;
15771 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15772 bRoamScanOffloadStarted = VOS_FALSE;
15773 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015774
15775 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15776 return status;
15777}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015778
15779eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15780{
15781 switch(reason)
15782 {
15783 case 0:
15784 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15785 break;
15786 case REASON_OS_REQUESTED_ROAMING_NOW:
15787 csrNeighborRoamProceedWithHandoffReq(pMac);
15788 break;
15789 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015790 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 -070015791 }
15792 return eHAL_STATUS_SUCCESS;
15793}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015794#endif
15795
Jeff Johnson295189b2012-06-20 16:38:30 -070015796tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15797 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15798{
15799 tANI_BOOLEAN found = FALSE;
15800 eHalStatus status = eHAL_STATUS_SUCCESS;
15801 tCsrPeStatsReqInfo staEntry;
15802 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15803 tListElem *pStaEntry = NULL;
15804 VOS_STATUS vosStatus;
15805 tPmcPowerState powerState;
15806 *pFound = FALSE;
15807
15808 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15809 if(pStaEntry)
15810 {
15811 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15812 if(pTempStaEntry->periodicity)
15813 {
15814 pTempStaEntry->periodicity =
15815 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15816 }
15817 else
15818 {
15819 pTempStaEntry->periodicity = periodicity;
15820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 pTempStaEntry->numClient++;
15822 found = TRUE;
15823 }
15824 else
15825 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015826 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015827 staEntry.numClient = 1;
15828 staEntry.periodicity = periodicity;
15829 staEntry.pMac = pMac;
15830 staEntry.rspPending = FALSE;
15831 staEntry.staId = staId;
15832 staEntry.statsMask = statsMask;
15833 staEntry.timerRunning = FALSE;
15834 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15835 if(!pTempStaEntry)
15836 {
15837 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015838 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 return NULL;
15840 }
15841 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15843 if(ePMC_FULL_POWER == powerState)
15844 {
15845 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15846 {
15847 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15848 }
15849 }
15850 else
15851 {
15852 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15853 {
15854 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15855 }
15856 }
15857 if(!pTempStaEntry->timerRunning)
15858 {
15859 //send down a req in case of one time req, for periodic ones wait for timer to expire
15860 if(!pTempStaEntry->rspPending &&
15861 !pTempStaEntry->periodicity)
15862 {
15863 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15864 if(!HAL_STATUS_SUCCESS(status))
15865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015866 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015867 }
15868 else
15869 {
15870 pTempStaEntry->rspPending = TRUE;
15871 }
15872 }
15873 if(pTempStaEntry->periodicity)
15874 {
15875 if(!found)
15876 {
15877
15878 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15879 csrRoamPeStatsTimerHandler, pTempStaEntry );
15880 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015882 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015883 return NULL;
15884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015885 }
15886 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015887 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015888 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15889 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015891 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015892 return NULL;
15893 }
15894 pTempStaEntry->timerRunning = TRUE;
15895 }
15896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015897 *pFound = found;
15898 return pTempStaEntry;
15899}
15900
Jeff Johnson295189b2012-06-20 16:38:30 -070015901/*
15902 pStaEntry is no longer invalid upon the return of this function.
15903*/
15904static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15905{
15906 if(pEntry)
15907 {
15908 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15909 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015910 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015912 }
15913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015914
15915void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15916{
15917 tListElem *pEntry;
15918 tCsrPeStatsReqInfo *pTempStaEntry;
15919 VOS_STATUS vosStatus;
15920 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015921 if(!pEntry)
15922 {
15923 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015924 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015925 return;
15926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015927 while( pEntry )
15928 {
15929 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15931 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015932 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015933 if(pTempStaEntry->timerRunning)
15934 {
15935 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15936 /* If we are not able to stop the timer here, just remove
15937 * the entry from the linked list. Destroy the timer object
15938 * and free the memory in the timer CB
15939 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015940 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 {
15942 /* the timer is successfully stopped */
15943 pTempStaEntry->timerRunning = FALSE;
15944
15945 /* Destroy the timer */
15946 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15947 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015949 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015950 }
15951 }
15952 else
15953 {
15954 // the timer could not be stopped. Hence destroy and free the
15955 // memory for the PE stat entry in the timer CB.
15956 pTempStaEntry->timerStopFailed = TRUE;
15957 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015959
15960 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15961 {
15962 // Only free the memory if we could stop the timer successfully
15963 if(!pTempStaEntry->timerStopFailed)
15964 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015965 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015966 pTempStaEntry = NULL;
15967 }
15968 break;
15969 }
15970
15971 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15972 }
15973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 return;
15975}
15976
15977
Jeff Johnsone7245742012-09-05 17:12:55 -070015978void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015979{
15980
Jeff Johnsone7245742012-09-05 17:12:55 -070015981 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15982 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15983 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15984 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15985 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15986 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15987 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015989 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15990 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15991 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15992 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15993 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15994 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015996 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15997 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015998
15999}
16000
Jeff Johnson295189b2012-06-20 16:38:30 -070016001void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16002 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16003{
16004 tANI_U8 stats[500];
16005 tANI_U8 *pStats = NULL;
16006 tANI_U32 tempMask = 0;
16007 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 if(!callback)
16009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016010 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016011 return;
16012 }
16013 if(!statsMask)
16014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016015 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 return;
16017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016018 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016020 while(tempMask)
16021 {
16022 if(tempMask & 1)
16023 {
16024 //new stats info from PE, fill up the stats strucutres in PMAC
16025 switch(counter)
16026 {
16027 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016028 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016029 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16030 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016031 pStats += sizeof(tCsrSummaryStatsInfo);
16032 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016034 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016035 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16036 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016037 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016040 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016041 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16042 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016045 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016046 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016047 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16048 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016049 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016050 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016051 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016052 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016053 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16054 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016055 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016056 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016057 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016058 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016059 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16060 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016061 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016062 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016063 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016064 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016065 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 }
16067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016068 tempMask >>=1;
16069 counter++;
16070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016072}
16073
Jeff Johnson295189b2012-06-20 16:38:30 -070016074eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16075{
16076 tListElem *pEntry = NULL;
16077 tListElem *pPrevEntry = NULL;
16078 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16079 eHalStatus status = eHAL_STATUS_SUCCESS;
16080 VOS_STATUS vosStatus;
16081 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016082 if(!pEntry)
16083 {
16084 //list empty
16085 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016086 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 return status;
16088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016089 while( pEntry )
16090 {
16091 if(pPrevEntry)
16092 {
16093 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16094 //send up the stats report
16095 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16096 pTempStaEntry->staId, pTempStaEntry->pContext);
16097 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016099 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016100 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16101 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016102 pTempStaEntry->pPeStaEntry->numClient--;
16103 //check if we need to delete the entry from peStatsReqList too
16104 if(!pTempStaEntry->pPeStaEntry->numClient)
16105 {
16106 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016108 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016109 //check if we need to stop the tl stats timer too
16110 pMac->roam.tlStatsReqInfo.numClient--;
16111 if(!pMac->roam.tlStatsReqInfo.numClient)
16112 {
16113 if(pMac->roam.tlStatsReqInfo.timerRunning)
16114 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016115 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16116 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016117 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016118 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016119 //we will continue
16120 }
16121 }
16122 pMac->roam.tlStatsReqInfo.periodicity = 0;
16123 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16124 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016125 if (pTempStaEntry->periodicity)
16126 {
16127 //While creating StaEntry in csrGetStatistics,
16128 //Initializing and starting timer only when periodicity is set.
16129 //So Stop and Destroy timer only when periodicity is set.
16130
Jeff Johnsone7245742012-09-05 17:12:55 -070016131 vos_timer_stop( &pTempStaEntry->timer );
16132 // Destroy the vos timer...
16133 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16134 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016136 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016138 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016139
Jeff Johnson295189b2012-06-20 16:38:30 -070016140
16141 pPrevEntry = pEntry;
16142 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16143 }
16144 //the last one
16145 if(pPrevEntry)
16146 {
16147 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16148 //send up the stats report
16149 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16150 pTempStaEntry->staId, pTempStaEntry->pContext);
16151 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016153 return status;
16154
16155}
16156
Jeff Johnson295189b2012-06-20 16:38:30 -070016157eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16158 tRequestFullPowerReason *pReason,
16159 tANI_BOOLEAN *pfNeedPower )
16160{
16161 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16162 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16163 tPmcState pmcState;
16164 eHalStatus status = eHAL_STATUS_SUCCESS;
16165 // TODO : Session info unavailable
16166 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016167 if( pfNeedPower )
16168 {
16169 *pfNeedPower = eANI_BOOLEAN_FALSE;
16170 }
16171 //We only handle CSR commands
16172 if( !(eSmeCsrCommandMask & pCommand->command) )
16173 {
16174 return eHAL_STATUS_SUCCESS;
16175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016176 //Check PMC state first
16177 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016178 switch( pmcState )
16179 {
16180 case REQUEST_IMPS:
16181 case IMPS:
16182 if( eSmeCommandScan == pCommand->command )
16183 {
16184 switch( pCommand->u.scanCmd.reason )
16185 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016186#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16187 case eCsrScanGetLfrResult:
16188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016189 case eCsrScanGetResult:
16190 case eCsrScanBGScanAbort:
16191 case eCsrScanBGScanEnable:
16192 case eCsrScanGetScanChnInfo:
16193 //Internal process, no need for full power
16194 fNeedFullPower = eANI_BOOLEAN_FALSE;
16195 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016196 default:
16197 //Other scans are real scan, ask for power
16198 fNeedFullPower = eANI_BOOLEAN_TRUE;
16199 break;
16200 } //switch
16201 }
16202 else
16203 {
16204 //ask for power for roam and status change
16205 fNeedFullPower = eANI_BOOLEAN_TRUE;
16206 }
16207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016208 case REQUEST_BMPS:
16209 case BMPS:
16210 case REQUEST_START_UAPSD:
16211 case UAPSD:
16212 //We treat WOWL same as BMPS
16213 case REQUEST_ENTER_WOWL:
16214 case WOWL:
16215 if( eSmeCommandRoam == pCommand->command )
16216 {
16217 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16218 tCsrScanResult *pScanResult;
16219 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016220 switch ( pCommand->u.roamCmd.roamReason )
16221 {
16222 case eCsrForcedDisassoc:
16223 case eCsrForcedDisassocMICFailure:
16224 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16225 fNeedFullPower = eANI_BOOLEAN_TRUE;
16226 break;
16227 case eCsrSmeIssuedDisassocForHandoff:
16228 case eCsrForcedDeauth:
16229 case eCsrHddIssuedReassocToSameAP:
16230 case eCsrSmeIssuedReassocToSameAP:
16231 fNeedFullPower = eANI_BOOLEAN_TRUE;
16232 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016233 case eCsrCapsChange:
16234 fNeedFullPower = eANI_BOOLEAN_TRUE;
16235 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016236 default:
16237 //Check whether the profile is already connected. If so, no need for full power
16238 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16239 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16240 {
16241 //Only need to check the first one
16242 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16243 if( pEntry )
16244 {
16245 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16246#if 0
16247 // TODO : Session Specific info pConnectBssDesc
16248 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16249 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16250 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16251 {
16252 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16253 // with Authenticating first. To force this, stop the current association (Disassociate) and
16254 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16255 // a new Association.
16256 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16257 {
16258 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16259 {
16260 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16261 //No need for full power
16262 //Set the flag so the code later can avoid to do the above
16263 //check again.
16264 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16265 break;
16266 }
16267 }
16268 }
16269#endif
16270 }
16271 }
16272 //If we are here, full power is needed
16273 fNeedFullPower = eANI_BOOLEAN_TRUE;
16274 break;
16275 }
16276 }
16277 else if( eSmeCommandWmStatusChange == pCommand->command )
16278 {
16279 //need full power for all
16280 fNeedFullPower = eANI_BOOLEAN_TRUE;
16281 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16282 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016283#ifdef FEATURE_WLAN_TDLS
16284 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16285 {
16286 //TDLS link is getting established. need full power
16287 fNeedFullPower = eANI_BOOLEAN_TRUE;
16288 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16289 }
16290#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016292 case REQUEST_STOP_UAPSD:
16293 case REQUEST_EXIT_WOWL:
16294 if( eSmeCommandRoam == pCommand->command )
16295 {
16296 fNeedFullPower = eANI_BOOLEAN_TRUE;
16297 switch ( pCommand->u.roamCmd.roamReason )
16298 {
16299 case eCsrForcedDisassoc:
16300 case eCsrForcedDisassocMICFailure:
16301 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16302 break;
16303 default:
16304 break;
16305 }
16306 }
16307 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016308 case STOPPED:
16309 case REQUEST_STANDBY:
16310 case STANDBY:
16311 case LOW_POWER:
16312 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016313 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016314 status = eHAL_STATUS_FAILURE;
16315 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 case FULL_POWER:
16317 case REQUEST_FULL_POWER:
16318 default:
16319 //No need to ask for full power. This has to be FULL_POWER state
16320 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 if( pReason )
16323 {
16324 *pReason = reason;
16325 }
16326 if( pfNeedPower )
16327 {
16328 *pfNeedPower = fNeedFullPower;
16329 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 return ( status );
16331}
16332
Jeff Johnson295189b2012-06-20 16:38:30 -070016333static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16334{
16335 eHalStatus status = eHAL_STATUS_SUCCESS;
16336 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16337 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016339 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16340 {
16341 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016343 return ( status );
16344}
16345
Jeff Johnson295189b2012-06-20 16:38:30 -070016346tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16347{
16348 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 if( pCmd )
16350 {
16351 pMac->roam.sPendingCommands++;
16352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016353 return ( pCmd );
16354}
16355
Jeff Johnson295189b2012-06-20 16:38:30 -070016356void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16357{
16358 if (pMac->roam.sPendingCommands > 0)
16359 {
16360 //All command allocated through csrGetCommandBuffer need to
16361 //decrement the pending count when releasing.
16362 pMac->roam.sPendingCommands--;
16363 smeReleaseCommand( pMac, pCommand );
16364 }
16365 else
16366 {
16367 smsLog(pMac, LOGE, FL( "no pending commands"));
16368 VOS_ASSERT(0);
16369 }
16370}
16371
Jeff Johnson295189b2012-06-20 16:38:30 -070016372//Return SUCCESS is the command is queued, failed
16373eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16374{
16375 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16377 {
16378 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16379 pCommand->u.scanCmd.reason);
16380 return eHAL_STATUS_CSR_WRONG_STATE;
16381 }
16382
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016383 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16384 {
16385 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16386 &pCommand->Link, LL_ACCESS_LOCK);
16387 // process the command queue...
16388 smeProcessPendingQueue(pMac);
16389 status = eHAL_STATUS_SUCCESS;
16390 goto end;
16391 }
16392
Jeff Johnson295189b2012-06-20 16:38:30 -070016393 //We can call request full power first before putting the command into pending Q
16394 //because we are holding SME lock at this point.
16395 status = csrRequestFullPower( pMac, pCommand );
16396 if( HAL_STATUS_SUCCESS( status ) )
16397 {
16398 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016399 //make sure roamCmdPendingList is not empty first
16400 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16401 if( fNoCmdPending )
16402 {
16403 smePushCommand( pMac, pCommand, fHighPriority );
16404 }
16405 else
16406 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016407 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 //no list lock is needed since SME lock is held
16409 if( !fHighPriority )
16410 {
16411 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16412 }
16413 else {
16414 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16415 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 }
16418 else if( eHAL_STATUS_PMC_PENDING == status )
16419 {
16420 //no list lock is needed since SME lock is held
16421 if( !fHighPriority )
16422 {
16423 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16424 }
16425 else {
16426 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16427 }
16428 //Let caller know the command is queue
16429 status = eHAL_STATUS_SUCCESS;
16430 }
16431 else
16432 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016433 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016434 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016435 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016436 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016437end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016438 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016439}
Jeff Johnson295189b2012-06-20 16:38:30 -070016440eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16441{
16442 eHalStatus status = eHAL_STATUS_SUCCESS;
16443 tSirUpdateAPWPSIEsReq *pMsg;
16444 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16445
16446 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16447 if (NULL == pSession)
16448 {
16449 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16450 return eHAL_STATUS_FAILURE;
16451 }
16452
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 do
16454 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016455 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16456 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16457 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16459
16460 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016461 VOS_ASSERT(pBuf);
16462
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016464 // transactionId
16465 *pBuf = 0;
16466 *( pBuf + 1 ) = 0;
16467 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016469 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16470 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 //sessionId
16473 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016474 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016475 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016476 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016477 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016478 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016479 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016480 return ( status );
16481}
Jeff Johnson295189b2012-06-20 16:38:30 -070016482eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16483{
16484 eHalStatus status = eHAL_STATUS_SUCCESS;
16485 tSirUpdateAPWPARSNIEsReq *pMsg;
16486 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16488 if (NULL == pSession)
16489 {
16490 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16491 return eHAL_STATUS_FAILURE;
16492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016493 do
16494 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016495 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16496 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16497 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 pBuf = (tANI_U8 *)&pMsg->transactionId;
16500 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 // transactionId
16502 *pBuf = 0;
16503 *( pBuf + 1 ) = 0;
16504 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016505 VOS_ASSERT(pBuf);
16506
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016508 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16509 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016510 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016511 // sessionId
16512 *pBuf++ = (tANI_U8)sessionId;
16513
16514 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016515 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016517 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016518 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016519 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 return ( status );
16521}
Jeff Johnson295189b2012-06-20 16:38:30 -070016522
16523#ifdef WLAN_FEATURE_VOWIFI_11R
16524//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16525eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16526{
16527 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16528 tpSirFTPreAuthReq pftPreAuthReq;
16529 tANI_U16 auth_req_len = 0;
16530 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016531 auth_req_len = sizeof(tSirFTPreAuthReq);
16532 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016533 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 {
16535 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16536 return eHAL_STATUS_RESOURCES;
16537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016538 // Save the SME Session ID here. We need it while processing the preauth response
16539 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016540 vos_mem_zero(pftPreAuthReq, auth_req_len);
16541
16542 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16543 sizeof(pBssDescription->length) + pBssDescription->length);
16544
16545 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16546
16547 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16548
Kiet Lam64c1b492013-07-12 13:56:44 +053016549 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16550 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16551 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16552 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016553
Jeff Johnson295189b2012-06-20 16:38:30 -070016554#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016555 if (csrRoamIs11rAssoc(pMac) &&
16556 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016557 {
16558 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016559 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16560 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 }
16562 else
16563#endif
16564 {
16565 pftPreAuthReq->ft_ies_length = 0;
16566 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016567 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16568 sizeof(pBssDescription->length) + pBssDescription->length);
16569 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016570 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16571}
Jeff Johnson295189b2012-06-20 16:38:30 -070016572/*--------------------------------------------------------------------------
16573 * This will receive and process the FT Pre Auth Rsp from the current
16574 * associated ap.
16575 *
16576 * This will invoke the hdd call back. This is so that hdd can now
16577 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16578 ------------------------------------------------------------------------*/
16579void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16580{
16581 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16582 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016583#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016584 tCsrRoamInfo roamInfo;
16585#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016586
16587#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016588 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016589#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016590#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016591 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016592 if (status != eHAL_STATUS_SUCCESS) {
16593 /*
16594 * Bail out if pre-auth was not even processed.
16595 */
16596 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16597 return;
16598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016599#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016600 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16601 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16602 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 // Implies a success
16604 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16606 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016607 /* No need to notify qos module if this is a non 11r roam*/
16608 if (csrRoamIs11rAssoc(pMac))
16609 {
16610 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016612 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16613 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016614 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16615 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016616 if (eHAL_STATUS_SUCCESS != status)
16617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016618 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016619 return;
16620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016621 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016622 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16623 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016624 if (csrRoamIs11rAssoc(pMac))
16625 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16626 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16627
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016628#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16629 if (csrRoamIsCCXAssoc(pMac))
16630 {
16631 /* read TSF */
16632 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16633
16634 // Save the bssid from the received response
16635 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16636 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16637 }
16638#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016639#ifdef FEATURE_WLAN_LFR
16640 // If Legacy Fast Roaming is enabled, signal the supplicant
16641 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016642 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016643 {
16644 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016645 vos_mem_copy((void *)&roamInfo.bssid,
16646 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016647 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16648 }
16649
16650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016651
16652 // Done with it, init it.
16653 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16654}
16655#endif
16656#ifdef FEATURE_WLAN_BTAMP_UT_RF
16657void csrRoamJoinRetryTimerHandler(void *pv)
16658{
16659 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16660 tpAniSirGlobal pMac = pInfo->pMac;
16661 tANI_U32 sessionId = pInfo->sessionId;
16662 tCsrRoamSession *pSession;
16663
16664 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016666 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016667 pSession = CSR_GET_SESSION( pMac, sessionId );
16668 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16669 {
16670 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016672 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016673 }
16674 }
16675 }
16676}
Jeff Johnson295189b2012-06-20 16:38:30 -070016677eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16678{
16679 eHalStatus status = eHAL_STATUS_FAILURE;
16680 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16681
16682 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016684 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016685 pSession->maxRetryCount--;
16686 pSession->joinRetryTimerInfo.pMac = pMac;
16687 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016688 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16689 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016691 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016692 }
16693 }
16694 else
16695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016696 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 pSession->maxRetryCount);
16698 }
16699
16700 return (status);
16701}
Jeff Johnson295189b2012-06-20 16:38:30 -070016702eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16703{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016704 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016705 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16706 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016707 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016708 }
16709
16710 return eHAL_STATUS_SUCCESS;
16711}
16712#endif
16713
16714
16715/*
16716 pBuf points to the beginning of the message
16717 LIM packs disassoc rsp as below,
16718 messageType - 2 bytes
16719 messageLength - 2 bytes
16720 sessionId - 1 byte
16721 transactionId - 2 bytes (tANI_U16)
16722 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16723 peerMacAddr - 6 bytes
16724 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16725*/
16726static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16727{
16728 if(pBuf && pRsp)
16729 {
16730 pBuf += 4; //skip type and length
16731 pRsp->sessionId = *pBuf++;
16732 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16733 pBuf += 2;
16734 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16735 pBuf += 4;
16736 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16737 }
16738}
16739
Jeff Johnsond13512a2012-07-17 11:42:19 -070016740eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16741{
16742 static uNvTables nvTables;
16743 eHalStatus status = eHAL_STATUS_SUCCESS;
16744 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16745
16746 /* read the country code from NV and use it */
16747 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16748 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016749 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16750 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016751 return status;
16752 }
16753 else
16754 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016755 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016756 status = eHAL_STATUS_FAILURE;
16757 return status;
16758 }
16759}
16760
16761eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16762{
Kiet Lam64c1b492013-07-12 13:56:44 +053016763 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016764 return eHAL_STATUS_SUCCESS;
16765}
schang86c22c42013-03-13 18:41:24 -070016766
16767eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16768{
16769 tSirSetTxPowerReq *pMsg = NULL;
16770 eHalStatus status = eHAL_STATUS_SUCCESS;
16771 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16772
16773 if (!pSession)
16774 {
16775 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16776 return eHAL_STATUS_FAILURE;
16777 }
16778
Kiet Lam64c1b492013-07-12 13:56:44 +053016779 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16780 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16781 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16782 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16783 pMsg->length = sizeof(tSirSetTxPowerReq);
16784 pMsg->mwPower = mW;
16785 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16786 sizeof(tSirMacAddr));
16787 status = palSendMBMessage(pMac->hHdd, pMsg);
16788 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016789 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016790 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16791 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016792 }
16793 return status;
16794}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016795
16796/* Returns whether a session is in VOS_STA_MODE...or not */
16797tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16798{
16799 tCsrRoamSession *pSession = NULL;
16800 pSession = CSR_GET_SESSION ( pMac, sessionId );
16801 if(!pSession)
16802 {
16803 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16804 return eANI_BOOLEAN_FALSE;
16805 }
16806 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16807 {
16808 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16809 return eANI_BOOLEAN_FALSE;
16810 }
16811 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16812 {
16813 return eANI_BOOLEAN_FALSE;
16814 }
16815 /* There is a possibility that the above check may fail,because
16816 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16817 * when it is connected.So,we may sneak through the above check even
16818 * if we are not a STA mode INFRA station. So, if we sneak through
16819 * the above condition, we can use the following check if we are
16820 * really in STA Mode.*/
16821
16822 if ( NULL != pSession->pCurRoamProfile )
16823 {
16824 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16825 {
16826 return eANI_BOOLEAN_TRUE;
16827 } else {
16828 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16829 return eANI_BOOLEAN_FALSE;
16830 }
16831 }
16832
16833 return eANI_BOOLEAN_FALSE;
16834}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016835
16836#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16837eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16838 tCsrHandoffRequest *pHandoffInfo)
16839{
16840 eHalStatus status = eHAL_STATUS_SUCCESS;
16841 vos_msg_t msg;
16842
16843 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016844 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16845 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016846 {
16847 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016848 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016849 }
16850 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16851 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16852 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16853 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016854 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016855 pHandoffInfo->bssid,
16856 6);
16857 msg.type = eWNI_SME_HANDOFF_REQ;
16858 msg.bodyptr = pMsg;
16859 msg.reserved = 0;
16860 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16861 {
16862 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016863 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016864 status = eHAL_STATUS_FAILURE;
16865 }
16866 return status;
16867}
16868#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016869
16870#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16871/* ---------------------------------------------------------------------------
16872 \fn csrSetCCKMIe
16873 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16874 data structure and this IE will be packed inside reassociation request
16875 \param pMac - pMac global structure
16876 \param sessionId - Current session id
16877 \param pCckmIe - pointer to CCKM IE data
16878 \param ccKmIeLen - length of the CCKM IE
16879 \- return Success or failure
16880 -------------------------------------------------------------------------*/
16881VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16882 const tANI_U8 *pCckmIe,
16883 const tANI_U8 ccKmIeLen)
16884{
16885 eHalStatus status = eHAL_STATUS_SUCCESS;
16886 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16887
16888 if (!pSession)
16889 {
16890 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16891 return eHAL_STATUS_FAILURE;
16892 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053016893 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016894 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16895 return status;
16896}
16897
16898/* ---------------------------------------------------------------------------
16899 \fn csrRoamReadTSF
16900 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16901 probe response reception from the hand off AP to arrive at the latest TSF value.
16902 \param pMac - pMac global structure
16903 \param pTimestamp - output TSF timestamp
16904 \- return Success or failure
16905 -------------------------------------------------------------------------*/
16906VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16907{
16908 eHalStatus status = eHAL_STATUS_SUCCESS;
16909 tCsrNeighborRoamBSSInfo handoffNode;
16910 tANI_U32 timer_diff = 0;
16911 tANI_U32 timeStamp[2];
16912 tpSirBssDescription pBssDescription = NULL;
16913
16914 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16915 pBssDescription = handoffNode.pBssDescription;
16916
16917 // Get the time diff in milli seconds
16918 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16919 // Convert msec to micro sec timer
16920 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16921
16922 timeStamp[0] = pBssDescription->timeStamp[0];
16923 timeStamp[1] = pBssDescription->timeStamp[1];
16924
16925 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16926
Kiet Lamf2f201e2013-11-16 21:24:16 +053016927 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016928 sizeof (tANI_U32) * 2);
16929 return status;
16930}
16931
16932#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16933