blob: e36fc3906e93d56e9b063e2934b58c01599e1cec [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 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305964 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
5965 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05305967 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05305968 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05305969 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5970 }
5971 else
5972 {
5973 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
5974 FL(" AddIEScanLength is not valid %u"),
5975 pSrcProfile->nAddIEScanLength);
5976 }
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);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008905 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008906 }
8907 else
8908 {
8909 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8910 if (NULL != reqBkp)
8911 {
8912 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008913 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008914 }
8915 }
8916 }
8917 else
8918 {
8919 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8920 }
8921 return;
8922}
8923#endif
8924
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008925
8926#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8927void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8928{
8929 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
8930
8931 if (NULL != pTsmStatsRsp)
8932 {
8933 /* Get roam Rssi request is backed up and passed back to the response,
8934 Extract the request message to fetch callback */
8935 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
8936
8937 if (NULL != reqBkp)
8938 {
8939 if (NULL != reqBkp->tsmStatsCallback)
8940 {
8941 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
8942 pTsmStatsRsp->staId, reqBkp->pDevContext);
8943 reqBkp->tsmStatsCallback = NULL;
8944 }
8945 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008946 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008947 }
8948 else
8949 {
8950 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
8951 if (NULL != reqBkp)
8952 {
8953 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008954 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008955 }
8956 }
8957 }
8958 else
8959 {
8960 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
8961 }
8962 return;
8963}
8964
8965void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
8966{
8967 tANI_U32 roamTS2 = 0;
8968 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008969 tpPESession pSessionEntry = NULL;
8970 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008971
8972 if (NULL == pSession)
8973 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008974 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008975 return;
8976 }
8977
8978 roamTS2 = vos_timer_get_system_time();
8979 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08008980 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
8981 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008982 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008983
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008984 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
8985 if (NULL == pSessionEntry)
8986 {
8987 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
8988 return;
8989 }
8990 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008991 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
8992 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
8993}
8994#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
8995
Jeff Johnsone7245742012-09-05 17:12:55 -07008996static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8997{
8998 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8999 if(pTlRssiInd)
9000 {
9001 if(NULL != pTlRssiInd->tlCallback)
9002 {
9003 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009004 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009005 }
9006 else
9007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009008 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009009 }
9010 }
9011 else
9012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009013 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009014 }
9015 return;
9016}
Jeff Johnson295189b2012-06-20 16:38:30 -07009017
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309018eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9019{
9020 tpSirResetAPCapsChange pMsg;
9021 tANI_U16 len;
9022 eHalStatus status = eHAL_STATUS_SUCCESS;
9023
9024 /* Create the message and send to lim */
9025 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309026 pMsg = vos_mem_malloc(len);
9027 if ( NULL == pMsg )
9028 status = eHAL_STATUS_FAILURE;
9029 else
9030 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309031 if (HAL_STATUS_SUCCESS(status))
9032 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309033 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309034 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9035 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309036 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009037 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9038 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309039 status = palSendMBMessage(pMac->hHdd, pMsg);
9040 }
9041 else
9042 {
9043 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9044 }
9045 return status;
9046}
9047
Jeff Johnson295189b2012-06-20 16:38:30 -07009048void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9049{
9050 tSirSmeAssocInd *pAssocInd;
9051 tSirSmeDisassocInd *pDisassocInd;
9052 tSirSmeDeauthInd *pDeauthInd;
9053 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9054 tSirSmeNewBssInfo *pNewBss;
9055 tSmeIbssPeerInd *pIbssPeerInd;
9056 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9057 tSirSmeApNewCaps *pApNewCaps;
9058 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9059 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9060 tCsrRoamInfo *pRoamInfo = NULL;
9061 tCsrRoamInfo roamInfo;
9062 eHalStatus status;
9063 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9064 tCsrRoamSession *pSession = NULL;
9065 tpSirSmeSwitchChannelInd pSwitchChnInd;
9066 tSmeMaxAssocInd *pSmeMaxAssocInd;
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 pSirMsg->messageType = (pSirMsg->messageType);
9068 pSirMsg->length = (pSirMsg->length);
9069 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309070 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 switch( pSirMsg->messageType )
9072 {
9073 case eWNI_SME_ASSOC_IND:
9074 {
9075 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009076 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009077 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9078 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9079 if( HAL_STATUS_SUCCESS( status ) )
9080 {
9081 pSession = CSR_GET_SESSION(pMac, sessionId);
9082
Jeff Johnson32d95a32012-09-10 13:15:23 -07009083 if(!pSession)
9084 {
9085 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9086 return;
9087 }
9088
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 pRoamInfo = &roamInfo;
9090
9091 // Required for indicating the frames to upper layer
9092 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9093 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9094
9095 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9096 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9097 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9098 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9099
9100 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9101 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9102 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9103
9104 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9105 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309106 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9107 sizeof(tSirMacAddr));
9108 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9109 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9111 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9114 {
9115 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9116 {
9117 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9118 pSession->pConnectBssDesc,
9119 &(pRoamInfo->peerMac),
9120 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9121 pRoamInfo->fAuthRequired = FALSE;
9122 }
9123 else
9124 {
9125 pRoamInfo->fAuthRequired = TRUE;
9126 }
9127 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9128 if (!HAL_STATUS_SUCCESS(status))
9129 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 /* Send Association completion message to PE */
9132 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9133
9134 /* send a message to CSR itself just to avoid the EAPOL frames going
9135 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9137 {
9138 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9141 {
9142 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9143 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9144 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 }
9147 }
9148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009149 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009150 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309151 // Check if AP dis-associated us because of MIC failure. If so,
9152 // then we need to take action immediately and not wait till the
9153 // the WmStatusChange requests is pushed and processed
9154 tSmeCmd *pCommand;
9155
9156 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9157 status = csrRoamGetSessionIdFromBSSID( pMac,
9158 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9159 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309161 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9162 " for session %d "), sessionId);
9163 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9164 MAC_ADDRESS_STR " "
9165 " reason = %d status = %d "),
9166 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9167 pDisassocInd->reasonCode,
9168 pDisassocInd->statusCode);
9169 // If we are in neighbor preauth done state then on receiving
9170 // disassoc or deauth we dont roam instead we just disassoc
9171 // from current ap and then go to disconnected state
9172 // This happens for CCX and 11r FT connections ONLY.
9173#ifdef WLAN_FEATURE_VOWIFI_11R
9174 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9175 {
9176 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009178#endif
9179#ifdef FEATURE_WLAN_CCX
Agarwal Ashish4f616132013-12-30 23:32:50 +05309180 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9181 {
9182 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009184#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009185#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309186 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9187 {
9188 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9189 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009190#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309191 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009192
Agarwal Ashish4f616132013-12-30 23:32:50 +05309193 if (!pSession)
9194 {
9195 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9196 return;
9197 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009198
Agarwal Ashish4f616132013-12-30 23:32:50 +05309199 if ( csrIsConnStateInfra( pMac, sessionId ) )
9200 {
9201 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009203#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309204 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009205#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309206 csrRoamLinkDown(pMac, sessionId);
9207 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9208 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9209 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009210
Agarwal Ashish4f616132013-12-30 23:32:50 +05309211 pCommand = csrGetCommandBuffer(pMac);
9212 if (NULL == pCommand)
9213 {
9214 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9215 status = eHAL_STATUS_RESOURCES;
9216 }
9217 pRoamInfo = &roamInfo;
9218 pRoamInfo->statusCode = pDisassocInd->statusCode;
9219 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9220 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221
Agarwal Ashish4f616132013-12-30 23:32:50 +05309222 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9223 sizeof(tSirMacAddr));
9224 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9225 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009226
Agarwal Ashish4f616132013-12-30 23:32:50 +05309227 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9228 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009229
Agarwal Ashish4f616132013-12-30 23:32:50 +05309230 /*
9231 * STA/P2P client got disassociated so remove any pending deauth
9232 * commands in sme pending list
9233 */
9234 pCommand->command = eSmeCommandRoam;
9235 pCommand->sessionId = (tANI_U8)sessionId;
9236 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9237 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9238 pDisassocInd->peerMacAddr,
9239 sizeof(tSirMacAddr));
9240 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9241 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009242
Agarwal Ashish4f616132013-12-30 23:32:50 +05309243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309245 else
9246 {
9247 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9248 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9249 }
Kiet Lam82004c62013-11-11 13:24:28 +05309250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009253 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9255 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9256 if( HAL_STATUS_SUCCESS( status ) )
9257 {
9258 // If we are in neighbor preauth done state then on receiving
9259 // disassoc or deauth we dont roam instead we just disassoc
9260 // from current ap and then go to disconnected state
9261 // This happens for CCX and 11r FT connections ONLY.
9262#ifdef WLAN_FEATURE_VOWIFI_11R
9263 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9264 {
9265 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9266 }
9267#endif
9268#ifdef FEATURE_WLAN_CCX
9269 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9270 {
9271 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9272 }
9273#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009274#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309275 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009276 {
9277 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9278 }
9279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 pSession = CSR_GET_SESSION( pMac, sessionId );
9281
Jeff Johnson32d95a32012-09-10 13:15:23 -07009282 if(!pSession)
9283 {
9284 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9285 return;
9286 }
9287
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 if ( csrIsConnStateInfra( pMac, sessionId ) )
9289 {
9290 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009292#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9293 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9294#endif
9295 csrRoamLinkDown(pMac, sessionId);
9296 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9298 {
9299
9300 pRoamInfo = &roamInfo;
9301
9302 pRoamInfo->statusCode = pDeauthInd->statusCode;
9303 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9304
9305 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9306
Kiet Lam64c1b492013-07-12 13:56:44 +05309307 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9308 sizeof(tSirMacAddr));
9309 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9310 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009311
9312 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 }
9315 break;
9316
9317 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 -08009318 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9320 //Update with the new channel id.
9321 //The channel id is hidden in the statusCode.
9322 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9323 if( HAL_STATUS_SUCCESS( status ) )
9324 {
9325 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009326 if(!pSession)
9327 {
9328 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9329 return;
9330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9332 if(pSession->pConnectBssDesc)
9333 {
9334 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9335 }
9336 }
9337 break;
9338
9339 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009340 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 {
9342 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9343 sessionId = pDeauthRsp->sessionId;
9344 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9345 {
9346 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009347 if(!pSession)
9348 {
9349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9350 return;
9351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9353 {
9354 pRoamInfo = &roamInfo;
9355 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309356 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9357 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009358 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9359 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9360 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9361 }
9362 }
9363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 break;
9365
9366 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009367 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009368 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 {
9370 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9371 sessionId = pDisassocRsp->sessionId;
9372 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9373 {
9374 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009375 if(!pSession)
9376 {
9377 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9378 return;
9379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9381 {
9382 pRoamInfo = &roamInfo;
9383 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309384 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9385 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009386 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9387 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9388 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9389 }
9390 }
9391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009393 case eWNI_SME_MIC_FAILURE_IND:
9394 {
9395 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9396 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9397 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009398
9399 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9400 if( HAL_STATUS_SUCCESS( status ) )
9401 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309402 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009403 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9404 pRoamInfo = &roamInfo;
9405 if(pMicInd->info.multicast)
9406 {
9407 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9408 }
9409 else
9410 {
9411 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9412 }
9413 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9414 }
9415
Jeff Johnson295189b2012-06-20 16:38:30 -07009416#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9417 {
lukez3c809222013-05-03 10:23:02 -07009418 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009419 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009420 if(!pSession)
9421 {
9422 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9423 return;
9424 }
lukez3c809222013-05-03 10:23:02 -07009425
Kiet Lam64c1b492013-07-12 13:56:44 +05309426 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9428 secEvent.encryptionModeMulticast =
9429 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9430 secEvent.encryptionModeUnicast =
9431 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9432 secEvent.authMode =
9433 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309434 vos_mem_copy(secEvent.bssid,
9435 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9437 }
9438#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 }
9440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9442 {
9443 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9444 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009445 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009446
9447 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9448 if( HAL_STATUS_SUCCESS( status ) )
9449 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309450 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9452 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9453 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9454 }
9455 }
9456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009457
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9459 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9460 switch( pStatusChangeMsg->statusChangeCode )
9461 {
9462 case eSIR_SME_IBSS_ACTIVE:
9463 sessionId = csrFindIbssSession( pMac );
9464 if( CSR_SESSION_ID_INVALID != sessionId )
9465 {
9466 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009467 if(!pSession)
9468 {
9469 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9470 return;
9471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9473 if(pSession->pConnectBssDesc)
9474 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309475 vos_mem_copy(&roamInfo.bssid,
9476 pSession->pConnectBssDesc->bssId,
9477 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9479 pRoamInfo = &roamInfo;
9480 }
9481 else
9482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009483 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 }
9485 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9486 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9487 }
9488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 case eSIR_SME_IBSS_INACTIVE:
9490 sessionId = csrFindIbssSession( pMac );
9491 if( CSR_SESSION_ID_INVALID != sessionId )
9492 {
9493 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009494 if(!pSession)
9495 {
9496 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9497 return;
9498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9500 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9501 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9502 }
9503 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9505 sessionId = csrFindIbssSession( pMac );
9506 if( CSR_SESSION_ID_INVALID != sessionId )
9507 {
9508 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009509 if(!pSession)
9510 {
9511 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9512 return;
9513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 // update the connection state information
9515 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009516#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9517 {
9518 vos_log_ibss_pkt_type *pIbssLog;
9519 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9521 if(pIbssLog)
9522 {
9523 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9524 if(pNewBss)
9525 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309526 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 if(pNewBss->ssId.length)
9528 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309529 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9530 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 }
9532 pIbssLog->operatingChannel = pNewBss->channelNumber;
9533 }
9534 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9535 {
9536 //***U8 is not enough for beacon interval
9537 pIbssLog->beaconInterval = (v_U8_t)bi;
9538 }
9539 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9540 }
9541 }
9542#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009544
9545 if ((eCSR_ENCRYPT_TYPE_NONE ==
9546 pSession->connectedProfile.EncryptionType ))
9547 {
9548 csrRoamIssueSetContextReq( pMac, sessionId,
9549 pSession->connectedProfile.EncryptionType,
9550 pSession->pConnectBssDesc,
9551 &Broadcastaddr,
9552 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9555 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309556 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9557 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009558 pRoamInfo = &roamInfo;
9559 //This BSSID is th ereal BSSID, let's save it
9560 if(pSession->pConnectBssDesc)
9561 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309562 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9563 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009566 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 // detection by LIM that the capabilities of the associated AP have changed.
9569 case eSIR_SME_AP_CAPS_CHANGED:
9570 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009571 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9573 if( HAL_STATUS_SUCCESS( status ) )
9574 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009575 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9576 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309577 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009578 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9579 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9580 )
9581 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309582 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9583 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009584 }
9585 else
9586 {
9587 smsLog(pMac, LOGW,
9588 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009589 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009590 pMac->roam.curState[sessionId],
9591 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309592 /* We ignore the caps change event if CSR is not in full connected state.
9593 * Send one event to PE to reset limSentCapsChangeNtf
9594 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9595 * otherwise lim cannot send any CAPS change events to SME */
9596 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 }
9599 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309600
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 default:
9602 roamStatus = eCSR_ROAM_FAILED;
9603 result = eCSR_ROAM_RESULT_NONE;
9604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 } // end switch on statusChangeCode
9606 if(eCSR_ROAM_RESULT_NONE != result)
9607 {
9608 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9609 }
9610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 case eWNI_SME_IBSS_NEW_PEER_IND:
9612 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009613#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9614 {
9615 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9617 if(pIbssLog)
9618 {
9619 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309620 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009621 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9622 }
9623 }
9624#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 sessionId = csrFindIbssSession( pMac );
9626 if( CSR_SESSION_ID_INVALID != sessionId )
9627 {
9628 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009629
9630 if(!pSession)
9631 {
9632 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9633 return;
9634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9636 if(pSession->pConnectBssDesc)
9637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309638 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9639 sizeof(tCsrBssid));
9640 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9641 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9643 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309644 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9645 - sizeof(tSmeIbssPeerInd)));
9646 if ( NULL == roamInfo.pbFrames )
9647 status = eHAL_STATUS_FAILURE;
9648 else
9649 status = eHAL_STATUS_SUCCESS;
9650 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 {
9652 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309653 vos_mem_copy(roamInfo.pbFrames,
9654 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9655 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 }
9657 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9658 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9659 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309660 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9661 if ( NULL == roamInfo.pBssDesc )
9662 status = eHAL_STATUS_FAILURE;
9663 else
9664 status = eHAL_STATUS_SUCCESS;
9665 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309667 vos_mem_copy(roamInfo.pBssDesc,
9668 pSession->pConnectBssDesc,
9669 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 }
9671 if(HAL_STATUS_SUCCESS(status))
9672 {
9673 pRoamInfo = &roamInfo;
9674 }
9675 else
9676 {
9677 if(roamInfo.pbFrames)
9678 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309679 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 }
9681 if(roamInfo.pBssDesc)
9682 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309683 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009684 }
9685 }
9686 }
9687 else
9688 {
9689 pRoamInfo = &roamInfo;
9690 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009691 if ((eCSR_ENCRYPT_TYPE_NONE ==
9692 pSession->connectedProfile.EncryptionType ))
9693 {
9694 csrRoamIssueSetContextReq( pMac, sessionId,
9695 pSession->connectedProfile.EncryptionType,
9696 pSession->pConnectBssDesc,
9697 &(pIbssPeerInd->peerAddr),
9698 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 }
9701 else
9702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009703 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 }
9705 //send up the sec type for the new peer
9706 if (pRoamInfo)
9707 {
9708 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9709 }
9710 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9711 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9712 if(pRoamInfo)
9713 {
9714 if(roamInfo.pbFrames)
9715 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309716 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 }
9718 if(roamInfo.pBssDesc)
9719 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309720 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 }
9722 }
9723 }
9724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9726 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9727 sessionId = csrFindIbssSession( pMac );
9728 if( CSR_SESSION_ID_INVALID != sessionId )
9729 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009730#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9731 {
9732 vos_log_ibss_pkt_type *pIbssLog;
9733
9734 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9735 if(pIbssLog)
9736 {
9737 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9738 if(pIbssPeerInd)
9739 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309740 vos_mem_copy(pIbssLog->peerMacAddr,
9741 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 }
9743 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9744 }
9745 }
9746#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009747 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9749 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9750 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309751 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9752 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009753 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9754 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9755 }
9756 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 case eWNI_SME_SETCONTEXT_RSP:
9758 {
9759 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9760 tListElem *pEntry;
9761 tSmeCmd *pCommand;
9762
9763 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9764 if ( pEntry )
9765 {
9766 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9767 if ( eSmeCommandSetKey == pCommand->command )
9768 {
9769 sessionId = pCommand->sessionId;
9770 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009771
9772 if(!pSession)
9773 {
9774 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9775 return;
9776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009777
9778#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9779 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9780 {
9781 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309782 vos_mem_set(&setKeyEvent,
9783 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 if( pRsp->peerMacAddr[0] & 0x01 )
9785 {
9786 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9787 }
9788 else
9789 {
9790 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9791 }
9792 setKeyEvent.encryptionModeMulticast =
9793 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9794 setKeyEvent.encryptionModeUnicast =
9795 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309796 vos_mem_copy(setKeyEvent.bssid,
9797 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 setKeyEvent.authMode =
9799 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009800 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 {
9802 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9803 }
9804 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9805 }
9806#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9807 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9808 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009809 csrRoamStopWaitForKeyTimer( pMac );
9810
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 //We are done with authentication, whethere succeed or not
9812 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009813 //We do it here because this linkup function is not called after association
9814 //when a key needs to be set.
9815 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9816 {
9817 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9818 }
9819 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009820 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309822 vos_mem_copy(&roamInfo.peerMac,
9823 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009824 //Make sure we install the GTK before indicating to HDD as authenticated
9825 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309826 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9827 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009828 {
Yathish9f22e662012-12-10 14:21:35 -08009829#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9830 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9831 {
9832 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309833 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009834 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9835 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9836 pMsg->seesionId = sessionId;
9837 status = palSendMBMessage(pMac->hHdd, pMsg );
9838 }
9839#endif
9840 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009841 }
9842 else
9843 {
9844 result = eCSR_ROAM_RESULT_NONE;
9845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 pRoamInfo = &roamInfo;
9847 }
9848 else
9849 {
9850 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009851 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9852 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9853 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009854 }
9855 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9856 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9858 // can go ahead and initiate the TSPEC if any are pending
9859 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009860#ifdef FEATURE_WLAN_CCX
9861 //Send Adjacent AP repot to new AP.
9862 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9863 pSession->isPrevApInfoValid &&
9864 pSession->connectedProfile.isCCXAssoc)
9865 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009866#ifdef FEATURE_WLAN_CCX_UPLOAD
9867 csrSendCcxAdjacentApRepInd(pMac, pSession);
9868#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9870#endif
9871 pSession->isPrevApInfoValid = FALSE;
9872 }
9873#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9875 {
9876 csrReleaseCommandSetKey( pMac, pCommand );
9877 }
9878 }
9879 else
9880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009881 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 }
9883 }
9884 else
9885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009886 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009888 smeProcessPendingQueue( pMac );
9889 }
9890 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 case eWNI_SME_REMOVEKEY_RSP:
9892 {
9893 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9894 tListElem *pEntry;
9895 tSmeCmd *pCommand;
9896
9897 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9898 if ( pEntry )
9899 {
9900 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9901 if ( eSmeCommandRemoveKey == pCommand->command )
9902 {
9903 sessionId = pCommand->sessionId;
9904 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009905
9906 if(!pSession)
9907 {
9908 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9909 return;
9910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009911#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9912 {
9913 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309914 vos_mem_set(&removeKeyEvent,
9915 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9917 removeKeyEvent.encryptionModeMulticast =
9918 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9919 removeKeyEvent.encryptionModeUnicast =
9920 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309921 vos_mem_copy( removeKeyEvent.bssid,
9922 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 removeKeyEvent.authMode =
9924 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009925 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 {
9927 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9928 }
9929 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9930 }
9931#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009932 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309934 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9935 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 result = eCSR_ROAM_RESULT_NONE;
9937 pRoamInfo = &roamInfo;
9938 }
9939 else
9940 {
9941 result = eCSR_ROAM_RESULT_FAILURE;
9942 }
9943 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9944 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9945 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9946 {
9947 csrReleaseCommandRemoveKey( pMac, pCommand );
9948 }
9949 }
9950 else
9951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009952 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 }
9954 }
9955 else
9956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009957 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 smeProcessPendingQueue( pMac );
9960 }
9961 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009963 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 csrRoamStatsRspProcessor( pMac, pSirMsg );
9965 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009966#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9967 case eWNI_SME_GET_ROAM_RSSI_RSP:
9968 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9969 csrRoamRssiRspProcessor( pMac, pSirMsg );
9970 break;
9971#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009972#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9973 case eWNI_SME_GET_TSM_STATS_RSP:
9974 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
9975 csrTsmStatsRspProcessor( pMac, pSirMsg );
9976 break;
9977#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009979 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 csrUpdateRssi( pMac, pSirMsg );
9981 break;
9982
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309983 case eWNI_SME_GET_SNR_REQ:
9984 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9985 csrUpdateSnr(pMac, pSirMsg);
9986 break;
9987
Jeff Johnson295189b2012-06-20 16:38:30 -07009988#ifdef WLAN_FEATURE_VOWIFI_11R
9989 case eWNI_SME_FT_PRE_AUTH_RSP:
9990 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9991 break;
9992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9994 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009995 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 -07009996 sessionId = pSmeMaxAssocInd->sessionId;
9997 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309998 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
9999 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10001 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10002 break;
10003
10004 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010005 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 btampEstablishLogLinkHdlr( pSirMsg );
10007 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010008 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010009 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010010 csrRoamRssiIndHdlr( pMac, pSirMsg );
10011 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010012#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10013 case eWNI_SME_CANDIDATE_FOUND_IND:
10014 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10015 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10016 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010017 case eWNI_SME_HANDOFF_REQ:
10018 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10019 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10020 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010022
10023 default:
10024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010026}
10027
Jeff Johnson295189b2012-06-20 16:38:30 -070010028void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10029 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10030{
10031 if(pSession)
10032 {
10033 if(pSession->bRefAssocStartCnt)
10034 {
10035 pSession->bRefAssocStartCnt--;
10036 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10037 //Need to call association_completion because there is an assoc_start pending.
10038 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10039 eCSR_ROAM_ASSOCIATION_COMPLETION,
10040 eCSR_ROAM_RESULT_FAILURE);
10041 }
10042 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10043 }
10044 else
10045 {
10046 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10047 }
10048}
10049
10050
10051eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10052{
10053 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10055 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10056 {
10057 status = csrScanRequestLostLink1( pMac, sessionId );
10058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 return(status);
10060}
10061
Jeff Johnson295189b2012-06-20 16:38:30 -070010062//return a boolean to indicate whether roaming completed or continue.
10063tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10064 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10065{
10066 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10067 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10068 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10069 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010070 if(!pSession)
10071 {
10072 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10073 return eANI_BOOLEAN_FALSE;
10074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010075 //Check whether time is up
10076 if(pSession->fCancelRoaming || fForce ||
10077 ((curTime - pSession->roamingStartTime) > roamTime) ||
10078 eCsrReassocRoaming == pSession->roamingReason ||
10079 eCsrDynamicRoaming == pSession->roamingReason)
10080 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010081 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10083 {
10084 //roaming is cancelled, tell HDD to indicate disconnect
10085 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10086 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10087 //to be eSIR_BEACON_MISSED
10088 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10089 {
10090 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10091 }
10092 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10093 {
10094 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10095 }
10096 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10097 {
10098 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10099 }
10100 else
10101 {
10102 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10103 }
10104 }
10105 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10106 pSession->roamingReason = eCsrNotRoaming;
10107 }
10108 else
10109 {
10110 pSession->roamResult = roamResult;
10111 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10112 {
10113 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10114 pSession->roamingReason = eCsrNotRoaming;
10115 }
10116 else
10117 {
10118 fCompleted = eANI_BOOLEAN_FALSE;
10119 }
10120 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 return(fCompleted);
10122}
10123
Jeff Johnson295189b2012-06-20 16:38:30 -070010124void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10125{
10126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010127
10128 if(!pSession)
10129 {
10130 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10131 return;
10132 }
10133
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 if(CSR_IS_ROAMING(pSession))
10135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010136 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10138 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10139 {
10140 //No need to do anything in here because the handler takes care of it
10141 }
10142 else
10143 {
10144 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10145 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10146 //Roaming is stopped after here
10147 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10148 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010149 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 csrRoamStopRoamingTimer(pMac, sessionId);
10151 }
10152 }
10153}
10154
Jeff Johnson295189b2012-06-20 16:38:30 -070010155void csrRoamRoamingTimerHandler(void *pv)
10156{
10157 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10158 tpAniSirGlobal pMac = pInfo->pMac;
10159 tANI_U32 sessionId = pInfo->sessionId;
10160 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010161
10162 if(!pSession)
10163 {
10164 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10165 return;
10166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010167
10168 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10169 {
10170 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10171 {
10172 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10173 pSession->roamingReason = eCsrNotRoaming;
10174 }
10175 }
10176}
10177
Jeff Johnson295189b2012-06-20 16:38:30 -070010178eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10179{
10180 eHalStatus status;
10181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010182
10183 if(!pSession)
10184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010185 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010186 return eHAL_STATUS_FAILURE;
10187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010188
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010189 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010190 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010191 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010192
10193 return (status);
10194}
10195
Jeff Johnson295189b2012-06-20 16:38:30 -070010196eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10197{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010198 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010199}
10200
Jeff Johnson295189b2012-06-20 16:38:30 -070010201void csrRoamWaitForKeyTimeOutHandler(void *pv)
10202{
10203 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10204 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010206 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010207
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010208 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010209 pMac->roam.neighborRoamInfo.neighborRoamState,
10210 pMac->roam.curSubState[pInfo->sessionId]);
10211
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10213 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010214#ifdef FEATURE_WLAN_LFR
10215 if (csrNeighborRoamIsHandoffInProgress(pMac))
10216 {
10217 /*
10218 * Enable heartbeat timer when hand-off is in progress
10219 * and Key Wait timer expired.
10220 */
10221 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010222 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010223 pMac->roam.configParam.HeartbeatThresh24);
10224 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10225 pMac->roam.configParam.HeartbeatThresh24,
10226 NULL, eANI_BOOLEAN_FALSE);
10227 }
10228#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010229 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010230
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010232 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10233 {
10234 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10235 pInfo->sessionId);
10236 }
10237
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010238 if (pSession)
10239 {
10240 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10241 {
10242 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10243 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010244 if( (pSession->connectedProfile.AuthType ==
10245 eCSR_AUTH_TYPE_SHARED_KEY) &&
10246 ( (pSession->connectedProfile.EncryptionType ==
10247 eCSR_ENCRYPT_TYPE_WEP40) ||
10248 (pSession->connectedProfile.EncryptionType ==
10249 eCSR_ENCRYPT_TYPE_WEP104) ))
10250 {
10251 status = sme_AcquireGlobalLock( &pMac->sme );
10252 if ( HAL_STATUS_SUCCESS( status ) )
10253 {
10254 csrRoamDisconnect( pMac, pInfo->sessionId,
10255 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10256 sme_ReleaseGlobalLock( &pMac->sme );
10257 }
10258 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010259 }
10260 else
10261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010262 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010263 __func__);
10264 }
10265 }
10266 else
10267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010268 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 }
10271
10272}
10273
Jeff Johnson295189b2012-06-20 16:38:30 -070010274eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10275{
10276 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010277#ifdef FEATURE_WLAN_LFR
10278 if (csrNeighborRoamIsHandoffInProgress(pMac))
10279 {
10280 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010281 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010282 __func__,
10283 pMac->roam.neighborRoamInfo.neighborRoamState,
10284 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10285 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10286 }
10287#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010288 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010289 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010290
10291 return (status);
10292}
10293
Jeff Johnson295189b2012-06-20 16:38:30 -070010294eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10295{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010296 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010297 pMac->roam.neighborRoamInfo.neighborRoamState,
10298 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10299#ifdef FEATURE_WLAN_LFR
10300 if (csrNeighborRoamIsHandoffInProgress(pMac))
10301 {
10302 /*
10303 * Enable heartbeat timer when hand-off is in progress
10304 * and Key Wait timer got stopped for some reason
10305 */
10306 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010307 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010308 pMac->roam.configParam.HeartbeatThresh24);
10309 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10310 pMac->roam.configParam.HeartbeatThresh24,
10311 NULL, eANI_BOOLEAN_FALSE);
10312 }
10313#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010314 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010315}
10316
Jeff Johnson295189b2012-06-20 16:38:30 -070010317void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10318 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10319{
10320 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10321 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010322 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10323 /* To silence the KW tool Null chaeck is added */
10324 if(!pSession)
10325 {
10326 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10327 return;
10328 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010329
10330 if(pCommand)
10331 {
10332 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10336 {
10337 //if success, force roaming completion
10338 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10339 }
10340 else
10341 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010342 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010343 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010344 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10345 }
10346}
10347
Jeff Johnson295189b2012-06-20 16:38:30 -070010348eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10349{
10350 eHalStatus status = eHAL_STATUS_SUCCESS;
10351 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10352 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10353 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10354 tCsrRoamInfo *pRoamInfo = NULL;
10355 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010356 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010358 /* To silence the KW tool Null chaeck is added */
10359 if(!pSession)
10360 {
10361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10362 return eHAL_STATUS_FAILURE;
10363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010365 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10367 if ( eWNI_SME_DISASSOC_IND == type )
10368 {
10369 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10370 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10371 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010372 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010373 }
10374 else if ( eWNI_SME_DEAUTH_IND == type )
10375 {
10376 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10377 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10378 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010379 /* Convert into proper reason code */
10380 pSession->joinFailStatusCode.reasonCode =
10381 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010382 0 : pDeauthIndMsg->reasonCode;
10383 /* cfg layer expects 0 as reason code if
10384 the driver dosent know the reason code
10385 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 }
10387 else
10388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010389 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010391 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 }
10393
10394 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010395 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 {
10397 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10398 }
10399
10400 if ( eWNI_SME_DISASSOC_IND == type )
10401 {
10402 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10403 }
10404 else if ( eWNI_SME_DEAUTH_IND == type )
10405 {
10406 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010408 if(!HAL_STATUS_SUCCESS(status))
10409 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010410 //If fail to send confirmation to PE, not to trigger roaming
10411 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 }
10413
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010414 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010415 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10417 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 if( eWNI_SME_DISASSOC_IND == type)
10419 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010420 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010421 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10422 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010423 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010425 else if( eWNI_SME_DEAUTH_IND == type )
10426 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010427 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010428 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10429 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010430 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10431 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010432 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010433
10434 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10435 that we are roaming. But if we cannot possibly roam, or if we are unable to
10436 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 if(fToRoam)
10438 {
10439 //Only remove the connected BSS in infrastructure mode
10440 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10441 //Not to do anying for lostlink with WDS
10442 if( pMac->roam.configParam.nRoamingTime )
10443 {
10444 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10445 ( eWNI_SME_DEAUTH_IND == type ) ?
10446 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10447 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010448 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 //For IBSS, we need to give some more info to HDD
10450 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10451 {
10452 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10453 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10454 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10455 }
10456 else
10457 {
10458 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10459 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010460 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10462 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10463 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10464 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10465 }
10466 else
10467 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010468 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 fToRoam = eANI_BOOLEAN_FALSE;
10470 }
10471 }
10472 else
10473 {
10474 //We are told not to roam, indicate lostlink
10475 fToRoam = eANI_BOOLEAN_FALSE;
10476 }
10477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010478 if(!fToRoam)
10479 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010480 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010481 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010482 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010483 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10484 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10485 * csrRoamCheckForLinkStatusChange API.
10486 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010487 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10488 }
10489
10490 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 Still enable idle scan for polling in case concurrent sessions are running */
10492 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10493 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010494 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 }
10496 }
10497
10498 return (status);
10499}
10500
Jeff Johnson295189b2012-06-20 16:38:30 -070010501eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10502{
10503 eHalStatus status = eHAL_STATUS_SUCCESS;
10504 tListElem *pEntry = NULL;
10505 tSmeCmd *pCommand = NULL;
10506 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010507
10508 if(!pSession)
10509 {
10510 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10511 return eHAL_STATUS_FAILURE;
10512 }
10513
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 //Only remove the connected BSS in infrastructure mode
10516 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10517 if(pMac->roam.configParam.nRoamingTime)
10518 {
10519 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10520 {
10521 //before starting the lost link logic release the roam command for handoff
10522 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10523 if(pEntry)
10524 {
10525 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10526 }
10527 if(pCommand)
10528 {
10529 if (( eSmeCommandRoam == pCommand->command ) &&
10530 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10531 {
10532 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10533 {
10534 csrReleaseCommandRoam( pMac, pCommand );
10535 }
10536 }
10537 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010538 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 }
10540 }
10541 else
10542 {
10543 //We are told not to roam, indicate lostlink
10544 status = eHAL_STATUS_FAILURE;
10545 }
10546
10547 return (status);
10548}
Jeff Johnson295189b2012-06-20 16:38:30 -070010549void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10550{
10551 tListElem *pEntry;
10552 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10554 if ( pEntry )
10555 {
10556 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10557 if ( eSmeCommandWmStatusChange == pCommand->command )
10558 {
10559 // Nothing to process in a Lost Link completion.... It just kicks off a
10560 // roaming sequence.
10561 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10562 {
10563 csrReleaseCommandWmStatusChange( pMac, pCommand );
10564 }
10565 else
10566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010567 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 }
10569
10570 }
10571 else
10572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010573 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 }
10575 }
10576 else
10577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010578 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010579 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 smeProcessPendingQueue( pMac );
10581}
10582
Jeff Johnson295189b2012-06-20 16:38:30 -070010583void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10584{
10585 eHalStatus status = eHAL_STATUS_FAILURE;
10586 tSirSmeRsp *pSirSmeMsg;
10587 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010588
10589 if(!pSession)
10590 {
10591 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10592 return;
10593 }
10594
Jeff Johnson295189b2012-06-20 16:38:30 -070010595 switch ( pCommand->u.wmStatusChangeCmd.Type )
10596 {
10597 case eCsrDisassociated:
10598 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10599 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 case eCsrDeauthenticated:
10602 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10603 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010606 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010607 break;
10608 }
10609 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10610 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10611 {
10612 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10613 {
10614 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010615 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 }
10617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10619 // command here since there is nothing else to do.
10620 csrRoamWmStatusChangeComplete( pMac );
10621}
10622
Jeff Johnson295189b2012-06-20 16:38:30 -070010623//This function returns band and mode information.
10624//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10625//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010626static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10627 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010628{
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10630 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10631 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010633
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 //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 -070010635 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10636 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10637 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10638 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 {
10640 switch( pMac->roam.configParam.uCfgDot11Mode )
10641 {
10642 case eCSR_CFG_DOT11_MODE_11A:
10643 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10644 eBand = eCSR_BAND_5G;
10645 break;
10646 case eCSR_CFG_DOT11_MODE_11B:
10647 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10648 eBand = eCSR_BAND_24;
10649 break;
10650 case eCSR_CFG_DOT11_MODE_11G:
10651 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10652 eBand = eCSR_BAND_24;
10653 break;
10654 case eCSR_CFG_DOT11_MODE_11N:
10655 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010656 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10657 break;
10658#ifdef WLAN_FEATURE_11AC
10659 case eCSR_CFG_DOT11_MODE_11AC:
10660 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10661 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010662 /* If the operating channel is in 2.4 GHz band, check for
10663 * INI item to disable VHT operation in 2.4 GHz band
10664 */
10665 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10666 !pMac->roam.configParam.enableVhtFor24GHz)
10667 {
10668 /* Disable 11AC operation */
10669 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10670 }
10671 else
10672 {
10673 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10674 }
10675 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010676 }
10677 else
10678 {
10679 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10680 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10681 }
10682 break;
10683 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10684 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10685 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010686 /* If the operating channel is in 2.4 GHz band, check for
10687 * INI item to disable VHT operation in 2.4 GHz band
10688 */
10689 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10690 !pMac->roam.configParam.enableVhtFor24GHz)
10691 {
10692 /* Disable 11AC operation */
10693 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10694 }
10695 else
10696 {
10697 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10698 }
10699 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010700 }
10701 else
10702 {
10703 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10704 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10705 }
10706 break;
10707#endif
10708 case eCSR_CFG_DOT11_MODE_AUTO:
10709 eBand = pMac->roam.configParam.eBand;
10710 if (eCSR_BAND_24 == eBand)
10711 {
10712 // WiFi tests require IBSS networks to start in 11b mode
10713 // without any change to the default parameter settings
10714 // on the adapter. We use ACU to start an IBSS through
10715 // creation of a startIBSS profile. This startIBSS profile
10716 // has Auto MACProtocol and the adapter property setting
10717 // for dot11Mode is also AUTO. So in this case, let's
10718 // start the IBSS network in 11b mode instead of 11g mode.
10719 // So this is for Auto=profile->MacProtocol && Auto=Global.
10720 // dot11Mode && profile->channel is < 14, then start the IBSS
10721 // in b mode.
10722 //
10723 // Note: we used to have this start as an 11g IBSS for best
10724 // performance... now to specify that the user will have to
10725 // set the do11Mode in the property page to 11g to force it.
10726 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10727 }
10728 else
10729 {
10730#ifdef WLAN_FEATURE_11AC
10731 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10732 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010733 /* If the operating channel is in 2.4 GHz band, check for
10734 * INI item to disable VHT operation in 2.4 GHz band
10735 */
10736 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10737 !pMac->roam.configParam.enableVhtFor24GHz)
10738 {
10739 /* Disable 11AC operation */
10740 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10741 }
10742 else
10743 {
10744 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10745 }
10746 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010747 }
10748 else
10749 {
10750 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10751 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10752 }
10753#else
10754 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10755 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10756#endif
10757 }
10758 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 default:
10760 // Global dot11 Mode setting is 11a/b/g.
10761 // use the channel number to determine the Mode setting.
10762 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10763 {
10764 eBand = pMac->roam.configParam.eBand;
10765 if(eCSR_BAND_24 == eBand)
10766 {
10767 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10768 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10769 }
10770 else
10771 {
10772 //prefer 5GHz
10773 eBand = eCSR_BAND_5G;
10774 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10775 }
10776 }
10777 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10778 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010779 // WiFi tests require IBSS networks to start in 11b mode
10780 // without any change to the default parameter settings
10781 // on the adapter. We use ACU to start an IBSS through
10782 // creation of a startIBSS profile. This startIBSS profile
10783 // has Auto MACProtocol and the adapter property setting
10784 // for dot11Mode is also AUTO. So in this case, let's
10785 // start the IBSS network in 11b mode instead of 11g mode.
10786 // So this is for Auto=profile->MacProtocol && Auto=Global.
10787 // dot11Mode && profile->channel is < 14, then start the IBSS
10788 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010790 // Note: we used to have this start as an 11g IBSS for best
10791 // performance... now to specify that the user will have to
10792 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10794 eBand = eCSR_BAND_24;
10795 }
10796 else
10797 {
10798 // else, it's a 5.0GHz channel. Set mode to 11a.
10799 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10800 eBand = eCSR_BAND_5G;
10801 }
10802 break;
10803 }//switch
10804 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10805 else
10806 {
10807 //dot11 mode is set, lets pick the band
10808 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10809 {
10810 // channel is Auto also.
10811 eBand = pMac->roam.configParam.eBand;
10812 if(eCSR_BAND_ALL == eBand)
10813 {
10814 //prefer 5GHz
10815 eBand = eCSR_BAND_5G;
10816 }
10817 }
10818 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10819 {
10820 eBand = eCSR_BAND_24;
10821 }
10822 else
10823 {
10824 eBand = eCSR_BAND_5G;
10825 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010826 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 if(pBand)
10828 {
10829 *pBand = eBand;
10830 }
10831
10832 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010833 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010834 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10835 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010836
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010837 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10838 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 -070010839 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010840#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010841 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010842#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010843 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10844 {
10845 //We cannot do 11n here
10846 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10847 {
10848 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10849 }
10850 else
10851 {
10852 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10853 }
10854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 return( cfgDot11Mode );
10856}
10857
Jeff Johnson295189b2012-06-20 16:38:30 -070010858eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10859{
10860 eHalStatus status;
10861 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010862
10863 if(!pSession)
10864 {
10865 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10866 return eHAL_STATUS_FAILURE;
10867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010868
10869#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10870 {
10871 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10873 if(pIbssLog)
10874 {
10875 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10876 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10877 }
10878 }
10879#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010880 // Set the roaming substate to 'stop Bss request'...
10881 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10882
10883 // attempt to stop the Bss (reason code is ignored...)
10884 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010885 if(!HAL_STATUS_SUCCESS(status))
10886 {
10887 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010889 return (status);
10890}
10891
Jeff Johnson295189b2012-06-20 16:38:30 -070010892//pNumChan is a caller allocated space with the sizeof pChannels
10893eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10894{
10895
10896 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10897 (tANI_U8 *)pChannels,
10898 pNumChan));
10899}
10900
Kiran4a17ebe2013-01-31 10:43:43 -080010901tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10902{
10903 tANI_U32 cfgLength = 0;
10904 tANI_U16 cfgId = 0;
10905 tPowerdBm maxTxPwr = 0;
10906 tANI_U8 *pCountryInfo = NULL;
10907 eHalStatus status;
10908 tANI_U8 count = 0;
10909 tANI_U8 firstChannel;
10910 tANI_U8 maxChannels;
10911
10912 if (CSR_IS_CHANNEL_5GHZ(channel))
10913 {
10914 cfgId = WNI_CFG_MAX_TX_POWER_5;
10915 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10916 }
10917 else if (CSR_IS_CHANNEL_24GHZ(channel))
10918 {
10919 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10920 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10921 }
10922 else
10923 return maxTxPwr;
10924
Kiet Lam64c1b492013-07-12 13:56:44 +053010925 pCountryInfo = vos_mem_malloc(cfgLength);
10926 if ( NULL == pCountryInfo )
10927 status = eHAL_STATUS_FAILURE;
10928 else
10929 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010930 if (status != eHAL_STATUS_SUCCESS)
10931 {
10932 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010933 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010934 __FUNCTION__, status);
10935 goto error;
10936 }
10937 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10938 if (status != eHAL_STATUS_SUCCESS)
10939 {
10940 goto error;
10941 }
10942 /* Identify the channel and maxtxpower */
10943 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10944 {
10945 firstChannel = pCountryInfo[count++];
10946 maxChannels = pCountryInfo[count++];
10947 maxTxPwr = pCountryInfo[count++];
10948
10949 if ((channel >= firstChannel) &&
10950 (channel < (firstChannel + maxChannels)))
10951 {
10952 break;
10953 }
10954 }
10955
10956error:
10957 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010958 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010959
10960 return maxTxPwr;
10961}
10962
10963
Jeff Johnson295189b2012-06-20 16:38:30 -070010964tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10965{
10966 tANI_BOOLEAN fValid = FALSE;
10967 tANI_U32 idxValidChannels;
10968 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10969
10970 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10971 {
10972 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10973 {
10974 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10975 {
10976 fValid = TRUE;
10977 break;
10978 }
10979 }
10980 }
10981 pMac->roam.numValidChannels = len;
10982 return fValid;
10983}
10984
Jeff Johnson295189b2012-06-20 16:38:30 -070010985tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10986{
10987 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10988 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10990 {
10991 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10992 {
10993 fValid = eANI_BOOLEAN_TRUE;
10994 break;
10995 }
10996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010997 return (fValid);
10998}
10999
Jeff Johnson295189b2012-06-20 16:38:30 -070011000//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011001 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011002{
Jeff Johnsone7245742012-09-05 17:12:55 -070011003 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 tANI_U8 centerChn;
11005 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011006 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11007 {
11008 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11009 }
11010 else
11011 {
11012 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11013 }
11014 //Figure what the other side's CB mode
11015 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11016 {
11017 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11018 {
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011019 // Check set as TKIP or not.
11020 if (NULL != &(pIes->RSN.pwise_cipher_suites[0][0]) &&
11021 !memcmp( &(pIes->RSN.pwise_cipher_suites[0][0]),
11022 "\x00\x0f\xac\x02" ,4))
11023 {
11024 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11025 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11026 }
11027
11028 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011030 /* This is called during INFRA STA/CLIENT and should use the merged value of
11031 * supported channel width and recommended tx width as per standard
11032 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011033 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011034 pIes->HTCaps.supportedChannelWidthSet,
11035 pIes->HTInfo.recommendedTxWidthSet,
11036 pIes->HTInfo.secondaryChannelOffset);
11037
11038 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11039 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011040 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011041 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11042 switch (eRet) {
11043 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11044 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11045 break;
11046 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11047 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11048 break;
11049 case PHY_SINGLE_CHANNEL_CENTERED:
11050 default:
11051 centerChn = primaryChn;
11052 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011054 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011056 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011057 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 }
11059 }
11060 }
11061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 return eRet;
11063}
Jeff Johnson295189b2012-06-20 16:38:30 -070011064tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11065{
11066 tANI_BOOLEAN fFound = FALSE;
11067 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11069 {
11070 if( pCipherList->encryptionType[idx] == encryptionType )
11071 {
11072 fFound = TRUE;
11073 break;
11074 }
11075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 return fFound;
11077}
Jeff Johnson295189b2012-06-20 16:38:30 -070011078tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11079{
11080 tANI_BOOLEAN fFound = FALSE;
11081 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11083 {
11084 if( pAuthList->authType[idx] == authType )
11085 {
11086 fFound = TRUE;
11087 break;
11088 }
11089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011090 return fFound;
11091}
Jeff Johnson295189b2012-06-20 16:38:30 -070011092tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11093{
11094 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11095 tCsrScanResultFilter *pScanFilter = NULL;
11096 eHalStatus status = eHAL_STATUS_SUCCESS;
11097
11098 if(pProfile1 && pProfile2)
11099 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011100 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11101 if ( NULL == pScanFilter )
11102 status = eHAL_STATUS_FAILURE;
11103 else
11104 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 if(HAL_STATUS_SUCCESS(status))
11106 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011107 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11109 if(HAL_STATUS_SUCCESS(status))
11110 {
11111 fCheck = eANI_BOOLEAN_FALSE;
11112 do
11113 {
11114 tANI_U32 i;
11115 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11116 {
11117 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11118 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11119 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11120 if ( fCheck ) break;
11121 }
11122 if(!fCheck)
11123 {
11124 break;
11125 }
11126 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11127 || pProfile2->BSSType != pProfile1->BSSType
11128 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11129 )
11130 {
11131 fCheck = eANI_BOOLEAN_FALSE;
11132 break;
11133 }
11134#ifdef WLAN_FEATURE_VOWIFI_11R
11135 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11136 {
11137 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11138 {
11139 fCheck = eANI_BOOLEAN_FALSE;
11140 break;
11141 }
11142 }
11143#endif
11144 //Match found
11145 fCheck = eANI_BOOLEAN_TRUE;
11146 }while(0);
11147 csrFreeScanFilter(pMac, pScanFilter);
11148 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011149 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 }
11151 }
11152
11153 return (fCheck);
11154}
11155
Jeff Johnson295189b2012-06-20 16:38:30 -070011156tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11157{
11158 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11159 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011160 do
11161 {
11162 //Only check for static WEP
11163 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11164 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11165 {
11166 fCheck = eANI_BOOLEAN_TRUE;
11167 break;
11168 }
11169 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11170 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11171 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11172 {
11173 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011174 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11175 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011176 {
11177 break;
11178 }
11179 }
11180 if( i == CSR_MAX_NUM_KEY)
11181 {
11182 fCheck = eANI_BOOLEAN_TRUE;
11183 }
11184 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011185 return (fCheck);
11186}
11187
Jeff Johnson295189b2012-06-20 16:38:30 -070011188//IBSS
11189
Jeff Johnson295189b2012-06-20 16:38:30 -070011190tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11191{
11192 tANI_U8 channel = 0;
11193 tANI_U32 idx;
11194 tANI_U32 idxValidChannels;
11195 tANI_BOOLEAN fFound = FALSE;
11196 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11197
11198 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11199 {
11200 channel = pMac->roam.configParam.AdHocChannel5G;
11201 if(!csrRoamIsChannelValid(pMac, channel))
11202 {
11203 channel = 0;
11204 }
11205 }
11206 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11207 {
11208 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11209 {
11210 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11211 {
11212 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11213 {
11214 fFound = TRUE;
11215 channel = csrStartIbssChannels50[ idx ];
11216 }
11217 }
11218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11220 if (!fFound)
11221 {
11222 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11223 {
11224 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11225 {
11226 channel = csrStartIbssChannels50[ idx ];
11227 break;
11228 }
11229 }
11230 }
11231 }//if
11232
11233 return( channel );
11234}
11235
Jeff Johnson295189b2012-06-20 16:38:30 -070011236tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11237{
11238 tANI_U8 channel = 1;
11239 tANI_U32 idx;
11240 tANI_U32 idxValidChannels;
11241 tANI_BOOLEAN fFound = FALSE;
11242 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11243
11244 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11245 {
11246 channel = pMac->roam.configParam.AdHocChannel24;
11247 if(!csrRoamIsChannelValid(pMac, channel))
11248 {
11249 channel = 0;
11250 }
11251 }
11252
11253 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11254 {
11255 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11256 {
11257 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11258 {
11259 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11260 {
11261 fFound = TRUE;
11262 channel = csrStartIbssChannels24[ idx ];
11263 }
11264 }
11265 }
11266 }
11267
11268 return( channel );
11269}
11270
Jeff Johnson295189b2012-06-20 16:38:30 -070011271static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11272 tCsrRoamStartBssParams *pParam )
11273{
11274 eCsrCfgDot11Mode cfgDot11Mode;
11275 eCsrBand eBand;
11276 tANI_U8 channel = 0;
11277 tSirNwType nwType;
11278 tANI_U8 operationChannel = 0;
11279
11280 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11281 {
11282 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11283 }
11284
Jeff Johnson295189b2012-06-20 16:38:30 -070011285 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011286
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11288 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11289 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11290 )
11291 {
11292 /* This should never happen */
11293 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011294 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 pProfile->csrPersona);
11296 VOS_ASSERT(0);
11297 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011298 switch( cfgDot11Mode )
11299 {
11300 case eCSR_CFG_DOT11_MODE_11G:
11301 nwType = eSIR_11G_NW_TYPE;
11302 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 case eCSR_CFG_DOT11_MODE_11B:
11304 nwType = eSIR_11B_NW_TYPE;
11305 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 case eCSR_CFG_DOT11_MODE_11A:
11307 nwType = eSIR_11A_NW_TYPE;
11308 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011309 default:
11310 case eCSR_CFG_DOT11_MODE_11N:
11311 case eCSR_CFG_DOT11_MODE_TAURUS:
11312 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11313 if(eCSR_BAND_24 == eBand)
11314 {
11315 nwType = eSIR_11G_NW_TYPE;
11316 }
11317 else
11318 {
11319 nwType = eSIR_11A_NW_TYPE;
11320 }
11321 break;
11322 }
11323
11324 pParam->extendedRateSet.numRates = 0;
11325
11326 switch ( nwType )
11327 {
11328 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011329 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 case eSIR_11A_NW_TYPE:
11331
11332 pParam->operationalRateSet.numRates = 8;
11333
11334 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11335 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11336 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11337 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11338 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11339 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11340 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11341 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11342
11343 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11344 {
11345 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11346 if( 0 == channel &&
11347 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11348 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11349 )
11350 {
11351 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11352 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11353 nwType = eSIR_11B_NW_TYPE;
11354 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11355 pParam->operationalRateSet.numRates = 4;
11356 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11357 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11358 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11359 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11360 }
11361 }
11362 else
11363 {
11364 channel = operationChannel;
11365 }
11366 break;
11367
11368 case eSIR_11B_NW_TYPE:
11369 pParam->operationalRateSet.numRates = 4;
11370 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11371 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11372 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11373 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11375 {
11376 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11377 }
11378 else
11379 {
11380 channel = operationChannel;
11381 }
11382
11383 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 /* For P2P Client and P2P GO, disable 11b rates */
11386 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11387 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11388 )
11389 {
11390 pParam->operationalRateSet.numRates = 8;
11391
11392 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11393 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11394 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11395 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11396 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11397 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11398 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11399 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11400 }
11401 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 {
11403 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11405 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11406 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11407 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11408
11409 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11411 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11412 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11413 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11414 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11415 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11416 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11417 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11418 }
11419
11420 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11421 {
11422 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11423 }
11424 else
11425 {
11426 channel = operationChannel;
11427 }
11428
11429 break;
11430 }
11431 pParam->operationChn = channel;
11432 pParam->sirNwType = nwType;
11433}
11434
Jeff Johnson295189b2012-06-20 16:38:30 -070011435static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11436 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11437{
11438
11439 if( pParam )
11440 {
11441 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011442 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011443 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011444 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011445
11446 if( pIes )
11447 {
11448 if(pIes->SuppRates.present)
11449 {
11450 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11451 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011453 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 -070011454 pIes->SuppRates.num_rates);
11455 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11456 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011457 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11458 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011460 if (pIes->ExtSuppRates.present)
11461 {
11462 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11463 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11464 {
11465 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11466 SIR_MAC_RATESET_EID_MAX, resetting to \
11467 SIR_MAC_RATESET_EID_MAX"),
11468 pIes->ExtSuppRates.num_rates);
11469 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11470 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011471 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011472 pIes->ExtSuppRates.rates,
11473 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 if( pIes->SSID.present )
11476 {
11477 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011478 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11479 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 }
11481 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 }
11483 else
11484 {
11485 pParam->ssId.length = 0;
11486 pParam->operationalRateSet.numRates = 0;
11487 }
11488 }
11489}
11490
Jeff Johnson295189b2012-06-20 16:38:30 -070011491static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11492{
11493 tANI_U8 MaxRate = 0;
11494 tANI_U32 i;
11495 tANI_U8 *pRate;
11496
11497 pRate = pSirRateSet->rate;
11498 for ( i = 0; i < pSirRateSet->numRates; i++ )
11499 {
11500 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11501 }
11502
11503 // Save the max rate in the connected state information...
11504
11505 // modify LastRates variable as well
11506
11507 return;
11508}
11509
Jeff Johnson295189b2012-06-20 16:38:30 -070011510eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11511 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11512{
11513 eHalStatus status = eHAL_STATUS_SUCCESS;
11514 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 // Set the roaming substate to 'Start BSS attempt'...
11516 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011517#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11518 //Need to figure out whether we need to log WDS???
11519 if( CSR_IS_IBSS( pProfile ) )
11520 {
11521 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11523 if(pIbssLog)
11524 {
11525 if(pBssDesc)
11526 {
11527 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011528 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 }
11530 else
11531 {
11532 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11533 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011534 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 if(pProfile->ChannelInfo.numOfChannels == 0)
11536 {
11537 pIbssLog->channelSetting = AUTO_PICK;
11538 }
11539 else
11540 {
11541 pIbssLog->channelSetting = SPECIFIED;
11542 }
11543 pIbssLog->operatingChannel = pParam->operationChn;
11544 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11545 }
11546 }
11547#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11548 //Put RSN information in for Starting BSS
11549 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11550 pParam->pRSNIE = pProfile->pRSNReqIE;
11551
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 pParam->privacy = pProfile->privacy;
11553 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11554 pParam->authType = pProfile->csr80211AuthType;
11555 pParam->beaconInterval = pProfile->beaconInterval;
11556 pParam->dtimPeriod = pProfile->dtimPeriod;
11557 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11558 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11559 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11560 {
11561 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11562 {
11563 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11564 }
11565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011566 pParam->protEnabled = pProfile->protEnabled;
11567 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11568 pParam->ht_protection = pProfile->cfg_protection;
11569 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011570
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11572 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 pParam->bssPersona = pProfile->csrPersona;
11574 // When starting an IBSS, start on the channel from the Profile.
11575 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 return (status);
11577}
11578
Jeff Johnson295189b2012-06-20 16:38:30 -070011579static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011580 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011581{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011582 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011583 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011585
11586 if(!pSession)
11587 {
11588 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11589 return;
11590 }
11591
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 if( pBssDesc )
11593 {
11594 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11595 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11596 //The following code has to be do after that.
11597 //For WDS station, use selfMac as the self BSSID
11598 if( CSR_IS_WDS_STA( pProfile ) )
11599 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011600 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11601 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 }
11603 }
11604 else
11605 {
11606 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 //Use the first SSID
11608 if(pProfile->SSIDs.numOfSSIDs)
11609 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011610 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11611 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 }
11613 //For WDS station, use selfMac as the self BSSID
11614 if( CSR_IS_WDS_STA( pProfile ) )
11615 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011616 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11617 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 }
11619 //Use the first BSSID
11620 else if( pProfile->BSSIDs.numOfBSSIDs )
11621 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011622 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11623 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 }
11625 else
11626 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011627 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 }
11629 }
11630 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 //Set operating channel in pProfile which will be used
11632 //in csrRoamSetBssConfigCfg() to determine channel bonding
11633 //mode and will be configured in CFG later
11634 pProfile->operationChannel = Channel;
11635
11636 if(Channel == 0)
11637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011638 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 }
11640 else
11641 {
11642
11643 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011644 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011645 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011646 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011647 {
11648 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11649 }
11650 else
11651 {
11652 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11653 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011654 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011655 pBssConfig->cbMode = cbMode;
11656 pSession->bssParams.cbMode = cbMode;
11657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 }
11659}
11660
Jeff Johnson295189b2012-06-20 16:38:30 -070011661static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11662 tANI_BOOLEAN *pfSameIbss )
11663{
11664 eHalStatus status = eHAL_STATUS_SUCCESS;
11665 tANI_BOOLEAN fSameIbss = FALSE;
11666
11667 if ( csrIsConnStateIbss( pMac, sessionId ) )
11668 {
11669 // Check if any profile parameter has changed ? If any profile parameter
11670 // has changed then stop old BSS and start a new one with new parameters
11671 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11672 {
11673 fSameIbss = TRUE;
11674 }
11675 else
11676 {
11677 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11678 }
11679 }
11680 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11681 {
11682 // Disassociate from the connected Infrastructure network...
11683 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11684 }
11685 else
11686 {
11687 tBssConfigParam *pBssConfig;
11688
Kiet Lam64c1b492013-07-12 13:56:44 +053011689 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11690 if ( NULL == pBssConfig )
11691 status = eHAL_STATUS_FAILURE;
11692 else
11693 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 if(HAL_STATUS_SUCCESS(status))
11695 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011696 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 // there is no Bss description before we start an IBSS so we need to adopt
11698 // all Bss configuration parameters from the Profile.
11699 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11700 if(HAL_STATUS_SUCCESS(status))
11701 {
11702 //save dotMode
11703 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11704 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011705 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011706 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11707 NULL, pBssConfig,
11708 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011710
11711 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 }//Allocate memory
11713 }
11714
11715 if(pfSameIbss)
11716 {
11717 *pfSameIbss = fSameIbss;
11718 }
11719 return( status );
11720}
11721
Jeff Johnson295189b2012-06-20 16:38:30 -070011722static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11723 tSirSmeNewBssInfo *pNewBss )
11724{
11725 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011726
11727 if(!pSession)
11728 {
11729 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11730 return;
11731 }
11732
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 if( pNewBss )
11734 {
11735 // Set the operating channel.
11736 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11737 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011738 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11739 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 return;
11742}
11743
Jeff Johnson295189b2012-06-20 16:38:30 -070011744#ifdef FEATURE_WLAN_WAPI
11745eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11746 tANI_U32 numItems )
11747{
11748 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11749 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011752 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 return status;
11754 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011755 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pSession = CSR_GET_SESSION( pMac, sessionId );
11757 if(numItems <= CSR_MAX_BKID_ALLOWED)
11758 {
11759 status = eHAL_STATUS_SUCCESS;
11760 //numItems may be 0 to clear the cache
11761 pSession->NumBkidCache = (tANI_U16)numItems;
11762 if(numItems && pBKIDCache)
11763 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011764 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11765 sizeof(tBkidCacheInfo) * numItems);
11766 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 }
11768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 return (status);
11770}
Jeff Johnson295189b2012-06-20 16:38:30 -070011771eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11772 tBkidCacheInfo *pBkidCache)
11773{
11774 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11775 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011776 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011778 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 return status;
11780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 pSession = CSR_GET_SESSION( pMac, sessionId );
11782 if(pNum && pBkidCache)
11783 {
11784 if(pSession->NumBkidCache == 0)
11785 {
11786 *pNum = 0;
11787 status = eHAL_STATUS_SUCCESS;
11788 }
11789 else if(*pNum >= pSession->NumBkidCache)
11790 {
11791 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011793 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 pSession->NumBkidCache);
11795 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11796 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011797 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11798 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 *pNum = pSession->NumBkidCache;
11800 status = eHAL_STATUS_SUCCESS;
11801 }
11802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011803 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011804}
Jeff Johnson295189b2012-06-20 16:38:30 -070011805tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11806{
11807 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011808}
11809#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011810eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11811 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11812{
11813 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11814 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011815
11816 if(!pSession)
11817 {
11818 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11819 return eHAL_STATUS_FAILURE;
11820 }
11821
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011822 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11824 {
11825#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11826 {
11827 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011828 vos_mem_set(&secEvent,
11829 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11831 secEvent.encryptionModeMulticast =
11832 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11833 secEvent.encryptionModeUnicast =
11834 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011835 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 secEvent.authMode =
11837 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11838 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11839 }
11840#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 status = eHAL_STATUS_SUCCESS;
11842 //numItems may be 0 to clear the cache
11843 pSession->NumPmkidCache = (tANI_U16)numItems;
11844 if(numItems && pPMKIDCache)
11845 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011846 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11847 sizeof(tPmkidCacheInfo) * numItems);
11848 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 }
11850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 return (status);
11852}
11853
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011854eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11855 tANI_U8 *pBSSId )
11856{
11857 eHalStatus status = eHAL_STATUS_FAILURE;
11858 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11859 tANI_BOOLEAN fMatchFound = FALSE;
11860 tANI_U32 Index;
11861 if(!pSession)
11862 {
11863 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11864 return eHAL_STATUS_FAILURE;
11865 }
11866 do
11867 {
11868 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11869 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011870 smsLog(pMac, LOGW, "Delete PMKID for "
11871 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053011872 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011873 {
11874 fMatchFound = TRUE;
11875 break;
11876 }
11877 }
11878 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011879 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011880 status = eHAL_STATUS_SUCCESS;
11881 }
11882 while( 0 );
11883 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11884 fMatchFound, status);
11885 return status;
11886}
Jeff Johnson295189b2012-06-20 16:38:30 -070011887tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11888{
11889 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11890}
11891
Jeff Johnson295189b2012-06-20 16:38:30 -070011892eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11893{
11894 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11895 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011896
11897 if(!pSession)
11898 {
11899 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11900 return eHAL_STATUS_FAILURE;
11901 }
11902
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 if(pNum && pPmkidCache)
11904 {
11905 if(pSession->NumPmkidCache == 0)
11906 {
11907 *pNum = 0;
11908 status = eHAL_STATUS_SUCCESS;
11909 }
11910 else if(*pNum >= pSession->NumPmkidCache)
11911 {
11912 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011914 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 pSession->NumPmkidCache);
11916 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11917 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011918 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11919 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 *pNum = pSession->NumPmkidCache;
11921 status = eHAL_STATUS_SUCCESS;
11922 }
11923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011924 return (status);
11925}
11926
Jeff Johnson295189b2012-06-20 16:38:30 -070011927eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11928{
11929 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11930 tANI_U32 len;
11931 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011932
11933 if(!pSession)
11934 {
11935 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11936 return eHAL_STATUS_FAILURE;
11937 }
11938
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 if(pLen)
11940 {
11941 len = *pLen;
11942 *pLen = pSession->nWpaRsnReqIeLength;
11943 if(pBuf)
11944 {
11945 if(len >= pSession->nWpaRsnReqIeLength)
11946 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011947 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11948 pSession->nWpaRsnReqIeLength);
11949 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 }
11951 }
11952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 return (status);
11954}
11955
Jeff Johnson295189b2012-06-20 16:38:30 -070011956eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11957{
11958 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11959 tANI_U32 len;
11960 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011961
11962 if(!pSession)
11963 {
11964 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11965 return eHAL_STATUS_FAILURE;
11966 }
11967
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 if(pLen)
11969 {
11970 len = *pLen;
11971 *pLen = pSession->nWpaRsnRspIeLength;
11972 if(pBuf)
11973 {
11974 if(len >= pSession->nWpaRsnRspIeLength)
11975 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011976 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11977 pSession->nWpaRsnRspIeLength);
11978 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 }
11980 }
11981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011982 return (status);
11983}
Jeff Johnson295189b2012-06-20 16:38:30 -070011984#ifdef FEATURE_WLAN_WAPI
11985eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11986{
11987 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11988 tANI_U32 len;
11989 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011990
11991 if(!pSession)
11992 {
11993 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11994 return eHAL_STATUS_FAILURE;
11995 }
11996
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 if(pLen)
11998 {
11999 len = *pLen;
12000 *pLen = pSession->nWapiReqIeLength;
12001 if(pBuf)
12002 {
12003 if(len >= pSession->nWapiReqIeLength)
12004 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012005 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12006 pSession->nWapiReqIeLength);
12007 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012008 }
12009 }
12010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 return (status);
12012}
Jeff Johnson295189b2012-06-20 16:38:30 -070012013eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12014{
12015 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12016 tANI_U32 len;
12017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012018
12019 if(!pSession)
12020 {
12021 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12022 return eHAL_STATUS_FAILURE;
12023 }
12024
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 if(pLen)
12026 {
12027 len = *pLen;
12028 *pLen = pSession->nWapiRspIeLength;
12029 if(pBuf)
12030 {
12031 if(len >= pSession->nWapiRspIeLength)
12032 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012033 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12034 pSession->nWapiRspIeLength);
12035 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 }
12037 }
12038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 return (status);
12040}
12041#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012042eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12043{
12044 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012046
12047 if(!pSession)
12048 {
12049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12050 return (retStatus);
12051 }
12052
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 if(CSR_IS_ROAMING(pSession))
12054 {
12055 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12056 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 return (retStatus);
12059}
12060
Jeff Johnson295189b2012-06-20 16:38:30 -070012061//This function remove the connected BSS from te cached scan result
12062eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12063 tCsrRoamConnectedProfile *pConnProfile)
12064{
12065 eHalStatus status = eHAL_STATUS_FAILURE;
12066 tCsrScanResultFilter *pScanFilter = NULL;
12067 tListElem *pEntry;
12068 tCsrScanResult *pResult;
12069 tDot11fBeaconIEs *pIes;
12070 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12072 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12073 {
12074 do
12075 {
12076 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012077 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12078 if ( NULL == pScanFilter )
12079 status = eHAL_STATUS_FAILURE;
12080 else
12081 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012083 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12084 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12085 if ( NULL == pScanFilter->BSSIDs.bssid )
12086 status = eHAL_STATUS_FAILURE;
12087 else
12088 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012090 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12091 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12093 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12094 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012095 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12096 if ( NULL == pScanFilter->SSIDs.SSIDList )
12097 status = eHAL_STATUS_FAILURE;
12098 else
12099 status = eHAL_STATUS_SUCCESS;
12100 if (!HAL_STATUS_SUCCESS(status)) break;
12101 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12102 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 }
12104 pScanFilter->authType.numEntries = 1;
12105 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12106 pScanFilter->BSSType = pConnProfile->BSSType;
12107 pScanFilter->EncryptionType.numEntries = 1;
12108 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12109 pScanFilter->mcEncryptionType.numEntries = 1;
12110 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12111 //We ignore the channel for now, BSSID should be enough
12112 pScanFilter->ChannelInfo.numOfChannels = 0;
12113 //Also ignore the following fields
12114 pScanFilter->uapsd_mask = 0;
12115 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12116 pScanFilter->countryCode[0] = 0;
12117 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 csrLLLock(&pMac->scan.scanResultList);
12119 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12120 while( pEntry )
12121 {
12122 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12123 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12124 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12125 pScanFilter, NULL, NULL, NULL, &pIes);
12126 //Release the IEs allocated by csrMatchBSS is needed
12127 if( !pResult->Result.pvIes )
12128 {
12129 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012130 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 }
12132 if(fMatch)
12133 {
12134 //We found the one
12135 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12136 {
12137 //Free the memory
12138 csrFreeScanResultEntry( pMac, pResult );
12139 }
12140 break;
12141 }
12142 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12143 }//while
12144 csrLLUnlock(&pMac->scan.scanResultList);
12145 }while(0);
12146 if(pScanFilter)
12147 {
12148 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012149 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 }
12151 }
12152 return (status);
12153}
12154
Jeff Johnson295189b2012-06-20 16:38:30 -070012155//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012156eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12157{
12158 eHalStatus status = eHAL_STATUS_SUCCESS;
12159 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12161 {
12162 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12163 {
12164 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12165 {
12166 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012167 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 status = eHAL_STATUS_CSR_WRONG_STATE;
12169 break;
12170 }
12171 if( csrIsConnStateInfra( pMac, sessionId ) )
12172 {
12173 if( chnId &&
12174 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012176 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12178 status = eHAL_STATUS_CSR_WRONG_STATE;
12179 break;
12180 }
12181 }
12182 }
12183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 return ( status );
12185}
12186
Jeff Johnson295189b2012-06-20 16:38:30 -070012187static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12188{
12189 eHalStatus status = eHAL_STATUS_SUCCESS;
12190 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12191 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012192
12193 if(!pSession)
12194 {
12195 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12196 return eHAL_STATUS_FAILURE;
12197 }
12198
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 if ( csrIsConnStateIbss( pMac, sessionId ) )
12200 {
12201 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12202 }
12203 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12204 {
12205 // Disassociate from the connected Infrastructure network...
12206 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12207 }
12208 else
12209 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012210 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12211 //Otherwise we need to add code to handle the
12212 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12213 //send stop_bss to PE, before we can continue.
12214 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012215 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012217 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12218 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 // there is no Bss description before we start an WDS so we need
12220 // to adopt all Bss configuration parameters from the Profile.
12221 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12222 if(HAL_STATUS_SUCCESS(status))
12223 {
12224 //Save profile for late use
12225 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012226 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12227 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012229 vos_mem_set(pSession->pCurRoamProfile,
12230 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012234 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012235 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12236 NULL, &bssConfig,
12237 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 }
12239 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012240
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 return( status );
12242}
12243
Jeff Johnson295189b2012-06-20 16:38:30 -070012244////////////////////Mail box
12245
Jeff Johnson295189b2012-06-20 16:38:30 -070012246//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12247//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012248static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12249 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12251{
12252 tCsrChannelSet channelGroup;
12253 tSirMacCapabilityInfo *pAP_capabilityInfo;
12254 tAniBool fTmp;
12255 tANI_BOOLEAN found = FALSE;
12256 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012257 tANI_S8 pwrLimit = 0;
12258 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12260 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12261 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12262 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012263 // 802.11h
12264 //We can do this because it is in HOST CPU order for now.
12265 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012266 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12267 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12268 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 fTmp = (tAniBool)pal_cpu_to_be32(1);
12270 }
12271 else
12272 fTmp = (tAniBool)0;
12273
12274 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012275 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 pBuf += sizeof(tAniBool);
12277 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012278 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 // This is required for 11k test VoWiFi Ent: Test 2.
12280 // We need the power capabilities for Assoc Req.
12281 // This macro is provided by the halPhyCfg.h. We pick our
12282 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012283 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12284 if (0 != pwrLimit)
12285 {
12286 *pBuf++ = pwrLimit;
12287 }
12288 else
12289 {
12290 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 size = sizeof(pMac->roam.validChannelList);
12293 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12294 {
12295 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12296 for ( i = 0; i < size; i++)
12297 {
12298 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12299
12300 }
12301 }
12302 else
12303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012304 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 *pBuf++ = 0; //tSirSupChnl->numChnl
12306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 //Check whether it is ok to enter UAPSD
12308#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12309 if( btcIsReadyForUapsd(pMac) )
12310#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12311 {
12312 *pBuf++ = uapsdMask;
12313 }
12314#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12315 else
12316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012317 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 *pBuf++ = 0;
12319 }
12320#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12321
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012323 vos_mem_copy(pBuf, pBssDescription,
12324 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12326}
12327
Jeff Johnson295189b2012-06-20 16:38:30 -070012328/*
12329 * The communication between HDD and LIM is thru mailbox (MB).
12330 * Both sides will access the data structure "tSirSmeJoinReq".
12331 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12332 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12333 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12334 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12335 */
12336eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012337 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012338{
12339 eHalStatus status = eHAL_STATUS_SUCCESS;
12340 tSirSmeJoinReq *pMsg;
12341 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012342 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 tANI_U16 msgLen, wTmp, ieLen;
12344 tSirMacRateSet OpRateSet;
12345 tSirMacRateSet ExRateSet;
12346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12347 tANI_U32 dwTmp;
12348 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012349 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012350
12351 if(!pSession)
12352 {
12353 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12354 return eHAL_STATUS_FAILURE;
12355 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012356 /* To satisfy klockworks */
12357 if (NULL == pBssDescription)
12358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012359 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012360 return eHAL_STATUS_FAILURE;
12361 }
12362
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 do {
12364 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12365 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012366 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12368 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12369 // IE fields, but the length field in the bssDescription needs to be interpreted to
12370 // determine length of the IE fields.
12371 //
12372 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12373 // add in the length from the bssDescription (then add the size of the 'length' field
12374 // itself because that is NOT included in the length field).
12375 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12376 pBssDescription->length + sizeof( pBssDescription->length ) +
12377 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
Kiet Lam64c1b492013-07-12 13:56:44 +053012378 pMsg = vos_mem_malloc(msgLen);
12379 if (NULL == pMsg)
12380 status = eHAL_STATUS_FAILURE;
12381 else
12382 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012384 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012385 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 pMsg->length = pal_cpu_to_be16(msgLen);
12387 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 // sessionId
12389 *pBuf = (tANI_U8)sessionId;
12390 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 // transactionId
12392 *pBuf = 0;
12393 *( pBuf + 1 ) = 0;
12394 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 // ssId
12396 if( pIes->SSID.present && pIes->SSID.num_ssid )
12397 {
12398 // ssId len
12399 *pBuf = pIes->SSID.num_ssid;
12400 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012401 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 pBuf += pIes->SSID.num_ssid;
12403 }
12404 else
12405 {
12406 *pBuf = 0;
12407 pBuf++;
12408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012410 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12411 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 pBuf += sizeof(tSirMacAddr);
12413 // bsstype
12414 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12415 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012416 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 pBuf += sizeof(tSirBssType);
12418 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012419 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12420 if (pBssDescription->channelId <= 14 &&
12421 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12422 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12423 {
12424 //Need to disable VHT operation in 2.4 GHz band
12425 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12426 }
12427 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 //Persona
12430 *pBuf = (tANI_U8)pProfile->csrPersona;
12431 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012432 //CBMode
12433 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12434 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012435
12436 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012437 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12438
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 // uapsdPerAcBitmask
12440 *pBuf = pProfile->uapsd_mask;
12441 pBuf++;
12442
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012443
12444
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012446 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 {
12448 // OperationalRateSet
12449 if (OpRateSet.numRates) {
12450 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012451 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 pBuf += OpRateSet.numRates;
12453 } else *pBuf++ = 0;
12454 // ExtendedRateSet
12455 if (ExRateSet.numRates) {
12456 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012457 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 pBuf += ExRateSet.numRates;
12459 } else *pBuf++ = 0;
12460 }
12461 else
12462 {
12463 *pBuf++ = 0;
12464 *pBuf++ = 0;
12465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 // rsnIE
12467 if ( csrIsProfileWpa( pProfile ) )
12468 {
12469 // Insert the Wpa IE into the join request
12470 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12471 (tCsrWpaIe *)( wpaRsnIE ) );
12472 }
12473 else if( csrIsProfileRSN( pProfile ) )
12474 {
12475 // Insert the RSN IE into the join request
12476 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12477 (tCsrRSNIe *)( wpaRsnIE ) );
12478 }
12479#ifdef FEATURE_WLAN_WAPI
12480 else if( csrIsProfileWapi( pProfile ) )
12481 {
12482 // Insert the WAPI IE into the join request
12483 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12484 (tCsrWapiIe *)( wpaRsnIE ) );
12485 }
12486#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 else
12488 {
12489 ieLen = 0;
12490 }
12491 //remember the IE for future use
12492 if( ieLen )
12493 {
12494 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012496 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"), ieLen, DOT11F_IE_RSN_MAX_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 ieLen = DOT11F_IE_RSN_MAX_LEN;
12498 }
12499#ifdef FEATURE_WLAN_WAPI
12500 if( csrIsProfileWapi( pProfile ) )
12501 {
12502 //Check whether we need to allocate more memory
12503 if(ieLen > pSession->nWapiReqIeLength)
12504 {
12505 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12506 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012507 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012508 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012509 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12510 if (NULL == pSession->pWapiReqIE)
12511 status = eHAL_STATUS_FAILURE;
12512 else
12513 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 if(!HAL_STATUS_SUCCESS(status)) break;
12515 }
12516 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012517 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012519 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012521 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 pBuf += ieLen;
12523 }
12524 else//should be WPA/WPA2 otherwise
12525#endif /* FEATURE_WLAN_WAPI */
12526 {
12527 //Check whether we need to allocate more memory
12528 if(ieLen > pSession->nWpaRsnReqIeLength)
12529 {
12530 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12531 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012532 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012534 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12535 if (NULL == pSession->pWpaRsnReqIE)
12536 status = eHAL_STATUS_FAILURE;
12537 else
12538 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 if(!HAL_STATUS_SUCCESS(status)) break;
12540 }
12541 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012542 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012544 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012546 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 pBuf += ieLen;
12548 }
12549 }
12550 else
12551 {
12552 //free whatever old info
12553 pSession->nWpaRsnReqIeLength = 0;
12554 if(pSession->pWpaRsnReqIE)
12555 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012556 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 pSession->pWpaRsnReqIE = NULL;
12558 }
12559#ifdef FEATURE_WLAN_WAPI
12560 pSession->nWapiReqIeLength = 0;
12561 if(pSession->pWapiReqIE)
12562 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012563 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 pSession->pWapiReqIE = NULL;
12565 }
12566#endif /* FEATURE_WLAN_WAPI */
12567 //length is two bytes
12568 *pBuf = 0;
12569 *(pBuf + 1) = 0;
12570 pBuf += 2;
12571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012572#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012573 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012575 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 //length is two bytes
12577 *pBuf = 0;
12578 *(pBuf + 1) = 0;
12579 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012580 }
12581 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012583 // cckmIE
12584 if( csrIsProfileCCX( pProfile ) )
12585 {
12586 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012587#ifdef FEATURE_WLAN_CCX_UPLOAD
12588 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12589 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12590 pSession->suppCckmIeInfo.cckmIe, ieLen);
12591#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012592 ieLen = csrConstructCcxCckmIe( pMac,
12593 pSession,
12594 pProfile,
12595 pBssDescription,
12596 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 pSession->nWpaRsnReqIeLength,
12598 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012599#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012600 }
12601 else
12602 {
12603 ieLen = 0;
12604 }
12605 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12606 if( ieLen )
12607 {
12608 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12609 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012610 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012611 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012612 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012613 pBuf += ieLen;
12614 }
12615 else
12616 {
12617 //Indicate you have no CCKM IE
12618 //length is two bytes
12619 *pBuf = 0;
12620 *(pBuf + 1) = 0;
12621 pBuf += 2;
12622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012623 }
12624#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012626 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 {
12628 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012629 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012631 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012633 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012635 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 pBuf += ieLen;
12637 }
12638 else
12639 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012640 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 *pBuf = 0;
12643 *(pBuf + 1) = 0;
12644 pBuf += 2;
12645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 // addIEAssoc
12647 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12648 {
12649 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 if(ieLen > pSession->nAddIEAssocLength)
12651 {
12652 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012653 {
12654 vos_mem_free(pSession->pAddIEAssoc);
12655 }
12656 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12657 if (NULL == pSession->pAddIEAssoc)
12658 status = eHAL_STATUS_FAILURE;
12659 else
12660 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012662 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012664 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012666 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012667 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012668 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012669 pBuf += ieLen;
12670 }
12671 else
12672 {
12673 pSession->nAddIEAssocLength = 0;
12674 if(pSession->pAddIEAssoc)
12675 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012676 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 pSession->pAddIEAssoc = NULL;
12678 }
12679 *pBuf = 0;
12680 *(pBuf + 1) = 0;
12681 pBuf += 2;
12682 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012683
12684 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012686 //Unmask any AC in reassoc that is ACM-set
12687 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12688 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012690 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12691 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012692#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012693 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012694#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012695 uapsd_mask &= ~(acm_mask);
12696 }
12697 else
12698 {
12699 uapsd_mask = 0;
12700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 }
12702 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012703
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012705 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012706 pBuf += sizeof(tANI_U32);
12707
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012709 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012710 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012711#ifdef WLAN_FEATURE_11W
12712 //MgmtEncryption
12713 if (pProfile->MFPEnabled)
12714 {
12715 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12716 }
12717 else
12718 {
12719 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12720 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012721 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012722 pBuf += sizeof(tANI_U32);
12723#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012724#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012725 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012726 if (csrIsProfile11r( pProfile )
12727#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012728 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12729 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012730#endif
12731 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012732 {
12733 // is11Rconnection;
12734 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012735 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012736 pBuf += sizeof(tAniBool);
12737 }
12738 else
12739 {
12740 // is11Rconnection;
12741 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012742 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012743 pBuf += sizeof(tAniBool);
12744 }
12745#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012746#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012747
12748 // isCCXFeatureIniEnabled
12749 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12750 {
12751 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012752 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012753 pBuf += sizeof(tAniBool);
12754 }
12755 else
12756 {
12757 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012758 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012759 pBuf += sizeof(tAniBool);
12760 }
12761
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012762 /* A profile can not be both CCX and 11R. But an 802.11R AP
12763 * may be advertising support for CCX as well. So if we are
12764 * associating Open or explicitly CCX then we will get CCX.
12765 * If we are associating explictly 11R only then we will get
12766 * 11R.
12767 */
12768 if ((csrIsProfileCCX(pProfile) ||
12769 ((pIes->CCXVersion.present)
12770 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012771 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12772 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12773 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012774#ifdef WLAN_FEATURE_11W
12775 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12776#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012777 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012778 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12779 {
12780 // isCCXconnection;
12781 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012782 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012783 pBuf += sizeof(tAniBool);
12784 }
12785 else
12786 {
12787 //isCCXconnection;
12788 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012789 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012790 pBuf += sizeof(tAniBool);
12791 }
12792
12793 if (eWNI_SME_JOIN_REQ == messageType)
12794 {
12795 tCCXTspecInfo ccxTspec;
12796 // CCX-Tspec IEs in the ASSOC request is presently not supported
12797 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012798 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12799 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012800 pBuf += sizeof(tCCXTspecInfo);
12801 }
12802 else if (eWNI_SME_REASSOC_REQ == messageType)
12803 {
12804 if ((csrIsProfileCCX(pProfile) ||
12805 ((pIes->CCXVersion.present)
12806 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012807 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12808 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12809 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012810#ifdef WLAN_FEATURE_11W
12811 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12812#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012813 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012814 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 {
12816 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012818 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12820 *pBuf = ccxTspec.numTspecs;
12821 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 // Copy the TSPEC information only if present
12823 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012824 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12825 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 }
12827 pBuf += sizeof(ccxTspec.tspec);
12828 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012829 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 tCCXTspecInfo ccxTspec;
12832 // CCX-Tspec IEs in the ASSOC request is presently not supported
12833 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012834 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12835 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 pBuf += sizeof(tCCXTspecInfo);
12837 }
12838 }
12839#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012840#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012842 if (pMac->roam.configParam.isFastTransitionEnabled
12843#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012844 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012845#endif
12846 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012848 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012849 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012850 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 }
12852 else
12853 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012854 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012855 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012856 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 }
12858#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012859#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012860 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012861 {
12862 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012863 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012864 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012865 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012866 }
12867 else
12868 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012869 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012871 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012872 }
12873#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012874
12875 // txLdpcIniFeatureEnabled
12876 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12877 pBuf++;
12878
Kiran4a17ebe2013-01-31 10:43:43 -080012879 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12880 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12881 {
12882 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12883 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12884 csrApplyPower2Current(pMac);
12885 }
12886
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012887#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012888 // txBFIniFeatureEnabled
12889 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12890 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012891
12892 // txBFCsnValue
12893 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12894 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012895#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012896 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12897 pBuf++;
12898
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053012899 // WME
12900 if(pMac->roam.roamSession[sessionId].fWMMConnection)
12901 {
12902 //WME enabled
12903 dwTmp = pal_cpu_to_be32(TRUE);
12904 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12905 pBuf += sizeof(tAniBool);
12906 }
12907 else
12908 {
12909 dwTmp = pal_cpu_to_be32(FALSE);
12910 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12911 pBuf += sizeof(tAniBool);
12912 }
12913
12914 // QOS
12915 if(pMac->roam.roamSession[sessionId].fQOSConnection)
12916 {
12917 //QOS enabled
12918 dwTmp = pal_cpu_to_be32(TRUE);
12919 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12920 pBuf += sizeof(tAniBool);
12921 }
12922 else
12923 {
12924 dwTmp = pal_cpu_to_be32(FALSE);
12925 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12926 pBuf += sizeof(tAniBool);
12927 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012928 //BssDesc
12929 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12930 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012931
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012932 status = palSendMBMessage(pMac->hHdd, pMsg );
12933 if(!HAL_STATUS_SUCCESS(status))
12934 {
12935 break;
12936 }
12937 else
12938 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012939#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012940 if (eWNI_SME_JOIN_REQ == messageType)
12941 {
12942 //Tush-QoS: notify QoS module that join happening
12943 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12944 }
12945 else if (eWNI_SME_REASSOC_REQ == messageType)
12946 {
12947 //Tush-QoS: notify QoS module that reassoc happening
12948 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012950#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012954}
12955
Jeff Johnson295189b2012-06-20 16:38:30 -070012956//
12957eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12958{
12959 eHalStatus status = eHAL_STATUS_SUCCESS;
12960 tSirSmeDisassocReq *pMsg;
12961 tANI_U8 *pBuf;
12962 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12964 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12965 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012967 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12968 if (NULL == pMsg)
12969 status = eHAL_STATUS_FAILURE;
12970 else
12971 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012973 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12975 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 pBuf = &pMsg->sessionId;
12977 // sessionId
12978 *pBuf++ = (tANI_U8)sessionId;
12979 // transactionId
12980 *pBuf = 0;
12981 *( pBuf + 1 ) = 0;
12982 pBuf += sizeof(tANI_U16);
12983
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012984 if ( (pSession->pCurRoamProfile != NULL) &&
12985 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12986 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 {
12988 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012989 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12990 sizeof( tSirMacAddr ));
12991 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012994 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12995 //perMacAddr is passed as bssId for softAP
12996 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 pBuf = pBuf + sizeof ( tSirMacAddr );
12998 }
12999 else
13000 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013002 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13003 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013005 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13006 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013007 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 if(!HAL_STATUS_SUCCESS(status))
13010 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013011 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 break;
13013 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 // reasonCode
13015 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013016 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13017 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 if(!HAL_STATUS_SUCCESS(status))
13019 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013020 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 break;
13022 }
13023 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13025 Here we should not send the disassoc over the air to the AP */
13026 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13027#ifdef WLAN_FEATURE_VOWIFI_11R
13028 && csrRoamIs11rAssoc(pMac)
13029#endif
13030 )
13031 {
13032 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13033 }
13034 pBuf += sizeof(tANI_U8);
13035 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 return( status );
13038}
Jeff Johnson295189b2012-06-20 16:38:30 -070013039eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13040{
13041 eHalStatus status = eHAL_STATUS_SUCCESS;
13042 tSirSmeTkipCntrMeasReq *pMsg;
13043 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 do
13045 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013046 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13047 if ( NULL == pMsg )
13048 status = eHAL_STATUS_FAILURE;
13049 else
13050 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013052 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13054 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 pBuf = &pMsg->sessionId;
13056 // sessionId
13057 *pBuf++ = (tANI_U8)sessionId;
13058 // transactionId
13059 *pBuf = 0;
13060 *( pBuf + 1 ) = 0;
13061 pBuf += sizeof(tANI_U16);
13062 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013063 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13064 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013065 pBuf = pBuf + sizeof ( tSirMacAddr );
13066 // bEnable
13067 *pBuf = (tANI_BOOLEAN)bEnable;
13068 if(!HAL_STATUS_SUCCESS(status))
13069 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013070 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 break;
13072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 return( status );
13076}
Jeff Johnson295189b2012-06-20 16:38:30 -070013077eHalStatus
13078csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13079 VOS_MODULE_ID modId, tSirMacAddr bssId,
13080 void *pUsrContext, void *pfnSapEventCallback,
13081 tANI_U8 *pAssocStasBuf )
13082{
13083 eHalStatus status = eHAL_STATUS_SUCCESS;
13084 tSirSmeGetAssocSTAsReq *pMsg;
13085 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13086 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 do
13088 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013089 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13090 if ( NULL == pMsg )
13091 status = eHAL_STATUS_FAILURE;
13092 else
13093 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013095 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 pBuf = (tANI_U8 *)&pMsg->bssId;
13098 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013100 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 // modId
13103 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013104 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 // pUsrContext
13107 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013108 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 // pfnSapEventCallback
13111 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013112 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 // pAssocStasBuf
13115 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013116 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 status = palSendMBMessage( pMac->hHdd, pMsg );
13120 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 return( status );
13122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013123eHalStatus
13124csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13125 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13126 {
13127 eHalStatus status = eHAL_STATUS_SUCCESS;
13128 tSirSmeGetWPSPBCSessionsReq *pMsg;
13129 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13130 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 do
13132 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013133 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13134 if ( NULL == pMsg )
13135 status = eHAL_STATUS_FAILURE;
13136 else
13137 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013139 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013142 VOS_ASSERT(pBuf);
13143
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 // pUsrContext
13146 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013147 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 // pSapEventCallback
13150 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013151 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013152 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013154 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013157 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013161 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013162 return( status );
13163}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013164
13165eHalStatus
13166csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13167{
13168 tpSirChangeBIParams pMsg;
13169 tANI_U16 len = 0;
13170 eHalStatus status = eHAL_STATUS_SUCCESS;
13171 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13172
13173 if(!pSession)
13174 {
13175 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13176 return eHAL_STATUS_FAILURE;
13177 }
13178
13179 //NO need to update the Beacon Params if update beacon parameter flag is not set
13180 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13181 return eHAL_STATUS_SUCCESS;
13182
13183 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13184
13185 /* Create the message and send to lim */
13186 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013187 pMsg = vos_mem_malloc(len);
13188 if ( NULL == pMsg )
13189 status = eHAL_STATUS_FAILURE;
13190 else
13191 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013192 if(HAL_STATUS_SUCCESS(status))
13193 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013194 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013195 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13196 pMsg->length = len;
13197
13198 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013199 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13200 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013201 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13202 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013203 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013204 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013205 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13206 status = palSendMBMessage(pMac->hHdd, pMsg);
13207 }
13208 return status;
13209}
13210
Jeff Johnson295189b2012-06-20 16:38:30 -070013211eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13212{
13213 eHalStatus status = eHAL_STATUS_SUCCESS;
13214 tSirSmeDeauthReq *pMsg;
13215 tANI_U8 *pBuf;
13216 tANI_U16 wTmp;
13217 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13218 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13219 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013220 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013221 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13222 if ( NULL == pMsg )
13223 status = eHAL_STATUS_FAILURE;
13224 else
13225 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013227 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13229 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13230 //sessionId
13231 pBuf = &pMsg->sessionId;
13232 *pBuf++ = (tANI_U8)sessionId;
13233
13234 //tansactionId
13235 *pBuf = 0;
13236 *(pBuf + 1 ) = 0;
13237 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13241 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013242 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13243 sizeof( pMsg->peerMacAddr ) );
13244 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 pBuf = pBuf + sizeof(tSirMacAddr);
13246 }
13247 else
13248 {
13249 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013250 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13251 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 }
13254 if(!HAL_STATUS_SUCCESS(status))
13255 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013256 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 break;
13258 }
13259 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013260 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13261 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 pBuf = pBuf + sizeof(tSirMacAddr);
13263 if(!HAL_STATUS_SUCCESS(status))
13264 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013265 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 break;
13267 }
13268 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013269 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13270 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 if(!HAL_STATUS_SUCCESS(status))
13272 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013273 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 break;
13275 }
13276 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013278 return( status );
13279}
13280
Jeff Johnson295189b2012-06-20 16:38:30 -070013281eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13282{
13283 eHalStatus status = eHAL_STATUS_SUCCESS;
13284 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013286 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13287 if ( NULL == pMsg )
13288 status = eHAL_STATUS_FAILURE;
13289 else
13290 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013292 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13294 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13295 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013296 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13297 sizeof(pMsg->peerMacAddr));
13298 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 if(!HAL_STATUS_SUCCESS(status))
13300 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013301 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 break;
13303 }
13304//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013305 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13306 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 if(!HAL_STATUS_SUCCESS(status))
13308 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013309 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 break;
13311 }
13312//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 return( status );
13316}
13317
Jeff Johnson295189b2012-06-20 16:38:30 -070013318eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13319{
13320 eHalStatus status = eHAL_STATUS_SUCCESS;
13321 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013323 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13324 if ( NULL == pMsg )
13325 status = eHAL_STATUS_FAILURE;
13326 else
13327 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013329 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13331 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13332 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13334 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 if(!HAL_STATUS_SUCCESS(status))
13336 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013337 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 break;
13339 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013340 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13341 sizeof(pMsg->peerMacAddr));
13342 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 if(!HAL_STATUS_SUCCESS(status))
13344 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013345 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 break;
13347 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 return( status );
13351}
Jeff Johnson295189b2012-06-20 16:38:30 -070013352eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13353{
13354 eHalStatus status = eHAL_STATUS_SUCCESS;
13355 tSirSmeAssocCnf *pMsg;
13356 tANI_U8 *pBuf;
13357 tSirResultCodes statusCode;
13358 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013360 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13361 if ( NULL == pMsg )
13362 status = eHAL_STATUS_FAILURE;
13363 else
13364 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013366 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13368 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 pBuf = (tANI_U8 *)&pMsg->statusCode;
13370 if(HAL_STATUS_SUCCESS(Halstatus))
13371 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13372 else
13373 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013374 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 pBuf += sizeof(tSirResultCodes);
13376 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013377 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13378 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 pBuf += sizeof (tSirMacAddr);
13380 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13382 sizeof(tSirMacAddr));
13383 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 pBuf += sizeof (tSirMacAddr);
13385 // aid
13386 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013387 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 pBuf += sizeof (tANI_U16);
13389 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013390 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13391 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 pBuf += sizeof (tSirMacAddr);
13393 // alternateChannelId
13394 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 status = palSendMBMessage( pMac->hHdd, pMsg );
13396 if(!HAL_STATUS_SUCCESS(status))
13397 {
13398 //pMsg is freed by palSendMBMessage
13399 break;
13400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 return( status );
13403}
Jeff Johnson295189b2012-06-20 16:38:30 -070013404eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13405 tpSirSmeAssocInd pAssocInd,
13406 eHalStatus Halstatus,
13407 tANI_U8 sessionId)
13408{
13409 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13411 tANI_U8 *pBuf;
13412 tSirResultCodes statusCode;
13413 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013415 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13416 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13417 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013418
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13420 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13421
13422 pMsg->sessionId = sessionId;
13423
13424 pBuf = (tANI_U8 *)&pMsg->statusCode;
13425 if(HAL_STATUS_SUCCESS(Halstatus))
13426 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13427 else
13428 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013429 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 pBuf += sizeof(tSirResultCodes);
13431 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013432 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 pBuf += sizeof (tSirMacAddr);
13434 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013435 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13436 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 pBuf += sizeof (tSirMacAddr);
13438 // StaId
13439 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013440 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 pBuf += sizeof (tANI_U16);
13442 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013443 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013444 pBuf += sizeof (tSirMacAddr);
13445 // alternateChannelId
13446 *pBuf = 11;
13447 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013448 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 //Wmm
13450 *pBuf = pAssocInd->wmmEnabledSta;
13451 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013453 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013456 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 //reassocReq
13459 *pBuf = pAssocInd->reassocReq;
13460 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13462 msgQ.bodyptr = pMsg;
13463 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013466 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013467}
Jeff Johnson295189b2012-06-20 16:38:30 -070013468
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013469eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13471 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13472 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13473 tANI_U8 *pKeyRsc )
13474{
13475 tSirSmeSetContextReq *pMsg;
13476 tANI_U16 msgLen;
13477 eHalStatus status = eHAL_STATUS_FAILURE;
13478 tAniEdType tmpEdType;
13479 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013480 tANI_U8 *pBuf = NULL;
13481 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13486 // key set. Since we only support upto one key, we always allocate memory for 1 key
13487 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13488 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13489 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13490 ( sizeof( pMsg->keyMaterial.key ) );
13491
Kiet Lam64c1b492013-07-12 13:56:44 +053013492 pMsg = vos_mem_malloc(msgLen);
13493 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13494 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13496 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 //sessionId
13498 pBuf = &pMsg->sessionId;
13499 *pBuf = (tANI_U8)sessionId;
13500 pBuf++;
13501 // transactionId
13502 *pBuf = 0;
13503 *(pBuf + 1) = 0;
13504 pBuf += sizeof(tANI_U16);
13505 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013506 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013507
13508 pBuf += sizeof(tSirMacAddr);
13509
13510 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013511 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13512 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013513
13514 pBuf += sizeof(tSirMacAddr);
13515
13516 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13518 // in the tSirKeyMaterial keyMaterial; field).
13519 //
13520 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13521 // shorter than this max size. Is LIM interpreting this ok ?
13522 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 -070013523 // set pMsg->keyMaterial.edType
13524 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013525 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 // set the pMsg->keyMaterial.numKeys field
13528 *p = numKeys;
13529 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 // set pSirKey->keyId = keyId;
13531 *p = keyId;
13532 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 // set pSirKey->unicast = (tANI_U8)fUnicast;
13534 *p = (tANI_U8)fUnicast;
13535 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 // set pSirKey->keyDirection = aniKeyDirection;
13537 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013538 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 p += sizeof(tAniKeyDirection);
13540 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013541 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 // set pSirKey->paeRole
13544 *p = paeRole; // 0 is Supplicant
13545 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 // set pSirKey->keyLength = keyLength;
13547 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 if ( keyLength && pKey )
13549 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013550 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 if(keyLength == 16)
13552 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013553 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 -070013554 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13555 pKey[5], pKey[6], pKey[7], pKey[8],
13556 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13557 }
13558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013560 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 return( status );
13562}
13563
Jeff Johnson295189b2012-06-20 16:38:30 -070013564eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13565 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13566{
13567 eHalStatus status;
13568 tSirSmeStartBssReq *pMsg;
13569 tANI_U8 *pBuf = NULL;
13570 tANI_U8 *wTmpBuf = NULL;
13571 tANI_U16 msgLen, wTmp;
13572 tANI_U32 dwTmp;
13573 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013574 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013577
13578 if(!pSession)
13579 {
13580 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13581 return eHAL_STATUS_FAILURE;
13582 }
13583
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 do {
13585 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13586 pSession->joinFailStatusCode.reasonCode = 0;
13587 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013588 pMsg = vos_mem_malloc(msgLen);
13589 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13590 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 //sessionId
13595 *pBuf = (tANI_U8)sessionId;
13596 pBuf++;
13597 // transactionId
13598 *pBuf = 0;
13599 *(pBuf + 1) = 0;
13600 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013602 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 pBuf += sizeof(tSirMacAddr);
13604 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013605 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 pBuf += sizeof(tSirMacAddr);
13607 // beaconInterval
13608 if( pBssDesc && pBssDesc->beaconInterval )
13609 {
13610 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 else if(pParam->beaconInterval)
13613 {
13614 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 else
13617 {
13618 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13619 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013620 if(csrIsconcurrentsessionValid (pMac, sessionId,
13621 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013622 == eHAL_STATUS_SUCCESS )
13623 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013624 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013625 pParam->bssPersona);
13626 //Update the beacon Interval
13627 pParam->beaconInterval = wTmp;
13628 }
13629 else
13630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013631 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013632 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013633 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013634 return status;
13635 }
13636
Kiet Lam64c1b492013-07-12 13:56:44 +053013637 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 pBuf += sizeof(tANI_U16);
13639 // dot11mode
13640 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13641 pBuf += 1;
13642 // bssType
13643 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013644 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 pBuf += sizeof(tSirBssType);
13646 // ssId
13647 if( pParam->ssId.length )
13648 {
13649 // ssId len
13650 *pBuf = pParam->ssId.length;
13651 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013652 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 pBuf += pParam->ssId.length;
13654 }
13655 else
13656 {
13657 *pBuf = 0;
13658 pBuf++;
13659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 // set the channel Id
13661 *pBuf = pParam->operationChn;
13662 pBuf++;
13663 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013664 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013665 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013666 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013667
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 // Set privacy
13669 *pBuf = pParam->privacy;
13670 pBuf++;
13671
13672 //Set Uapsd
13673 *pBuf = pParam->ApUapsdEnable;
13674 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 //Set SSID hidden
13676 *pBuf = pParam->ssidHidden;
13677 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13679 pBuf++;
13680
13681 //Ht protection Enable/Disable
13682 *pBuf = (tANI_U8)pParam->protEnabled;
13683 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 //Enable Beacons to Receive for OBSS protection Enable/Disable
13685 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13686 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 //set cfg related to protection
13688 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013689 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 // Set Auth type
13692 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013693 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 // Set DTIM
13696 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013697 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013698 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 // Set wps_state
13700 *pBuf = pParam->wps_state;
13701 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013702 // set isCoalesingInIBSSAllowed
13703 *pBuf = pMac->isCoalesingInIBSSAllowed;
13704 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 //Persona
13706 *pBuf = (tANI_U8)pParam->bssPersona;
13707 pBuf++;
13708
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013709 //txLdpcIniFeatureEnabled
13710 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13711 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013712
krunal soni4f087d22013-07-29 16:32:26 -070013713 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13715 {
13716 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013717 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 break;
13719 }
13720 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013721 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pBuf += sizeof(tANI_U16);
13723 if( wTmp )
13724 {
13725 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013726 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 pBuf += wTmp;
13728 }
13729 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013730 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13733 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013734 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13735 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 pBuf += pParam->operationalRateSet.numRates ;
13737 *pBuf++ = pParam->extendedRateSet.numRates;
13738 if(0 != pParam->extendedRateSet.numRates)
13739 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013740 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13741 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 pBuf += pParam->extendedRateSet.numRates;
13743 }
krunal sonie9002db2013-11-25 14:24:17 -080013744
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13746 pMsg->length = pal_cpu_to_be16(msgLen);
13747
13748 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 return( status );
13751}
13752
Jeff Johnson295189b2012-06-20 16:38:30 -070013753eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13754{
13755 eHalStatus status = eHAL_STATUS_FAILURE;
13756 tSirSmeStopBssReq *pMsg;
13757 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13758 tANI_U8 *pBuf;
13759 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013760
13761 if(!pSession)
13762 {
13763 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13764 return eHAL_STATUS_FAILURE;
13765 }
13766
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13769 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13770 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13772 pBuf = &pMsg->sessionId;
13773 //sessionId
13774 *pBuf = (tANI_U8)sessionId;
13775 pBuf++;
13776 // transactionId
13777 *pBuf = 0;
13778 pBuf += sizeof(tANI_U16);
13779 //reason code
13780 *pBuf = 0;
13781 pBuf += sizeof(tSirResultCodes);
13782 // bssid
13783 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13784 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13785 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013786 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13787 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 }
13789 else
13790 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013791 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13792 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 }
13794 pBuf += sizeof(tSirMacAddr);
13795 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13796 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 status = palSendMBMessage( pMac->hHdd, pMsg );
13798#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013799 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13800 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13801 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13803 pMsg->reasonCode = 0;
13804 // bssid
13805 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13806 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13807 {
13808 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13809 }
13810 else
13811 {
13812 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13813 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013814 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 pMsg->transactionId = 0;
13816 pMsg->sessionId = (tANI_U8)sessionId;
13817 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13818 status = palSendMBMessage( pMac->hHdd, pMsg );
13819#endif
13820 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 return( status );
13822}
13823
Jeff Johnson295189b2012-06-20 16:38:30 -070013824eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13825 tCsrRoamModifyProfileFields *pModProfileFields,
13826 tANI_U32 *pRoamId, v_BOOL_t fForce)
13827{
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 eHalStatus status = eHAL_STATUS_FAILURE;
13829 tANI_U32 roamId = 0;
13830 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013832 (fForce || (!vos_mem_compare( &pModProfileFields,
13833 &pSession->connectedProfile.modifyProfileFields,
13834 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 {
13836 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13837 if(pRoamId)
13838 {
13839 *pRoamId = roamId;
13840 }
13841
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13843 eCsrSmeIssuedReassocToSameAP, roamId,
13844 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 return status;
13847}
Jeff Johnson295189b2012-06-20 16:38:30 -070013848static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13849{
13850 eHalStatus status = eHAL_STATUS_SUCCESS;
13851 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013852 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13854 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13855 return (status);
13856}
Jeff Johnson295189b2012-06-20 16:38:30 -070013857eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13858{
13859 eHalStatus status = eHAL_STATUS_SUCCESS;
13860 tListElem *pEntry = NULL;
13861 tSmeCmd *pCommand = NULL;
13862 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 do
13864 {
13865 if(pMsg == NULL)
13866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013867 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 status = eHAL_STATUS_FAILURE;
13869 break;
13870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13872 if(pEntry)
13873 {
13874 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13875 if(eSmeCommandAddStaSession == pCommand->command)
13876 {
13877 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013878 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 //Remove this command out of the active list
13882 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13883 {
13884 //Now put this command back on the avilable command list
13885 csrReleaseCommand(pMac, pCommand);
13886 }
13887 smeProcessPendingQueue( pMac );
13888 }
13889 else
13890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013891 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013892 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 status = eHAL_STATUS_FAILURE;
13894 break;
13895 }
13896 }
13897 else
13898 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013899 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 -070013900 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 status = eHAL_STATUS_FAILURE;
13902 break;
13903 }
13904 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013906}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013907eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13908 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013909{
13910 tSirSmeAddStaSelfReq *pMsg;
13911 tANI_U16 msgLen;
13912 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013914 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013915 pMsg = vos_mem_malloc(msgLen);
13916 if ( NULL == pMsg ) break;
13917 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13919 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013921 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013922 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13923
13924 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13925
Arif Hussain24bafea2013-11-15 15:10:03 -080013926 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
13927 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 return( status );
13931}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013932eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13933 tANI_U32 sessionId,
13934 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013935{
13936 eHalStatus status = eHAL_STATUS_SUCCESS;
13937 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 pCommand = csrGetCommandBuffer(pMac);
13939 if(NULL == pCommand)
13940 {
13941 status = eHAL_STATUS_RESOURCES;
13942 }
13943 else
13944 {
13945 pCommand->command = eSmeCommandAddStaSession;
13946 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013947 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13948 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013949 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13951 if( !HAL_STATUS_SUCCESS( status ) )
13952 {
13953 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013954 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 }
13956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 return (status);
13958}
Jeff Johnson295189b2012-06-20 16:38:30 -070013959eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13960{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013961 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013962}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013963eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13964 csrRoamCompleteCallback callback,
13965 void *pContext, tANI_U8 *pSelfMacAddr,
13966 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013967{
13968 eHalStatus status = eHAL_STATUS_SUCCESS;
13969 tANI_U32 i;
13970 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013971 *pbSessionId = CSR_SESSION_ID_INVALID;
13972 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13973 {
13974 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13975 {
13976 pSession = CSR_GET_SESSION( pMac, i );
13977 status = eHAL_STATUS_SUCCESS;
13978 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13979 pSession->sessionId = (tANI_U8)i;
13980 pSession->callback = callback;
13981 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013982 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013984 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13985 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013987 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013989 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 break;
13991 }
13992#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013993 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13994 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013996 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013998 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 break;
14000 }
14001#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014002 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 break;
14004 }
14005 }
14006 if( CSR_ROAM_SESSION_MAX == i )
14007 {
14008 //No session is available
14009 status = eHAL_STATUS_RESOURCES;
14010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 return ( status );
14012}
Jeff Johnson295189b2012-06-20 16:38:30 -070014013eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14014{
14015 eHalStatus status = eHAL_STATUS_SUCCESS;
14016 tListElem *pEntry = NULL;
14017 tSmeCmd *pCommand = NULL;
14018 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 do
14020 {
14021 if(pMsg == NULL)
14022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014023 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 status = eHAL_STATUS_FAILURE;
14025 break;
14026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14028 if(pEntry)
14029 {
14030 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14031 if(eSmeCommandDelStaSession == pCommand->command)
14032 {
14033 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014035 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 //This session is done.
14037 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 if(pCommand->u.delStaSessionCmd.callback)
14039 {
14040
14041 status = sme_ReleaseGlobalLock( &pMac->sme );
14042 if ( HAL_STATUS_SUCCESS( status ) )
14043 {
14044 pCommand->u.delStaSessionCmd.callback(
14045 pCommand->u.delStaSessionCmd.pContext);
14046 status = sme_AcquireGlobalLock( &pMac->sme );
14047 if (! HAL_STATUS_SUCCESS( status ) )
14048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014049 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014050 return status;
14051 }
14052 }
14053 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014054 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 }
14056 }
14057
14058 //Remove this command out of the active list
14059 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14060 {
14061 //Now put this command back on the avilable command list
14062 csrReleaseCommand(pMac, pCommand);
14063 }
14064 smeProcessPendingQueue( pMac );
14065 }
14066 else
14067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014068 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 -070014069 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 status = eHAL_STATUS_FAILURE;
14071 break;
14072 }
14073 }
14074 else
14075 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014076 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 -070014077 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 status = eHAL_STATUS_FAILURE;
14079 break;
14080 }
14081 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014083}
Jeff Johnson295189b2012-06-20 16:38:30 -070014084eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14085{
14086 tSirSmeDelStaSelfReq *pMsg;
14087 tANI_U16 msgLen;
14088 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14091 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014092 pMsg = vos_mem_malloc(msgLen);
14093 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14094 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14096 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014098 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14099 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014102 return( status );
14103}
Jeff Johnson295189b2012-06-20 16:38:30 -070014104eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14105 tSirMacAddr sessionMacAddr,
14106 csrRoamSessionCloseCallback callback,
14107 void *pContext)
14108{
14109 eHalStatus status = eHAL_STATUS_SUCCESS;
14110 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 pCommand = csrGetCommandBuffer(pMac);
14112 if(NULL == pCommand)
14113 {
14114 status = eHAL_STATUS_RESOURCES;
14115 }
14116 else
14117 {
14118 pCommand->command = eSmeCommandDelStaSession;
14119 pCommand->sessionId = (tANI_U8)sessionId;
14120 pCommand->u.delStaSessionCmd.callback = callback;
14121 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014122 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14123 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14125 if( !HAL_STATUS_SUCCESS( status ) )
14126 {
14127 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014128 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 }
14130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 return (status);
14132}
Jeff Johnson295189b2012-06-20 16:38:30 -070014133eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14134{
14135 return csrSendMBDelSelfStaReqMsg( pMac,
14136 pCommand->u.delStaSessionCmd.selfMacAddr );
14137}
Jeff Johnson295189b2012-06-20 16:38:30 -070014138static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14139{
14140 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14141 tListElem *pEntry, *pNext;
14142 tSmeCmd *pCommand;
14143 tDblLinkList localList;
14144
14145 vos_mem_zero(&localList, sizeof(tDblLinkList));
14146 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14147 {
14148 smsLog(pMac, LOGE, FL(" failed to open list"));
14149 return;
14150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 csrLLLock(pList);
14152 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14153 while(pEntry != NULL)
14154 {
14155 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14156 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14157 if(pCommand->sessionId == sessionId)
14158 {
14159 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14160 {
14161 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14162 }
14163 }
14164 pEntry = pNext;
14165 }
14166 csrLLUnlock(pList);
14167
14168 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14169 {
14170 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14171 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14172 }
14173 csrLLClose(&localList);
14174}
14175
Jeff Johnson295189b2012-06-20 16:38:30 -070014176void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14177{
14178 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14179 {
14180 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 csrRoamStop(pMac, sessionId);
14182 csrFreeConnectBssDesc(pMac, sessionId);
14183 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14184 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014185 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014186#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014187 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014188#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014189 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14190 if (pMac->fScanOffload)
14191 {
14192 purgeSmeSessionCmdList(pMac, sessionId,
14193 &pMac->sme.smeScanCmdPendingList);
14194 }
14195
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 purgeCsrSessionCmdList(pMac, sessionId);
14197 csrInitSession(pMac, sessionId);
14198 }
14199}
14200
Jeff Johnson295189b2012-06-20 16:38:30 -070014201eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14202 tANI_BOOLEAN fSync,
14203 csrRoamSessionCloseCallback callback,
14204 void *pContext )
14205{
14206 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14208 {
14209 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14210 if(fSync)
14211 {
14212 csrCleanupSession(pMac, sessionId);
14213 }
14214 else
14215 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014216 purgeSmeSessionCmdList(pMac, sessionId,
14217 &pMac->sme.smeCmdPendingList);
14218 if (pMac->fScanOffload)
14219 {
14220 purgeSmeSessionCmdList(pMac, sessionId,
14221 &pMac->sme.smeScanCmdPendingList);
14222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 purgeCsrSessionCmdList(pMac, sessionId);
14224 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14225 pSession->selfMacAddr, callback, pContext);
14226 }
14227 }
14228 else
14229 {
14230 status = eHAL_STATUS_INVALID_PARAMETER;
14231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 return ( status );
14233}
14234
Jeff Johnson295189b2012-06-20 16:38:30 -070014235static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14236{
14237 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014238
14239 if(!pSession)
14240 {
14241 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14242 return;
14243 }
14244
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14246 pSession->sessionId = CSR_SESSION_ID_INVALID;
14247 pSession->callback = NULL;
14248 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14250 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14251 csrFreeRoamProfile( pMac, sessionId );
14252 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14253 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14254 csrFreeConnectBssDesc(pMac, sessionId);
14255 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014256 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14257 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014259 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 pSession->pWpaRsnReqIE = NULL;
14261 }
14262 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014263 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014265 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 pSession->pWpaRsnRspIE = NULL;
14267 }
14268 pSession->nWpaRsnRspIeLength = 0;
14269#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014270 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014271 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014272 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 pSession->pWapiReqIE = NULL;
14274 }
14275 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014276 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014277 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014278 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014279 pSession->pWapiRspIE = NULL;
14280 }
14281 pSession->nWapiRspIeLength = 0;
14282#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014283 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014285 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 }
14287 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014288
Kiet Lam64c1b492013-07-12 13:56:44 +053014289 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014291 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014295}
14296
Jeff Johnson295189b2012-06-20 16:38:30 -070014297eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14298{
14299 eHalStatus status = eHAL_STATUS_FAILURE;
14300 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14302 {
14303 if( CSR_IS_SESSION_VALID( pMac, i ) )
14304 {
14305 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14306 {
14307 //Found it
14308 status = eHAL_STATUS_SUCCESS;
14309 *pSessionId = i;
14310 break;
14311 }
14312 }
14313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 return( status );
14315}
14316
Jeff Johnson295189b2012-06-20 16:38:30 -070014317//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14318//session because for IBSS, the bssid changes.
14319static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14320{
14321 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14322 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14324 {
14325 if( CSR_IS_SESSION_VALID( pMac, i ) )
14326 {
14327 pSession = CSR_GET_SESSION( pMac, i );
14328 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14329 {
14330 //Found it
14331 nRet = i;
14332 break;
14333 }
14334 }
14335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 return (nRet);
14337}
Jeff Johnson295189b2012-06-20 16:38:30 -070014338static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14339{
14340 /* Update the current BSS info in ho control block based on connected
14341 profile info from pmac global structure */
14342
Arif Hussain24bafea2013-11-15 15:10:03 -080014343 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14344 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014345 /* Check for user misconfig of RSSI trigger threshold */
14346 pMac->roam.configParam.vccRssiThreshold =
14347 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14348 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14349 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 /* Check for user misconfig of UL MAC Loss trigger threshold */
14351 pMac->roam.configParam.vccUlMacLossThreshold =
14352 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14353 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014354#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14355 {
14356 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 /* Indicate the neighbor roal algorithm about the connect indication */
14358 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14359 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14360 }
14361#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014362}
14363
Jeff Johnson295189b2012-06-20 16:38:30 -070014364static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14365{
14366 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014367
14368 if(!pSession)
14369 {
14370 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14371 return;
14372 }
14373
Jeff Johnson295189b2012-06-20 16:38:30 -070014374 //Only to handle the case for Handover on infra link
14375 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14376 {
14377 return;
14378 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14380 csrRoamDeregStatisticsReq(pMac);
14381 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14382#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14383 /* Indicate the neighbor roal algorithm about the disconnect indication */
14384 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14385#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014386
14387 //Remove this code once SLM_Sessionization is supported
14388 //BMPS_WORKAROUND_NOT_NEEDED
14389 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014390 csrIsInfraApStarted( pMac ) &&
14391 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014392 {
14393 pMac->roam.configParam.doBMPSWorkaround = 0;
14394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014395}
14396
Jeff Johnson295189b2012-06-20 16:38:30 -070014397void csrRoamTlStatsTimerHandler(void *pv)
14398{
14399 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14400 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14402
Jeff Johnsone7245742012-09-05 17:12:55 -070014403 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14404
Jeff Johnson295189b2012-06-20 16:38:30 -070014405#if 0
14406 // TODO Persession .???
14407 //req TL for stats
14408 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014410 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014411 }
14412 else
14413 {
14414 //save in SME
14415 csrRoamSaveStatsFromTl(pMac, tlStats);
14416 }
14417#endif
14418 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14419 {
14420 if(pMac->roam.tlStatsReqInfo.periodicity)
14421 {
14422 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014423 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14424 pMac->roam.tlStatsReqInfo.periodicity);
14425 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014427 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014428 return;
14429 }
14430 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14431 }
14432 }
14433}
Jeff Johnson295189b2012-06-20 16:38:30 -070014434void csrRoamPeStatsTimerHandler(void *pv)
14435{
14436 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14437 eHalStatus status;
14438 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14439 VOS_STATUS vosStatus;
14440 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 pPeStatsReqListEntry->timerRunning = FALSE;
14442 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14443 {
14444 // If we entered here, meaning the timer could not be successfully
14445 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14446
14447 /* Destroy the timer */
14448 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14449 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014451 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014452 }
14453
14454 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014455 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014456 pPeStatsReqListEntry = NULL;
14457 }
14458 else
14459 {
14460 if(!pPeStatsReqListEntry->rspPending)
14461 {
14462 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14463 pPeStatsReqListEntry->staId);
14464 if(!HAL_STATUS_SUCCESS(status))
14465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014466 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014467 }
14468 else
14469 {
14470 pPeStatsReqListEntry->rspPending = TRUE;
14471 }
14472 }
14473
14474 //send down a req
14475 if(pPeStatsReqListEntry->periodicity &&
14476 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14477 {
14478 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14479 if(ePMC_FULL_POWER == powerState)
14480 {
14481 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14482 {
14483 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14484 }
14485 }
14486 else
14487 {
14488 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14489 {
14490 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14491 }
14492 }
14493 //start timer
14494 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14495 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014497 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 return;
14499 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 pPeStatsReqListEntry->timerRunning = TRUE;
14501
14502 }
14503
14504 }
14505}
Jeff Johnson295189b2012-06-20 16:38:30 -070014506void csrRoamStatsClientTimerHandler(void *pv)
14507{
14508 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014509 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14510 {
14511#if 0
14512 // TODO Stats fix for multisession
14513 //start the timer
14514 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14515
14516 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014518 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 }
14520#endif
14521 }
14522#if 0
14523 //send up the stats report
14524 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14525 pStaEntry->staId, pStaEntry->pContext);
14526#endif
14527}
14528
14529
14530
Jeff Johnson295189b2012-06-20 16:38:30 -070014531eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14532{
14533 tAniGetPEStatsReq *pMsg;
14534 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014535 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14536 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014538 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014539 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 }
14541 // need to initiate a stats request to PE
14542 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14543 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14544 pMsg->staId = staId;
14545 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014546 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 if(!HAL_STATUS_SUCCESS(status))
14548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014549 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 return status;
14552}
Jeff Johnson295189b2012-06-20 16:38:30 -070014553void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14554{
14555 tAniGetPEStatsRsp *pSmeStatsRsp;
14556 eHalStatus status = eHAL_STATUS_FAILURE;
14557 tListElem *pEntry = NULL;
14558 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14559 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14560 tANI_U32 tempMask = 0;
14561 tANI_U8 counter = 0;
14562 tANI_U8 *pStats = NULL;
14563 tANI_U32 length = 0;
14564 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014565 v_S7_t rssi = 0, snr = 0;
14566 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014567 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14569 if(pSmeStatsRsp->rc)
14570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014571 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 goto post_update;
14573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 tempMask = pSmeStatsRsp->statsMask;
14575 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 /* subtract all statistics from this length, and after processing the entire
14577 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14578 * in this 'stats' message.
14579 */
14580 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 //new stats info from PE, fill up the stats strucutres in PMAC
14582 while(tempMask)
14583 {
14584 if(tempMask & 1)
14585 {
14586 switch(counter)
14587 {
14588 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014589 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014590 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14591 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 pStats += sizeof(tCsrSummaryStatsInfo);
14593 length -= sizeof(tCsrSummaryStatsInfo);
14594 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014596 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014597 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14598 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14600 length -= sizeof(tCsrGlobalClassAStatsInfo);
14601 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014602 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014603 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014604 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14605 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14607 length -= sizeof(tCsrGlobalClassBStatsInfo);
14608 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014610 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014611 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14612 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14614 length -= sizeof(tCsrGlobalClassCStatsInfo);
14615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014616 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014617 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14619 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014620 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14621 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 }
14623 else
14624 {
14625 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014626 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 VOS_ASSERT( 0 );
14628 }
14629 if(!HAL_STATUS_SUCCESS(status))
14630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014631 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 }
14633 pStats += sizeof(tCsrPerStaStatsInfo);
14634 length -= sizeof(tCsrPerStaStatsInfo);
14635 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014637 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014638 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 }
14640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 tempMask >>=1;
14642 counter++;
14643 }
14644 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14645 if (length != 0)
14646 {
14647 pRssi = (tANI_U32*)pStats;
14648 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014649 pStats += sizeof(tANI_U32);
14650 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 }
14652 else
14653 {
14654 /* If riva is not sending rssi, continue to use the hack */
14655 rssi = RSSI_HACK_BMPS;
14656 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014657
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014659
14660 if (length != 0)
14661 {
14662 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014663 pStats += sizeof(tANI_U32);
14664 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014665 }
14666 else
14667 {
14668 linkCapacity = 0;
14669 }
14670
14671 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014672
14673 if (length != 0)
14674 {
14675 pSnr = (tANI_U32*)pStats;
14676 snr = (v_S7_t)*pSnr;
14677 }
14678 else
14679 {
14680 snr = SNR_HACK_BMPS;
14681 }
14682
14683 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014684post_update:
14685 //make sure to update the pe stats req list
14686 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14687 if(pEntry)
14688 {
14689 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14690 pPeStaEntry->rspPending = FALSE;
14691
14692 }
14693 //check the one timer cases
14694 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14695 if(pEntry)
14696 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014697 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 if(pTempStaEntry->timerExpired)
14699 {
14700 //send up the stats report
14701 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14702 pTempStaEntry->staId, pTempStaEntry->pContext);
14703 //also remove from the client list
14704 csrRoamRemoveStatListEntry(pMac, pEntry);
14705 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 }
14707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014708}
Jeff Johnson295189b2012-06-20 16:38:30 -070014709tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14710{
14711 tListElem *pEntry = NULL;
14712 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 if(!pEntry)
14715 {
14716 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014717 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014718 return NULL;
14719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 while( pEntry )
14721 {
14722 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 if(pTempStaEntry->statsMask == statsMask)
14724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014725 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 break;
14727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 return pEntry;
14731}
14732
Jeff Johnson295189b2012-06-20 16:38:30 -070014733tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14734 tANI_BOOLEAN update)
14735{
14736 tListElem *pEntry;
14737 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 if(!pEntry)
14740 {
14741 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014742 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014743 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 return NULL;
14745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 while( pEntry )
14747 {
14748 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14750 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014752 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 if(update)
14754 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014755 pTempStaEntry->periodicity = pStaEntry->periodicity;
14756 pTempStaEntry->callback = pStaEntry->callback;
14757 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 }
14759 break;
14760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014763 return pEntry;
14764}
Jeff Johnson295189b2012-06-20 16:38:30 -070014765tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14766{
14767 tListElem *pEntry;
14768 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 if(!pEntry)
14771 {
14772 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014773 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014774 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 return NULL;
14776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 while( pEntry )
14778 {
14779 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014780 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014782 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 break;
14784 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014785 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 return pEntry;
14788}
Jeff Johnson295189b2012-06-20 16:38:30 -070014789eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14790 csrRoamLinkQualityIndCallback callback,
14791 void *pContext)
14792{
14793 pMac->roam.linkQualityIndInfo.callback = callback;
14794 pMac->roam.linkQualityIndInfo.context = pContext;
14795 if( NULL == callback )
14796 {
14797 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14798 }
14799 else
14800 {
14801 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 /* do we need to invoke the callback to notify client of initial value ?? */
14803 }
14804 return eHAL_STATUS_SUCCESS;
14805}
Jeff Johnson295189b2012-06-20 16:38:30 -070014806void csrRoamVccTrigger(tpAniSirGlobal pMac)
14807{
14808 eCsrRoamLinkQualityInd newVccLinkQuality;
14809 tANI_U32 ul_mac_loss = 0;
14810 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14812 /*-------------------------------------------------------------------------
14813 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 Check for a change in link quality and notify client if necessary
14815 -------------------------------------------------------------------------*/
14816 ul_mac_loss_trigger_threshold =
14817 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014819 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014823 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014824 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14825 }
14826 else
14827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14832 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014835 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014838 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 newVccLinkQuality );
14840
14841 /* we now invoke the callback once to notify client of initial value */
14842 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14843 pMac->roam.linkQualityIndInfo.context );
14844 //event: EVENT_WLAN_VCC
14845 }
14846 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 pMac->roam.vccLinkQuality = newVccLinkQuality;
14848
Jeff Johnson295189b2012-06-20 16:38:30 -070014849}
Jeff Johnson295189b2012-06-20 16:38:30 -070014850VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14851 v_U8_t rssiNotification,
14852 void * context)
14853{
14854 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14855 eCsrRoamLinkQualityInd newVccLinkQuality;
14856 // TODO : Session info unavailable
14857 tANI_U32 sessionId = 0;
14858 VOS_STATUS status = VOS_STATUS_SUCCESS;
14859 /*-------------------------------------------------------------------------
14860 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 Check for a change in link quality and notify client if necessary
14862 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014863 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 pMac->roam.configParam.vccRssiThreshold);
14865 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014867 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 return VOS_STATUS_SUCCESS;
14869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014870 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014872 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14874 }
14875 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014877 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14879 }
14880 else
14881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014882 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 //Set to this so the code below won't do anything
14884 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 VOS_ASSERT(0);
14886 }
14887
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014890 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014893 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 /* we now invoke the callback once to notify client of initial value */
14896 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14897 pMac->roam.linkQualityIndInfo.context );
14898 //event: EVENT_WLAN_VCC
14899 }
14900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014901 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 return status;
14903}
Jeff Johnson295189b2012-06-20 16:38:30 -070014904tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14905 tDblLinkList *pStaList,
14906 tCsrStatsClientReqInfo *pStaEntry)
14907{
14908 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 //if same entity requested for same set of stats with different periodicity &
14910 // callback update it
14911 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14912 {
14913
Kiet Lam64c1b492013-07-12 13:56:44 +053014914 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14915 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 {
14917 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014918 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 return NULL;
14920 }
14921
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 pNewStaEntry->callback = pStaEntry->callback;
14923 pNewStaEntry->pContext = pStaEntry->pContext;
14924 pNewStaEntry->periodicity = pStaEntry->periodicity;
14925 pNewStaEntry->requesterId = pStaEntry->requesterId;
14926 pNewStaEntry->statsMask = pStaEntry->statsMask;
14927 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14928 pNewStaEntry->pMac = pStaEntry->pMac;
14929 pNewStaEntry->staId = pStaEntry->staId;
14930 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14931
14932 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14933 }
14934 return pNewStaEntry;
14935}
14936
Jeff Johnson295189b2012-06-20 16:38:30 -070014937tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14938 tDblLinkList *pStaList,
14939 tCsrPeStatsReqInfo *pStaEntry)
14940{
14941 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014942 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14943 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 {
14945 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014946 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 return NULL;
14948 }
14949
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14951 pNewStaEntry->numClient = pStaEntry->numClient;
14952 pNewStaEntry->periodicity = pStaEntry->periodicity;
14953 pNewStaEntry->statsMask = pStaEntry->statsMask;
14954 pNewStaEntry->pMac = pStaEntry->pMac;
14955 pNewStaEntry->staId = pStaEntry->staId;
14956 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14957 pNewStaEntry->rspPending = pStaEntry->rspPending;
14958
14959 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 return pNewStaEntry;
14961}
Jeff Johnson295189b2012-06-20 16:38:30 -070014962eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14963 tCsrRssiCallback callback,
14964 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14965{
14966 eHalStatus status = eHAL_STATUS_SUCCESS;
14967 vos_msg_t msg;
14968 tANI_U32 sessionId;
14969
14970 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014971 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014972 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14973 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014975 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014976 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14979
14980 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14981 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14982 pMsg->sessionId = sessionId;
14983 pMsg->staId = staId;
14984 pMsg->rssiCallback = callback;
14985 pMsg->pDevContext = pContext;
14986 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 msg.type = eWNI_SME_GET_RSSI_REQ;
14988 msg.bodyptr = pMsg;
14989 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014992 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014993 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 status = eHAL_STATUS_FAILURE;
14995 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014996 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 return status;
14998}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014999
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015000eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15001 tCsrSnrCallback callback,
15002 tANI_U8 staId, tCsrBssid bssId,
15003 void *pContext)
15004{
15005 eHalStatus status = eHAL_STATUS_SUCCESS;
15006 vos_msg_t msg;
15007 tANI_U32 sessionId;
15008
15009 tAniGetSnrReq *pMsg;
15010
15011 smsLog(pMac, LOG2, FL("called"));
15012
15013 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15014 if (NULL == pMsg )
15015 {
15016 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15017 return status;
15018 }
15019
15020 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15021
15022 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15023 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15024 pMsg->sessionId = sessionId;
15025 pMsg->staId = staId;
15026 pMsg->snrCallback = callback;
15027 pMsg->pDevContext = pContext;
15028 msg.type = eWNI_SME_GET_SNR_REQ;
15029 msg.bodyptr = pMsg;
15030 msg.reserved = 0;
15031
15032 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15033 {
15034 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15035 vos_mem_free((v_VOID_t *)pMsg);
15036 status = eHAL_STATUS_FAILURE;
15037 }
15038
15039 smsLog(pMac, LOG2, FL("returned"));
15040 return status;
15041}
15042
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015043#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15044eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15045 tCsrRssiCallback callback,
15046 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15047{
15048 eHalStatus status = eHAL_STATUS_SUCCESS;
15049 tAniGetRssiReq *pMsg;
15050
Kiet Lam64c1b492013-07-12 13:56:44 +053015051 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15052 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015053 {
15054 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053015055 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015056 }
15057 // need to initiate a stats request to PE
15058 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15059 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15060 pMsg->staId = staId;
15061 pMsg->rssiCallback = callback;
15062 pMsg->pDevContext = pContext;
15063 pMsg->pVosContext = pVosContext;
15064 status = palSendMBMessage(pMac->hHdd, pMsg );
15065 if(!HAL_STATUS_SUCCESS(status))
15066 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015067 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15068 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015069 status = eHAL_STATUS_FAILURE;
15070 }
15071 return status;
15072}
15073#endif
15074
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015075
15076
15077#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15078eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15079 tCsrTsmStatsCallback callback,
15080 tANI_U8 staId,
15081 tCsrBssid bssId,
15082 void *pContext,
15083 void* pVosContext,
15084 tANI_U8 tid)
15085{
15086 eHalStatus status = eHAL_STATUS_SUCCESS;
15087 tAniGetTsmStatsReq *pMsg = NULL;
15088
15089 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15090 if ( !HAL_STATUS_SUCCESS(status) )
15091 {
15092 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15093 return status;
15094 }
15095 // need to initiate a stats request to PE
15096 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15097 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15098 pMsg->staId = staId;
15099 pMsg->tid = tid;
15100 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15101 pMsg->tsmStatsCallback = callback;
15102 pMsg->pDevContext = pContext;
15103 pMsg->pVosContext = pVosContext;
15104 status = palSendMBMessage(pMac->hHdd, pMsg );
15105 if(!HAL_STATUS_SUCCESS(status))
15106 {
15107 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15108 //pMsg is freed by palSendMBMessage
15109 status = eHAL_STATUS_FAILURE;
15110 }
15111 return status;
15112}
15113#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15114
15115
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015116/* ---------------------------------------------------------------------------
15117 \fn csrGetTLSTAState
15118 \helper function to get teh TL STA State whenever the function is called.
15119
15120 \param staId - The staID to be passed to the TL
15121 to get the relevant TL STA State
15122 \return the state as tANI_U16
15123 ---------------------------------------------------------------------------*/
15124tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15125{
15126 WLANTL_STAStateType tlSTAState;
15127 tlSTAState = WLANTL_STA_INIT;
15128
15129 //request TL for STA State
15130 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15131 {
15132 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15133 }
15134
15135 return tlSTAState;
15136}
15137
Jeff Johnson295189b2012-06-20 16:38:30 -070015138eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15139 tANI_U32 statsMask,
15140 tCsrStatsCallback callback,
15141 tANI_U32 periodicity, tANI_BOOLEAN cache,
15142 tANI_U8 staId, void *pContext)
15143{
15144 tCsrStatsClientReqInfo staEntry;
15145 tCsrStatsClientReqInfo *pStaEntry = NULL;
15146 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15147 tListElem *pEntry = NULL;
15148 tANI_BOOLEAN found = FALSE;
15149 eHalStatus status = eHAL_STATUS_SUCCESS;
15150 tANI_BOOLEAN insertInClientList = FALSE;
15151 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015152 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015153
15154 if( csrIsAllSessionDisconnected(pMac) )
15155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015156 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 return eHAL_STATUS_FAILURE;
15158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 if((!statsMask) && (!callback))
15160 {
15161 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015162 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015163 return eHAL_STATUS_FAILURE;
15164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 //for the search list method for deregister
15166 staEntry.requesterId = requesterId;
15167 staEntry.statsMask = statsMask;
15168 //requester wants to deregister or just an error
15169 if((statsMask) && (!callback))
15170 {
15171 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15172 if(!pEntry)
15173 {
15174 //msg
15175 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015176 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 return eHAL_STATUS_FAILURE;
15178 }
15179 else
15180 {
15181 //clean up & return
15182 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015183 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015185 pStaEntry->pPeStaEntry->numClient--;
15186 //check if we need to delete the entry from peStatsReqList too
15187 if(!pStaEntry->pPeStaEntry->numClient)
15188 {
15189 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015192
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 //check if we need to stop the tl stats timer too
15194 pMac->roam.tlStatsReqInfo.numClient--;
15195 if(!pMac->roam.tlStatsReqInfo.numClient)
15196 {
15197 if(pMac->roam.tlStatsReqInfo.timerRunning)
15198 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015199 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15200 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015202 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015203 return eHAL_STATUS_FAILURE;
15204 }
15205 }
15206 pMac->roam.tlStatsReqInfo.periodicity = 0;
15207 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15208 }
15209 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015210 // Destroy the vos timer...
15211 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15212 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015214 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 csrRoamRemoveStatListEntry(pMac, pEntry);
15217 pStaEntry = NULL;
15218 return eHAL_STATUS_SUCCESS;
15219 }
15220 }
15221
15222 if(cache && !periodicity)
15223 {
15224 //return the cached stats
15225 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15226 }
15227 else
15228 {
15229 //add the request in the client req list
15230 staEntry.callback = callback;
15231 staEntry.pContext = pContext;
15232 staEntry.periodicity = periodicity;
15233 staEntry.pPeStaEntry = NULL;
15234 staEntry.staId = staId;
15235 staEntry.pMac = pMac;
15236 staEntry.timerExpired = FALSE;
15237
15238
Jeff Johnson295189b2012-06-20 16:38:30 -070015239 //if periodic report requested with non cached result from PE/TL
15240 if(periodicity)
15241 {
15242
15243 //if looking for stats from PE
15244 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15245 {
15246
15247 //check if same request made already & waiting for rsp
15248 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15249 periodicity, &found, staId);
15250 if(!pPeStaEntry)
15251 {
15252 //bail out, maxed out on number of req for PE
15253 return eHAL_STATUS_FAILURE;
15254 }
15255 else
15256 {
15257 staEntry.pPeStaEntry = pPeStaEntry;
15258 }
15259
15260 }
15261 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15262 if(statsMask & (1 << eCsrGlobalClassDStats))
15263 {
15264 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015266 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 }
15268 else
15269 {
15270
15271 //update periodicity
15272 if(pMac->roam.tlStatsReqInfo.periodicity)
15273 {
15274 pMac->roam.tlStatsReqInfo.periodicity =
15275 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15276 }
15277 else
15278 {
15279 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15280 }
15281 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15282 {
15283 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15284 }
15285
15286 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15287 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015288 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015289 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015291 //req TL for class D stats
15292 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015294 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015295 }
15296 else
15297 {
15298 //save in SME
15299 csrRoamSaveStatsFromTl(pMac, pTlStats);
15300 }
15301 vos_mem_free(pTlStats);
15302 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 }
15304 else
15305 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015306 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015308
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 if(pMac->roam.tlStatsReqInfo.periodicity)
15310 {
15311 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015312 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15313 pMac->roam.tlStatsReqInfo.periodicity);
15314 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015316 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015317 return eHAL_STATUS_FAILURE;
15318 }
15319 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15320 }
15321 }
15322 }
15323 pMac->roam.tlStatsReqInfo.numClient++;
15324 }
15325
15326 insertInClientList = TRUE;
15327 }
15328 //if one time report requested with non cached result from PE/TL
15329 else if(!cache && !periodicity)
15330 {
15331 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15332 {
15333 //send down a req
15334 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15335 if(!HAL_STATUS_SUCCESS(status))
15336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015337 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 }
15339 //so that when the stats rsp comes back from PE we respond to upper layer
15340 //right away
15341 staEntry.timerExpired = TRUE;
15342 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015343 }
15344 if(statsMask & (1 << eCsrGlobalClassDStats))
15345 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015346 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015347 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015349 //req TL for class D stats
15350 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15351 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015352 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015353 }
15354 else
15355 {
15356 //save in SME
15357 csrRoamSaveStatsFromTl(pMac, pTlStats);
15358 }
15359 vos_mem_free(pTlStats);
15360 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 }
15362 else
15363 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015364 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015366
15367 }
15368 //if looking for stats from TL only
15369 if(!insertInClientList)
15370 {
15371 //return the stats
15372 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 if(insertInClientList)
15376 {
15377 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15378 if(!pStaEntry)
15379 {
15380 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015381 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 return eHAL_STATUS_FAILURE;
15383 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015384 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 //Init & start timer if needed
15386 if(periodicity)
15387 {
15388 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15389 csrRoamStatsClientTimerHandler, pStaEntry );
15390 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015392 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 return eHAL_STATUS_FAILURE;
15394 }
15395 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15396 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015398 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 return eHAL_STATUS_FAILURE;
15400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015403 }
15404 return eHAL_STATUS_SUCCESS;
15405}
15406
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015407#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15408
15409static tSirRetStatus
15410csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15411 tANI_U8* pBD,
15412 tANI_U8 type,
15413 tANI_U8 subType,
15414 tSirMacAddr peerAddr,
15415 tSirMacAddr selfMacAddr)
15416{
15417 tSirRetStatus statusCode = eSIR_SUCCESS;
15418 tpSirMacMgmtHdr pMacHdr;
15419
15420 /* Prepare MAC management header */
15421 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15422
15423 /* Prepare FC */
15424 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15425 pMacHdr->fc.type = type;
15426 pMacHdr->fc.subType = subType;
15427
15428 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015429 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15430 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015431
15432 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15433
15434 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015435 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15436 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015437 return statusCode;
15438} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15439
15440static tSirRetStatus
15441csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15442 tANI_U8 nChannelNum,
15443 tANI_U32 dot11mode,
15444 tSirMacAddr selfMacAddr,
15445 tANI_U8 *pFrame,
15446 tANI_U16 *pusLen)
15447{
15448 tDot11fProbeRequest pr;
15449 tANI_U32 nStatus, nBytes, nPayload;
15450 tSirRetStatus nSirStatus;
15451 /*Bcast tx*/
15452 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15453 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15454
15455
Kiet Lam64c1b492013-07-12 13:56:44 +053015456 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015457
15458 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15459
15460 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15461 {
15462 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15463 }
15464
15465
15466 if (IS_DOT11_MODE_HT(dot11mode))
15467 {
15468 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15469 }
15470
15471
15472 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15473 if ( DOT11F_FAILED( nStatus ) )
15474 {
15475 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15476 "Failed to calculate the packed size f"
15477 "or a Probe Request (0x%08x).\n", nStatus );
15478
15479
15480 nPayload = sizeof( tDot11fProbeRequest );
15481 }
15482 else if ( DOT11F_WARNED( nStatus ) )
15483 {
15484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15485 "There were warnings while calculating"
15486 "the packed size for a Probe Request ("
15487 "0x%08x).\n", nStatus );
15488 }
15489
15490 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15491
15492 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015493 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015494
15495
15496 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015497 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015498
15499 if ( eSIR_SUCCESS != nSirStatus )
15500 {
15501 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15502 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15503 nSirStatus );
15504 return nSirStatus;
15505 }
15506
15507
15508 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15509 sizeof( tSirMacMgmtHdr ),
15510 nPayload, &nPayload );
15511 if ( DOT11F_FAILED( nStatus ) )
15512 {
15513 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15514 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15515 return eSIR_FAILURE;
15516 }
15517 else if ( DOT11F_WARNED( nStatus ) )
15518 {
15519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015520 "There were warnings while packing a Probe Request (0x%08x).\n",
15521 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015522 }
15523
15524 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15525 return eSIR_SUCCESS;
15526}
15527
15528eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15529{
15530 vos_msg_t msg;
15531 tSirRoamOffloadScanReq *pRequestBuf;
15532 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15533 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015534 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015535 tANI_U8 *ChannelList = NULL;
15536 tANI_U32 sessionId;
15537 eHalStatus status = eHAL_STATUS_SUCCESS;
15538 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015539 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015540 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015541 eCsrBand eBand;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015542 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15543
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015544 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015545 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015546 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015547 return eHAL_STATUS_FAILURE;
15548 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015549
15550 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15551 {
15552 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15553 return eHAL_STATUS_FAILURE;
15554 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015555 status = csrRoamGetSessionIdFromBSSID(pMac,
15556 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15557 &sessionId);
15558 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15559 * It is important to ensure that the command is passed down to the FW only
15560 * if the Infra Station is in a connected state.A connected station could also be
15561 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15562 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15563 * irrespective of whichever state we are in.*/
15564 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15565 (command != ROAM_SCAN_OFFLOAD_STOP))
15566 {
15567 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15568 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15569 return eHAL_STATUS_FAILURE;
15570 }
15571
15572 if ( !HAL_STATUS_SUCCESS( status ) )
15573 {
15574 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15575 return eHAL_STATUS_FAILURE;
15576 }
15577 pSession = CSR_GET_SESSION( pMac, sessionId );
15578 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15579 if (NULL == pRequestBuf)
15580 {
15581 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15582 return eHAL_STATUS_FAILED_ALLOC;
15583 }
15584
Kiet Lam64c1b492013-07-12 13:56:44 +053015585 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015586 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15587 * host driver reloads, but Riva still up and running*/
15588 if(command == ROAM_SCAN_OFFLOAD_STOP)
15589 pRequestBuf->RoamScanOffloadEnabled = 0;
15590 else
15591 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015592 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15593 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015594 sizeof(tCsrBssid));
15595 pRequestBuf->ConnectedNetwork.ssId.length =
15596 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15597 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15598 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15599 pRequestBuf->ConnectedNetwork.ssId.length);
15600 pRequestBuf->ConnectedNetwork.authentication =
15601 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15602 pRequestBuf->ConnectedNetwork.encryption =
15603 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15604 pRequestBuf->ConnectedNetwork.mcencryption =
15605 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15606 pRequestBuf->LookupThreshold =
15607 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15608 pRequestBuf->RoamRssiDiff =
15609 pMac->roam.configParam.RoamRssiDiff;
15610 pRequestBuf->Command = command;
15611 pRequestBuf->StartScanReason = reason;
15612 pRequestBuf->NeighborScanTimerPeriod =
15613 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15614 pRequestBuf->NeighborRoamScanRefreshPeriod =
15615 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15616 pRequestBuf->NeighborScanChannelMinTime =
15617 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15618 pRequestBuf->NeighborScanChannelMaxTime =
15619 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15620 pRequestBuf->EmptyRefreshScanPeriod =
15621 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015622 /* MAWC feature */
15623 pRequestBuf->MAWCEnabled =
15624 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015625#ifdef FEATURE_WLAN_CCX
15626 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15627#endif
15628 if (
15629#ifdef FEATURE_WLAN_CCX
15630 ((pNeighborRoamInfo->isCCXAssoc) &&
15631 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15632 eANI_BOOLEAN_FALSE)) ||
15633 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15634#endif // CCX
15635 currChannelListInfo->numOfChannels == 0)
15636 {
15637
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015638 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15639 * Give Preference to INI Channels.*/
15640 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15641 {
15642 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15643 /*The INI channels need to be filtered with respect to the current
15644 * band that is supported.*/
15645 eBand = pMac->roam.configParam.bandCapability;
15646 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015647 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015648 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15649 "Invalid band, No operation carried out (Band %d)", eBand);
15650 vos_mem_free(pRequestBuf);
15651 return eHAL_STATUS_FAILURE;
15652 }
15653 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15654 {
15655 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15656 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15657 (eCSR_BAND_ALL == eBand))
15658 {
15659 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15660 csrRoamIsChannelValid(pMac, *ChannelList) &&
15661 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15662 {
15663 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15664 }
15665 }
15666 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015667 }
15668 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15669 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015670 }
15671 else
15672 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015673 ChannelList = pMac->scan.occupiedChannels.channelList;
15674 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15675 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015676 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15677 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15678 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015679 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015680 }
15681 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015682 }
15683 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15684 /* If the profile changes as to what it was earlier, inform the FW through
15685 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15686 * for the earlier profile and try to learn them afresh.*/
15687 if (reason == REASON_FLUSH_CHANNEL_LIST)
15688 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15689 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015690 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15691 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15692 else
15693 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015694 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015695 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015696 }
15697#ifdef FEATURE_WLAN_CCX
15698 else
15699 {
15700 /* If CCX is enabled, and a neighbor Report is received,then
15701 * Ignore the INI Channels or the Occupied Channel List. Consider
15702 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015703 if (currChannelListInfo->numOfChannels != 0)
15704 {
15705 ChannelList = currChannelListInfo->ChannelList;
15706 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015707 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015708 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15709 {
15710 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15711 }
15712 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015713 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015714 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15715 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15716 }
15717 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015718#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015719 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15720 {
15721 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15722 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15723 }
15724 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15725 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15726 pRequestBuf->ChannelCacheType,
15727 pRequestBuf->ConnectedNetwork.ChannelCount,
15728 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015729 num_channels = 0;
15730 ChannelList = NULL;
15731
15732 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015733 host_channels = sizeof(pMac->roam.validChannelList);
15734 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015735 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015736 ChannelList = pMac->roam.validChannelList;
15737 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015738 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015739 else
15740 {
15741 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15742 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015743 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015744 return eHAL_STATUS_FAILURE;
15745 }
15746 for(i=0; i<pMac->roam.numValidChannels; i++)
15747 {
15748 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15749 {
15750 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15751 }
15752 ChannelList++;
15753 }
15754 pRequestBuf->ValidChannelCount = num_channels;
15755
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015756 pRequestBuf->MDID.mdiePresent =
15757 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15758 pRequestBuf->MDID.mobilityDomain =
15759 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015760 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15761
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015762 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015763 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
15764 * where RFS is the RF Switching time. It is twice RFS to consider the
15765 * time to go off channel and return to the home channel. */
15766 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
15767 {
15768 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
15769 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
15770 " Hence enforcing home away time to disable (0)",
15771 __func__, pRequestBuf->HomeAwayTime,
15772 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
15773 pRequestBuf->HomeAwayTime = 0;
15774 }
15775 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015776
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015777 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15778 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15779 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15780 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15781 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15782
15783 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15784 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015785 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015786 msg.reserved = 0;
15787 msg.bodyptr = pRequestBuf;
15788 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15789 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015790 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15791 vos_mem_free(pRequestBuf);
15792 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015793 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015794 else
15795 {
15796 if (ROAM_SCAN_OFFLOAD_START == command)
15797 bRoamScanOffloadStarted = VOS_TRUE;
15798 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15799 bRoamScanOffloadStarted = VOS_FALSE;
15800 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015801
15802 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15803 return status;
15804}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015805
15806eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15807{
15808 switch(reason)
15809 {
15810 case 0:
15811 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15812 break;
15813 case REASON_OS_REQUESTED_ROAMING_NOW:
15814 csrNeighborRoamProceedWithHandoffReq(pMac);
15815 break;
15816 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015817 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 -070015818 }
15819 return eHAL_STATUS_SUCCESS;
15820}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015821#endif
15822
Jeff Johnson295189b2012-06-20 16:38:30 -070015823tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15824 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15825{
15826 tANI_BOOLEAN found = FALSE;
15827 eHalStatus status = eHAL_STATUS_SUCCESS;
15828 tCsrPeStatsReqInfo staEntry;
15829 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15830 tListElem *pStaEntry = NULL;
15831 VOS_STATUS vosStatus;
15832 tPmcPowerState powerState;
15833 *pFound = FALSE;
15834
15835 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15836 if(pStaEntry)
15837 {
15838 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15839 if(pTempStaEntry->periodicity)
15840 {
15841 pTempStaEntry->periodicity =
15842 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15843 }
15844 else
15845 {
15846 pTempStaEntry->periodicity = periodicity;
15847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015848 pTempStaEntry->numClient++;
15849 found = TRUE;
15850 }
15851 else
15852 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015853 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015854 staEntry.numClient = 1;
15855 staEntry.periodicity = periodicity;
15856 staEntry.pMac = pMac;
15857 staEntry.rspPending = FALSE;
15858 staEntry.staId = staId;
15859 staEntry.statsMask = statsMask;
15860 staEntry.timerRunning = FALSE;
15861 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15862 if(!pTempStaEntry)
15863 {
15864 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015865 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015866 return NULL;
15867 }
15868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15870 if(ePMC_FULL_POWER == powerState)
15871 {
15872 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15873 {
15874 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15875 }
15876 }
15877 else
15878 {
15879 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15880 {
15881 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15882 }
15883 }
15884 if(!pTempStaEntry->timerRunning)
15885 {
15886 //send down a req in case of one time req, for periodic ones wait for timer to expire
15887 if(!pTempStaEntry->rspPending &&
15888 !pTempStaEntry->periodicity)
15889 {
15890 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15891 if(!HAL_STATUS_SUCCESS(status))
15892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015893 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 }
15895 else
15896 {
15897 pTempStaEntry->rspPending = TRUE;
15898 }
15899 }
15900 if(pTempStaEntry->periodicity)
15901 {
15902 if(!found)
15903 {
15904
15905 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15906 csrRoamPeStatsTimerHandler, pTempStaEntry );
15907 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015909 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 return NULL;
15911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015912 }
15913 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015914 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015915 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15916 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015918 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015919 return NULL;
15920 }
15921 pTempStaEntry->timerRunning = TRUE;
15922 }
15923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015924 *pFound = found;
15925 return pTempStaEntry;
15926}
15927
Jeff Johnson295189b2012-06-20 16:38:30 -070015928/*
15929 pStaEntry is no longer invalid upon the return of this function.
15930*/
15931static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15932{
15933 if(pEntry)
15934 {
15935 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15936 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015937 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 }
15940 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015941
15942void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15943{
15944 tListElem *pEntry;
15945 tCsrPeStatsReqInfo *pTempStaEntry;
15946 VOS_STATUS vosStatus;
15947 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015948 if(!pEntry)
15949 {
15950 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015951 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015952 return;
15953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 while( pEntry )
15955 {
15956 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015959 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015960 if(pTempStaEntry->timerRunning)
15961 {
15962 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15963 /* If we are not able to stop the timer here, just remove
15964 * the entry from the linked list. Destroy the timer object
15965 * and free the memory in the timer CB
15966 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015967 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015968 {
15969 /* the timer is successfully stopped */
15970 pTempStaEntry->timerRunning = FALSE;
15971
15972 /* Destroy the timer */
15973 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15974 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015976 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 }
15978 }
15979 else
15980 {
15981 // the timer could not be stopped. Hence destroy and free the
15982 // memory for the PE stat entry in the timer CB.
15983 pTempStaEntry->timerStopFailed = TRUE;
15984 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015985 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015986
15987 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15988 {
15989 // Only free the memory if we could stop the timer successfully
15990 if(!pTempStaEntry->timerStopFailed)
15991 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015992 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 pTempStaEntry = NULL;
15994 }
15995 break;
15996 }
15997
15998 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15999 }
16000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 return;
16002}
16003
16004
Jeff Johnsone7245742012-09-05 17:12:55 -070016005void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016006{
16007
Jeff Johnsone7245742012-09-05 17:12:55 -070016008 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16009 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16010 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16011 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16012 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16013 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16014 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016015 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016016 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16017 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16018 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16019 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16020 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16021 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016023 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16024 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016025
16026}
16027
Jeff Johnson295189b2012-06-20 16:38:30 -070016028void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16029 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16030{
16031 tANI_U8 stats[500];
16032 tANI_U8 *pStats = NULL;
16033 tANI_U32 tempMask = 0;
16034 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 if(!callback)
16036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016037 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 return;
16039 }
16040 if(!statsMask)
16041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016042 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 return;
16044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016045 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016047 while(tempMask)
16048 {
16049 if(tempMask & 1)
16050 {
16051 //new stats info from PE, fill up the stats strucutres in PMAC
16052 switch(counter)
16053 {
16054 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016055 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016056 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16057 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016058 pStats += sizeof(tCsrSummaryStatsInfo);
16059 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016061 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016062 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16063 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016064 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016065 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016067 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016068 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16069 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016072 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016073 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016074 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16075 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016076 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016078 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016079 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016080 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16081 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016082 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016083 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016084 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016085 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016086 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16087 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016088 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016089 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016090 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016091 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016092 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016093 }
16094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016095 tempMask >>=1;
16096 counter++;
16097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016099}
16100
Jeff Johnson295189b2012-06-20 16:38:30 -070016101eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16102{
16103 tListElem *pEntry = NULL;
16104 tListElem *pPrevEntry = NULL;
16105 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16106 eHalStatus status = eHAL_STATUS_SUCCESS;
16107 VOS_STATUS vosStatus;
16108 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016109 if(!pEntry)
16110 {
16111 //list empty
16112 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016113 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016114 return status;
16115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016116 while( pEntry )
16117 {
16118 if(pPrevEntry)
16119 {
16120 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16121 //send up the stats report
16122 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16123 pTempStaEntry->staId, pTempStaEntry->pContext);
16124 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016126 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016127 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16128 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016129 pTempStaEntry->pPeStaEntry->numClient--;
16130 //check if we need to delete the entry from peStatsReqList too
16131 if(!pTempStaEntry->pPeStaEntry->numClient)
16132 {
16133 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016136 //check if we need to stop the tl stats timer too
16137 pMac->roam.tlStatsReqInfo.numClient--;
16138 if(!pMac->roam.tlStatsReqInfo.numClient)
16139 {
16140 if(pMac->roam.tlStatsReqInfo.timerRunning)
16141 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016142 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16143 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016145 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016146 //we will continue
16147 }
16148 }
16149 pMac->roam.tlStatsReqInfo.periodicity = 0;
16150 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016152 if (pTempStaEntry->periodicity)
16153 {
16154 //While creating StaEntry in csrGetStatistics,
16155 //Initializing and starting timer only when periodicity is set.
16156 //So Stop and Destroy timer only when periodicity is set.
16157
Jeff Johnsone7245742012-09-05 17:12:55 -070016158 vos_timer_stop( &pTempStaEntry->timer );
16159 // Destroy the vos timer...
16160 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16161 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016163 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016166
Jeff Johnson295189b2012-06-20 16:38:30 -070016167
16168 pPrevEntry = pEntry;
16169 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16170 }
16171 //the last one
16172 if(pPrevEntry)
16173 {
16174 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16175 //send up the stats report
16176 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16177 pTempStaEntry->staId, pTempStaEntry->pContext);
16178 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016180 return status;
16181
16182}
16183
Jeff Johnson295189b2012-06-20 16:38:30 -070016184eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16185 tRequestFullPowerReason *pReason,
16186 tANI_BOOLEAN *pfNeedPower )
16187{
16188 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16189 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16190 tPmcState pmcState;
16191 eHalStatus status = eHAL_STATUS_SUCCESS;
16192 // TODO : Session info unavailable
16193 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016194 if( pfNeedPower )
16195 {
16196 *pfNeedPower = eANI_BOOLEAN_FALSE;
16197 }
16198 //We only handle CSR commands
16199 if( !(eSmeCsrCommandMask & pCommand->command) )
16200 {
16201 return eHAL_STATUS_SUCCESS;
16202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016203 //Check PMC state first
16204 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 switch( pmcState )
16206 {
16207 case REQUEST_IMPS:
16208 case IMPS:
16209 if( eSmeCommandScan == pCommand->command )
16210 {
16211 switch( pCommand->u.scanCmd.reason )
16212 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016213#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16214 case eCsrScanGetLfrResult:
16215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016216 case eCsrScanGetResult:
16217 case eCsrScanBGScanAbort:
16218 case eCsrScanBGScanEnable:
16219 case eCsrScanGetScanChnInfo:
16220 //Internal process, no need for full power
16221 fNeedFullPower = eANI_BOOLEAN_FALSE;
16222 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016223 default:
16224 //Other scans are real scan, ask for power
16225 fNeedFullPower = eANI_BOOLEAN_TRUE;
16226 break;
16227 } //switch
16228 }
16229 else
16230 {
16231 //ask for power for roam and status change
16232 fNeedFullPower = eANI_BOOLEAN_TRUE;
16233 }
16234 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016235 case REQUEST_BMPS:
16236 case BMPS:
16237 case REQUEST_START_UAPSD:
16238 case UAPSD:
16239 //We treat WOWL same as BMPS
16240 case REQUEST_ENTER_WOWL:
16241 case WOWL:
16242 if( eSmeCommandRoam == pCommand->command )
16243 {
16244 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16245 tCsrScanResult *pScanResult;
16246 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016247 switch ( pCommand->u.roamCmd.roamReason )
16248 {
16249 case eCsrForcedDisassoc:
16250 case eCsrForcedDisassocMICFailure:
16251 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16252 fNeedFullPower = eANI_BOOLEAN_TRUE;
16253 break;
16254 case eCsrSmeIssuedDisassocForHandoff:
16255 case eCsrForcedDeauth:
16256 case eCsrHddIssuedReassocToSameAP:
16257 case eCsrSmeIssuedReassocToSameAP:
16258 fNeedFullPower = eANI_BOOLEAN_TRUE;
16259 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016260 case eCsrCapsChange:
16261 fNeedFullPower = eANI_BOOLEAN_TRUE;
16262 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016263 default:
16264 //Check whether the profile is already connected. If so, no need for full power
16265 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16266 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16267 {
16268 //Only need to check the first one
16269 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16270 if( pEntry )
16271 {
16272 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16273#if 0
16274 // TODO : Session Specific info pConnectBssDesc
16275 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16276 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16277 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16278 {
16279 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16280 // with Authenticating first. To force this, stop the current association (Disassociate) and
16281 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16282 // a new Association.
16283 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16284 {
16285 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16286 {
16287 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16288 //No need for full power
16289 //Set the flag so the code later can avoid to do the above
16290 //check again.
16291 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16292 break;
16293 }
16294 }
16295 }
16296#endif
16297 }
16298 }
16299 //If we are here, full power is needed
16300 fNeedFullPower = eANI_BOOLEAN_TRUE;
16301 break;
16302 }
16303 }
16304 else if( eSmeCommandWmStatusChange == pCommand->command )
16305 {
16306 //need full power for all
16307 fNeedFullPower = eANI_BOOLEAN_TRUE;
16308 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16309 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016310#ifdef FEATURE_WLAN_TDLS
16311 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16312 {
16313 //TDLS link is getting established. need full power
16314 fNeedFullPower = eANI_BOOLEAN_TRUE;
16315 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16316 }
16317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016319 case REQUEST_STOP_UAPSD:
16320 case REQUEST_EXIT_WOWL:
16321 if( eSmeCommandRoam == pCommand->command )
16322 {
16323 fNeedFullPower = eANI_BOOLEAN_TRUE;
16324 switch ( pCommand->u.roamCmd.roamReason )
16325 {
16326 case eCsrForcedDisassoc:
16327 case eCsrForcedDisassocMICFailure:
16328 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16329 break;
16330 default:
16331 break;
16332 }
16333 }
16334 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 case STOPPED:
16336 case REQUEST_STANDBY:
16337 case STANDBY:
16338 case LOW_POWER:
16339 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016340 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016341 status = eHAL_STATUS_FAILURE;
16342 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016343 case FULL_POWER:
16344 case REQUEST_FULL_POWER:
16345 default:
16346 //No need to ask for full power. This has to be FULL_POWER state
16347 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016348 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 if( pReason )
16350 {
16351 *pReason = reason;
16352 }
16353 if( pfNeedPower )
16354 {
16355 *pfNeedPower = fNeedFullPower;
16356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016357 return ( status );
16358}
16359
Jeff Johnson295189b2012-06-20 16:38:30 -070016360static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16361{
16362 eHalStatus status = eHAL_STATUS_SUCCESS;
16363 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16364 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016366 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16367 {
16368 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016370 return ( status );
16371}
16372
Jeff Johnson295189b2012-06-20 16:38:30 -070016373tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16374{
16375 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 if( pCmd )
16377 {
16378 pMac->roam.sPendingCommands++;
16379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016380 return ( pCmd );
16381}
16382
Jeff Johnson295189b2012-06-20 16:38:30 -070016383void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16384{
16385 if (pMac->roam.sPendingCommands > 0)
16386 {
16387 //All command allocated through csrGetCommandBuffer need to
16388 //decrement the pending count when releasing.
16389 pMac->roam.sPendingCommands--;
16390 smeReleaseCommand( pMac, pCommand );
16391 }
16392 else
16393 {
16394 smsLog(pMac, LOGE, FL( "no pending commands"));
16395 VOS_ASSERT(0);
16396 }
16397}
16398
Jeff Johnson295189b2012-06-20 16:38:30 -070016399//Return SUCCESS is the command is queued, failed
16400eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16401{
16402 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16404 {
16405 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16406 pCommand->u.scanCmd.reason);
16407 return eHAL_STATUS_CSR_WRONG_STATE;
16408 }
16409
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016410 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16411 {
16412 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16413 &pCommand->Link, LL_ACCESS_LOCK);
16414 // process the command queue...
16415 smeProcessPendingQueue(pMac);
16416 status = eHAL_STATUS_SUCCESS;
16417 goto end;
16418 }
16419
Jeff Johnson295189b2012-06-20 16:38:30 -070016420 //We can call request full power first before putting the command into pending Q
16421 //because we are holding SME lock at this point.
16422 status = csrRequestFullPower( pMac, pCommand );
16423 if( HAL_STATUS_SUCCESS( status ) )
16424 {
16425 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016426 //make sure roamCmdPendingList is not empty first
16427 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16428 if( fNoCmdPending )
16429 {
16430 smePushCommand( pMac, pCommand, fHighPriority );
16431 }
16432 else
16433 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016434 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 //no list lock is needed since SME lock is held
16436 if( !fHighPriority )
16437 {
16438 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16439 }
16440 else {
16441 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16442 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016443 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016444 }
16445 else if( eHAL_STATUS_PMC_PENDING == status )
16446 {
16447 //no list lock is needed since SME lock is held
16448 if( !fHighPriority )
16449 {
16450 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16451 }
16452 else {
16453 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16454 }
16455 //Let caller know the command is queue
16456 status = eHAL_STATUS_SUCCESS;
16457 }
16458 else
16459 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016460 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016462 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016464end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016466}
Jeff Johnson295189b2012-06-20 16:38:30 -070016467eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16468{
16469 eHalStatus status = eHAL_STATUS_SUCCESS;
16470 tSirUpdateAPWPSIEsReq *pMsg;
16471 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16472
16473 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16474 if (NULL == pSession)
16475 {
16476 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16477 return eHAL_STATUS_FAILURE;
16478 }
16479
Jeff Johnson295189b2012-06-20 16:38:30 -070016480 do
16481 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016482 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16483 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16484 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016485 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16486
16487 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016488 VOS_ASSERT(pBuf);
16489
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016491 // transactionId
16492 *pBuf = 0;
16493 *( pBuf + 1 ) = 0;
16494 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016496 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16497 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 //sessionId
16500 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016502 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016503 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016504 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 return ( status );
16508}
Jeff Johnson295189b2012-06-20 16:38:30 -070016509eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16510{
16511 eHalStatus status = eHAL_STATUS_SUCCESS;
16512 tSirUpdateAPWPARSNIEsReq *pMsg;
16513 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16515 if (NULL == pSession)
16516 {
16517 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16518 return eHAL_STATUS_FAILURE;
16519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 do
16521 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016522 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16523 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16524 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016525 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016526 pBuf = (tANI_U8 *)&pMsg->transactionId;
16527 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016528 // transactionId
16529 *pBuf = 0;
16530 *( pBuf + 1 ) = 0;
16531 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016532 VOS_ASSERT(pBuf);
16533
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016535 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16536 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016537 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016538 // sessionId
16539 *pBuf++ = (tANI_U8)sessionId;
16540
16541 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016542 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016543 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016545 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016547 return ( status );
16548}
Jeff Johnson295189b2012-06-20 16:38:30 -070016549
16550#ifdef WLAN_FEATURE_VOWIFI_11R
16551//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16552eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16553{
16554 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16555 tpSirFTPreAuthReq pftPreAuthReq;
16556 tANI_U16 auth_req_len = 0;
16557 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016558 auth_req_len = sizeof(tSirFTPreAuthReq);
16559 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016560 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 {
16562 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16563 return eHAL_STATUS_RESOURCES;
16564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016565 // Save the SME Session ID here. We need it while processing the preauth response
16566 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016567 vos_mem_zero(pftPreAuthReq, auth_req_len);
16568
16569 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16570 sizeof(pBssDescription->length) + pBssDescription->length);
16571
16572 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16573
16574 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16575
Kiet Lam64c1b492013-07-12 13:56:44 +053016576 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16577 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16578 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16579 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016580
Jeff Johnson295189b2012-06-20 16:38:30 -070016581#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016582 if (csrRoamIs11rAssoc(pMac) &&
16583 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 {
16585 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016586 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16587 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016588 }
16589 else
16590#endif
16591 {
16592 pftPreAuthReq->ft_ies_length = 0;
16593 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016594 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16595 sizeof(pBssDescription->length) + pBssDescription->length);
16596 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16598}
Jeff Johnson295189b2012-06-20 16:38:30 -070016599/*--------------------------------------------------------------------------
16600 * This will receive and process the FT Pre Auth Rsp from the current
16601 * associated ap.
16602 *
16603 * This will invoke the hdd call back. This is so that hdd can now
16604 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16605 ------------------------------------------------------------------------*/
16606void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16607{
16608 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16609 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016610#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016611 tCsrRoamInfo roamInfo;
16612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016613
16614#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016615 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016616#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016617#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016618 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016619 if (status != eHAL_STATUS_SUCCESS) {
16620 /*
16621 * Bail out if pre-auth was not even processed.
16622 */
16623 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16624 return;
16625 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016627 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16628 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16629 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016630 // Implies a success
16631 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016632 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16633 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016634 /* No need to notify qos module if this is a non 11r roam*/
16635 if (csrRoamIs11rAssoc(pMac))
16636 {
16637 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16640 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016641 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16642 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016643 if (eHAL_STATUS_SUCCESS != status)
16644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016645 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016646 return;
16647 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016648 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016649 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16650 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016651 if (csrRoamIs11rAssoc(pMac))
16652 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16653 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16654
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016655#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16656 if (csrRoamIsCCXAssoc(pMac))
16657 {
16658 /* read TSF */
16659 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16660
16661 // Save the bssid from the received response
16662 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16663 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16664 }
16665#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016666#ifdef FEATURE_WLAN_LFR
16667 // If Legacy Fast Roaming is enabled, signal the supplicant
16668 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016669 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016670 {
16671 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016672 vos_mem_copy((void *)&roamInfo.bssid,
16673 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016674 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16675 }
16676
16677#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016678
16679 // Done with it, init it.
16680 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16681}
16682#endif
16683#ifdef FEATURE_WLAN_BTAMP_UT_RF
16684void csrRoamJoinRetryTimerHandler(void *pv)
16685{
16686 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16687 tpAniSirGlobal pMac = pInfo->pMac;
16688 tANI_U32 sessionId = pInfo->sessionId;
16689 tCsrRoamSession *pSession;
16690
16691 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16692 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016693 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016694 pSession = CSR_GET_SESSION( pMac, sessionId );
16695 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16696 {
16697 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16698 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016699 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016700 }
16701 }
16702 }
16703}
Jeff Johnson295189b2012-06-20 16:38:30 -070016704eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16705{
16706 eHalStatus status = eHAL_STATUS_FAILURE;
16707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16708
16709 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016711 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016712 pSession->maxRetryCount--;
16713 pSession->joinRetryTimerInfo.pMac = pMac;
16714 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016715 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16716 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016718 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016719 }
16720 }
16721 else
16722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016723 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016724 pSession->maxRetryCount);
16725 }
16726
16727 return (status);
16728}
Jeff Johnson295189b2012-06-20 16:38:30 -070016729eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16730{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016731 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016732 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16733 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016734 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016735 }
16736
16737 return eHAL_STATUS_SUCCESS;
16738}
16739#endif
16740
16741
16742/*
16743 pBuf points to the beginning of the message
16744 LIM packs disassoc rsp as below,
16745 messageType - 2 bytes
16746 messageLength - 2 bytes
16747 sessionId - 1 byte
16748 transactionId - 2 bytes (tANI_U16)
16749 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16750 peerMacAddr - 6 bytes
16751 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16752*/
16753static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16754{
16755 if(pBuf && pRsp)
16756 {
16757 pBuf += 4; //skip type and length
16758 pRsp->sessionId = *pBuf++;
16759 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16760 pBuf += 2;
16761 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16762 pBuf += 4;
16763 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16764 }
16765}
16766
Jeff Johnsond13512a2012-07-17 11:42:19 -070016767eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16768{
16769 static uNvTables nvTables;
16770 eHalStatus status = eHAL_STATUS_SUCCESS;
16771 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16772
16773 /* read the country code from NV and use it */
16774 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16775 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016776 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16777 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016778 return status;
16779 }
16780 else
16781 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016782 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016783 status = eHAL_STATUS_FAILURE;
16784 return status;
16785 }
16786}
16787
16788eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16789{
Kiet Lam64c1b492013-07-12 13:56:44 +053016790 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016791 return eHAL_STATUS_SUCCESS;
16792}
schang86c22c42013-03-13 18:41:24 -070016793
16794eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16795{
16796 tSirSetTxPowerReq *pMsg = NULL;
16797 eHalStatus status = eHAL_STATUS_SUCCESS;
16798 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16799
16800 if (!pSession)
16801 {
16802 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16803 return eHAL_STATUS_FAILURE;
16804 }
16805
Kiet Lam64c1b492013-07-12 13:56:44 +053016806 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16807 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16808 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16809 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16810 pMsg->length = sizeof(tSirSetTxPowerReq);
16811 pMsg->mwPower = mW;
16812 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16813 sizeof(tSirMacAddr));
16814 status = palSendMBMessage(pMac->hHdd, pMsg);
16815 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016816 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016817 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16818 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016819 }
16820 return status;
16821}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016822
16823/* Returns whether a session is in VOS_STA_MODE...or not */
16824tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16825{
16826 tCsrRoamSession *pSession = NULL;
16827 pSession = CSR_GET_SESSION ( pMac, sessionId );
16828 if(!pSession)
16829 {
16830 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16831 return eANI_BOOLEAN_FALSE;
16832 }
16833 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16834 {
16835 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16836 return eANI_BOOLEAN_FALSE;
16837 }
16838 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16839 {
16840 return eANI_BOOLEAN_FALSE;
16841 }
16842 /* There is a possibility that the above check may fail,because
16843 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16844 * when it is connected.So,we may sneak through the above check even
16845 * if we are not a STA mode INFRA station. So, if we sneak through
16846 * the above condition, we can use the following check if we are
16847 * really in STA Mode.*/
16848
16849 if ( NULL != pSession->pCurRoamProfile )
16850 {
16851 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16852 {
16853 return eANI_BOOLEAN_TRUE;
16854 } else {
16855 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16856 return eANI_BOOLEAN_FALSE;
16857 }
16858 }
16859
16860 return eANI_BOOLEAN_FALSE;
16861}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016862
16863#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16864eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16865 tCsrHandoffRequest *pHandoffInfo)
16866{
16867 eHalStatus status = eHAL_STATUS_SUCCESS;
16868 vos_msg_t msg;
16869
16870 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016871 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16872 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016873 {
16874 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016875 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016876 }
16877 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16878 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16879 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16880 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016881 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016882 pHandoffInfo->bssid,
16883 6);
16884 msg.type = eWNI_SME_HANDOFF_REQ;
16885 msg.bodyptr = pMsg;
16886 msg.reserved = 0;
16887 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16888 {
16889 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016890 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016891 status = eHAL_STATUS_FAILURE;
16892 }
16893 return status;
16894}
16895#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016896
16897#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16898/* ---------------------------------------------------------------------------
16899 \fn csrSetCCKMIe
16900 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16901 data structure and this IE will be packed inside reassociation request
16902 \param pMac - pMac global structure
16903 \param sessionId - Current session id
16904 \param pCckmIe - pointer to CCKM IE data
16905 \param ccKmIeLen - length of the CCKM IE
16906 \- return Success or failure
16907 -------------------------------------------------------------------------*/
16908VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16909 const tANI_U8 *pCckmIe,
16910 const tANI_U8 ccKmIeLen)
16911{
16912 eHalStatus status = eHAL_STATUS_SUCCESS;
16913 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16914
16915 if (!pSession)
16916 {
16917 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16918 return eHAL_STATUS_FAILURE;
16919 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053016920 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016921 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16922 return status;
16923}
16924
16925/* ---------------------------------------------------------------------------
16926 \fn csrRoamReadTSF
16927 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16928 probe response reception from the hand off AP to arrive at the latest TSF value.
16929 \param pMac - pMac global structure
16930 \param pTimestamp - output TSF timestamp
16931 \- return Success or failure
16932 -------------------------------------------------------------------------*/
16933VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16934{
16935 eHalStatus status = eHAL_STATUS_SUCCESS;
16936 tCsrNeighborRoamBSSInfo handoffNode;
16937 tANI_U32 timer_diff = 0;
16938 tANI_U32 timeStamp[2];
16939 tpSirBssDescription pBssDescription = NULL;
16940
16941 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16942 pBssDescription = handoffNode.pBssDescription;
16943
16944 // Get the time diff in milli seconds
16945 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16946 // Convert msec to micro sec timer
16947 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16948
16949 timeStamp[0] = pBssDescription->timeStamp[0];
16950 timeStamp[1] = pBssDescription->timeStamp[1];
16951
16952 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16953
Kiet Lamf2f201e2013-11-16 21:24:16 +053016954 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016955 sizeof (tANI_U32) * 2);
16956 return status;
16957}
16958
16959#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16960