blob: 5a899ca926543b2c4f9e52ea72174ef3c74cbb75 [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;
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3309 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 return (status);
3311}
Jeff Johnson295189b2012-06-20 16:38:30 -07003312static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3313 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3314{
3315 eHalStatus status = eHAL_STATUS_FAILURE;
3316 int i;
3317 eCsrCfgDot11Mode cfgDot11Mode;
3318 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303319 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3320 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003322
3323 if( NULL != pIes )
3324 {
3325 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 // Originally, we thought that for 11a networks, the 11a rates are always
3327 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3328 // appear in the Operational Rate set. Consequently, in either case, we
3329 // would blindly put the rates we support into our Operational Rate set
3330 // (including the basic rates, which we have already verified are
3331 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 // However, it turns out that this is not always the case. Some AP's
3333 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3334 // too. Now, we're a little more careful:
3335 pDstRate = pOpRateSet->rate;
3336 if(pIes->SuppRates.present)
3337 {
3338 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3339 {
3340 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3341 {
3342 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003343 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 }
3345 }
3346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3348 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3349 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3350 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3351 {
3352 // If there are Extended Rates in the beacon, we will reflect those
3353 // extended rates that we support in out Extended Operational Rate
3354 // set:
3355 pDstRate = pExRateSet->rate;
3356 if(pIes->ExtSuppRates.present)
3357 {
3358 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3359 {
3360 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3361 {
3362 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3363 pExRateSet->numRates++;
3364 }
3365 }
3366 }
3367 }
3368 }//Parsing BSSDesc
3369 else
3370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003371 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 }
3373 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3374 return status;
3375}
3376
3377static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3378 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3379{
3380 int i;
3381 tANI_U8 *pDstRate;
3382 eCsrCfgDot11Mode cfgDot11Mode;
3383 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3384 tANI_U32 OperationalRatesLength = 0;
3385 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3386 tANI_U32 ExtendedOperationalRatesLength = 0;
3387 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3388 tANI_U32 ProprietaryOperationalRatesLength = 0;
3389 tANI_U32 PropRatesEnable = 0;
3390 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3391 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 if( NULL != pIes )
3394 {
3395 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 // Originally, we thought that for 11a networks, the 11a rates are always
3397 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3398 // appear in the Operational Rate set. Consequently, in either case, we
3399 // would blindly put the rates we support into our Operational Rate set
3400 // (including the basic rates, which we have already verified are
3401 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 // However, it turns out that this is not always the case. Some AP's
3403 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3404 // too. Now, we're a little more careful:
3405 pDstRate = OperationalRates;
3406 if(pIes->SuppRates.present)
3407 {
3408 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3409 {
3410 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3411 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3412 {
3413 *pDstRate++ = pIes->SuppRates.rates[ i ];
3414 OperationalRatesLength++;
3415 }
3416 }
3417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3419 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3420 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3421 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3422 {
3423 // If there are Extended Rates in the beacon, we will reflect those
3424 // extended rates that we support in out Extended Operational Rate
3425 // set:
3426 pDstRate = ExtendedOperationalRates;
3427 if(pIes->ExtSuppRates.present)
3428 {
3429 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3430 {
3431 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3432 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3433 {
3434 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3435 ExtendedOperationalRatesLength++;
3436 }
3437 }
3438 }
3439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 // Enable proprietary MAC features if peer node is Airgo node and STA
3441 // user wants to use them
3442 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3443 {
3444 PropRatesEnable = 1;
3445 }
3446 else
3447 {
3448 PropRatesEnable = 0;
3449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 // For ANI network companions, we need to populate the proprietary rate
3451 // set with any proprietary rates we found in the beacon, only if user
3452 // allows them...
3453 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3454 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3455 {
3456 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3457 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3458 {
3459 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3460 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303461 vos_mem_copy(ProprietaryOperationalRates,
3462 pIes->Airgo.PropSuppRates.rates,
3463 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 }
3465 else {
3466 // No proprietary modes...
3467 ProprietaryOperationalRatesLength = 0;
3468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 /* Get MCS Rate */
3470 pDstRate = MCSRateIdxSet;
3471 if ( pIes->HTCaps.present )
3472 {
3473 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3474 {
3475 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3476 {
3477 MCSRateLength++;
3478 *pDstRate++ = i;
3479 }
3480 }
3481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 // Set the operational rate set CFG variables...
3483 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3484 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3485 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3486 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3487 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3488 ProprietaryOperationalRates,
3489 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3490 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3491 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3492 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3493 }//Parsing BSSDesc
3494 else
3495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003496 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 }
3498}
3499
Jeff Johnson295189b2012-06-20 16:38:30 -07003500static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3501 tCsrRoamProfile *pProfile )
3502{
3503 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3504 { 8,
3505 { SIR_MAC_RATE_6,
3506 SIR_MAC_RATE_9,
3507 SIR_MAC_RATE_12,
3508 SIR_MAC_RATE_18,
3509 SIR_MAC_RATE_24,
3510 SIR_MAC_RATE_36,
3511 SIR_MAC_RATE_48,
3512 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3514 { 4,
3515 { SIR_MAC_RATE_1,
3516 SIR_MAC_RATE_2,
3517 SIR_MAC_RATE_5_5,
3518 SIR_MAC_RATE_11 } } };
3519
3520
3521 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3522 { SIR_MAC_RATE_72,
3523 SIR_MAC_RATE_96,
3524 SIR_MAC_RATE_108 } };
3525 eCsrCfgDot11Mode cfgDot11Mode;
3526 eCsrBand eBand;
3527 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3528 tANI_U32 OperationalRatesLength = 0;
3529 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3530 tANI_U32 ExtendedOperationalRatesLength = 0;
3531 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3532 tANI_U32 ProprietaryOperationalRatesLength = 0;
3533 tANI_U32 PropRatesEnable = 0;
3534 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 if(pProfile->ChannelInfo.ChannelList)
3536 {
3537 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3541 // networks, the 11b rates appear in the Operational Rate set. In either case,
3542 // we can blindly put the rates we support into our Operational Rate set
3543 // (including the basic rates, which we have already verified are supported
3544 // earlier in the roaming decision).
3545 if ( eCSR_BAND_5G == eBand )
3546 {
3547 // 11a rates into the Operational Rate Set.
3548 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3549 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303550 vos_mem_copy(OperationalRates,
3551 DefaultSupportedRates11a.supportedRateSet.rate,
3552 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003553
3554 // Nothing in the Extended rate set.
3555 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 // populate proprietary rates if user allows them
3557 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3558 {
3559 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3560 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303561 vos_mem_copy(ProprietaryOperationalRates,
3562 DefaultSupportedPropRates.propRate,
3563 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 }
3565 else
3566 {
3567 // No proprietary modes
3568 ProprietaryOperationalRatesLength = 0;
3569 }
3570 }
3571 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3572 {
3573 // 11b rates into the Operational Rate Set.
3574 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3575 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303576 vos_mem_copy(OperationalRates,
3577 DefaultSupportedRates11b.supportedRateSet.rate,
3578 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 // Nothing in the Extended rate set.
3580 ExtendedOperationalRatesLength = 0;
3581 // No proprietary modes
3582 ProprietaryOperationalRatesLength = 0;
3583 }
3584 else
3585 {
3586 // 11G
3587
3588 // 11b rates into the Operational Rate Set.
3589 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3590 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303591 vos_mem_copy(OperationalRates,
3592 DefaultSupportedRates11b.supportedRateSet.rate,
3593 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003594
3595 // 11a rates go in the Extended rate set.
3596 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3597 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303598 vos_mem_copy(ExtendedOperationalRates,
3599 DefaultSupportedRates11a.supportedRateSet.rate,
3600 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003601
3602 // populate proprietary rates if user allows them
3603 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3604 {
3605 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3606 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303607 vos_mem_copy(ProprietaryOperationalRates,
3608 DefaultSupportedPropRates.propRate,
3609 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 }
3611 else
3612 {
3613 // No proprietary modes
3614 ProprietaryOperationalRatesLength = 0;
3615 }
3616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3618 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3619 {
3620 PropRatesEnable = 1;
3621 }
3622 else
3623 {
3624 PropRatesEnable = 0;
3625 }
3626
3627 // Set the operational rate set CFG variables...
3628 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3629 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3630 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3631 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3632 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3633 ProprietaryOperationalRates,
3634 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3635 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003636}
Jeff Johnson295189b2012-06-20 16:38:30 -07003637void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3638{
3639 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003640
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3642 tANI_U32 sessionId;
3643 tSmeCmd *pCommand = NULL;
3644
3645 if(NULL == pEntry)
3646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003647 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 return;
3649 }
3650 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3651 sessionId = pCommand->sessionId;
3652
3653 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3654 {
3655 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3656 }
3657}
3658
Jeff Johnson295189b2012-06-20 16:38:30 -07003659//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3660tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3661{
3662 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3663 {
3664 return (WNI_CFG_PHY_MODE_11B);
3665 }
3666 else
3667 {
3668 if(eCSR_BAND_24 == band)
3669 return (WNI_CFG_PHY_MODE_11G);
3670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 return (WNI_CFG_PHY_MODE_11A);
3672}
Jeff Johnson295189b2012-06-20 16:38:30 -07003673
Jeff Johnsone7245742012-09-05 17:12:55 -07003674
3675#ifdef WLAN_FEATURE_11AC
3676ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3677{
3678 switch ( aniCBMode )
3679 {
3680 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3681 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3682 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3683 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3684 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3685 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3686 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3687 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3688 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003689 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003690 return PHY_SINGLE_CHANNEL_CENTERED;
3691 }
3692}
3693#endif
3694
Jeff Johnson295189b2012-06-20 16:38:30 -07003695//pIes may be NULL
3696eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3697 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303698 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003699{
3700 eHalStatus status = eHAL_STATUS_SUCCESS;
3701 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3702 tANI_U8 channel = 0;
3703 //Make sure we have the domain info for the BSS we try to connect to.
3704 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303705 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303707 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 {
3709 //Make sure the 11d info from this BSSDesc can be applied
3710 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303711 if (VOS_TRUE == resetCountry)
3712 {
3713 csrApplyCountryInformation(pMac, FALSE);
3714 }
3715 else
3716 {
3717 csrApplyCountryInformation(pMac, TRUE);
3718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 }
Kiran4a17ebe2013-01-31 10:43:43 -08003720 if ((csrIs11dSupported (pMac)) && pIes)
3721 {
3722 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003723 {
Kiran4a17ebe2013-01-31 10:43:43 -08003724 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003725 }
3726 else
3727 {
3728 //Let's also update the below to make sure we don't update CC while
3729 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303730 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003731 pBssDesc->bssId, sizeof(tSirMacAddr));
3732 }
Kiran4a17ebe2013-01-31 10:43:43 -08003733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 //Qos
3736 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3737 //SSID
3738 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3739 //fragment threshold
3740 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3741 //RTS threshold
3742 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3743
3744 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3745
3746 //Auth type
3747 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3748 //encryption type
3749 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3750 //short slot time
3751 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 //11d
3753 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3754 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3755 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 /*//11h
3757 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3758 */
3759 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3760 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003761
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003762 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 {
3764 channel = pProfile->operationChannel;
3765 }
3766 else
3767 {
3768 if(pBssDesc)
3769 {
3770 channel = pBssDesc->channelId;
3771 }
3772 }
3773 if(0 != channel)
3774 {
3775 if(CSR_IS_CHANNEL_24GHZ(channel))
3776 {//for now if we are on 2.4 Ghz, CB will be always disabled
3777 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3778 }
3779 else
3780 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003781 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 }
3783 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003784#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003785 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3786 // in function csrConvertCBIniValueToPhyCBState()
3787 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3788 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003789 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003790 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003791 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003792 }
3793 else
3794 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003795 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003796 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003797 }
3798 else
3799#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3801 //Rate
3802 //Fixed Rate
3803 if(pBssDesc)
3804 {
3805 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3806 }
3807 else
3808 {
3809 csrSetCfgRateSetFromProfile(pMac, pProfile);
3810 }
3811 //Make this the last CFG to set. The callback will trigger a join_req
3812 //Join time out
3813 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3814
3815 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 return (status);
3817}
3818
Jeff Johnson295189b2012-06-20 16:38:30 -07003819eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3820 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3821{
3822 eHalStatus status;
3823 tBssConfigParam *pBssConfig;
3824 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003825
3826 if(!pSession)
3827 {
3828 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3829 return eHAL_STATUS_FAILURE;
3830 }
3831
Kiet Lam64c1b492013-07-12 13:56:44 +05303832 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3833 if ( NULL == pBssConfig )
3834 status = eHAL_STATUS_FAILURE;
3835 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303837 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3839 if(HAL_STATUS_SUCCESS(status))
3840 {
3841 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003842 /* This will allow to pass cbMode during join req */
3843 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 //For IBSS, we need to prepare some more information
3845 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 )
3848 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003849 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 }
3851 // If we are in an IBSS, then stop the IBSS...
3852 ////Not worry about WDS connection for now
3853 if ( csrIsConnStateIbss( pMac, sessionId ) )
3854 {
3855 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3856 }
3857 else
3858 {
3859 // if we are in an Infrastructure association....
3860 if ( csrIsConnStateInfra( pMac, sessionId ) )
3861 {
3862 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3863 // across SSIDs (roaming to a new SSID)... //
3864 //Not worry about WDS connection for now
3865 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303866 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 {
3868 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303869 status = csrRoamIssueDisassociate( pMac, sessionId,
3870 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303872 else
3873 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3875 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303876 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303878 // Set parameters for this Bss.
3879 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3880 pBssDesc, pBssConfig,
3881 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303885 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 {
3887 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3888 // Nothing to stop.
3889 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303891 )
3892 {
3893 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3894 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3895 // Set parameters for this Bss.
3896 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3897 pBssDesc, pBssConfig,
3898 pIes, is11rRoamingFlag);
3899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 }
3901 }
3902 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303903 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 return (status);
3906}
3907
Jeff Johnson295189b2012-06-20 16:38:30 -07003908eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3909 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3910{
3911 eCsrJoinState eRoamState = eCsrContinueRoaming;
3912 eHalStatus status;
3913 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3914 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3915 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003916
3917 if(!pSession)
3918 {
3919 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3920 return (eCsrStopRoaming);
3921 }
3922
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 if( CSR_IS_WDS_STA( pProfile ) )
3924 {
3925 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3926 if( !HAL_STATUS_SUCCESS( status ) )
3927 {
3928 eRoamState = eCsrStopRoaming;
3929 }
3930 }
3931 else
3932 {
3933 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3934 {
3935 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3936 return (eCsrStopRoaming);
3937 }
3938 if ( csrIsInfraBssDesc( pBssDesc ) )
3939 {
3940 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3941 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3942 // have changed and handle the changes (without disturbing the current association).
3943
3944 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3945 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3946 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3947 )
3948 {
3949 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3950 // with Authenticating first. To force this, stop the current association (Disassociate) and
3951 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3952 // a new Association.
3953 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3954 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07003955 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3957 {
3958 eRoamState = eCsrReassocToSelfNoCapChange;
3959 }
3960 else
3961 {
3962 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05303964 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3966 if(HAL_STATUS_SUCCESS(status))
3967 {
3968 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003969 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303971 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3972 pBssDesc, &bssConfig,
3973 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 if(!HAL_STATUS_SUCCESS(status))
3975 {
3976 eRoamState = eCsrStopRoaming;
3977 }
3978 }
3979 else
3980 {
3981 eRoamState = eCsrStopRoaming;
3982 }
3983 }//same profile
3984 }
3985 else
3986 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303987 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003990 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303994 }
3995 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 {
3997 // 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 +05303998 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 // work much better.
4000 //
4001 //
4002 // stop the existing network before attempting to join the new network...
4003 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4004 {
4005 eRoamState = eCsrStopRoaming;
4006 }
4007 }
4008 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304009 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 {
4011 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4012 {
4013 eRoamState = eCsrStopRoaming;
4014 }
4015 }
4016 if( pIesLocal && !pScanResult->pvIes )
4017 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304018 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 }
4020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 return( eRoamState );
4022}
4023
Jeff Johnson295189b2012-06-20 16:38:30 -07004024eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4025 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4026{
4027 eHalStatus status = eHAL_STATUS_SUCCESS;
4028 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304029 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 roamInfo.pBssDesc = pBssDesc;
4031 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4032 return (status);
4033}
Jeff Johnson295189b2012-06-20 16:38:30 -07004034//In case no matching BSS is found, use whatever default we can find
4035static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4036{
4037 //Need to get all negotiated types in place first
4038 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004039 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 {
4041 default:
4042 case eCSR_AUTH_TYPE_WPA:
4043 case eCSR_AUTH_TYPE_WPA_PSK:
4044 case eCSR_AUTH_TYPE_WPA_NONE:
4045 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4046 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4047 break;
4048
4049 case eCSR_AUTH_TYPE_SHARED_KEY:
4050 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4051 break;
4052
4053 case eCSR_AUTH_TYPE_AUTOSWITCH:
4054 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4055 break;
4056 }
4057 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4058 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4059 //In this case, the multicast encryption needs to follow the uncast ones.
4060 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4061 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4062}
4063
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004064
4065static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4066{
4067 switch(pCommand->u.roamCmd.roamReason)
4068 {
4069 case eCsrLostLink1:
4070 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4071 break;
4072 case eCsrLostLink2:
4073 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4074 break;
4075 case eCsrLostLink3:
4076 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4077 break;
4078 default:
4079 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4080 pCommand->u.roamCmd.roamReason);
4081 break;
4082 }
4083}
4084
Jeff Johnson295189b2012-06-20 16:38:30 -07004085static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4086{
4087 eHalStatus status;
4088 tCsrScanResult *pScanResult = NULL;
4089 eCsrJoinState eRoamState = eCsrStopRoaming;
4090 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4091 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4092 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4093#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4094 v_U8_t acm_mask = 0;
4095#endif
4096 tANI_U32 sessionId = pCommand->sessionId;
4097 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4098 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4099 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004100
4101 if(!pSession)
4102 {
4103 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4104 return (eCsrStopRoaming);
4105 }
4106
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 do
4108 {
4109 // Check for Cardbus eject condition, before trying to Roam to any BSS
4110 //***if( !balIsCardPresent(pAdapter) ) break;
4111
Kiet Lam64c1b492013-07-12 13:56:44 +05304112 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004113 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 if(NULL != pBSSList)
4115 {
4116 // When handling AP's capability change, continue to associate to
4117 // same BSS and make sure pRoamBssEntry is not Null.
4118 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4119 {
4120 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4121 {
4122 //Try the first BSS
4123 pCommand->u.roamCmd.pLastRoamBss = NULL;
4124 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4125 }
4126 else
4127 {
4128 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4129 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4130 {
4131 //Done with all the BSSs
4132 //In this case, will tell HDD the completion
4133 break;
4134 }
4135 else
4136 {
4137 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304138 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4140 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4141 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4142 pRoamInfo = &roamInfo;
4143 }
4144 }
4145 while(pCommand->u.roamCmd.pRoamBssEntry)
4146 {
4147 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 /*If concurrency enabled take the concurrent connected channel first. */
4149 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004150 if (vos_concurrent_sessions_running() &&
4151 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 {
4153 concurrentChannel =
4154 csrGetConcurrentOperationChannel(pMac);
4155 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004156 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 if ((concurrentChannel) &&
4158 (concurrentChannel ==
4159 pScanResult->Result.BssDescriptor.channelId))
4160 {
4161 //make this 0 because we do not want the
4162 //below check to pass as we don't want to
4163 //connect on other channel
4164 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4165 FL("Concurrent channel match =%d"),
4166 concurrentChannel);
4167 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 }
4169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004170
4171 if (!concurrentChannel)
4172 {
4173
4174 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4175 sessionId, &pScanResult->Result.BssDescriptor,
4176 pCommand->u.roamCmd.roamId)))
4177 {
4178 //Ok to roam this
4179 break;
4180 }
4181 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004182 else
4183 {
4184 eRoamState = eCsrStopRoamingDueToConcurrency;
4185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4187 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4188 {
4189 //Done with all the BSSs
4190 fDone = eANI_BOOLEAN_TRUE;
4191 break;
4192 }
4193 }
4194 if(fDone)
4195 {
4196 break;
4197 }
4198 }
4199 }
4200 //We have something to roam, tell HDD when it is infra.
4201 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4202 //For WDS, the indication is eCSR_ROAM_WDS_IND
4203 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4204 {
4205 if(pRoamInfo)
4206 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004207 if(pSession->bRefAssocStartCnt)
4208 {
4209 pSession->bRefAssocStartCnt--;
4210 //Complete the last association attemp because a new one is about to be tried
4211 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4212 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004214 }
4215 }
4216 /* If the roaming has stopped, not to continue the roaming command*/
4217 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4218 {
4219 //No need to complete roaming here as it already completes
4220 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4221 pCommand->u.roamCmd.roamReason);
4222 eRoamState = eCsrStopRoaming;
4223 csrSetAbortRoamingCommand(pMac, pCommand);
4224 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304226 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 if(pScanResult)
4228 {
4229 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004232 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 fDone = eANI_BOOLEAN_TRUE;
4234 eRoamState = eCsrStopRoaming;
4235 break;
4236 }
4237 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4238 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4239 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4240 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4241 CSR_IS_QOS_BSS(pIesLocal) &&
4242 CSR_IS_UAPSD_BSS(pIesLocal) )
4243 {
4244#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4246 pIesLocal);
4247 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4248#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 }
4250 else
4251 {
4252 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4253 }
4254 if( pIesLocal && !pScanResult->Result.pvIes)
4255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304256 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 }
4258 }
4259 else
4260 {
4261 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4262 }
4263 roamInfo.pProfile = pProfile;
4264 pSession->bRefAssocStartCnt++;
4265 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4266 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4269 {
4270 // If this is a start IBSS profile, then we need to start the IBSS.
4271 if ( CSR_IS_START_IBSS(pProfile) )
4272 {
4273 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 // Attempt to start this IBSS...
4275 csrRoamAssignDefaultParam( pMac, pCommand );
4276 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4277 if(HAL_STATUS_SUCCESS(status))
4278 {
4279 if ( fSameIbss )
4280 {
4281 eRoamState = eCsrStartIbssSameIbss;
4282 }
4283 else
4284 {
4285 eRoamState = eCsrContinueRoaming;
4286 }
4287 }
4288 else
4289 {
4290 //it somehow fail need to stop
4291 eRoamState = eCsrStopRoaming;
4292 }
4293 break;
4294 }
4295 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 )
4298 {
4299 // Attempt to start this WDS...
4300 csrRoamAssignDefaultParam( pMac, pCommand );
4301 /* For AP WDS, we dont have any BSSDescription */
4302 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4303 if(HAL_STATUS_SUCCESS(status))
4304 {
4305 eRoamState = eCsrContinueRoaming;
4306 }
4307 else
4308 {
4309 //it somehow fail need to stop
4310 eRoamState = eCsrStopRoaming;
4311 }
4312 }
4313 else
4314 {
4315 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004316 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 eRoamState = eCsrStopRoaming;
4318 break;
4319 }
4320 }
4321 else //We have BSS
4322 {
4323 //Need to assign these value because they are used in csrIsSameProfile
4324 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4325 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4326 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4327 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4328 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4329 {
4330 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4331 {
4332 eRoamState = eCsrStartIbssSameIbss;
4333 break;
4334 }
4335 }
4336 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4337 {
4338 //trying to connect to the one already connected
4339 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4340 eRoamState = eCsrReassocToSelfNoCapChange;
4341 break;
4342 }
4343 // Attempt to Join this Bss...
4344 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4345 break;
4346 }
4347
4348 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4350 {
4351 //Need to indicate association_completion if association_start has been done
4352 if(pSession->bRefAssocStartCnt > 0)
4353 {
4354 pSession->bRefAssocStartCnt--;
4355 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004356 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4358 eCSR_ROAM_ASSOCIATION_COMPLETION,
4359 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4360 }
4361 }
4362
4363 return( eRoamState );
4364}
4365
Jeff Johnson295189b2012-06-20 16:38:30 -07004366static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4367{
4368 eHalStatus status = eHAL_STATUS_SUCCESS;
4369 eCsrJoinState RoamState;
4370 tANI_U32 sessionId = pCommand->sessionId;
4371
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 //***if( hddIsRadioStateOn( pAdapter ) )
4373 {
4374 // Attept to join a Bss...
4375 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004376
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004378 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 {
4380 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 // and if connected in Infrastructure mode...
4382 if ( csrIsConnStateInfra(pMac, sessionId) )
4383 {
4384 //... then we need to issue a disassociation
4385 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4386 if(!HAL_STATUS_SUCCESS(status))
4387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004388 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 //roam command is completed by caller in the failed case
4390 fComplete = eANI_BOOLEAN_TRUE;
4391 }
4392 }
4393 else if( csrIsConnStateIbss(pMac, sessionId) )
4394 {
4395 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4396 if(!HAL_STATUS_SUCCESS(status))
4397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004398 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 //roam command is completed by caller in the failed case
4400 fComplete = eANI_BOOLEAN_TRUE;
4401 }
4402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4404 {
4405 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4406 if(!HAL_STATUS_SUCCESS(status))
4407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004408 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 //roam command is completed by caller in the failed case
4410 fComplete = eANI_BOOLEAN_TRUE;
4411 }
4412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 else
4414 {
4415 fComplete = eANI_BOOLEAN_TRUE;
4416 }
4417 if(fComplete)
4418 {
4419 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004420 if(eCsrStopRoamingDueToConcurrency == RoamState)
4421 {
4422 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4423 }
4424 else
4425 {
4426 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 }
4429 }
4430 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4431 {
4432 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4433 }
4434 else if ( eCsrStartIbssSameIbss == RoamState )
4435 {
4436 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4437 }
4438 }//hddIsRadioStateOn
4439
4440 return status;
4441}
Jeff Johnson295189b2012-06-20 16:38:30 -07004442eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4443{
4444 tANI_U32 sessionId;
4445 tCsrRoamSession *pSession;
4446 tCsrScanResult *pScanResult = NULL;
4447 tSirBssDescription *pBssDesc = NULL;
4448 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 sessionId = pCommand->sessionId;
4450 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004451
4452 if(!pSession)
4453 {
4454 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4455 return eHAL_STATUS_FAILURE;
4456 }
4457
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4459 {
4460 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004461 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4463 return eHAL_STATUS_FAILURE;
4464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 if (pCommand->u.roamCmd.pRoamBssEntry)
4466 {
4467 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4468 pBssDesc = &pScanResult->Result.BssDescriptor;
4469 }
4470 else
4471 {
4472 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004473 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4475 return eHAL_STATUS_FAILURE;
4476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4478 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4479 return status;
4480}
4481
Jeff Johnson295189b2012-06-20 16:38:30 -07004482eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4483{
4484 eHalStatus status = eHAL_STATUS_SUCCESS;
4485 tCsrRoamInfo roamInfo;
4486 tANI_U32 sessionId = pCommand->sessionId;
4487 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004488
4489 if(!pSession)
4490 {
4491 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4492 return eHAL_STATUS_FAILURE;
4493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004494
4495 switch ( pCommand->u.roamCmd.roamReason )
4496 {
4497 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004499 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 case eCsrSmeIssuedDisassocForHandoff:
4502 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4503#if 0 // TODO : Confirm this change
4504 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4505#else
4506 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4507#endif
4508
4509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004512 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004516 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 case eCsrHddIssuedReassocToSameAP:
4519 case eCsrSmeIssuedReassocToSameAP:
4520 {
4521 tDot11fBeaconIEs *pIes = NULL;
4522
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 if( pSession->pConnectBssDesc )
4524 {
4525 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4526 if(!HAL_STATUS_SUCCESS(status) )
4527 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004528 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 }
4530 else
4531 {
4532 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4533 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4534 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4536 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4537 pSession->bRefAssocStartCnt++;
4538 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4539 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4540
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004541 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004542 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4543 &pCommand->u.roamCmd.roamProfile );
4544 if(!HAL_STATUS_SUCCESS(status))
4545 {
4546 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004547 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004548 }
4549
Kiet Lam64c1b492013-07-12 13:56:44 +05304550 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 pIes = NULL;
4552 }
4553 }
4554 break;
4555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004557 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4559 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4560 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004562 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4564 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004565
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 case eCsrStopBss:
4567 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4568 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4569 break;
4570
4571 case eCsrForcedDisassocSta:
4572 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4573 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4574 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4575 pCommand->u.roamCmd.reason);
4576 break;
4577
4578 case eCsrForcedDeauthSta:
4579 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4580 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4581 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4582 pCommand->u.roamCmd.reason);
4583 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004584
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004585 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004586 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004587 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4588 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004590
4591 default:
4592 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4593
4594 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4595 {
4596 //Remember the roaming profile
4597 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304598 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4599 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304601 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4603 }
4604 }
4605
4606 //At this point, original uapsd_mask is saved in pCurRoamProfile
4607 //uapsd_mask in the pCommand may change from this point on.
4608
4609 // Attempt to roam with the new scan results (if we need to..)
4610 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004611 if(!HAL_STATUS_SUCCESS(status))
4612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004613 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 break;
4616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 return (status);
4618}
4619
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004620void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4621{
4622 pCommand->u.roamCmd.pLastRoamBss = NULL;
4623 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4624 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304625 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004626}
4627
Jeff Johnson295189b2012-06-20 16:38:30 -07004628void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4629{
4630 if(pCommand->u.roamCmd.fReleaseBssList)
4631 {
4632 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4633 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4634 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4635 }
4636 if(pCommand->u.roamCmd.fReleaseProfile)
4637 {
4638 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4639 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4640 }
4641 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4642 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304643 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644}
4645
Jeff Johnson295189b2012-06-20 16:38:30 -07004646void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4647{
Kiet Lam64c1b492013-07-12 13:56:44 +05304648 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004649}
Jeff Johnson295189b2012-06-20 16:38:30 -07004650void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4651{
4652 tListElem *pEntry;
4653 tSmeCmd *pCommand;
4654 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004655 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4657 if ( pEntry )
4658 {
4659 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 // If the head of the queue is Active and it is a ROAM command, remove
4661 // and put this on the Free queue.
4662 if ( eSmeCommandRoam == pCommand->command )
4663 {
4664 //we need to process the result first before removing it from active list because state changes
4665 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4666 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4667 if( fReleaseCommand )
4668 {
4669 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4670 {
4671 csrReleaseCommandRoam( pMac, pCommand );
4672 }
4673 else
4674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004675 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004676 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 }
4678 }
4679 else
4680 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004681 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004682 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 }
4684 }
4685 else
4686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004687 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 }
4689 }
4690 else
4691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004692 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 if( fReleaseCommand )
4695 {
4696 smeProcessPendingQueue( pMac );
4697 }
4698}
4699
Jeff Johnson295189b2012-06-20 16:38:30 -07004700void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4701{
4702 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004703 if(!pSession)
4704 {
4705 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4706 return;
4707 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304708 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4709 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 pSession->NumPmkidCandidate = 0;
4711}
Jeff Johnson295189b2012-06-20 16:38:30 -07004712#ifdef FEATURE_WLAN_WAPI
4713void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4714{
4715 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004716 if(!pSession)
4717 {
4718 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4719 return;
4720 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304721 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4722 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 pSession->NumBkidCandidate = 0;
4724}
4725#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004726extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4727
Jeff Johnson295189b2012-06-20 16:38:30 -07004728static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4729 tSirBssDescription *pSirBssDesc,
4730 tDot11fBeaconIEs *pIes)
4731{
4732 eHalStatus status = eHAL_STATUS_SUCCESS;
4733 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4734 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004735
4736 if(!pSession)
4737 {
4738 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4739 return eHAL_STATUS_FAILURE;
4740 }
4741
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 if((eCSR_AUTH_TYPE_WPA == authType) ||
4743 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4744 (eCSR_AUTH_TYPE_RSN == authType) ||
4745 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4746#if defined WLAN_FEATURE_VOWIFI_11R
4747 ||
4748 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4749 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4750#endif /* FEATURE_WLAN_WAPI */
4751#ifdef FEATURE_WLAN_WAPI
4752 ||
4753 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4754 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4755#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004756#ifdef WLAN_FEATURE_11W
4757 ||
4758 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4759#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 )
4761 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004764 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 }
4766 if( pIesLocal )
4767 {
4768 tANI_U32 nIeLen;
4769 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 if((eCSR_AUTH_TYPE_RSN == authType) ||
4771#if defined WLAN_FEATURE_VOWIFI_11R
4772 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4773 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4774#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004775#if defined WLAN_FEATURE_11W
4776 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4777#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4779 {
4780 if(pIesLocal->RSN.present)
4781 {
4782 //Calculate the actual length
4783 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4784 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4785 + 2 //akm_suite_count
4786 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4787 + 2; //reserved
4788 if( pIesLocal->RSN.pmkid_count )
4789 {
4790 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4791 }
4792 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304793 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4794 if (NULL == pSession->pWpaRsnRspIE)
4795 status = eHAL_STATUS_FAILURE;
4796 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304798 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4800 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4801 //copy upto akm_suites
4802 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304803 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4804 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004805 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304806 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4807 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004808 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304809 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4810 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004811 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 if( pIesLocal->RSN.pwise_cipher_suite_count )
4813 {
4814 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304815 vos_mem_copy(pIeBuf,
4816 pIesLocal->RSN.pwise_cipher_suites,
4817 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4819 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304820 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 pIeBuf += 2;
4822 if( pIesLocal->RSN.akm_suite_count )
4823 {
4824 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304825 vos_mem_copy(pIeBuf,
4826 pIesLocal->RSN.akm_suites,
4827 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4829 }
4830 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304831 vos_mem_copy(pIeBuf,
4832 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4833 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4835 }
4836 }
4837 }
4838 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4839 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4840 {
4841 if(pIesLocal->WPA.present)
4842 {
4843 //Calculate the actual length
4844 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4845 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4846 + 2 //auth_suite_count
4847 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4848 // The WPA capabilities follows the Auth Suite (two octects)--
4849 // this field is optional, and we always "send" zero, so just
4850 // remove it. This is consistent with our assumptions in the
4851 // frames compiler; c.f. bug 15234:
4852 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304853
4854 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4855 if ( NULL == pSession->pWpaRsnRspIE )
4856 status = eHAL_STATUS_FAILURE;
4857 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 {
4859 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4860 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4861 pIeBuf = pSession->pWpaRsnRspIE + 2;
4862 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304863 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304865 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4866 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304868 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4869 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4871 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4872 }
4873 }
4874 }
4875#ifdef FEATURE_WLAN_WAPI
4876 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4877 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4878 {
4879 if(pIesLocal->WAPI.present)
4880 {
4881 //Calculate the actual length
4882 nIeLen = 4 //version + akm_suite_count
4883 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4884 + 2 //pwise_cipher_suite_count
4885 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4886 + 6; //gp_cipher_suite + preauth + reserved
4887 if( pIesLocal->WAPI.bkid_count )
4888 {
4889 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4890 }
4891
4892 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304893 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4894 if ( NULL == pSession->pWapiRspIE )
4895 status = eHAL_STATUS_FAILURE;
4896 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 {
4898 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4899 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4900 pIeBuf = pSession->pWapiRspIE + 2;
4901 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304902 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 pIeBuf += 4;
4904 if( pIesLocal->WAPI.akm_suite_count )
4905 {
4906 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304907 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4908 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304910 }
4911 vos_mem_copy(pIeBuf,
4912 &pIesLocal->WAPI.unicast_cipher_suite_count,
4913 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4916 {
4917 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304918 vos_mem_copy( pIeBuf,
4919 pIesLocal->WAPI.unicast_cipher_suites,
4920 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4922 }
lukez3c809222013-05-03 10:23:02 -07004923 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05304924 vos_mem_copy(pIeBuf,
4925 pIesLocal->WAPI.multicast_cipher_suite,
4926 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004927 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304928 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05304929 vos_mem_copy(pIeBuf,
4930 pIesLocal->WAPI.multicast_cipher_suite + 4,
4931 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004932 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304933 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304934 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
4935
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004936 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 if( pIesLocal->WAPI.bkid_count )
4938 {
4939 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304940 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
4941 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4943 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304944 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 }
4947 }
4948#endif /* FEATURE_WLAN_WAPI */
4949 if( !pIes )
4950 {
4951 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304952 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 }
4954 }
4955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 return (status);
4957}
4958
Jeff Johnson295189b2012-06-20 16:38:30 -07004959static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4960{
4961 v_U8_t bACWeights[WLANTL_MAX_AC];
4962 v_U8_t paramBk, paramBe, paramVi, paramVo;
4963 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4965 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4966 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4967 //This doesn't address the case where the lower AC needs a real higher weight
4968 if( pIEs->WMMParams.present )
4969 {
4970 //no change to the lowest ones
4971 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4972 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4973 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4974 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4975 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4976 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4977 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4978 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4979 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4980 {
4981 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4982 fWeightChange = VOS_TRUE;
4983 }
4984 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4985 {
4986 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4987 fWeightChange = VOS_TRUE;
4988 }
4989 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4990 {
4991 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4992 fWeightChange = VOS_TRUE;
4993 }
4994 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4995 {
4996 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4997 fWeightChange = VOS_TRUE;
4998 }
4999 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5000 {
5001 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5002 fWeightChange = VOS_TRUE;
5003 }
5004 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5005 {
5006 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5007 fWeightChange = VOS_TRUE;
5008 }
5009 if(fWeightChange)
5010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005011 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 bACWeights[2], bACWeights[3]);
5013 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5014 }
5015 }
5016}
Jeff Johnson295189b2012-06-20 16:38:30 -07005017#ifdef WLAN_FEATURE_VOWIFI_11R
5018//Returns whether the current association is a 11r assoc or not
5019tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5020{
5021#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5022 return csrNeighborRoamIs11rAssoc(pMac);
5023#else
5024 return eANI_BOOLEAN_FALSE;
5025#endif
5026}
5027#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005028#ifdef FEATURE_WLAN_CCX
5029//Returns whether the current association is a CCX assoc or not
5030tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5031{
5032#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5033 return csrNeighborRoamIsCCXAssoc(pMac);
5034#else
5035 return eANI_BOOLEAN_FALSE;
5036#endif
5037}
5038#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005039#ifdef FEATURE_WLAN_LFR
5040//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305041tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005042{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305043 tCsrRoamSession *pSession = NULL;
5044
5045 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5046 {
5047 pSession = CSR_GET_SESSION( pMac, sessionId );
5048 if (NULL != pSession->pCurRoamProfile)
5049 {
5050 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5051 {
5052 return eANI_BOOLEAN_FALSE;
5053 }
5054 }
5055 }
5056
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005057#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5058 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5059 {
5060 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5061 }
5062 else
5063#endif
5064 {
5065 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005066 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005067 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005068}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005069
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005070#ifdef FEATURE_WLAN_CCX
5071/* ---------------------------------------------------------------------------
5072
5073 \fn csrNeighborRoamIsCCXAssoc
5074
5075 \brief This function returns whether the current association is a CCX assoc or not
5076
5077 \param pMac - The handle returned by macOpen.
5078
5079 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5080
5081---------------------------------------------------------------------------*/
5082tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5083{
5084 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5085}
5086#endif /* FEATURE_WLAN_CCX */
5087
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005088#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5089//Returns whether "FW based BG scan" is currently enabled...or not
5090tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5091{
5092 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5093}
5094#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005095#endif
5096
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005097#if defined(FEATURE_WLAN_CCX)
5098tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5099{
5100 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5101}
5102#endif /*FEATURE_WLAN_CCX*/
5103
Jeff Johnson295189b2012-06-20 16:38:30 -07005104//Return true means the command can be release, else not
5105static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5106 eCsrRoamCompleteResult Result, void *Context )
5107{
5108 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5109 tSirBssDescription *pSirBssDesc = NULL;
5110 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5111 tCsrScanResult *pScanResult = NULL;
5112 tCsrRoamInfo roamInfo;
5113 sme_QosAssocInfo assocInfo;
5114 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5115 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5116 tDot11fBeaconIEs *pIes = NULL;
5117 tANI_U32 sessionId = pCommand->sessionId;
5118 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5119 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5120 eRoamCmdStatus roamStatus;
5121 eCsrRoamResult roamResult;
5122 eHalStatus status;
5123 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005125
Jeff Johnson32d95a32012-09-10 13:15:23 -07005126 if(!pSession)
5127 {
5128 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5129 return eANI_BOOLEAN_FALSE;
5130 }
5131
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005132 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 switch( Result )
5134 {
5135 case eCsrJoinSuccess:
5136 // reset the IDLE timer
5137 // !!
5138 // !! fall through to the next CASE statement here is intentional !!
5139 // !!
5140 case eCsrReassocSuccess:
5141 if(eCsrReassocSuccess == Result)
5142 {
5143 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5144 }
5145 else
5146 {
5147 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5148 }
5149 // Success Join Response from LIM. Tell NDIS we are connected and save the
5150 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005151 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305152 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 //always free the memory here
5154 if(pSession->pWpaRsnRspIE)
5155 {
5156 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305157 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 pSession->pWpaRsnRspIE = NULL;
5159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005160#ifdef FEATURE_WLAN_WAPI
5161 if(pSession->pWapiRspIE)
5162 {
5163 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305164 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 pSession->pWapiRspIE = NULL;
5166 }
5167#endif /* FEATURE_WLAN_WAPI */
5168#ifdef FEATURE_WLAN_BTAMP_UT_RF
5169 //Reset counter so no join retry is needed.
5170 pSession->maxRetryCount = 0;
5171 csrRoamStopJoinRetryTimer(pMac, sessionId);
5172#endif
5173 /* This creates problem since we have not saved the connected profile.
5174 So moving this after saving the profile
5175 */
5176 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5177 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5178 {
5179 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5180 }
5181 else
5182 {
5183 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 //Use the last connected bssdesc for reassoc-ing to the same AP.
5186 //NOTE: What to do when reassoc to a different AP???
5187 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5188 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5189 {
5190 pSirBssDesc = pSession->pConnectBssDesc;
5191 if(pSirBssDesc)
5192 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305193 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5194 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 }
5196 }
5197 else
5198 {
5199
5200 if(pCommand->u.roamCmd.pRoamBssEntry)
5201 {
5202 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5203 if(pScanResult != NULL)
5204 {
5205 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5206 //this can be NULL
5207 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305208 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5209 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 }
5211 }
5212 }
5213 if( pSirBssDesc )
5214 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5217 //Save WPA/RSN IE
5218 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5219#ifdef FEATURE_WLAN_CCX
5220 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5221#endif
5222
5223 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5224 // substate change.
5225 // Moving even save profile above so that below mentioned conditon is also met.
5226 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5227 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5229 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5230 // will be dropped for the security context may not be set properly.
5231 //
5232 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5233 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5234 //
5235 // this reordering was done on titan_prod_usb branch and is being replicated here.
5236 //
5237
5238 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5239 !pProfile->bWPSAssociation)
5240 {
5241 // Issue the set Context request to LIM to establish the Unicast STA context
5242 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5243 pProfile->negotiatedUCEncryptionType,
5244 pSirBssDesc, &(pSirBssDesc->bssId),
5245 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005247 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5249 }
5250 // Issue the set Context request to LIM to establish the Broadcast STA context
5251 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5252 pSirBssDesc, &BroadcastMac,
5253 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5254 }
5255 else
5256 {
5257 //Need to wait for supplicant authtication
5258 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 //Set the subestate to WaitForKey in case authentiation is needed
5260 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5261
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 if(pProfile->bWPSAssociation)
5263 {
5264 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5265 }
5266 else
5267 {
5268 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5269 }
5270
5271 //Save sessionId in case of timeout
5272 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5273 //This time should be long enough for the rest of the process plus setting key
5274 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5275 {
5276 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005277 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5279 }
5280 }
5281
5282 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5283 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 if(Context)
5285 {
5286 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5287 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5289 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5290#ifdef WLAN_FEATURE_VOWIFI_11R
5291 len += pJoinRsp->parsedRicRspLen;
5292#endif /* WLAN_FEATURE_VOWIFI_11R */
5293#ifdef FEATURE_WLAN_CCX
5294 len += pJoinRsp->tspecIeLen;
5295#endif
5296 if(len)
5297 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305298 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5299 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305301 vos_mem_copy(pSession->connectedInfo.pbFrames,
5302 pJoinRsp->frames, len);
5303 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5304 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5305 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005306#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305307 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005308#endif /* WLAN_FEATURE_VOWIFI_11R */
5309#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305310 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005311#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305312 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5313 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5314 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5315 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 }
5317 }
5318 if(pCommand->u.roamCmd.fReassoc)
5319 {
5320 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5321 }
5322 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5323 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5324 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5325 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5326 }
5327 else
5328 {
5329 if(pCommand->u.roamCmd.fReassoc)
5330 {
5331 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5332 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5333 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5334 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5335 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5336 }
5337 }
5338#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5339 // Indicate SME-QOS with reassoc success event, only after
5340 // copying the frames
5341 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5342#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 roamInfo.pBssDesc = pSirBssDesc;
5344 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5345 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5346#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5347 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5348#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5349 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5351 //It may be better to let QoS do this????
5352 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5353 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005354 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5356 pmcStartUapsd( pMac, NULL, NULL );
5357 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305358 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5360 if( pSession->bRefAssocStartCnt > 0 )
5361 {
5362 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005363 //Remove this code once SLM_Sessionization is supported
5364 //BMPS_WORKAROUND_NOT_NEEDED
5365 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005366 {
5367 pMac->roam.configParam.doBMPSWorkaround = 1;
5368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5370 }
5371
5372 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 // reset the PMKID candidate list
5374 csrResetPMKIDCandidateList( pMac, sessionId );
5375 //Update TL's AC weight base on the current EDCA parameters
5376 //These parameters may change in the course of the connection, that sictuation
5377 //is not taken care here. This change is mainly to address a WIFI WMM test where
5378 //BE has a equal or higher TX priority than VI.
5379 //We only do this for infra link
5380 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5381 {
5382 csrCheckAndUpdateACWeight(pMac, pIes);
5383 }
5384#ifdef FEATURE_WLAN_WAPI
5385 // reset the BKID candidate list
5386 csrResetBKIDCandidateList( pMac, sessionId );
5387#endif /* FEATURE_WLAN_WAPI */
5388 }
5389 else
5390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005391 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 csrScanCancelIdleScan(pMac);
5394 //Not to signal link up because keys are yet to be set.
5395 //The linkup function will overwrite the sub-state that we need to keep at this point.
5396 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5397 {
5398 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5401 //enough to let security and DHCP handshake succeed before entry into BMPS
5402 if (pmcShouldBmpsTimerRun(pMac))
5403 {
5404 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5405 != eHAL_STATUS_SUCCESS)
5406 {
5407 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5408 }
5409 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 break;
5412
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 case eCsrStartBssSuccess:
5414 // on the StartBss Response, LIM is returning the Bss Description that we
5415 // are beaconing. Add this Bss Description to our scan results and
5416 // chain the Profile to this Bss Description. On a Start BSS, there was no
5417 // detected Bss description (no partner) so we issued the Start Bss to
5418 // start the Ibss without any Bss description. Lim was kind enough to return
5419 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005420 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305423 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 if( CSR_IS_IBSS( pProfile ) )
5425 {
5426 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 else if (CSR_IS_INFRA_AP(pProfile))
5429 {
5430 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 else
5433 {
5434 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5435 }
5436 if( !CSR_IS_WDS_STA( pProfile ) )
5437 {
5438 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005442 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 roamInfo.pBssDesc = pSirBssDesc;
5444 //We need to associate_complete it first, becasue Associate_start already indicated.
5445 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5446 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5447 break;
5448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005451 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 }
5453 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5454 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5455 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5456 if(pSirBssDesc)
5457 {
5458 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305459 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5460 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 }
5462 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305463 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5465 {
5466 vos_log_ibss_pkt_type *pIbssLog;
5467 tANI_U32 bi;
5468
5469 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5470 if(pIbssLog)
5471 {
5472 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5473 {
5474 //We start the IBSS (didn't find any matched IBSS out there)
5475 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5476 }
5477 else
5478 {
5479 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5480 }
5481 if(pSirBssDesc)
5482 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305483 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5485 }
5486 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5487 {
5488 //***U8 is not enough for beacon interval
5489 pIbssLog->beaconInterval = (v_U8_t)bi;
5490 }
5491 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5492 }
5493 }
5494#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5495 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5496 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5498 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5500 csrRoamIssueSetContextReq( pMac, sessionId,
5501 pProfile->negotiatedMCEncryptionType,
5502 pSirBssDesc, &BroadcastMac,
5503 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5504 }
5505 }
5506 else
5507 {
5508 //Keep the state to eCSR_ROAMING_STATE_JOINING
5509 //Need to send join_req.
5510 if(pCommand->u.roamCmd.pRoamBssEntry)
5511 {
5512 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5513 {
5514 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5515 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5516 // Set the roaming substate to 'join attempt'...
5517 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005518 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 }
5520 }
5521 else
5522 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005523 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 VOS_ASSERT( 0 );
5525 }
5526 }
5527 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5528 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5529 //trigger the connection start indication in Vista
5530 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5531 {
5532 roamStatus = eCSR_ROAM_IBSS_IND;
5533 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5534 if( CSR_IS_WDS( pProfile ) )
5535 {
5536 roamStatus = eCSR_ROAM_WDS_IND;
5537 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 if( CSR_IS_INFRA_AP( pProfile ) )
5540 {
5541 roamStatus = eCSR_ROAM_INFRA_IND;
5542 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005544
5545 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5546 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5547 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305548 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5550 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005551 //We start the IBSS (didn't find any matched IBSS out there)
5552 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305554 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5555 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005556 //Remove this code once SLM_Sessionization is supported
5557 //BMPS_WORKAROUND_NOT_NEEDED
5558 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005559 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005560 {
5561 pMac->roam.configParam.doBMPSWorkaround = 1;
5562 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005563
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5565 }
5566
5567 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005568
5569 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 {
5571 //need to send stop BSS because we fail to send join_req
5572 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5573 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5574 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 case eCsrStartBssFailure:
5578#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5579 {
5580 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5582 if(pIbssLog)
5583 {
5584 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5585 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5586 }
5587 }
5588#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 roamStatus = eCSR_ROAM_IBSS_IND;
5590 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5591 if( CSR_IS_WDS( pProfile ) )
5592 {
5593 roamStatus = eCSR_ROAM_WDS_IND;
5594 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 if( CSR_IS_INFRA_AP( pProfile ) )
5597 {
5598 roamStatus = eCSR_ROAM_INFRA_IND;
5599 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 if(Context)
5602 {
5603 pSirBssDesc = (tSirBssDescription *)Context;
5604 }
5605 else
5606 {
5607 pSirBssDesc = NULL;
5608 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305609 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 roamInfo.pBssDesc = pSirBssDesc;
5611 //We need to associate_complete it first, becasue Associate_start already indicated.
5612 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5613 csrSetDefaultDot11Mode( pMac );
5614 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 case eCsrSilentlyStopRoaming:
5616 // We are here because we try to start the same IBSS
5617 //No message to PE
5618 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005619 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5621 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305622 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5624 if( roamInfo.pBssDesc )
5625 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305626 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5627 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 }
5629 //Since there is no change in the current state, simply pass back no result otherwise
5630 //HDD may be mistakenly mark to disconnected state.
5631 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5632 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 case eCsrSilentlyStopRoamingSaveState:
5635 //We are here because we try to connect to the same AP
5636 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005637 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305638 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005639
5640 //to aviod resetting the substate to NONE
5641 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5642 //No need to change substate to wai_for_key because there is no state change
5643 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5644 if( roamInfo.pBssDesc )
5645 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305646 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5647 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5650 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5651 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5652 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5653 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5654 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5655 roamInfo.staId = pSession->connectedInfo.staId;
5656 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 pSession->bRefAssocStartCnt--;
5659 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5660 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5661 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5662 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 case eCsrReassocFailure:
5664#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5665 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5666#endif
5667 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005668 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 csrFreeConnectBssDesc(pMac, sessionId);
5670 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5671 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305672 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5674 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5675 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5676 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5677 eCSR_ROAM_WDS_IND,
5678 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5679 //Need to issue stop_bss
5680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 case eCsrJoinFailure:
5682 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005683 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 default:
5685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005686 smsLog(pMac, LOGW, FL("receives no association indication"));
5687 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005688 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5690 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5691 {
5692 //do not free for the other profiles as we need to send down stop BSS later
5693 csrFreeConnectBssDesc(pMac, sessionId);
5694 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5695 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5696 csrSetDefaultDot11Mode( pMac );
5697 }
5698
5699 switch( pCommand->u.roamCmd.roamReason )
5700 {
5701 // If this transition is because of an 802.11 OID, then we transition
5702 // back to INIT state so we sit waiting for more OIDs to be issued and
5703 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005704 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 case eCsrSmeIssuedAssocToSimilarAP:
5706 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005707 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305709 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5711 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5712 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305713 vos_mem_copy(&roamInfo.bssid,
5714 &pSession->joinFailStatusCode.bssId,
5715 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005716
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 /* Defeaturize this later if needed */
5718#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5719 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5720 if (csrRoamIsHandoffInProgress(pMac))
5721 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 /* Should indicate neighbor roam algorithm about the connect failure here */
5723 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005725#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 if(pSession->bRefAssocStartCnt > 0)
5727 {
5728 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005729 if(eCsrJoinFailureDueToConcurrency == Result)
5730 {
5731 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5732 eCSR_ROAM_ASSOCIATION_COMPLETION,
5733 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5734 }
5735 else
5736 {
5737 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 eCSR_ROAM_ASSOCIATION_COMPLETION,
5739 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005742 else
5743 {
5744 /* bRefAssocStartCnt is not incremented when
5745 * eRoamState == eCsrStopRoamingDueToConcurrency
5746 * in csrRoamJoinNextBss API. so handle this in
5747 * else case by sending assoc failure
5748 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005749 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005750 pCommand->u.scanCmd.roamId,
5751 eCSR_ROAM_ASSOCIATION_FAILURE,
5752 eCSR_ROAM_RESULT_FAILURE);
5753 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005754 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005755#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5756 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5757#endif
5758 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5759 csrScanStartIdleScan(pMac);
5760#ifdef FEATURE_WLAN_BTAMP_UT_RF
5761 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5762 //BT activity and not able to recevie WLAN traffic. Retry the join
5763 if( CSR_IS_WDS_STA(pProfile) )
5764 {
5765 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5766 }
5767#endif
5768 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 case eCsrHddIssuedReassocToSameAP:
5770 case eCsrSmeIssuedReassocToSameAP:
5771 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5772
5773 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5774#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5775 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5776#endif
5777 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5778 csrScanStartIdleScan(pMac);
5779 break;
5780 case eCsrForcedDisassoc:
5781 case eCsrForcedDeauth:
5782 case eCsrSmeIssuedIbssJoinFailure:
5783 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5784
5785 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5786 {
5787 // Notify HDD that IBSS join failed
5788 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5789 }
5790 else
5791 {
5792 csrRoamCallCallback(pMac, sessionId, NULL,
5793 pCommand->u.roamCmd.roamId,
5794 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5795 }
5796#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5797 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5798#endif
5799 csrRoamLinkDown(pMac, sessionId);
5800 csrScanStartIdleScan(pMac);
5801 break;
5802 case eCsrForcedIbssLeave:
5803 csrRoamCallCallback(pMac, sessionId, NULL,
5804 pCommand->u.roamCmd.roamId,
5805 eCSR_ROAM_IBSS_LEAVE,
5806 eCSR_ROAM_RESULT_IBSS_STOP);
5807 break;
5808 case eCsrForcedDisassocMICFailure:
5809 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5810
5811 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5812#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5813 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5814#endif
5815 csrScanStartIdleScan(pMac);
5816 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 case eCsrStopBss:
5818 csrRoamCallCallback(pMac, sessionId, NULL,
5819 pCommand->u.roamCmd.roamId,
5820 eCSR_ROAM_INFRA_IND,
5821 eCSR_ROAM_RESULT_INFRA_STOPPED);
5822 break;
5823 case eCsrForcedDisassocSta:
5824 case eCsrForcedDeauthSta:
5825 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5826 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5827 {
5828 pSession = CSR_GET_SESSION(pMac, sessionId);
5829 if (!pSession)
5830 break;
5831
5832 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5833 {
5834 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305835 vos_mem_copy(roamInfo.peerMac,
5836 pCommand->u.roamCmd.peerMac,
5837 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5839 roamInfo.statusCode = eSIR_SME_SUCCESS;
5840 status = csrRoamCallCallback(pMac, sessionId,
5841 &roamInfo, pCommand->u.roamCmd.roamId,
5842 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5843 }
5844 }
5845 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 case eCsrLostLink1:
5847 // if lost link roam1 failed, then issue lost link Scan2 ...
5848 csrScanRequestLostLink2(pMac, sessionId);
5849 break;
5850 case eCsrLostLink2:
5851 // if lost link roam2 failed, then issue lost link scan3 ...
5852 csrScanRequestLostLink3(pMac, sessionId);
5853 break;
5854 case eCsrLostLink3:
5855 default:
5856 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5857
5858 //We are done with one round of lostlink roaming here
5859 csrScanHandleFailedLostlink3(pMac, sessionId);
5860 break;
5861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 break;
5863 }
5864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 return ( fReleaseCommand );
5866}
5867
Jeff Johnson295189b2012-06-20 16:38:30 -07005868eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5869{
5870 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 return (status);
5872}
5873
Jeff Johnson295189b2012-06-20 16:38:30 -07005874eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5875{
5876 eHalStatus status = eHAL_STATUS_SUCCESS;
5877 tANI_U32 size = 0;
5878
5879 do
5880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305881 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5883 {
5884 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305885 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5886 if ( NULL == pDstProfile->BSSIDs.bssid )
5887 status = eHAL_STATUS_FAILURE;
5888 else
5889 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 if(!HAL_STATUS_SUCCESS(status))
5891 {
5892 break;
5893 }
5894 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305895 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5896 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005897 }
5898 if(pSrcProfile->SSIDs.numOfSSIDs)
5899 {
5900 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305901 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5902 if ( NULL == pDstProfile->SSIDs.SSIDList )
5903 status = eHAL_STATUS_FAILURE;
5904 else
5905 status = eHAL_STATUS_SUCCESS;
5906 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 {
5908 break;
5909 }
5910 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305911 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5912 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 }
5914 if(pSrcProfile->nWPAReqIELength)
5915 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305916 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5917 if ( NULL == pDstProfile->pWPAReqIE )
5918 status = eHAL_STATUS_FAILURE;
5919 else
5920 status = eHAL_STATUS_SUCCESS;
5921
5922 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 {
5924 break;
5925 }
5926 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305927 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
5928 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 }
5930 if(pSrcProfile->nRSNReqIELength)
5931 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305932 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
5933 if ( NULL == pDstProfile->pRSNReqIE )
5934 status = eHAL_STATUS_FAILURE;
5935 else
5936 status = eHAL_STATUS_SUCCESS;
5937
5938 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 {
5940 break;
5941 }
5942 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305943 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
5944 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 }
5946#ifdef FEATURE_WLAN_WAPI
5947 if(pSrcProfile->nWAPIReqIELength)
5948 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305949 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
5950 if ( NULL == pDstProfile->pWAPIReqIE )
5951 status = eHAL_STATUS_FAILURE;
5952 else
5953 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 if(!HAL_STATUS_SUCCESS(status))
5955 {
5956 break;
5957 }
5958 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305959 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
5960 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 }
5962#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 if(pSrcProfile->nAddIEScanLength)
5964 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305965 pDstProfile->pAddIEScan = vos_mem_malloc(pSrcProfile->nAddIEScanLength);
5966 if ( NULL == pDstProfile->pAddIEScan )
5967 status = eHAL_STATUS_FAILURE;
5968 else
5969 status = eHAL_STATUS_SUCCESS;
5970
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 if(!HAL_STATUS_SUCCESS(status))
5972 {
5973 break;
5974 }
5975 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305976 vos_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5977 pSrcProfile->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 if(pSrcProfile->nAddIEAssocLength)
5980 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305981 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
5982 if ( NULL == pDstProfile->pAddIEAssoc )
5983 status = eHAL_STATUS_FAILURE;
5984 else
5985 status = eHAL_STATUS_SUCCESS;
5986
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 if(!HAL_STATUS_SUCCESS(status))
5988 {
5989 break;
5990 }
5991 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305992 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5993 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 if(pSrcProfile->ChannelInfo.ChannelList)
5996 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305997 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
5998 pSrcProfile->ChannelInfo.numOfChannels);
5999 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6000 status = eHAL_STATUS_FAILURE;
6001 else
6002 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 if(!HAL_STATUS_SUCCESS(status))
6004 {
6005 break;
6006 }
6007 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306008 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6009 pSrcProfile->ChannelInfo.ChannelList,
6010 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 pDstProfile->AuthType = pSrcProfile->AuthType;
6013 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6014 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6015 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6016 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6017 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006018#ifdef WLAN_FEATURE_11W
6019 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6020 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6021 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6022#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 pDstProfile->BSSType = pSrcProfile->BSSType;
6024 pDstProfile->phyMode = pSrcProfile->phyMode;
6025 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6026
6027#ifdef FEATURE_WLAN_WAPI
6028 if(csrIsProfileWapi(pSrcProfile))
6029 {
6030 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6031 {
6032 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6033 }
6034 }
6035#endif /* FEATURE_WLAN_WAPI */
6036 pDstProfile->CBMode = pSrcProfile->CBMode;
6037 /*Save the WPS info*/
6038 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6039 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 pDstProfile->privacy = pSrcProfile->privacy;
6042 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6043 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6044 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6045 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6046 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6047 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6048 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6049 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6050 pDstProfile->wps_state = pSrcProfile->wps_state;
6051 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306052 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6053 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006054#ifdef WLAN_FEATURE_VOWIFI_11R
6055 if (pSrcProfile->MDID.mdiePresent)
6056 {
6057 pDstProfile->MDID.mdiePresent = 1;
6058 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6059 }
6060#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 }while(0);
6062
6063 if(!HAL_STATUS_SUCCESS(status))
6064 {
6065 csrReleaseProfile(pMac, pDstProfile);
6066 pDstProfile = NULL;
6067 }
6068
6069 return (status);
6070}
Jeff Johnson295189b2012-06-20 16:38:30 -07006071eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6072{
6073 eHalStatus status = eHAL_STATUS_SUCCESS;
6074 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6075 do
6076 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306077 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 if(pSrcProfile->bssid)
6079 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6081 if ( NULL == pDstProfile->BSSIDs.bssid )
6082 status = eHAL_STATUS_FAILURE;
6083 else
6084 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 if(!HAL_STATUS_SUCCESS(status))
6086 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306087 smsLog( pMac, LOGE,
6088 FL("failed to allocate memory for BSSID"
6089 "%02x:%02x:%02x:%02x:%02x:%02x"),
6090 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6091 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 break;
6093 }
6094 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306095 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6096 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 }
6098 if(pSrcProfile->SSID.ssId)
6099 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306100 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6101 if ( NULL == pDstProfile->SSIDs.SSIDList )
6102 status = eHAL_STATUS_FAILURE;
6103 else
6104 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 if(!HAL_STATUS_SUCCESS(status))
6106 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306107 smsLog( pMac, LOGE,
6108 FL("failed to allocate memory for SSIDList"
6109 "%02x:%02x:%02x:%02x:%02x:%02x"),
6110 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6111 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 break;
6113 }
6114 pDstProfile->SSIDs.numOfSSIDs = 1;
6115 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6116 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306117 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6118 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006120 if(pSrcProfile->nAddIEAssocLength)
6121 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306122 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6123 if ( NULL == pDstProfile->pAddIEAssoc)
6124 status = eHAL_STATUS_FAILURE;
6125 else
6126 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006127 if(!HAL_STATUS_SUCCESS(status))
6128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006129 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006130 break;
6131 }
6132 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306133 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6134 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006135 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306136 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6137 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6138 status = eHAL_STATUS_FAILURE;
6139 else
6140 status = eHAL_STATUS_SUCCESS;
6141
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 if(!HAL_STATUS_SUCCESS(status))
6143 {
6144 break;
6145 }
6146 pDstProfile->ChannelInfo.numOfChannels = 1;
6147 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 pDstProfile->AuthType.numEntries = 1;
6149 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6150 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6151 pDstProfile->EncryptionType.numEntries = 1;
6152 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6153 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6154 pDstProfile->mcEncryptionType.numEntries = 1;
6155 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6156 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6157 pDstProfile->BSSType = pSrcProfile->BSSType;
6158 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306159 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6160 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006161#ifdef WLAN_FEATURE_VOWIFI_11R
6162 if (pSrcProfile->MDID.mdiePresent)
6163 {
6164 pDstProfile->MDID.mdiePresent = 1;
6165 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6166 }
6167#endif
6168
6169 }while(0);
6170
6171 if(!HAL_STATUS_SUCCESS(status))
6172 {
6173 csrReleaseProfile(pMac, pDstProfile);
6174 pDstProfile = NULL;
6175 }
6176
6177 return (status);
6178}
6179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6181 tScanResultHandle hBSSList,
6182 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6183 tANI_BOOLEAN fClearScan)
6184{
6185 eHalStatus status = eHAL_STATUS_SUCCESS;
6186 tSmeCmd *pCommand;
6187
6188 pCommand = csrGetCommandBuffer(pMac);
6189 if(NULL == pCommand)
6190 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006191 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 status = eHAL_STATUS_RESOURCES;
6193 }
6194 else
6195 {
6196 if( fClearScan )
6197 {
6198 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306199 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 }
6201 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6202 if(NULL == pProfile)
6203 {
6204 //We can roam now
6205 //Since pProfile is NULL, we need to build our own profile, set everything to default
6206 //We can only support open and no encryption
6207 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6208 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6209 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6210 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6211 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6212 }
6213 else
6214 {
6215 //make a copy of the profile
6216 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6217 if(HAL_STATUS_SUCCESS(status))
6218 {
6219 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6220 }
6221 }
6222 pCommand->command = eSmeCommandRoam;
6223 pCommand->sessionId = (tANI_U8)sessionId;
6224 pCommand->u.roamCmd.hBSSList = hBSSList;
6225 pCommand->u.roamCmd.roamId = roamId;
6226 pCommand->u.roamCmd.roamReason = reason;
6227 //We need to free the BssList when the command is done
6228 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6229 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6231 FL("CSR PERSONA=%d"),
6232 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6234 if( !HAL_STATUS_SUCCESS( status ) )
6235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006236 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 csrReleaseCommandRoam( pMac, pCommand );
6238 }
6239 }
6240
6241 return (status);
6242}
Jeff Johnson295189b2012-06-20 16:38:30 -07006243eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6244 tCsrRoamModifyProfileFields *pMmodProfileFields,
6245 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6246{
6247 eHalStatus status = eHAL_STATUS_SUCCESS;
6248 tSmeCmd *pCommand;
6249
6250 pCommand = csrGetCommandBuffer(pMac);
6251 if(NULL == pCommand)
6252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006253 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 status = eHAL_STATUS_RESOURCES;
6255 }
6256 else
6257 {
6258 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306259 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 if(pProfile)
6261 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 //This is likely trying to reassoc to different profile
6263 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6264 //make a copy of the profile
6265 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6266 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 }
6268 else
6269 {
6270 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6271 //how to update WPA/WPA2 info in roamProfile??
6272 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 if(HAL_STATUS_SUCCESS(status))
6275 {
6276 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6277 }
6278 pCommand->command = eSmeCommandRoam;
6279 pCommand->sessionId = (tANI_U8)sessionId;
6280 pCommand->u.roamCmd.roamId = roamId;
6281 pCommand->u.roamCmd.roamReason = reason;
6282 //We need to free the BssList when the command is done
6283 //For reassoc there is no BSS list, so the boolean set to false
6284 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6285 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6286 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6288 if( !HAL_STATUS_SUCCESS( status ) )
6289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006290 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6292 csrReleaseCommandRoam( pMac, pCommand );
6293 }
6294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 return (status);
6296}
6297
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006298eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6299 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306300// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006301{
6302 eHalStatus status = eHAL_STATUS_SUCCESS;
6303 tSmeCmd *pCommand;
6304
6305 pCommand = csrGetCommandBuffer(pMac);
6306 if(NULL == pCommand)
6307 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006308 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006309 status = eHAL_STATUS_RESOURCES;
6310 }
6311 else
6312 {
6313 if(pBssDescription)
6314 {
6315 //copy over the parameters we need later
6316 pCommand->command = eSmeCommandRoam;
6317 pCommand->sessionId = (tANI_U8)sessionId;
6318 pCommand->u.roamCmd.roamReason = reason;
6319 //this is the important parameter
6320 //in this case we are using this field for the "next" BSS
6321 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6322 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6323 if( !HAL_STATUS_SUCCESS( status ) )
6324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006325 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006326 csrReleaseCommandPreauth( pMac, pCommand );
6327 }
6328 }
6329 else
6330 {
6331 //Return failure
6332 status = eHAL_STATUS_RESOURCES;
6333 }
6334 }
6335 return (status);
6336}
6337
6338eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6339{
6340 tListElem *pEntry;
6341 tSmeCmd *pCommand;
6342 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6343 if ( pEntry )
6344 {
6345 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6346 if ( (eSmeCommandRoam == pCommand->command) &&
6347 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6348 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006349 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006350 pCommand->command, pCommand->u.roamCmd.roamReason);
6351 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6352 csrReleaseCommandPreauth( pMac, pCommand );
6353 }
6354 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006355 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006356 pCommand->command, pCommand->u.roamCmd.roamReason);
6357 }
6358 }
6359 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006360 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006361 }
6362 smeProcessPendingQueue( pMac );
6363 return eHAL_STATUS_SUCCESS;
6364}
6365
Jeff Johnson295189b2012-06-20 16:38:30 -07006366eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6367 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6368{
6369 eHalStatus status = eHAL_STATUS_FAILURE;
6370 tScanResultHandle hBSSList;
6371 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6373 if(HAL_STATUS_SUCCESS(status))
6374 {
6375 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6376 if(pRoamId)
6377 {
6378 *pRoamId = roamId;
6379 }
6380 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6381 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6382 if(!HAL_STATUS_SUCCESS(status))
6383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006384 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 csrScanResultPurge(pMac, hBSSList);
6386 }
6387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 return (status);
6389}
6390
Jeff Johnson295189b2012-06-20 16:38:30 -07006391eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6392 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6393{
6394 eHalStatus status = eHAL_STATUS_SUCCESS;
6395 tScanResultHandle hBSSList;
6396 tCsrScanResultFilter *pScanFilter;
6397 tANI_U32 roamId = 0;
6398 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6399 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 if (NULL == pProfile)
6401 {
6402 smsLog(pMac, LOGP, FL("No profile specified"));
6403 return eHAL_STATUS_FAILURE;
6404 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006405 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 if( CSR_IS_WDS( pProfile ) &&
6408 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006410 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006411 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 return status;
6413 }
6414 csrRoamCancelRoaming(pMac, sessionId);
6415 csrScanRemoveFreshScanCommand(pMac, sessionId);
6416 csrScanCancelIdleScan(pMac);
6417 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306418 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6420 {
6421 csrScanDisable(pMac);
6422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6424 //Check whether ssid changes
6425 if(csrIsConnStateConnected(pMac, sessionId))
6426 {
6427 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6428 {
6429 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6430 }
6431 }
6432#ifdef FEATURE_WLAN_BTAMP_UT_RF
6433 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6434#endif
6435 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006437 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6439 if(pRoamId)
6440 {
6441 roamId = *pRoamId;
6442 }
6443 if(!HAL_STATUS_SUCCESS(status))
6444 {
6445 fCallCallback = eANI_BOOLEAN_TRUE;
6446 }
6447 }
6448 else
6449 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306450 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6451 if ( NULL == pScanFilter )
6452 status = eHAL_STATUS_FAILURE;
6453 else
6454 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 if(HAL_STATUS_SUCCESS(status))
6456 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306457 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 //Try to connect to any BSS
6459 if(NULL == pProfile)
6460 {
6461 //No encryption
6462 pScanFilter->EncryptionType.numEntries = 1;
6463 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6464 }//we don't have a profile
6465 else
6466 {
6467 //Here is the profile we need to connect to
6468 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6469 }//We have a profile
6470 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6471 if(pRoamId)
6472 {
6473 *pRoamId = roamId;
6474 }
6475
6476 if(HAL_STATUS_SUCCESS(status))
6477 {
6478 /*Save the WPS info*/
6479 if(NULL != pProfile)
6480 {
6481 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6482 }
6483 else
6484 {
6485 pScanFilter->bWPSAssociation = 0;
6486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 do
6488 {
6489 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 )
6492 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006493 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6495 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6496 if(!HAL_STATUS_SUCCESS(status))
6497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006498 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 fCallCallback = eANI_BOOLEAN_TRUE;
6500 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006501 else
6502 {
6503 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 break;
6506 }
6507 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006508 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 if(HAL_STATUS_SUCCESS(status))
6510 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6512 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6513 if(!HAL_STATUS_SUCCESS(status))
6514 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006515 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 csrScanResultPurge(pMac, hBSSList);
6517 fCallCallback = eANI_BOOLEAN_TRUE;
6518 }
6519 }//Have scan result
6520 else if(NULL != pProfile)
6521 {
6522 //Check whether it is for start ibss
6523 if(CSR_IS_START_IBSS(pProfile))
6524 {
6525 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6526 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6527 if(!HAL_STATUS_SUCCESS(status))
6528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006529 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 fCallCallback = eANI_BOOLEAN_TRUE;
6531 }
6532 }
6533 else
6534 {
6535 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006536 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 if(!HAL_STATUS_SUCCESS(status))
6538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006539 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 fCallCallback = eANI_BOOLEAN_TRUE;
6541 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006542 else
6543 {
6544 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 }
6547 }
6548 else
6549 {
6550 fCallCallback = eANI_BOOLEAN_TRUE;
6551 }
6552 } while (0);
6553 if(NULL != pProfile)
6554 {
6555 //we need to free memory for filter if profile exists
6556 csrFreeScanFilter(pMac, pScanFilter);
6557 }
6558 }//Got the scan filter from profile
6559
Kiet Lam64c1b492013-07-12 13:56:44 +05306560 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 }//allocated memory for pScanFilter
6562 }//No Bsslist coming in
6563 //tell the caller if we fail to trigger a join request
6564 if( fCallCallback )
6565 {
6566 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6567 }
6568
6569 return (status);
6570}
Jeff Johnson295189b2012-06-20 16:38:30 -07006571eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6572 tCsrRoamModifyProfileFields modProfileFields,
6573 tANI_U32 *pRoamId)
6574{
6575 eHalStatus status = eHAL_STATUS_SUCCESS;
6576 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6577 tANI_U32 roamId = 0;
6578 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 if (NULL == pProfile)
6580 {
6581 smsLog(pMac, LOGP, FL("No profile specified"));
6582 return eHAL_STATUS_FAILURE;
6583 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006584 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 -07006585 csrRoamCancelRoaming(pMac, sessionId);
6586 csrScanRemoveFreshScanCommand(pMac, sessionId);
6587 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306588 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 if(csrIsConnStateConnected(pMac, sessionId))
6591 {
6592 if(pProfile)
6593 {
6594 if(pProfile->SSIDs.numOfSSIDs &&
6595 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6596 {
6597 fCallCallback = eANI_BOOLEAN_FALSE;
6598 }
6599 else
6600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006601 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 }
6603 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306604 else if (!vos_mem_compare(&modProfileFields,
6605 &pSession->connectedProfile.modifyProfileFields,
6606 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 {
6608 fCallCallback = eANI_BOOLEAN_FALSE;
6609 }
6610 else
6611 {
6612 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006613 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 }
6615 }
6616 else
6617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006618 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 if(!fCallCallback)
6621 {
6622 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6623 if(pRoamId)
6624 {
6625 *pRoamId = roamId;
6626 }
6627
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6629 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 }
6631 else
6632 {
6633 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6634 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 return status;
6637}
Jeff Johnson295189b2012-06-20 16:38:30 -07006638eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6639{
6640 eHalStatus status = eHAL_STATUS_FAILURE;
6641 tScanResultHandle hBSSList = NULL;
6642 tCsrScanResultFilter *pScanFilter = NULL;
6643 tANI_U32 roamId;
6644 tCsrRoamProfile *pProfile = NULL;
6645 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006646
6647 if(!pSession)
6648 {
6649 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6650 return eHAL_STATUS_FAILURE;
6651 }
6652
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 do
6654 {
6655 if(pSession->pCurRoamProfile)
6656 {
6657 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306658 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306660 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6661 if ( NULL == pProfile )
6662 status = eHAL_STATUS_FAILURE;
6663 else
6664 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 if(!HAL_STATUS_SUCCESS(status))
6666 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306667 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306669 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306671 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6672 if ( NULL == pScanFilter )
6673 status = eHAL_STATUS_FAILURE;
6674 else
6675 status = eHAL_STATUS_SUCCESS;
6676
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 if(!HAL_STATUS_SUCCESS(status))
6678 {
6679 break;
6680 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306681 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6683 if(!HAL_STATUS_SUCCESS(status))
6684 {
6685 break;
6686 }
6687 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6688 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6689 if(HAL_STATUS_SUCCESS(status))
6690 {
6691 //we want to put the last connected BSS to the very beginning, if possible
6692 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6693 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6694 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6695 if(!HAL_STATUS_SUCCESS(status))
6696 {
6697 csrScanResultPurge(pMac, hBSSList);
6698 break;
6699 }
6700 }
6701 else
6702 {
6703 //Do a scan on this profile
6704 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006705 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 if(!HAL_STATUS_SUCCESS(status))
6707 {
6708 break;
6709 }
6710 }
6711 }//We have a profile
6712 else
6713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006714 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 break;
6716 }
6717 }while(0);
6718 if(pScanFilter)
6719 {
6720 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306721 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 }
6723 if(NULL != pProfile)
6724 {
6725 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306726 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006728 return (status);
6729}
Jeff Johnson295189b2012-06-20 16:38:30 -07006730eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6731{
6732 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 if(csrIsConnStateConnected(pMac, sessionId))
6734 {
6735 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6736 if(HAL_STATUS_SUCCESS(status))
6737 {
6738 status = csrRoamJoinLastProfile(pMac, sessionId);
6739 }
6740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 return (status);
6742}
6743
Jeff Johnson295189b2012-06-20 16:38:30 -07006744eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6745{
6746 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006747 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 csrRoamCancelRoaming(pMac, sessionId);
6749 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6750 if(csrIsConnStateDisconnected(pMac, sessionId))
6751 {
6752 status = csrRoamJoinLastProfile(pMac, sessionId);
6753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 return (status);
6755}
6756
Jeff Johnson295189b2012-06-20 16:38:30 -07006757eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6758{
6759 eHalStatus status = eHAL_STATUS_SUCCESS;
6760 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6761 eCsrRoamSubState NewSubstate;
6762 tANI_U32 sessionId = pCommand->sessionId;
6763
6764 // change state to 'Roaming'...
6765 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6766
6767 if ( csrIsConnStateIbss( pMac, sessionId ) )
6768 {
6769 // If we are in an IBSS, then stop the IBSS...
6770 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6771 fComplete = (!HAL_STATUS_SUCCESS(status));
6772 }
6773 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006775 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 -07006776 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6777 //Restore AC weight in case we change it
6778 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6779 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6780 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6781 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6782 {
6783 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6784 }
6785 if( fDisassoc )
6786 {
6787 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6788 }
6789 else
6790 {
6791 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6792 }
6793 fComplete = (!HAL_STATUS_SUCCESS(status));
6794 }
6795 else if ( csrIsConnStateWds( pMac, sessionId ) )
6796 {
6797 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6798 {
6799 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6800 fComplete = (!HAL_STATUS_SUCCESS(status));
6801 }
6802 //This has to be WDS station
6803 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6804 {
6805
6806 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6807 if( fDisassoc )
6808 {
6809 status = csrRoamIssueDisassociate( pMac, sessionId,
6810 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6811 fComplete = (!HAL_STATUS_SUCCESS(status));
6812 }
6813 }
6814 } else {
6815 // we got a dis-assoc request while not connected to any peer
6816 // just complete the command
6817 fComplete = eANI_BOOLEAN_TRUE;
6818 status = eHAL_STATUS_FAILURE;
6819 }
6820 if(fComplete)
6821 {
6822 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6823 }
6824
6825 if(HAL_STATUS_SUCCESS(status))
6826 {
6827 if ( csrIsConnStateInfra( pMac, sessionId ) )
6828 {
6829 //Set the state to disconnect here
6830 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6831 }
6832 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006833 else
6834 {
6835 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 return (status);
6838}
6839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840/* This is been removed from latest code base */
6841/*
6842static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6843{
6844 eHalStatus status;
6845 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6847 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 return ( status );
6849}
6850*/
6851
Jeff Johnson295189b2012-06-20 16:38:30 -07006852eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6853{
6854 eHalStatus status = eHAL_STATUS_SUCCESS;
6855 tSmeCmd *pCommand;
6856 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 do
6858 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006859 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 pCommand = csrGetCommandBuffer( pMac );
6861 if ( !pCommand )
6862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006863 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 status = eHAL_STATUS_RESOURCES;
6865 break;
6866 }
6867 //Change the substate in case it is wait-for-key
6868 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6869 {
6870 csrRoamStopWaitForKeyTimer( pMac );
6871 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6872 }
6873 pCommand->command = eSmeCommandRoam;
6874 pCommand->sessionId = (tANI_U8)sessionId;
6875 switch ( reason )
6876 {
6877 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6878 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6879 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 case eCSR_DISCONNECT_REASON_DEAUTH:
6881 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6882 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 case eCSR_DISCONNECT_REASON_HANDOFF:
6884 fHighPriority = eANI_BOOLEAN_TRUE;
6885 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006887 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6888 case eCSR_DISCONNECT_REASON_DISASSOC:
6889 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6890 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6892 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6893 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6895 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6896 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 default:
6898 break;
6899 }
6900 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6901 if( !HAL_STATUS_SUCCESS( status ) )
6902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006903 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 csrReleaseCommandRoam( pMac, pCommand );
6905 }
6906 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 return( status );
6908}
6909
Jeff Johnson295189b2012-06-20 16:38:30 -07006910eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6911{
6912 eHalStatus status = eHAL_STATUS_SUCCESS;
6913 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 pCommand = csrGetCommandBuffer( pMac );
6915 if ( NULL != pCommand )
6916 {
6917 //Change the substate in case it is wait-for-key
6918 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6919 {
6920 csrRoamStopWaitForKeyTimer( pMac );
6921 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6922 }
6923 pCommand->command = eSmeCommandRoam;
6924 pCommand->sessionId = (tANI_U8)sessionId;
6925 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6926 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6927 if( !HAL_STATUS_SUCCESS( status ) )
6928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006929 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 csrReleaseCommandRoam( pMac, pCommand );
6931 }
6932 }
6933 else
6934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006935 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 status = eHAL_STATUS_RESOURCES;
6937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 return ( status );
6939}
6940
Jeff Johnson295189b2012-06-20 16:38:30 -07006941eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6942{
6943 eHalStatus status = eHAL_STATUS_SUCCESS;
6944 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006945
6946 if(!pSession)
6947 {
6948 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6949 return eHAL_STATUS_FAILURE;
6950 }
6951
Jeff Johnson295189b2012-06-20 16:38:30 -07006952#ifdef FEATURE_WLAN_BTAMP_UT_RF
6953 //Stop te retry
6954 pSession->maxRetryCount = 0;
6955 csrRoamStopJoinRetryTimer(pMac, sessionId);
6956#endif
6957 //Not to call cancel roaming here
6958 //Only issue disconnect when necessary
6959 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6960 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6961 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6962
6963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006964 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 return (status);
6968}
6969
Jeff Johnson295189b2012-06-20 16:38:30 -07006970eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6971{
6972 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006973
6974 if(!pSession)
6975 {
6976 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6977 return eHAL_STATUS_FAILURE;
6978 }
6979
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6982
6983 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6984}
6985
Jeff Johnson295189b2012-06-20 16:38:30 -07006986eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6987 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6988{
6989 eHalStatus status = eHAL_STATUS_SUCCESS;
6990 tDot11fBeaconIEs *pIesTemp = pIes;
6991 tANI_U8 index;
6992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6993 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006994
6995 if(!pSession)
6996 {
6997 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6998 return eHAL_STATUS_FAILURE;
6999 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007000 if(pConnectProfile->pAddIEAssoc)
7001 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307002 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007003 pConnectProfile->pAddIEAssoc = NULL;
7004 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307005 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7007 pConnectProfile->AuthInfo = pProfile->AuthType;
7008 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7009 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7010 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7011 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7012 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7013 pConnectProfile->BSSType = pProfile->BSSType;
7014 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7015 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007016 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7017
Kiet Lam64c1b492013-07-12 13:56:44 +05307018 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007019 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7020 if(pProfile->nAddIEAssocLength)
7021 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307022 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7023 if ( NULL == pConnectProfile->pAddIEAssoc )
7024 status = eHAL_STATUS_FAILURE;
7025 else
7026 status = eHAL_STATUS_SUCCESS;
7027 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007028 {
7029 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7030 return eHAL_STATUS_FAILURE;
7031 }
7032 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307033 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7034 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007035 }
7036
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 //Save bssid
7038 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7039#ifdef WLAN_FEATURE_VOWIFI_11R
7040 if (pSirBssDesc->mdiePresent)
7041 {
7042 pConnectProfile->MDID.mdiePresent = 1;
7043 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7044 }
7045#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007046 if( NULL == pIesTemp )
7047 {
7048 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007050#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007051 if ((csrIsProfileCCX(pProfile) ||
7052 ((pIesTemp->CCXVersion.present)
7053 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7054 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7055 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7056 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007057#ifdef WLAN_FEATURE_11W
7058 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7059#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307060 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007061 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 {
7063 pConnectProfile->isCCXAssoc = 1;
7064 }
7065#endif
7066 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 if(HAL_STATUS_SUCCESS(status))
7068 {
7069 if(pIesTemp->SSID.present)
7070 {
7071 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307072 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7073 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 }
7075
7076 //Save the bss desc
7077 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307078
7079 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307081 //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 -07007082 pConnectProfile->qap = TRUE;
7083 }
7084 else
7085 {
7086 pConnectProfile->qap = FALSE;
7087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007088 if ( NULL == pIes )
7089 {
7090 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307091 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 }
7093 }
7094 //Save Qos connection
7095 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7096
7097 if(!HAL_STATUS_SUCCESS(status))
7098 {
7099 csrFreeConnectBssDesc(pMac, sessionId);
7100 }
7101 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7102 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307103 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7104 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7105 pConnectProfile->SSID.ssId,
7106 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007107 {
7108 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7109 break;
7110 }
7111 pConnectProfile->handoffPermitted = FALSE;
7112 }
7113
7114 return (status);
7115}
7116
Jeff Johnson295189b2012-06-20 16:38:30 -07007117static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7118{
7119 tListElem *pEntry = NULL;
7120 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 //The head of the active list is the request we sent
7122 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7123 if(pEntry)
7124 {
7125 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7128 {
7129 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7130 {
7131#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7132 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7133#endif
7134 }
7135 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7136 }
7137 else
7138 {
7139 tANI_U32 roamId = 0;
7140 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007141 if(!pSession)
7142 {
7143 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7144 return;
7145 }
7146
Jeff Johnson295189b2012-06-20 16:38:30 -07007147
7148 //The head of the active list is the request we sent
7149 //Try to get back the same profile and roam again
7150 if(pCommand)
7151 {
7152 roamId = pCommand->u.roamCmd.roamId;
7153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7155 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007156 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007157#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7158 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7159 if (csrRoamIsHandoffInProgress(pMac))
7160 {
7161 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7162 /* Should indicate neighbor roam algorithm about the connect failure here */
7163 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7164 }
7165#endif
7166 if (pCommand)
7167 {
7168 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7169 {
7170 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7171 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7172 csrRoamReissueRoamCommand(pMac);
7173 }
7174 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7175 {
7176 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7177 }
7178 else
7179 {
7180 csrRoam(pMac, pCommand);
7181 }
7182 }
7183 else
7184 {
7185 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7186 }
7187 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7188}
7189
Jeff Johnson295189b2012-06-20 16:38:30 -07007190eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7191 tDot11fBeaconIEs *pIes,
7192 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7193{
7194 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007195 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7196 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007197
7198 // Set the roaming substate to 'join attempt'...
7199 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007201 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 return (status);
7203}
7204
Jeff Johnson295189b2012-06-20 16:38:30 -07007205static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7206 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7207{
7208 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 // Set the roaming substate to 'join attempt'...
7210 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7211
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007212 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007213
7214 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007215 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007216}
7217
Jeff Johnson295189b2012-06-20 16:38:30 -07007218void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7219{
7220 tListElem *pEntry;
7221 tSmeCmd *pCommand;
7222 tCsrRoamInfo roamInfo;
7223 tANI_U32 sessionId;
7224 tCsrRoamSession *pSession;
7225
7226 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7227 if(pEntry)
7228 {
7229 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7230 if ( eSmeCommandRoam == pCommand->command )
7231 {
7232 sessionId = pCommand->sessionId;
7233 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007234
7235 if(!pSession)
7236 {
7237 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7238 return;
7239 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307240 /* While switching between two AP, csr will reissue roam command again
7241 to the nextbss if it was interrupted by the dissconnect req for the
7242 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7243 so reset the bRefAssocStartCnt.
7244 */
7245 if(pSession->bRefAssocStartCnt > 0)
7246 {
7247 pSession->bRefAssocStartCnt--;
7248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 if( pCommand->u.roamCmd.fStopWds )
7250 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307251 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7253 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7254 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7257 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7258 eCSR_ROAM_WDS_IND,
7259 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7261 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7262 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7263 eCSR_ROAM_INFRA_IND,
7264 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7265 }
7266
Jeff Johnson295189b2012-06-20 16:38:30 -07007267
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7269 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007270 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7272 }
7273 }
7274 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007276 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7278 }
7279 }
7280 else
7281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007282 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 }
7284 }
7285 else
7286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007287 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 }
7289}
7290
Jeff Johnson295189b2012-06-20 16:38:30 -07007291tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7292{
7293 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7294 tListElem *pEntry;
7295 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 //alwasy lock active list before locking pending list
7297 csrLLLock( &pMac->sme.smeCmdActiveList );
7298 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7299 if(pEntry)
7300 {
7301 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7302 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7303 {
7304 fRet = eANI_BOOLEAN_TRUE;
7305 }
7306 }
7307 if(eANI_BOOLEAN_FALSE == fRet)
7308 {
7309 csrLLLock(&pMac->sme.smeCmdPendingList);
7310 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7311 while(pEntry)
7312 {
7313 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7314 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7315 {
7316 fRet = eANI_BOOLEAN_TRUE;
7317 break;
7318 }
7319 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7320 }
7321 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7322 }
7323 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 return (fRet);
7325}
7326
Jeff Johnson295189b2012-06-20 16:38:30 -07007327tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7328{
7329 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7330 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7332 {
7333 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7334 {
7335 break;
7336 }
7337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 return ( fRet );
7339}
7340
Jeff Johnson295189b2012-06-20 16:38:30 -07007341tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7342{
7343 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 //alwasy lock active list before locking pending list
7345 csrLLLock( &pMac->sme.smeCmdActiveList );
7346 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7347 if(eANI_BOOLEAN_FALSE == fRet)
7348 {
7349 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7350 }
7351 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 return (fRet);
7353}
7354
Jeff Johnson295189b2012-06-20 16:38:30 -07007355tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7356{
7357 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7358 tListElem *pEntry;
7359 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 //alwasy lock active list before locking pending list
7361 csrLLLock( &pMac->sme.smeCmdActiveList );
7362 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7363 if( pEntry )
7364 {
7365 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7366 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7367 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7368 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7369 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7370 {
7371 fRet = eANI_BOOLEAN_TRUE;
7372 }
7373 }
7374 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 return (fRet);
7376}
Jeff Johnson295189b2012-06-20 16:38:30 -07007377eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7378{
7379 eHalStatus status = eHAL_STATUS_SUCCESS;
7380 tSmeCmd *pCommand = NULL;
7381 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7382 tANI_BOOLEAN fRemoveCmd = FALSE;
7383 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 // Delete the old assoc command. All is setup for reassoc to be serialized
7385 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7386 if ( pEntry )
7387 {
7388 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7389 if ( !pCommand )
7390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007391 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 return eHAL_STATUS_RESOURCES;
7393 }
7394 if ( eSmeCommandRoam == pCommand->command )
7395 {
7396 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7397 {
7398 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7399 }
7400 else
7401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007402 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 }
7404 if (fRemoveCmd == FALSE)
7405 {
7406 // Implies we did not get the serialized assoc command we
7407 // were expecting
7408 pCommand = NULL;
7409 }
7410 }
7411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 if(NULL == pCommand)
7413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007414 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 return eHAL_STATUS_RESOURCES;
7416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 do
7418 {
7419 //Change the substate in case it is wait-for-key
7420 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7421 {
7422 csrRoamStopWaitForKeyTimer( pMac );
7423 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7424 }
7425 pCommand->command = eSmeCommandRoam;
7426 pCommand->sessionId = (tANI_U8)sessionId;
7427 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7429 if( !HAL_STATUS_SUCCESS( status ) )
7430 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007431 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 csrReleaseCommandRoam( pMac, pCommand );
7433 }
7434 } while( 0 );
7435
Jeff Johnson295189b2012-06-20 16:38:30 -07007436 return( status );
7437}
7438static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7439{
7440 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7441 tCsrScanResult *pScanResult = NULL;
7442 tSirBssDescription *pBssDesc = NULL;
7443 tSmeCmd *pCommand = NULL;
7444 tANI_U32 sessionId;
7445 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 if(NULL == pEntry)
7447 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007448 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 return;
7450 }
7451 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7452 sessionId = pCommand->sessionId;
7453 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007454
7455 if(!pSession)
7456 {
7457 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7458 return;
7459 }
7460
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7462 {
7463 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007464 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7466 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007467 /* If the roaming has stopped, not to continue the roaming command*/
7468 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7469 {
7470 //No need to complete roaming here as it already completes
7471 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7472 pCommand->u.roamCmd.roamReason);
7473 csrSetAbortRoamingCommand( pMac, pCommand );
7474 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 else
7477 {
7478 if ( CCM_IS_RESULT_SUCCESS(result) )
7479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007480 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 // Successfully set the configuration parameters for the new Bss. Attempt to
7482 // join the roaming Bss.
7483 if(pCommand->u.roamCmd.pRoamBssEntry)
7484 {
7485 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7486 pBssDesc = &pScanResult->Result.BssDescriptor;
7487 }
7488 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7489 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 )
7492 {
7493 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7494 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7495 pBssDesc, pCommand->u.roamCmd.roamId )))
7496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007497 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 //We need to complete the command
7499 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7500 }
7501 }
7502 else
7503 {
7504 if (!pCommand->u.roamCmd.pRoamBssEntry)
7505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007506 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 //We need to complete the command
7508 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7509 return;
7510 }
7511 // If we are roaming TO an Infrastructure BSS...
7512 VOS_ASSERT(pScanResult != NULL);
7513 if ( csrIsInfraBssDesc( pBssDesc ) )
7514 {
7515 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7517 {
7518 // ..and currently in an Infrastructure connection....
7519 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7520 {
7521 // ...and the SSIDs are equal, then we Reassoc.
7522 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7523 pIesLocal ) )
7524 // ..and currently in an infrastructure connection
7525 {
7526 // then issue a Reassoc.
7527 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7528 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7529 &pCommand->u.roamCmd.roamProfile );
7530 }
7531 else
7532 {
7533
7534 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7535 // previously associated AP.
7536 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7537 pIesLocal,
7538 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7539 {
7540 //try something else
7541 csrRoam( pMac, pCommand );
7542 }
7543 }
7544 }
7545 else
7546 {
7547 eHalStatus status = eHAL_STATUS_SUCCESS;
7548
7549 /* We need to come with other way to figure out that this is because of HO in BMP
7550 The below API will be only available for Android as it uses a different HO algorithm */
7551 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7552 * use join request */
7553#ifdef WLAN_FEATURE_VOWIFI_11R
7554 if (csrRoamIsHandoffInProgress(pMac) &&
7555 csrRoamIs11rAssoc(pMac))
7556 {
7557 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7558 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7559 }
7560 else
7561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007562#ifdef FEATURE_WLAN_CCX
7563 if (csrRoamIsHandoffInProgress(pMac) &&
7564 csrRoamIsCCXAssoc(pMac))
7565 {
7566 // Now serialize the reassoc command.
7567 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7568 }
7569 else
7570#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007571#ifdef FEATURE_WLAN_LFR
7572 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307573 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007574 {
7575 // Now serialize the reassoc command.
7576 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7577 }
7578 else
7579#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 // else we are not connected and attempting to Join. Issue the
7581 // Join request.
7582 {
7583 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7584 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7585 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7586 }
7587 if(!HAL_STATUS_SUCCESS(status))
7588 {
7589 //try something else
7590 csrRoam( pMac, pCommand );
7591 }
7592 }
7593 if( !pScanResult->Result.pvIes )
7594 {
7595 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307596 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 }
7598 }
7599 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7600 else
7601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007602 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 }
7604 }//else
7605 }//if ( WNI_CFG_SUCCESS == result )
7606 else
7607 {
7608 // In the event the configuration failed, for infra let the roam processor
7609 //attempt to join something else...
7610 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7611 {
7612 csrRoam(pMac, pCommand);
7613 }
7614 else
7615 {
7616 //We need to complete the command
7617 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7618 {
7619 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7620 }
7621 else
7622 {
7623 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7624 }
7625 }
7626 }
7627 }//we have active entry
7628}
7629
Jeff Johnson295189b2012-06-20 16:38:30 -07007630static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7631{
7632 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007633 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007636 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7638 // join the new one...
7639 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7641 }
7642 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007643 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 /***profHandleLostLinkAfterReset(pAdapter);
7645 // In the event the authenticate fails, let the roam processor attempt to join something else...
7646 roamRoam( pAdapter );***/
7647 }
7648}
7649
Jeff Johnson295189b2012-06-20 16:38:30 -07007650static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7651{
7652 eCsrRoamCompleteResult result;
7653 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7654 tCsrRoamInfo roamInfo;
7655 tANI_U32 roamId = 0;
7656
7657 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007659 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 /* Defeaturize this part later if needed */
7662#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7663 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7664 * we need the response contents while processing the result in csrRoamProcessResults() */
7665 if (csrRoamIsHandoffInProgress(pMac))
7666 {
7667 /* Need to dig more on indicating events to SME QoS module */
7668 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7669 csrRoamComplete( pMac, result, pSmeJoinRsp);
7670 }
7671 else
7672#endif
7673 {
7674 csrRoamComplete( pMac, result, NULL );
7675 }
7676 }
7677 /* Should we handle this similar to handling the join failure? Is it ok
7678 * to call csrRoamComplete() with state as CsrJoinFailure */
7679 else
7680 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007681 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 result = eCsrReassocFailure;
7683#ifdef WLAN_FEATURE_VOWIFI_11R
7684 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7685 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7686 {
7687 // Inform HDD to turn off FT flag in HDD
7688 if (pNeighborRoamInfo)
7689 {
7690 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7691 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7692 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007693 /*
7694 * Since the above callback sends a disconnect
7695 * to HDD, we should clean-up our state
7696 * machine as well to be in sync with the upper
7697 * layers. There is no need to send a disassoc
7698 * since: 1) we will never reassoc to the current
7699 * AP in LFR, and 2) there is no need to issue a
7700 * disassoc to the AP with which we were trying
7701 * to reassoc.
7702 */
7703 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7704 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 }
7706 }
7707#endif
7708 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7709 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7710 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7711 //The disassoc rsp message will remove the command from active list
7712 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7713 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7714 {
7715 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7716 }
7717 }
7718}
7719
Jeff Johnson295189b2012-06-20 16:38:30 -07007720static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7721{
Jeff Johnson295189b2012-06-20 16:38:30 -07007722#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7723 {
7724 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7726 if(pIbssLog)
7727 {
7728 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7729 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7730 {
7731 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7732 }
7733 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7734 }
7735 }
7736#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7738 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7739 {
7740 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7741 }
7742 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7743 {
7744 csrRoamReissueRoamCommand(pMac);
7745 }
7746}
7747
Jeff Johnson295189b2012-06-20 16:38:30 -07007748void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7749{
7750 tSirResultCodes statusCode;
7751#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7752 tScanResultHandle hBSSList;
7753 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7754 eHalStatus status;
7755 tCsrRoamInfo roamInfo;
7756 tCsrScanResultFilter *pScanFilter = NULL;
7757 tANI_U32 roamId = 0;
7758 tCsrRoamProfile *pCurRoamProfile = NULL;
7759 tListElem *pEntry = NULL;
7760 tSmeCmd *pCommand = NULL;
7761#endif
7762 tANI_U32 sessionId;
7763 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007764
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 tSirSmeDisassocRsp SmeDisassocRsp;
7766
7767 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7768 sessionId = SmeDisassocRsp.sessionId;
7769 statusCode = SmeDisassocRsp.statusCode;
7770
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007771 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007772
7773 if ( csrIsConnStateInfra( pMac, sessionId ) )
7774 {
7775 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007778
7779 if(!pSession)
7780 {
7781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7782 return;
7783 }
7784
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7786 {
7787 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7788 }
7789 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7790 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7791 {
7792 if ( eSIR_SME_SUCCESS == statusCode )
7793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007794 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7796 }
7797 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007801 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007802#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007803 /*
7804 * First ensure if the roam profile is in the scan cache.
7805 * If not, post a reassoc failure and disconnect.
7806 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307807 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7808 if ( NULL == pScanFilter )
7809 status = eHAL_STATUS_FAILURE;
7810 else
7811 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007812 if(HAL_STATUS_SUCCESS(status))
7813 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307814 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007815 status = csrRoamPrepareFilterFromProfile(pMac,
7816 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7817 if(!HAL_STATUS_SUCCESS(status))
7818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007819 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007820 __func__, status);
7821 goto POST_ROAM_FAILURE;
7822 }
7823 else
7824 {
7825 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7826 if (!HAL_STATUS_SUCCESS(status))
7827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007828 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007829 __func__, status);
7830 goto POST_ROAM_FAILURE;
7831 }
7832 }
7833 }
7834 else
7835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007836 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007837 __func__, status);
7838 goto POST_ROAM_FAILURE;
7839 }
7840
7841 /*
7842 * After ensuring that the roam profile is in the scan result list,
7843 * dequeue the command from the active list.
7844 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7846 if ( pEntry )
7847 {
7848 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007849 /* If the head of the queue is Active and it is a ROAM command, remove
7850 * and put this on the Free queue.
7851 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 if ( eSmeCommandRoam == pCommand->command )
7853 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007854
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007855 /*
7856 * we need to process the result first before removing it from active list
7857 * because state changes still happening insides roamQProcessRoamResults so
7858 * no other roam command should be issued.
7859 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7861 if(pCommand->u.roamCmd.fReleaseProfile)
7862 {
7863 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7864 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 else
7869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007870 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007871 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007872 }
7873 }
7874 else
7875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007876 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 }
7878 }
7879 else
7880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007881 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007883
7884 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7886
Kiet Lam64c1b492013-07-12 13:56:44 +05307887 vos_mem_copy(roamInfo.bssid,
7888 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7889 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007890
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007891 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7892 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007893
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007894 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307895 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7896 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307898 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007899 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7900 //make sure to put it at the head of the cmd queue
7901 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7902 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7903 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7904
Jeff Johnson295189b2012-06-20 16:38:30 -07007905 if(!HAL_STATUS_SUCCESS(status))
7906 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007907 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007908 __func__, status);
7909 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 }
7911
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007912 /* Notify sub-modules like QoS etc. that handoff happening */
7913 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007914 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307915 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307917 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007918 return;
7919 }
7920
7921POST_ROAM_FAILURE:
7922 if (pScanFilter)
7923 {
7924 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307925 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007926 }
7927 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05307928 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007929
7930 /* Inform the upper layers that the reassoc failed */
7931 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7932 csrRoamCallCallback(pMac, sessionId,
7933 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7934
7935 /*
7936 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7937 * Upon success, we would re-enter this routine after receiving the disassoc
7938 * response and will fall into the reassoc fail sub-state. And, eventually
7939 * call csrRoamComplete which would remove the roam command from SME active
7940 * queue.
7941 */
7942 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7943 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007945 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007946 __func__, status);
7947 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007949#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007950
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7952 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7953 {
7954 // Disassoc due to Reassoc failure falls into this codepath....
7955 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7956 }
7957 else
7958 {
7959 if ( eSIR_SME_SUCCESS == statusCode )
7960 {
7961 // Successfully disassociated from the 'old' Bss...
7962 //
7963 // We get Disassociate response in three conditions.
7964 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7965 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7966 // Infrastructure network.
7967 // - Third is where we are doing an Infra to Infra roam between networks with different
7968 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7969
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007970 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 }
7972 else
7973 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007974 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 }
7976 //We are not done yet. Get the data and continue roaming
7977 csrRoamReissueRoamCommand(pMac);
7978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007979}
7980
Jeff Johnson295189b2012-06-20 16:38:30 -07007981static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7982{
7983 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007985 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7987 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7988 {
7989 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7990 }
7991 else
7992 {
7993 if ( eSIR_SME_SUCCESS == statusCode )
7994 {
7995 // Successfully deauth from the 'old' Bss...
7996 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007997 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 }
7999 else
8000 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008001 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008002 }
8003 //We are not done yet. Get the data and continue roaming
8004 csrRoamReissueRoamCommand(pMac);
8005 }
8006}
8007
Jeff Johnson295189b2012-06-20 16:38:30 -07008008static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8009{
8010 eCsrRoamCompleteResult result;
8011
8012 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008014 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008015 result = eCsrStartBssSuccess;
8016 }
8017 else
8018 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008019 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008020 //Let csrRoamComplete decide what to do
8021 result = eCsrStartBssFailure;
8022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008024}
8025
Jeff Johnson295189b2012-06-20 16:38:30 -07008026/*
8027 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8028 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8029 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8030 For the messages where sender allocates memory for specific structures, then it can be
8031 cast accordingly.
8032*/
8033void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8034{
8035 tSirSmeRsp *pSmeRsp;
8036 tSmeIbssPeerInd *pIbssPeerInd;
8037 tCsrRoamInfo roamInfo;
8038 // TODO Session Id need to be acquired in this function
8039 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008041 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 pSmeRsp->messageType, pSmeRsp->messageType,
8043 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 pSmeRsp->messageType = (pSmeRsp->messageType);
8045 pSmeRsp->length = (pSmeRsp->length);
8046 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 switch (pSmeRsp->messageType)
8048 {
8049
8050 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8051 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8052 {
8053 //We sent a JOIN_REQ
8054 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8055 }
8056 break;
8057
8058 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8059 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8060 {
8061 //We sent a AUTH_REQ
8062 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8063 }
8064 break;
8065
8066 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8067 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8068 {
8069 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8070 }
8071 break;
8072
8073 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8074 {
8075 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8076 }
8077 break;
8078
8079 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8080 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8081 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8082 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8083 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8084 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8085//HO
8086 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008088 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8090 }
8091 break;
8092
8093 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8094 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8095 {
8096 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8097 }
8098 break;
8099
8100 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8101 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8102 {
8103 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8104 }
8105 break;
8106
8107 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8108 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8109 {
8110 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8114 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8115 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008116 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308117 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8118 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8120 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308121 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8122 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8124 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8125 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8126 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008128 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 pSmeRsp->messageType, pSmeRsp->messageType,
8130 pMac->roam.curSubState[pSmeRsp->sessionId] );
8131
8132 //If we are connected, check the link status change
8133 if(!csrIsConnStateDisconnected(pMac, sessionId))
8134 {
8135 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8136 }
8137 break;
8138 }
8139}
8140
Jeff Johnson295189b2012-06-20 16:38:30 -07008141void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8142{
8143 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 switch (pSirMsg->messageType)
8145 {
8146 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008147 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 csrRoamStatsRspProcessor( pMac, pSirMsg );
8149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8151 {
8152 tCsrRoamSession *pSession;
8153 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8154 tCsrRoamInfo roamInfo;
8155 tCsrRoamInfo *pRoamInfo = NULL;
8156 tANI_U32 sessionId;
8157 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008158 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308159 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8162 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8163 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008164
8165 if(!pSession)
8166 {
8167 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8168 return;
8169 }
8170
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8172 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8174 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8175 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8177 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308178 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8179 sizeof(tSirMacAddr));
8180 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8181 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8184 {
8185 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8186 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8187 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8188 }
8189 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8190 {
8191 vos_sleep( 100 );
8192 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8193 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8194 }
8195
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 }
8197 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 default:
8199 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8200 break;
8201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008202}
8203
Jeff Johnson295189b2012-06-20 16:38:30 -07008204eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8205 tSirBssDescription *pBssDescription,
8206 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8207 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8208 tANI_U8 keyId, tANI_U16 keyLength,
8209 tANI_U8 *pKey, tANI_U8 paeRole )
8210{
8211 eHalStatus status = eHAL_STATUS_SUCCESS;
8212 tAniEdType edType;
8213
8214 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8215 {
8216 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8217 }
8218
8219 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8220
8221 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8222 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8223 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8224 addKey )
8225 {
8226 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 setKey.encType = EncryptType;
8228 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308229 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 setKey.paeRole = paeRole; //0 for supplicant
8231 setKey.keyId = keyId; // Kye index
8232 setKey.keyLength = keyLength;
8233 if( keyLength )
8234 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308235 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 }
8237 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 return (status);
8240}
8241
Jeff Johnson295189b2012-06-20 16:38:30 -07008242static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8243 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8244{
8245 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8246 tSmeCmd *pCommand = NULL;
8247#ifdef FEATURE_WLAN_CCX
8248 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8249#endif /* FEATURE_WLAN_CCX */
8250
8251 do
8252 {
8253 pCommand = csrGetCommandBuffer(pMac);
8254 if(NULL == pCommand)
8255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008256 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 status = eHAL_STATUS_RESOURCES;
8258 break;
8259 }
8260 pCommand->command = eSmeCommandSetKey;
8261 pCommand->sessionId = (tANI_U8)sessionId;
8262 // validate the key length, Adjust if too long...
8263 // for static WEP the keys are not set thru' SetContextReq
8264 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8265 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8266 {
8267 //KeyLength maybe 0 for static WEP
8268 if( pSetKey->keyLength )
8269 {
8270 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008272 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 break;
8274 }
8275
8276 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308277 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8278 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 }
8280 }
8281 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8282 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8283 {
8284 //KeyLength maybe 0 for static WEP
8285 if( pSetKey->keyLength )
8286 {
8287 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008289 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 break;
8291 }
8292
8293 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308294 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8295 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 }
8297 }
8298 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8299 {
8300 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008302 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 break;
8304 }
8305 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308306 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8307 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 }
8309 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8310 {
8311 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008313 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 break;
8315 }
8316 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308317 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8318 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 }
8320#ifdef FEATURE_WLAN_WAPI
8321 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8322 {
8323 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008325 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 break;
8327 }
8328 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308329 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8330 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 }
8332#endif /* FEATURE_WLAN_WAPI */
8333#ifdef FEATURE_WLAN_CCX
8334 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8335 {
8336 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008338 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 break;
8340 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308341 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8342 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008343 pSession->ccxCckmInfo.reassoc_req_num=1;
8344 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8345 status = eHAL_STATUS_SUCCESS;
8346 break;
8347 }
8348#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008349
Jeff Johnson295189b2012-06-20 16:38:30 -07008350#ifdef WLAN_FEATURE_11W
8351 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008352 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008354 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008356 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 break;
8358 }
8359 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308360 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 }
8362#endif
8363 status = eHAL_STATUS_SUCCESS;
8364 pCommand->u.setKeyCmd.roamId = roamId;
8365 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8366 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308367 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8368 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8370 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308371 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 //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
8373
8374 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8375 if( !HAL_STATUS_SUCCESS( status ) )
8376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008377 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 }
8379 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 // Free the command if there has been a failure, or it is a
8381 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008382 if ( ( NULL != pCommand ) &&
8383 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008384#ifdef FEATURE_WLAN_CCX
8385 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8386#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008387 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008388 {
8389 csrReleaseCommandSetKey( pMac, pCommand );
8390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 return( status );
8392}
8393
Jeff Johnson295189b2012-06-20 16:38:30 -07008394eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8395 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8396{
8397 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8398 tSmeCmd *pCommand = NULL;
8399 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 do
8401 {
8402 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008404 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 status = eHAL_STATUS_CSR_WRONG_STATE;
8406 break;
8407 }
8408 pCommand = csrGetCommandBuffer(pMac);
8409 if(NULL == pCommand)
8410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008411 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 status = eHAL_STATUS_RESOURCES;
8413 break;
8414 }
8415 pCommand->command = eSmeCommandRemoveKey;
8416 pCommand->sessionId = (tANI_U8)sessionId;
8417 pCommand->u.removeKeyCmd.roamId = roamId;
8418 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308419 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8420 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8422 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8423 {
8424 //in this case, put it to the end of the Q incase there is a set key pending.
8425 fImediate = eANI_BOOLEAN_FALSE;
8426 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008427 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008429 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8431 if( !HAL_STATUS_SUCCESS( status ) )
8432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008433 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 break;
8435 }
8436 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8438 {
8439 csrReleaseCommandRemoveKey( pMac, pCommand );
8440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 return (status );
8442}
8443
Jeff Johnson295189b2012-06-20 16:38:30 -07008444eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8445{
8446 eHalStatus status;
8447 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8448 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8449 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8450 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008451#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8452 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8453 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008454 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308456 vos_mem_set(&setKeyEvent,
8457 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8459 {
8460 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8461 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8462 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8463 }
8464 else
8465 {
8466 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8467 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8468 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8469 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308470 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008471 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 {
8473 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 //It has to be static WEP here
8475 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8476 {
8477 setKeyEvent.keyId = (v_U8_t)defKeyId;
8478 }
8479 }
8480 else
8481 {
8482 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8483 }
8484 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8485 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8486 }
8487#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 if( csrIsSetKeyAllowed(pMac, sessionId) )
8489 {
8490 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8491 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8492 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8493 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8494 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8495 pCommand->u.setKeyCmd.keyRsc);
8496 }
8497 else
8498 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008499 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 //Set this status so the error handling take care of the case.
8501 status = eHAL_STATUS_CSR_WRONG_STATE;
8502 }
8503 if( !HAL_STATUS_SUCCESS(status) )
8504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008505 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008507#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008508 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 {
8510 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8511 {
8512 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8513 }
8514 else
8515 {
8516 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8517 }
8518 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8519 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8520 }
8521#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 return ( status );
8524}
8525
Jeff Johnson295189b2012-06-20 16:38:30 -07008526eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8527{
8528 eHalStatus status;
8529 tpSirSmeRemoveKeyReq pMsg = NULL;
8530 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8531 tANI_U8 *p;
8532 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008533#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8535 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308536 vos_mem_set(&removeKeyEvent,
8537 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8539 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8540 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308541 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8543 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8544 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8545#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008546 if( csrIsSetKeyAllowed(pMac, sessionId) )
8547 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308548 pMsg = vos_mem_malloc(wMsgLen);
8549 if ( NULL == pMsg )
8550 status = eHAL_STATUS_FAILURE;
8551 else
8552 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 }
8554 else
8555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008556 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 //Set the error status so error handling kicks in below
8558 status = eHAL_STATUS_CSR_WRONG_STATE;
8559 }
8560 if( HAL_STATUS_SUCCESS( status ) )
8561 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308562 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8564 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 pMsg->sessionId = (tANI_U8)sessionId;
8566 pMsg->transactionId = 0;
8567 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8568 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8569 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308570 vos_mem_copy(p,
8571 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8572 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 p += sizeof(tSirMacAddr);
8574 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308575 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008576 p += sizeof(tSirMacAddr);
8577 // edType
8578 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8579 p++;
8580 // weptype
8581 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8582 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8583 {
8584 *p = (tANI_U8)eSIR_WEP_STATIC;
8585 }
8586 else
8587 {
8588 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8589 }
8590 p++;
8591 //keyid
8592 *p = pCommand->u.removeKeyCmd.keyId;
8593 p++;
8594 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008595 status = palSendMBMessage(pMac->hHdd, pMsg);
8596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 if( !HAL_STATUS_SUCCESS( status ) )
8598 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008599 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008600#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8601 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008602 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8604#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008607 return ( status );
8608}
8609
Jeff Johnson295189b2012-06-20 16:38:30 -07008610eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8611{
8612 eHalStatus status;
8613
8614 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8615 {
8616 status = eHAL_STATUS_CSR_WRONG_STATE;
8617 }
8618 else
8619 {
8620 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 return ( status );
8623}
8624
Jeff Johnson295189b2012-06-20 16:38:30 -07008625/*
8626 Prepare a filter base on a profile for parsing the scan results.
8627 Upon successful return, caller MUST call csrFreeScanFilter on
8628 pScanFilter when it is done with the filter.
8629*/
8630eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8631 tCsrScanResultFilter *pScanFilter)
8632{
8633 eHalStatus status = eHAL_STATUS_SUCCESS;
8634 tANI_U32 size = 0;
8635 tANI_U8 index = 0;
8636
8637 do
8638 {
8639 if(pProfile->BSSIDs.numOfBSSIDs)
8640 {
8641 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308642 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8643 if ( NULL == pScanFilter->BSSIDs.bssid )
8644 status = eHAL_STATUS_FAILURE;
8645 else
8646 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 if(!HAL_STATUS_SUCCESS(status))
8648 {
8649 break;
8650 }
8651 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308652 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 }
8654 if(pProfile->SSIDs.numOfSSIDs)
8655 {
8656 if( !CSR_IS_WDS_STA( pProfile ) )
8657 {
8658 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8659 }
8660 else
8661 {
8662 //For WDS station
8663 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8664 pScanFilter->SSIDs.numOfSSIDs = 1;
8665 }
8666 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308667 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8668 if ( NULL == pScanFilter->SSIDs.SSIDList )
8669 status = eHAL_STATUS_FAILURE;
8670 else
8671 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 if(!HAL_STATUS_SUCCESS(status))
8673 {
8674 break;
8675 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308676 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8677 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 }
8679 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8680 {
8681 pScanFilter->ChannelInfo.numOfChannels = 0;
8682 pScanFilter->ChannelInfo.ChannelList = NULL;
8683 }
8684 else if(pProfile->ChannelInfo.numOfChannels)
8685 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308686 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8687 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8688 pProfile->ChannelInfo.numOfChannels);
8689 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8690 status = eHAL_STATUS_FAILURE;
8691 else
8692 status = eHAL_STATUS_SUCCESS;
8693
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 pScanFilter->ChannelInfo.numOfChannels = 0;
8695 if(HAL_STATUS_SUCCESS(status))
8696 {
8697 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8698 {
8699 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8700 {
8701 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8702 = pProfile->ChannelInfo.ChannelList[index];
8703 pScanFilter->ChannelInfo.numOfChannels++;
8704 }
8705 else
8706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008707 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 }
8710 }
8711 else
8712 {
8713 break;
8714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 }
8716 else
8717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008718 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 status = eHAL_STATUS_FAILURE;
8720 break;
8721 }
8722 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8723 pScanFilter->authType = pProfile->AuthType;
8724 pScanFilter->EncryptionType = pProfile->EncryptionType;
8725 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8726 pScanFilter->BSSType = pProfile->BSSType;
8727 pScanFilter->phyMode = pProfile->phyMode;
8728#ifdef FEATURE_WLAN_WAPI
8729 //check if user asked for WAPI with 11n or auto mode, in that case modify
8730 //the phymode to 11g
8731 if(csrIsProfileWapi(pProfile))
8732 {
8733 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8734 {
8735 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8736 }
8737 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8738 {
8739 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8740 }
8741 if(!pScanFilter->phyMode)
8742 {
8743 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8744 }
8745 }
8746#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 /*Save the WPS info*/
8748 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 if( pProfile->countryCode[0] )
8750 {
8751 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308752 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8753 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 }
8755#ifdef WLAN_FEATURE_VOWIFI_11R
8756 if (pProfile->MDID.mdiePresent)
8757 {
8758 pScanFilter->MDID.mdiePresent = 1;
8759 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8760 }
8761#endif
8762
8763 }while(0);
8764
8765 if(!HAL_STATUS_SUCCESS(status))
8766 {
8767 csrFreeScanFilter(pMac, pScanFilter);
8768 }
8769
8770 return(status);
8771}
8772
Jeff Johnson295189b2012-06-20 16:38:30 -07008773tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8774 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8775{
8776 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8777 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 do
8779 {
8780 // Validate the type is ok...
8781 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8782 pCommand = csrGetCommandBuffer( pMac );
8783 if ( !pCommand )
8784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008785 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 break;
8787 }
8788 //Change the substate in case it is waiting for key
8789 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8790 {
8791 csrRoamStopWaitForKeyTimer( pMac );
8792 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8793 }
8794 pCommand->command = eSmeCommandWmStatusChange;
8795 pCommand->sessionId = (tANI_U8)sessionId;
8796 pCommand->u.wmStatusChangeCmd.Type = Type;
8797 if ( eCsrDisassociated == Type )
8798 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308799 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8800 pSmeRsp,
8801 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 }
8803 else
8804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308805 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8806 pSmeRsp,
8807 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 }
8809 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8810 {
8811 fCommandQueued = eANI_BOOLEAN_TRUE;
8812 }
8813 else
8814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008815 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 csrReleaseCommandWmStatusChange( pMac, pCommand );
8817 }
8818
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8820 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008821 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 return( fCommandQueued );
8823}
8824
Jeff Johnson295189b2012-06-20 16:38:30 -07008825static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8826{
8827 v_S7_t rssi = 0;
8828 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8829 if(pGetRssiReq)
8830 {
8831 if(NULL != pGetRssiReq->pVosContext)
8832 {
8833 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8834 }
8835 else
8836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008837 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 return;
8839 }
8840
8841 if(NULL != pGetRssiReq->rssiCallback)
8842 {
8843 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8844 }
8845 else
8846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008847 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008848 return;
8849 }
8850 }
8851 else
8852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008853 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 }
8855 return;
8856}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308857
8858static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8859{
8860 tANI_S8 snr = 0;
8861 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8862
8863 if (pGetSnrReq)
8864 {
8865 if (VOS_STATUS_SUCCESS !=
8866 WDA_GetSnr(pGetSnrReq->staId, &snr))
8867 {
8868 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8869 return;
8870 }
8871
8872 if (pGetSnrReq->snrCallback)
8873 {
8874 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8875 pGetSnrReq->pDevContext);
8876 }
8877 else
8878 {
8879 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8880 return;
8881 }
8882 }
8883 else
8884 {
8885 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8886 }
8887 return;
8888}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008889#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8890void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8891{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008892 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8893
Jeff Johnson36d483b2013-04-08 11:08:53 -07008894 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008895 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008896 /* Get roam Rssi request is backed up and passed back to the response,
8897 Extract the request message to fetch callback */
8898 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8899 v_S7_t rssi = pRoamRssiRsp->rssi;
8900
8901 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008902 {
8903 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8904 reqBkp->rssiCallback = NULL;
8905 vos_mem_free(reqBkp);
8906 }
8907 else
8908 {
8909 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8910 if (NULL != reqBkp)
8911 {
8912 vos_mem_free(reqBkp);
8913 }
8914 }
8915 }
8916 else
8917 {
8918 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8919 }
8920 return;
8921}
8922#endif
8923
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008924
8925#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8926void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8927{
8928 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
8929
8930 if (NULL != pTsmStatsRsp)
8931 {
8932 /* Get roam Rssi request is backed up and passed back to the response,
8933 Extract the request message to fetch callback */
8934 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
8935
8936 if (NULL != reqBkp)
8937 {
8938 if (NULL != reqBkp->tsmStatsCallback)
8939 {
8940 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
8941 pTsmStatsRsp->staId, reqBkp->pDevContext);
8942 reqBkp->tsmStatsCallback = NULL;
8943 }
8944 vos_mem_free(reqBkp);
8945 }
8946 else
8947 {
8948 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
8949 if (NULL != reqBkp)
8950 {
8951 vos_mem_free(reqBkp);
8952 }
8953 }
8954 }
8955 else
8956 {
8957 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
8958 }
8959 return;
8960}
8961
8962void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
8963{
8964 tANI_U32 roamTS2 = 0;
8965 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008966 tpPESession pSessionEntry = NULL;
8967 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008968
8969 if (NULL == pSession)
8970 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008971 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008972 return;
8973 }
8974
8975 roamTS2 = vos_timer_get_system_time();
8976 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08008977 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
8978 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008979 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008980
Srinivas Girigowda026433f2013-10-28 11:51:55 -07008981 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
8982 if (NULL == pSessionEntry)
8983 {
8984 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
8985 return;
8986 }
8987 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008988 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
8989 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
8990}
8991#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
8992
Jeff Johnsone7245742012-09-05 17:12:55 -07008993static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8994{
8995 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8996 if(pTlRssiInd)
8997 {
8998 if(NULL != pTlRssiInd->tlCallback)
8999 {
9000 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009001 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009002 }
9003 else
9004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009005 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009006 }
9007 }
9008 else
9009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009010 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009011 }
9012 return;
9013}
Jeff Johnson295189b2012-06-20 16:38:30 -07009014
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309015eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9016{
9017 tpSirResetAPCapsChange pMsg;
9018 tANI_U16 len;
9019 eHalStatus status = eHAL_STATUS_SUCCESS;
9020
9021 /* Create the message and send to lim */
9022 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309023 pMsg = vos_mem_malloc(len);
9024 if ( NULL == pMsg )
9025 status = eHAL_STATUS_FAILURE;
9026 else
9027 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309028 if (HAL_STATUS_SUCCESS(status))
9029 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309030 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309031 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9032 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309033 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009034 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9035 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309036 status = palSendMBMessage(pMac->hHdd, pMsg);
9037 }
9038 else
9039 {
9040 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9041 }
9042 return status;
9043}
9044
Jeff Johnson295189b2012-06-20 16:38:30 -07009045void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9046{
9047 tSirSmeAssocInd *pAssocInd;
9048 tSirSmeDisassocInd *pDisassocInd;
9049 tSirSmeDeauthInd *pDeauthInd;
9050 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9051 tSirSmeNewBssInfo *pNewBss;
9052 tSmeIbssPeerInd *pIbssPeerInd;
9053 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9054 tSirSmeApNewCaps *pApNewCaps;
9055 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9056 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9057 tCsrRoamInfo *pRoamInfo = NULL;
9058 tCsrRoamInfo roamInfo;
9059 eHalStatus status;
9060 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9061 tCsrRoamSession *pSession = NULL;
9062 tpSirSmeSwitchChannelInd pSwitchChnInd;
9063 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009064 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 pSirMsg->messageType = (pSirMsg->messageType);
9066 pSirMsg->length = (pSirMsg->length);
9067 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309068 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 switch( pSirMsg->messageType )
9070 {
9071 case eWNI_SME_ASSOC_IND:
9072 {
9073 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009074 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009075 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9076 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9077 if( HAL_STATUS_SUCCESS( status ) )
9078 {
9079 pSession = CSR_GET_SESSION(pMac, sessionId);
9080
Jeff Johnson32d95a32012-09-10 13:15:23 -07009081 if(!pSession)
9082 {
9083 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9084 return;
9085 }
9086
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 pRoamInfo = &roamInfo;
9088
9089 // Required for indicating the frames to upper layer
9090 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9091 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9092
9093 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9094 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9095 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9096 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9097
9098 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9099 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9100 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9101
9102 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9103 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309104 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9105 sizeof(tSirMacAddr));
9106 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9107 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9109 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009110 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9112 {
9113 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9114 {
9115 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9116 pSession->pConnectBssDesc,
9117 &(pRoamInfo->peerMac),
9118 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9119 pRoamInfo->fAuthRequired = FALSE;
9120 }
9121 else
9122 {
9123 pRoamInfo->fAuthRequired = TRUE;
9124 }
9125 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9126 if (!HAL_STATUS_SUCCESS(status))
9127 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 /* Send Association completion message to PE */
9130 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9131
9132 /* send a message to CSR itself just to avoid the EAPOL frames going
9133 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9135 {
9136 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9139 {
9140 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9141 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9142 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009144 }
9145 }
9146 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 // Check if AP dis-associated us because of MIC failure. If so,
9149 // then we need to take action immediately and not wait till the
9150 // the WmStatusChange requests is pushed and processed
9151 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9152 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9153 if( HAL_STATUS_SUCCESS( status ) )
9154 {
Kiet Lam82004c62013-11-11 13:24:28 +05309155 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC for session %d "), sessionId);
9156 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer =" MAC_ADDRESS_STR " "
9157 " reason = %d status = %d "),
9158 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9159 pDisassocInd->reasonCode, pDisassocInd->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 // If we are in neighbor preauth done state then on receiving
9161 // disassoc or deauth we dont roam instead we just disassoc
9162 // from current ap and then go to disconnected state
9163 // This happens for CCX and 11r FT connections ONLY.
9164#ifdef WLAN_FEATURE_VOWIFI_11R
9165 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9166 {
9167 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9168 }
9169#endif
9170#ifdef FEATURE_WLAN_CCX
9171 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9172 {
9173 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9174 }
9175#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009176#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309177 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009178 {
9179 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9180 }
9181#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 pSession = CSR_GET_SESSION( pMac, sessionId );
9183
Jeff Johnson32d95a32012-09-10 13:15:23 -07009184 if(!pSession)
9185 {
9186 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9187 return;
9188 }
9189
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 if ( csrIsConnStateInfra( pMac, sessionId ) )
9191 {
9192 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009194#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9195 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9196#endif
9197 csrRoamLinkDown(pMac, sessionId);
9198 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9200 {
9201
9202 pRoamInfo = &roamInfo;
9203
9204 pRoamInfo->statusCode = pDisassocInd->statusCode;
9205 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9206
9207 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
9208
Kiet Lam64c1b492013-07-12 13:56:44 +05309209 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9210 sizeof(tSirMacAddr));
9211 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9212 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009213
9214 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009215
9216 /*
9217 * STA/P2P client got disassociated so remove any pending deauth
9218 * commands in sme pending list
9219 */
9220 pCommand.command = eSmeCommandRoam;
9221 pCommand.sessionId = (tANI_U8)sessionId;
9222 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Kiet Lam64c1b492013-07-12 13:56:44 +05309223 vos_mem_copy(pCommand.u.roamCmd.peerMac,
9224 pDisassocInd->peerMacAddr,
9225 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009226 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 }
Kiet Lam82004c62013-11-11 13:24:28 +05309229 else
9230 {
9231 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9232 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009236 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9238 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9239 if( HAL_STATUS_SUCCESS( status ) )
9240 {
9241 // If we are in neighbor preauth done state then on receiving
9242 // disassoc or deauth we dont roam instead we just disassoc
9243 // from current ap and then go to disconnected state
9244 // This happens for CCX and 11r FT connections ONLY.
9245#ifdef WLAN_FEATURE_VOWIFI_11R
9246 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9247 {
9248 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9249 }
9250#endif
9251#ifdef FEATURE_WLAN_CCX
9252 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9253 {
9254 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9255 }
9256#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009257#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309258 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009259 {
9260 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9261 }
9262#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009263 pSession = CSR_GET_SESSION( pMac, sessionId );
9264
Jeff Johnson32d95a32012-09-10 13:15:23 -07009265 if(!pSession)
9266 {
9267 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9268 return;
9269 }
9270
Jeff Johnson295189b2012-06-20 16:38:30 -07009271 if ( csrIsConnStateInfra( pMac, sessionId ) )
9272 {
9273 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009275#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9276 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9277#endif
9278 csrRoamLinkDown(pMac, sessionId);
9279 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009280 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9281 {
9282
9283 pRoamInfo = &roamInfo;
9284
9285 pRoamInfo->statusCode = pDeauthInd->statusCode;
9286 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9287
9288 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9289
Kiet Lam64c1b492013-07-12 13:56:44 +05309290 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9291 sizeof(tSirMacAddr));
9292 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9293 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009294
9295 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 }
9298 break;
9299
9300 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 -08009301 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9303 //Update with the new channel id.
9304 //The channel id is hidden in the statusCode.
9305 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9306 if( HAL_STATUS_SUCCESS( status ) )
9307 {
9308 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009309 if(!pSession)
9310 {
9311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9312 return;
9313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9315 if(pSession->pConnectBssDesc)
9316 {
9317 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9318 }
9319 }
9320 break;
9321
9322 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009323 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 {
9325 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9326 sessionId = pDeauthRsp->sessionId;
9327 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9328 {
9329 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009330 if(!pSession)
9331 {
9332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9333 return;
9334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9336 {
9337 pRoamInfo = &roamInfo;
9338 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309339 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9340 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009341 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9342 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9343 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9344 }
9345 }
9346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 break;
9348
9349 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009350 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009351 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 {
9353 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9354 sessionId = pDisassocRsp->sessionId;
9355 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9356 {
9357 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009358 if(!pSession)
9359 {
9360 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9361 return;
9362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9364 {
9365 pRoamInfo = &roamInfo;
9366 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309367 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9368 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9370 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9371 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9372 }
9373 }
9374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009376 case eWNI_SME_MIC_FAILURE_IND:
9377 {
9378 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9379 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9380 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009381
9382 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9383 if( HAL_STATUS_SUCCESS( status ) )
9384 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309385 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009386 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9387 pRoamInfo = &roamInfo;
9388 if(pMicInd->info.multicast)
9389 {
9390 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9391 }
9392 else
9393 {
9394 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9395 }
9396 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9397 }
9398
Jeff Johnson295189b2012-06-20 16:38:30 -07009399#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9400 {
lukez3c809222013-05-03 10:23:02 -07009401 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009403 if(!pSession)
9404 {
9405 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9406 return;
9407 }
lukez3c809222013-05-03 10:23:02 -07009408
Kiet Lam64c1b492013-07-12 13:56:44 +05309409 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9411 secEvent.encryptionModeMulticast =
9412 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9413 secEvent.encryptionModeUnicast =
9414 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9415 secEvent.authMode =
9416 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309417 vos_mem_copy(secEvent.bssid,
9418 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009419 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9420 }
9421#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 }
9423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9425 {
9426 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9427 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009428 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009429
9430 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9431 if( HAL_STATUS_SUCCESS( status ) )
9432 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309433 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9435 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9436 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9437 }
9438 }
9439 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009440
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9442 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9443 switch( pStatusChangeMsg->statusChangeCode )
9444 {
9445 case eSIR_SME_IBSS_ACTIVE:
9446 sessionId = csrFindIbssSession( pMac );
9447 if( CSR_SESSION_ID_INVALID != sessionId )
9448 {
9449 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009450 if(!pSession)
9451 {
9452 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9453 return;
9454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9456 if(pSession->pConnectBssDesc)
9457 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309458 vos_mem_copy(&roamInfo.bssid,
9459 pSession->pConnectBssDesc->bssId,
9460 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9462 pRoamInfo = &roamInfo;
9463 }
9464 else
9465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009466 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 }
9468 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9469 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9470 }
9471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009472 case eSIR_SME_IBSS_INACTIVE:
9473 sessionId = csrFindIbssSession( pMac );
9474 if( CSR_SESSION_ID_INVALID != sessionId )
9475 {
9476 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009477 if(!pSession)
9478 {
9479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9480 return;
9481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9483 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9484 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9485 }
9486 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9488 sessionId = csrFindIbssSession( pMac );
9489 if( CSR_SESSION_ID_INVALID != sessionId )
9490 {
9491 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009492 if(!pSession)
9493 {
9494 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9495 return;
9496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 // update the connection state information
9498 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009499#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9500 {
9501 vos_log_ibss_pkt_type *pIbssLog;
9502 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9504 if(pIbssLog)
9505 {
9506 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9507 if(pNewBss)
9508 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309509 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 if(pNewBss->ssId.length)
9511 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309512 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9513 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 }
9515 pIbssLog->operatingChannel = pNewBss->channelNumber;
9516 }
9517 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9518 {
9519 //***U8 is not enough for beacon interval
9520 pIbssLog->beaconInterval = (v_U8_t)bi;
9521 }
9522 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9523 }
9524 }
9525#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009527
9528 if ((eCSR_ENCRYPT_TYPE_NONE ==
9529 pSession->connectedProfile.EncryptionType ))
9530 {
9531 csrRoamIssueSetContextReq( pMac, sessionId,
9532 pSession->connectedProfile.EncryptionType,
9533 pSession->pConnectBssDesc,
9534 &Broadcastaddr,
9535 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9538 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309539 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9540 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 pRoamInfo = &roamInfo;
9542 //This BSSID is th ereal BSSID, let's save it
9543 if(pSession->pConnectBssDesc)
9544 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309545 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9546 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009549 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 // detection by LIM that the capabilities of the associated AP have changed.
9552 case eSIR_SME_AP_CAPS_CHANGED:
9553 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009554 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9556 if( HAL_STATUS_SUCCESS( status ) )
9557 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009558 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9559 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309560 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009561 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9562 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9563 )
9564 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309565 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9566 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009567 }
9568 else
9569 {
9570 smsLog(pMac, LOGW,
9571 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009572 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009573 pMac->roam.curState[sessionId],
9574 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309575 /* We ignore the caps change event if CSR is not in full connected state.
9576 * Send one event to PE to reset limSentCapsChangeNtf
9577 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9578 * otherwise lim cannot send any CAPS change events to SME */
9579 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009581 }
9582 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309583
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 default:
9585 roamStatus = eCSR_ROAM_FAILED;
9586 result = eCSR_ROAM_RESULT_NONE;
9587 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009588 } // end switch on statusChangeCode
9589 if(eCSR_ROAM_RESULT_NONE != result)
9590 {
9591 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9592 }
9593 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009594 case eWNI_SME_IBSS_NEW_PEER_IND:
9595 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009596#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9597 {
9598 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9600 if(pIbssLog)
9601 {
9602 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309603 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9605 }
9606 }
9607#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009608 sessionId = csrFindIbssSession( pMac );
9609 if( CSR_SESSION_ID_INVALID != sessionId )
9610 {
9611 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009612
9613 if(!pSession)
9614 {
9615 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9616 return;
9617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9619 if(pSession->pConnectBssDesc)
9620 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309621 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9622 sizeof(tCsrBssid));
9623 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9624 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9626 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309627 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9628 - sizeof(tSmeIbssPeerInd)));
9629 if ( NULL == roamInfo.pbFrames )
9630 status = eHAL_STATUS_FAILURE;
9631 else
9632 status = eHAL_STATUS_SUCCESS;
9633 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 {
9635 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309636 vos_mem_copy(roamInfo.pbFrames,
9637 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9638 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 }
9640 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9641 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9642 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309643 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9644 if ( NULL == roamInfo.pBssDesc )
9645 status = eHAL_STATUS_FAILURE;
9646 else
9647 status = eHAL_STATUS_SUCCESS;
9648 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309650 vos_mem_copy(roamInfo.pBssDesc,
9651 pSession->pConnectBssDesc,
9652 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 }
9654 if(HAL_STATUS_SUCCESS(status))
9655 {
9656 pRoamInfo = &roamInfo;
9657 }
9658 else
9659 {
9660 if(roamInfo.pbFrames)
9661 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309662 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 }
9664 if(roamInfo.pBssDesc)
9665 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309666 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }
9668 }
9669 }
9670 else
9671 {
9672 pRoamInfo = &roamInfo;
9673 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009674 if ((eCSR_ENCRYPT_TYPE_NONE ==
9675 pSession->connectedProfile.EncryptionType ))
9676 {
9677 csrRoamIssueSetContextReq( pMac, sessionId,
9678 pSession->connectedProfile.EncryptionType,
9679 pSession->pConnectBssDesc,
9680 &(pIbssPeerInd->peerAddr),
9681 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 }
9684 else
9685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009686 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 }
9688 //send up the sec type for the new peer
9689 if (pRoamInfo)
9690 {
9691 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9692 }
9693 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9694 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9695 if(pRoamInfo)
9696 {
9697 if(roamInfo.pbFrames)
9698 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309699 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 }
9701 if(roamInfo.pBssDesc)
9702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309703 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 }
9705 }
9706 }
9707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9709 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9710 sessionId = csrFindIbssSession( pMac );
9711 if( CSR_SESSION_ID_INVALID != sessionId )
9712 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009713#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9714 {
9715 vos_log_ibss_pkt_type *pIbssLog;
9716
9717 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9718 if(pIbssLog)
9719 {
9720 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9721 if(pIbssPeerInd)
9722 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309723 vos_mem_copy(pIbssLog->peerMacAddr,
9724 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 }
9726 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9727 }
9728 }
9729#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009730 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9732 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9733 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309734 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9735 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9737 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9738 }
9739 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 case eWNI_SME_SETCONTEXT_RSP:
9741 {
9742 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9743 tListElem *pEntry;
9744 tSmeCmd *pCommand;
9745
9746 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9747 if ( pEntry )
9748 {
9749 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9750 if ( eSmeCommandSetKey == pCommand->command )
9751 {
9752 sessionId = pCommand->sessionId;
9753 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009754
9755 if(!pSession)
9756 {
9757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9758 return;
9759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009760
9761#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9762 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9763 {
9764 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309765 vos_mem_set(&setKeyEvent,
9766 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009767 if( pRsp->peerMacAddr[0] & 0x01 )
9768 {
9769 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9770 }
9771 else
9772 {
9773 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9774 }
9775 setKeyEvent.encryptionModeMulticast =
9776 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9777 setKeyEvent.encryptionModeUnicast =
9778 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309779 vos_mem_copy(setKeyEvent.bssid,
9780 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 setKeyEvent.authMode =
9782 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009783 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 {
9785 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9786 }
9787 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9788 }
9789#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9790 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9791 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009792 csrRoamStopWaitForKeyTimer( pMac );
9793
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 //We are done with authentication, whethere succeed or not
9795 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 //We do it here because this linkup function is not called after association
9797 //when a key needs to be set.
9798 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9799 {
9800 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9801 }
9802 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009803 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309805 vos_mem_copy(&roamInfo.peerMac,
9806 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009807 //Make sure we install the GTK before indicating to HDD as authenticated
9808 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309809 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9810 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009811 {
Yathish9f22e662012-12-10 14:21:35 -08009812#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9813 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9814 {
9815 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309816 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009817 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9818 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9819 pMsg->seesionId = sessionId;
9820 status = palSendMBMessage(pMac->hHdd, pMsg );
9821 }
9822#endif
9823 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009824 }
9825 else
9826 {
9827 result = eCSR_ROAM_RESULT_NONE;
9828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 pRoamInfo = &roamInfo;
9830 }
9831 else
9832 {
9833 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009834 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9835 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9836 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 }
9838 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9839 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9841 // can go ahead and initiate the TSPEC if any are pending
9842 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009843#ifdef FEATURE_WLAN_CCX
9844 //Send Adjacent AP repot to new AP.
9845 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9846 pSession->isPrevApInfoValid &&
9847 pSession->connectedProfile.isCCXAssoc)
9848 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009849#ifdef FEATURE_WLAN_CCX_UPLOAD
9850 csrSendCcxAdjacentApRepInd(pMac, pSession);
9851#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009852 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9853#endif
9854 pSession->isPrevApInfoValid = FALSE;
9855 }
9856#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9858 {
9859 csrReleaseCommandSetKey( pMac, pCommand );
9860 }
9861 }
9862 else
9863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009864 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 }
9866 }
9867 else
9868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009869 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009871 smeProcessPendingQueue( pMac );
9872 }
9873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 case eWNI_SME_REMOVEKEY_RSP:
9875 {
9876 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9877 tListElem *pEntry;
9878 tSmeCmd *pCommand;
9879
9880 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9881 if ( pEntry )
9882 {
9883 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9884 if ( eSmeCommandRemoveKey == pCommand->command )
9885 {
9886 sessionId = pCommand->sessionId;
9887 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009888
9889 if(!pSession)
9890 {
9891 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9892 return;
9893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009894#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9895 {
9896 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309897 vos_mem_set(&removeKeyEvent,
9898 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9900 removeKeyEvent.encryptionModeMulticast =
9901 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9902 removeKeyEvent.encryptionModeUnicast =
9903 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309904 vos_mem_copy( removeKeyEvent.bssid,
9905 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 removeKeyEvent.authMode =
9907 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009908 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 {
9910 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9911 }
9912 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9913 }
9914#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009915 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309917 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9918 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 result = eCSR_ROAM_RESULT_NONE;
9920 pRoamInfo = &roamInfo;
9921 }
9922 else
9923 {
9924 result = eCSR_ROAM_RESULT_FAILURE;
9925 }
9926 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9927 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9928 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9929 {
9930 csrReleaseCommandRemoveKey( pMac, pCommand );
9931 }
9932 }
9933 else
9934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009935 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 }
9937 }
9938 else
9939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009940 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 smeProcessPendingQueue( pMac );
9943 }
9944 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009946 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 csrRoamStatsRspProcessor( pMac, pSirMsg );
9948 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009949#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9950 case eWNI_SME_GET_ROAM_RSSI_RSP:
9951 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9952 csrRoamRssiRspProcessor( pMac, pSirMsg );
9953 break;
9954#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009955#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9956 case eWNI_SME_GET_TSM_STATS_RSP:
9957 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
9958 csrTsmStatsRspProcessor( pMac, pSirMsg );
9959 break;
9960#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07009961 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009962 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 csrUpdateRssi( pMac, pSirMsg );
9964 break;
9965
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309966 case eWNI_SME_GET_SNR_REQ:
9967 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9968 csrUpdateSnr(pMac, pSirMsg);
9969 break;
9970
Jeff Johnson295189b2012-06-20 16:38:30 -07009971#ifdef WLAN_FEATURE_VOWIFI_11R
9972 case eWNI_SME_FT_PRE_AUTH_RSP:
9973 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9974 break;
9975#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9977 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009978 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 -07009979 sessionId = pSmeMaxAssocInd->sessionId;
9980 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309981 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
9982 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9984 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9985 break;
9986
9987 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009988 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 btampEstablishLogLinkHdlr( pSirMsg );
9990 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009991 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009992 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009993 csrRoamRssiIndHdlr( pMac, pSirMsg );
9994 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009995#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9996 case eWNI_SME_CANDIDATE_FOUND_IND:
9997 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9998 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9999 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010000 case eWNI_SME_HANDOFF_REQ:
10001 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10002 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10003 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010005
10006 default:
10007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010009}
10010
Jeff Johnson295189b2012-06-20 16:38:30 -070010011void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10012 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10013{
10014 if(pSession)
10015 {
10016 if(pSession->bRefAssocStartCnt)
10017 {
10018 pSession->bRefAssocStartCnt--;
10019 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10020 //Need to call association_completion because there is an assoc_start pending.
10021 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10022 eCSR_ROAM_ASSOCIATION_COMPLETION,
10023 eCSR_ROAM_RESULT_FAILURE);
10024 }
10025 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10026 }
10027 else
10028 {
10029 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10030 }
10031}
10032
10033
10034eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10035{
10036 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10038 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10039 {
10040 status = csrScanRequestLostLink1( pMac, sessionId );
10041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 return(status);
10043}
10044
Jeff Johnson295189b2012-06-20 16:38:30 -070010045//return a boolean to indicate whether roaming completed or continue.
10046tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10047 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10048{
10049 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10050 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10051 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10052 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010053 if(!pSession)
10054 {
10055 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10056 return eANI_BOOLEAN_FALSE;
10057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 //Check whether time is up
10059 if(pSession->fCancelRoaming || fForce ||
10060 ((curTime - pSession->roamingStartTime) > roamTime) ||
10061 eCsrReassocRoaming == pSession->roamingReason ||
10062 eCsrDynamicRoaming == pSession->roamingReason)
10063 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010064 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10066 {
10067 //roaming is cancelled, tell HDD to indicate disconnect
10068 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10069 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10070 //to be eSIR_BEACON_MISSED
10071 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10072 {
10073 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10074 }
10075 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10076 {
10077 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10078 }
10079 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10080 {
10081 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10082 }
10083 else
10084 {
10085 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10086 }
10087 }
10088 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10089 pSession->roamingReason = eCsrNotRoaming;
10090 }
10091 else
10092 {
10093 pSession->roamResult = roamResult;
10094 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10095 {
10096 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10097 pSession->roamingReason = eCsrNotRoaming;
10098 }
10099 else
10100 {
10101 fCompleted = eANI_BOOLEAN_FALSE;
10102 }
10103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 return(fCompleted);
10105}
10106
Jeff Johnson295189b2012-06-20 16:38:30 -070010107void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10108{
10109 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010110
10111 if(!pSession)
10112 {
10113 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10114 return;
10115 }
10116
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 if(CSR_IS_ROAMING(pSession))
10118 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010119 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10121 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10122 {
10123 //No need to do anything in here because the handler takes care of it
10124 }
10125 else
10126 {
10127 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10128 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10129 //Roaming is stopped after here
10130 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10131 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010132 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 csrRoamStopRoamingTimer(pMac, sessionId);
10134 }
10135 }
10136}
10137
Jeff Johnson295189b2012-06-20 16:38:30 -070010138void csrRoamRoamingTimerHandler(void *pv)
10139{
10140 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10141 tpAniSirGlobal pMac = pInfo->pMac;
10142 tANI_U32 sessionId = pInfo->sessionId;
10143 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010144
10145 if(!pSession)
10146 {
10147 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10148 return;
10149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010150
10151 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10152 {
10153 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10154 {
10155 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10156 pSession->roamingReason = eCsrNotRoaming;
10157 }
10158 }
10159}
10160
Jeff Johnson295189b2012-06-20 16:38:30 -070010161eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10162{
10163 eHalStatus status;
10164 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010165
10166 if(!pSession)
10167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010168 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010169 return eHAL_STATUS_FAILURE;
10170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010171
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010172 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010174 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010175
10176 return (status);
10177}
10178
Jeff Johnson295189b2012-06-20 16:38:30 -070010179eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10180{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010181 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010182}
10183
Jeff Johnson295189b2012-06-20 16:38:30 -070010184void csrRoamWaitForKeyTimeOutHandler(void *pv)
10185{
10186 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10187 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010188 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
10189
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010190 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010191 pMac->roam.neighborRoamInfo.neighborRoamState,
10192 pMac->roam.curSubState[pInfo->sessionId]);
10193
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10195 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010196#ifdef FEATURE_WLAN_LFR
10197 if (csrNeighborRoamIsHandoffInProgress(pMac))
10198 {
10199 /*
10200 * Enable heartbeat timer when hand-off is in progress
10201 * and Key Wait timer expired.
10202 */
10203 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010204 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010205 pMac->roam.configParam.HeartbeatThresh24);
10206 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10207 pMac->roam.configParam.HeartbeatThresh24,
10208 NULL, eANI_BOOLEAN_FALSE);
10209 }
10210#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010211 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010212
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010214 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10215 {
10216 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10217 pInfo->sessionId);
10218 }
10219
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010220 if (pSession)
10221 {
10222 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10223 {
10224 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10225 smeProcessPendingQueue(pMac);
10226 }
10227 else
10228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010229 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010230 __func__);
10231 }
10232 }
10233 else
10234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010235 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010237 }
10238
10239}
10240
Jeff Johnson295189b2012-06-20 16:38:30 -070010241eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10242{
10243 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010244#ifdef FEATURE_WLAN_LFR
10245 if (csrNeighborRoamIsHandoffInProgress(pMac))
10246 {
10247 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010248 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010249 __func__,
10250 pMac->roam.neighborRoamInfo.neighborRoamState,
10251 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10252 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10253 }
10254#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010255 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010256 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010257
10258 return (status);
10259}
10260
Jeff Johnson295189b2012-06-20 16:38:30 -070010261eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10262{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010263 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010264 pMac->roam.neighborRoamInfo.neighborRoamState,
10265 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10266#ifdef FEATURE_WLAN_LFR
10267 if (csrNeighborRoamIsHandoffInProgress(pMac))
10268 {
10269 /*
10270 * Enable heartbeat timer when hand-off is in progress
10271 * and Key Wait timer got stopped for some reason
10272 */
10273 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010274 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010275 pMac->roam.configParam.HeartbeatThresh24);
10276 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10277 pMac->roam.configParam.HeartbeatThresh24,
10278 NULL, eANI_BOOLEAN_FALSE);
10279 }
10280#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010281 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010282}
10283
Jeff Johnson295189b2012-06-20 16:38:30 -070010284void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10285 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10286{
10287 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10288 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010289 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10290 /* To silence the KW tool Null chaeck is added */
10291 if(!pSession)
10292 {
10293 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10294 return;
10295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010296
10297 if(pCommand)
10298 {
10299 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10303 {
10304 //if success, force roaming completion
10305 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10306 }
10307 else
10308 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010309 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010310 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10312 }
10313}
10314
Jeff Johnson295189b2012-06-20 16:38:30 -070010315eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10316{
10317 eHalStatus status = eHAL_STATUS_SUCCESS;
10318 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10319 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10320 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10321 tCsrRoamInfo *pRoamInfo = NULL;
10322 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010323 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010325 /* To silence the KW tool Null chaeck is added */
10326 if(!pSession)
10327 {
10328 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10329 return eHAL_STATUS_FAILURE;
10330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010332 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10334 if ( eWNI_SME_DISASSOC_IND == type )
10335 {
10336 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10337 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10338 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010339 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010340 }
10341 else if ( eWNI_SME_DEAUTH_IND == type )
10342 {
10343 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10344 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10345 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010346 /* Convert into proper reason code */
10347 pSession->joinFailStatusCode.reasonCode =
10348 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010349 0 : pDeauthIndMsg->reasonCode;
10350 /* cfg layer expects 0 as reason code if
10351 the driver dosent know the reason code
10352 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 }
10354 else
10355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010356 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010358 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 }
10360
10361 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010362 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010363 {
10364 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10365 }
10366
10367 if ( eWNI_SME_DISASSOC_IND == type )
10368 {
10369 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10370 }
10371 else if ( eWNI_SME_DEAUTH_IND == type )
10372 {
10373 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010375 if(!HAL_STATUS_SUCCESS(status))
10376 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010377 //If fail to send confirmation to PE, not to trigger roaming
10378 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 }
10380
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010381 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010382 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010383 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10384 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 if( eWNI_SME_DISASSOC_IND == type)
10386 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010387 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010388 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10389 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010390 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010392 else if( eWNI_SME_DEAUTH_IND == type )
10393 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010394 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010395 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10396 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010397 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10398 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010399 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010400
10401 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10402 that we are roaming. But if we cannot possibly roam, or if we are unable to
10403 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 if(fToRoam)
10405 {
10406 //Only remove the connected BSS in infrastructure mode
10407 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10408 //Not to do anying for lostlink with WDS
10409 if( pMac->roam.configParam.nRoamingTime )
10410 {
10411 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10412 ( eWNI_SME_DEAUTH_IND == type ) ?
10413 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10414 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010415 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 //For IBSS, we need to give some more info to HDD
10417 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10418 {
10419 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10420 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10421 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10422 }
10423 else
10424 {
10425 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10426 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010427 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10429 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10430 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10431 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10432 }
10433 else
10434 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010435 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 fToRoam = eANI_BOOLEAN_FALSE;
10437 }
10438 }
10439 else
10440 {
10441 //We are told not to roam, indicate lostlink
10442 fToRoam = eANI_BOOLEAN_FALSE;
10443 }
10444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 if(!fToRoam)
10446 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010447 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010448 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010449 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010450 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10451 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10452 * csrRoamCheckForLinkStatusChange API.
10453 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010454 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10455 }
10456
10457 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 Still enable idle scan for polling in case concurrent sessions are running */
10459 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10460 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010461 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 }
10463 }
10464
10465 return (status);
10466}
10467
Jeff Johnson295189b2012-06-20 16:38:30 -070010468eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10469{
10470 eHalStatus status = eHAL_STATUS_SUCCESS;
10471 tListElem *pEntry = NULL;
10472 tSmeCmd *pCommand = NULL;
10473 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010474
10475 if(!pSession)
10476 {
10477 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10478 return eHAL_STATUS_FAILURE;
10479 }
10480
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010482 //Only remove the connected BSS in infrastructure mode
10483 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10484 if(pMac->roam.configParam.nRoamingTime)
10485 {
10486 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10487 {
10488 //before starting the lost link logic release the roam command for handoff
10489 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10490 if(pEntry)
10491 {
10492 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10493 }
10494 if(pCommand)
10495 {
10496 if (( eSmeCommandRoam == pCommand->command ) &&
10497 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10498 {
10499 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10500 {
10501 csrReleaseCommandRoam( pMac, pCommand );
10502 }
10503 }
10504 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010505 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010506 }
10507 }
10508 else
10509 {
10510 //We are told not to roam, indicate lostlink
10511 status = eHAL_STATUS_FAILURE;
10512 }
10513
10514 return (status);
10515}
Jeff Johnson295189b2012-06-20 16:38:30 -070010516void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10517{
10518 tListElem *pEntry;
10519 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10521 if ( pEntry )
10522 {
10523 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10524 if ( eSmeCommandWmStatusChange == pCommand->command )
10525 {
10526 // Nothing to process in a Lost Link completion.... It just kicks off a
10527 // roaming sequence.
10528 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10529 {
10530 csrReleaseCommandWmStatusChange( pMac, pCommand );
10531 }
10532 else
10533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010534 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 }
10536
10537 }
10538 else
10539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010540 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 }
10542 }
10543 else
10544 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010545 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 smeProcessPendingQueue( pMac );
10548}
10549
Jeff Johnson295189b2012-06-20 16:38:30 -070010550void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10551{
10552 eHalStatus status = eHAL_STATUS_FAILURE;
10553 tSirSmeRsp *pSirSmeMsg;
10554 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010555
10556 if(!pSession)
10557 {
10558 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10559 return;
10560 }
10561
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 switch ( pCommand->u.wmStatusChangeCmd.Type )
10563 {
10564 case eCsrDisassociated:
10565 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10566 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 case eCsrDeauthenticated:
10569 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10570 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010573 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 break;
10575 }
10576 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10577 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10578 {
10579 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10580 {
10581 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010582 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 }
10584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10586 // command here since there is nothing else to do.
10587 csrRoamWmStatusChangeComplete( pMac );
10588}
10589
Jeff Johnson295189b2012-06-20 16:38:30 -070010590//This function returns band and mode information.
10591//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10592//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010593static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10594 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010595{
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10597 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10598 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010600
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 //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 -070010602 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10603 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10604 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10605 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 {
10607 switch( pMac->roam.configParam.uCfgDot11Mode )
10608 {
10609 case eCSR_CFG_DOT11_MODE_11A:
10610 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10611 eBand = eCSR_BAND_5G;
10612 break;
10613 case eCSR_CFG_DOT11_MODE_11B:
10614 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10615 eBand = eCSR_BAND_24;
10616 break;
10617 case eCSR_CFG_DOT11_MODE_11G:
10618 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10619 eBand = eCSR_BAND_24;
10620 break;
10621 case eCSR_CFG_DOT11_MODE_11N:
10622 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010623 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10624 break;
10625#ifdef WLAN_FEATURE_11AC
10626 case eCSR_CFG_DOT11_MODE_11AC:
10627 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10628 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010629 /* If the operating channel is in 2.4 GHz band, check for
10630 * INI item to disable VHT operation in 2.4 GHz band
10631 */
10632 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10633 !pMac->roam.configParam.enableVhtFor24GHz)
10634 {
10635 /* Disable 11AC operation */
10636 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10637 }
10638 else
10639 {
10640 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10641 }
10642 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010643 }
10644 else
10645 {
10646 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10647 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10648 }
10649 break;
10650 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10651 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10652 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010653 /* If the operating channel is in 2.4 GHz band, check for
10654 * INI item to disable VHT operation in 2.4 GHz band
10655 */
10656 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10657 !pMac->roam.configParam.enableVhtFor24GHz)
10658 {
10659 /* Disable 11AC operation */
10660 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10661 }
10662 else
10663 {
10664 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10665 }
10666 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010667 }
10668 else
10669 {
10670 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10671 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10672 }
10673 break;
10674#endif
10675 case eCSR_CFG_DOT11_MODE_AUTO:
10676 eBand = pMac->roam.configParam.eBand;
10677 if (eCSR_BAND_24 == eBand)
10678 {
10679 // WiFi tests require IBSS networks to start in 11b mode
10680 // without any change to the default parameter settings
10681 // on the adapter. We use ACU to start an IBSS through
10682 // creation of a startIBSS profile. This startIBSS profile
10683 // has Auto MACProtocol and the adapter property setting
10684 // for dot11Mode is also AUTO. So in this case, let's
10685 // start the IBSS network in 11b mode instead of 11g mode.
10686 // So this is for Auto=profile->MacProtocol && Auto=Global.
10687 // dot11Mode && profile->channel is < 14, then start the IBSS
10688 // in b mode.
10689 //
10690 // Note: we used to have this start as an 11g IBSS for best
10691 // performance... now to specify that the user will have to
10692 // set the do11Mode in the property page to 11g to force it.
10693 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10694 }
10695 else
10696 {
10697#ifdef WLAN_FEATURE_11AC
10698 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10699 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010700 /* If the operating channel is in 2.4 GHz band, check for
10701 * INI item to disable VHT operation in 2.4 GHz band
10702 */
10703 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10704 !pMac->roam.configParam.enableVhtFor24GHz)
10705 {
10706 /* Disable 11AC operation */
10707 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10708 }
10709 else
10710 {
10711 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10712 }
10713 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010714 }
10715 else
10716 {
10717 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10718 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10719 }
10720#else
10721 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10722 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10723#endif
10724 }
10725 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010726 default:
10727 // Global dot11 Mode setting is 11a/b/g.
10728 // use the channel number to determine the Mode setting.
10729 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10730 {
10731 eBand = pMac->roam.configParam.eBand;
10732 if(eCSR_BAND_24 == eBand)
10733 {
10734 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10735 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10736 }
10737 else
10738 {
10739 //prefer 5GHz
10740 eBand = eCSR_BAND_5G;
10741 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10742 }
10743 }
10744 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10745 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010746 // WiFi tests require IBSS networks to start in 11b mode
10747 // without any change to the default parameter settings
10748 // on the adapter. We use ACU to start an IBSS through
10749 // creation of a startIBSS profile. This startIBSS profile
10750 // has Auto MACProtocol and the adapter property setting
10751 // for dot11Mode is also AUTO. So in this case, let's
10752 // start the IBSS network in 11b mode instead of 11g mode.
10753 // So this is for Auto=profile->MacProtocol && Auto=Global.
10754 // dot11Mode && profile->channel is < 14, then start the IBSS
10755 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010757 // Note: we used to have this start as an 11g IBSS for best
10758 // performance... now to specify that the user will have to
10759 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10761 eBand = eCSR_BAND_24;
10762 }
10763 else
10764 {
10765 // else, it's a 5.0GHz channel. Set mode to 11a.
10766 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10767 eBand = eCSR_BAND_5G;
10768 }
10769 break;
10770 }//switch
10771 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10772 else
10773 {
10774 //dot11 mode is set, lets pick the band
10775 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10776 {
10777 // channel is Auto also.
10778 eBand = pMac->roam.configParam.eBand;
10779 if(eCSR_BAND_ALL == eBand)
10780 {
10781 //prefer 5GHz
10782 eBand = eCSR_BAND_5G;
10783 }
10784 }
10785 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10786 {
10787 eBand = eCSR_BAND_24;
10788 }
10789 else
10790 {
10791 eBand = eCSR_BAND_5G;
10792 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010793 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010794 if(pBand)
10795 {
10796 *pBand = eBand;
10797 }
10798
10799 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010800 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10802 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010803
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010804 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10805 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 -070010806 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010807#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010808 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010809#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010810 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10811 {
10812 //We cannot do 11n here
10813 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10814 {
10815 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10816 }
10817 else
10818 {
10819 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10820 }
10821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010822 return( cfgDot11Mode );
10823}
10824
Jeff Johnson295189b2012-06-20 16:38:30 -070010825eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10826{
10827 eHalStatus status;
10828 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010829
10830 if(!pSession)
10831 {
10832 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10833 return eHAL_STATUS_FAILURE;
10834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010835
10836#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10837 {
10838 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10840 if(pIbssLog)
10841 {
10842 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10843 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10844 }
10845 }
10846#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 // Set the roaming substate to 'stop Bss request'...
10848 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10849
10850 // attempt to stop the Bss (reason code is ignored...)
10851 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010852 if(!HAL_STATUS_SUCCESS(status))
10853 {
10854 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10855 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 return (status);
10857}
10858
Jeff Johnson295189b2012-06-20 16:38:30 -070010859//pNumChan is a caller allocated space with the sizeof pChannels
10860eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10861{
10862
10863 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10864 (tANI_U8 *)pChannels,
10865 pNumChan));
10866}
10867
Kiran4a17ebe2013-01-31 10:43:43 -080010868tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10869{
10870 tANI_U32 cfgLength = 0;
10871 tANI_U16 cfgId = 0;
10872 tPowerdBm maxTxPwr = 0;
10873 tANI_U8 *pCountryInfo = NULL;
10874 eHalStatus status;
10875 tANI_U8 count = 0;
10876 tANI_U8 firstChannel;
10877 tANI_U8 maxChannels;
10878
10879 if (CSR_IS_CHANNEL_5GHZ(channel))
10880 {
10881 cfgId = WNI_CFG_MAX_TX_POWER_5;
10882 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10883 }
10884 else if (CSR_IS_CHANNEL_24GHZ(channel))
10885 {
10886 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10887 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10888 }
10889 else
10890 return maxTxPwr;
10891
Kiet Lam64c1b492013-07-12 13:56:44 +053010892 pCountryInfo = vos_mem_malloc(cfgLength);
10893 if ( NULL == pCountryInfo )
10894 status = eHAL_STATUS_FAILURE;
10895 else
10896 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010897 if (status != eHAL_STATUS_SUCCESS)
10898 {
10899 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010900 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010901 __FUNCTION__, status);
10902 goto error;
10903 }
10904 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10905 if (status != eHAL_STATUS_SUCCESS)
10906 {
10907 goto error;
10908 }
10909 /* Identify the channel and maxtxpower */
10910 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10911 {
10912 firstChannel = pCountryInfo[count++];
10913 maxChannels = pCountryInfo[count++];
10914 maxTxPwr = pCountryInfo[count++];
10915
10916 if ((channel >= firstChannel) &&
10917 (channel < (firstChannel + maxChannels)))
10918 {
10919 break;
10920 }
10921 }
10922
10923error:
10924 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010925 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010926
10927 return maxTxPwr;
10928}
10929
10930
Jeff Johnson295189b2012-06-20 16:38:30 -070010931tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10932{
10933 tANI_BOOLEAN fValid = FALSE;
10934 tANI_U32 idxValidChannels;
10935 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10936
10937 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10938 {
10939 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10940 {
10941 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10942 {
10943 fValid = TRUE;
10944 break;
10945 }
10946 }
10947 }
10948 pMac->roam.numValidChannels = len;
10949 return fValid;
10950}
10951
Jeff Johnson295189b2012-06-20 16:38:30 -070010952tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10953{
10954 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10955 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010956 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10957 {
10958 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10959 {
10960 fValid = eANI_BOOLEAN_TRUE;
10961 break;
10962 }
10963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 return (fValid);
10965}
10966
Jeff Johnson295189b2012-06-20 16:38:30 -070010967//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010968 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010969{
Jeff Johnsone7245742012-09-05 17:12:55 -070010970 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010971 tANI_U8 centerChn;
10972 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010973 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10974 {
10975 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10976 }
10977 else
10978 {
10979 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10980 }
10981 //Figure what the other side's CB mode
10982 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10983 {
10984 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10985 {
10986 if(pIes->HTInfo.present)
10987 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010988 /* This is called during INFRA STA/CLIENT and should use the merged value of
10989 * supported channel width and recommended tx width as per standard
10990 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010991 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010992 pIes->HTCaps.supportedChannelWidthSet,
10993 pIes->HTInfo.recommendedTxWidthSet,
10994 pIes->HTInfo.secondaryChannelOffset);
10995
10996 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10997 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010999 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11000 switch (eRet) {
11001 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11002 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11003 break;
11004 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11005 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11006 break;
11007 case PHY_SINGLE_CHANNEL_CENTERED:
11008 default:
11009 centerChn = primaryChn;
11010 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011011 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011012 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011014 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011015 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011016 }
11017 }
11018 }
11019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 return eRet;
11021}
Jeff Johnson295189b2012-06-20 16:38:30 -070011022tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11023{
11024 tANI_BOOLEAN fFound = FALSE;
11025 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11027 {
11028 if( pCipherList->encryptionType[idx] == encryptionType )
11029 {
11030 fFound = TRUE;
11031 break;
11032 }
11033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 return fFound;
11035}
Jeff Johnson295189b2012-06-20 16:38:30 -070011036tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11037{
11038 tANI_BOOLEAN fFound = FALSE;
11039 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011040 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11041 {
11042 if( pAuthList->authType[idx] == authType )
11043 {
11044 fFound = TRUE;
11045 break;
11046 }
11047 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011048 return fFound;
11049}
Jeff Johnson295189b2012-06-20 16:38:30 -070011050tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11051{
11052 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11053 tCsrScanResultFilter *pScanFilter = NULL;
11054 eHalStatus status = eHAL_STATUS_SUCCESS;
11055
11056 if(pProfile1 && pProfile2)
11057 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011058 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11059 if ( NULL == pScanFilter )
11060 status = eHAL_STATUS_FAILURE;
11061 else
11062 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 if(HAL_STATUS_SUCCESS(status))
11064 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011065 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11067 if(HAL_STATUS_SUCCESS(status))
11068 {
11069 fCheck = eANI_BOOLEAN_FALSE;
11070 do
11071 {
11072 tANI_U32 i;
11073 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11074 {
11075 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11076 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11077 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11078 if ( fCheck ) break;
11079 }
11080 if(!fCheck)
11081 {
11082 break;
11083 }
11084 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11085 || pProfile2->BSSType != pProfile1->BSSType
11086 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11087 )
11088 {
11089 fCheck = eANI_BOOLEAN_FALSE;
11090 break;
11091 }
11092#ifdef WLAN_FEATURE_VOWIFI_11R
11093 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11094 {
11095 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11096 {
11097 fCheck = eANI_BOOLEAN_FALSE;
11098 break;
11099 }
11100 }
11101#endif
11102 //Match found
11103 fCheck = eANI_BOOLEAN_TRUE;
11104 }while(0);
11105 csrFreeScanFilter(pMac, pScanFilter);
11106 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011107 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 }
11109 }
11110
11111 return (fCheck);
11112}
11113
Jeff Johnson295189b2012-06-20 16:38:30 -070011114tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11115{
11116 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11117 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 do
11119 {
11120 //Only check for static WEP
11121 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11122 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11123 {
11124 fCheck = eANI_BOOLEAN_TRUE;
11125 break;
11126 }
11127 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11128 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11129 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11130 {
11131 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011132 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11133 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 {
11135 break;
11136 }
11137 }
11138 if( i == CSR_MAX_NUM_KEY)
11139 {
11140 fCheck = eANI_BOOLEAN_TRUE;
11141 }
11142 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 return (fCheck);
11144}
11145
Jeff Johnson295189b2012-06-20 16:38:30 -070011146//IBSS
11147
Jeff Johnson295189b2012-06-20 16:38:30 -070011148tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11149{
11150 tANI_U8 channel = 0;
11151 tANI_U32 idx;
11152 tANI_U32 idxValidChannels;
11153 tANI_BOOLEAN fFound = FALSE;
11154 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11155
11156 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11157 {
11158 channel = pMac->roam.configParam.AdHocChannel5G;
11159 if(!csrRoamIsChannelValid(pMac, channel))
11160 {
11161 channel = 0;
11162 }
11163 }
11164 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11165 {
11166 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11167 {
11168 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11169 {
11170 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11171 {
11172 fFound = TRUE;
11173 channel = csrStartIbssChannels50[ idx ];
11174 }
11175 }
11176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11178 if (!fFound)
11179 {
11180 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11181 {
11182 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11183 {
11184 channel = csrStartIbssChannels50[ idx ];
11185 break;
11186 }
11187 }
11188 }
11189 }//if
11190
11191 return( channel );
11192}
11193
Jeff Johnson295189b2012-06-20 16:38:30 -070011194tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11195{
11196 tANI_U8 channel = 1;
11197 tANI_U32 idx;
11198 tANI_U32 idxValidChannels;
11199 tANI_BOOLEAN fFound = FALSE;
11200 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11201
11202 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11203 {
11204 channel = pMac->roam.configParam.AdHocChannel24;
11205 if(!csrRoamIsChannelValid(pMac, channel))
11206 {
11207 channel = 0;
11208 }
11209 }
11210
11211 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11212 {
11213 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11214 {
11215 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11216 {
11217 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11218 {
11219 fFound = TRUE;
11220 channel = csrStartIbssChannels24[ idx ];
11221 }
11222 }
11223 }
11224 }
11225
11226 return( channel );
11227}
11228
Jeff Johnson295189b2012-06-20 16:38:30 -070011229static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11230 tCsrRoamStartBssParams *pParam )
11231{
11232 eCsrCfgDot11Mode cfgDot11Mode;
11233 eCsrBand eBand;
11234 tANI_U8 channel = 0;
11235 tSirNwType nwType;
11236 tANI_U8 operationChannel = 0;
11237
11238 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11239 {
11240 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11241 }
11242
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011244
Jeff Johnson295189b2012-06-20 16:38:30 -070011245 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11246 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11247 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11248 )
11249 {
11250 /* This should never happen */
11251 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011252 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011253 pProfile->csrPersona);
11254 VOS_ASSERT(0);
11255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011256 switch( cfgDot11Mode )
11257 {
11258 case eCSR_CFG_DOT11_MODE_11G:
11259 nwType = eSIR_11G_NW_TYPE;
11260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 case eCSR_CFG_DOT11_MODE_11B:
11262 nwType = eSIR_11B_NW_TYPE;
11263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011264 case eCSR_CFG_DOT11_MODE_11A:
11265 nwType = eSIR_11A_NW_TYPE;
11266 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011267 default:
11268 case eCSR_CFG_DOT11_MODE_11N:
11269 case eCSR_CFG_DOT11_MODE_TAURUS:
11270 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11271 if(eCSR_BAND_24 == eBand)
11272 {
11273 nwType = eSIR_11G_NW_TYPE;
11274 }
11275 else
11276 {
11277 nwType = eSIR_11A_NW_TYPE;
11278 }
11279 break;
11280 }
11281
11282 pParam->extendedRateSet.numRates = 0;
11283
11284 switch ( nwType )
11285 {
11286 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011287 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011288 case eSIR_11A_NW_TYPE:
11289
11290 pParam->operationalRateSet.numRates = 8;
11291
11292 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11293 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11294 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11295 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11296 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11297 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11298 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11299 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11300
11301 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11302 {
11303 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11304 if( 0 == channel &&
11305 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11306 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11307 )
11308 {
11309 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11310 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11311 nwType = eSIR_11B_NW_TYPE;
11312 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11313 pParam->operationalRateSet.numRates = 4;
11314 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11315 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11316 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11317 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11318 }
11319 }
11320 else
11321 {
11322 channel = operationChannel;
11323 }
11324 break;
11325
11326 case eSIR_11B_NW_TYPE:
11327 pParam->operationalRateSet.numRates = 4;
11328 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11329 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11330 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11331 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11333 {
11334 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11335 }
11336 else
11337 {
11338 channel = operationChannel;
11339 }
11340
11341 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 /* For P2P Client and P2P GO, disable 11b rates */
11344 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11345 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11346 )
11347 {
11348 pParam->operationalRateSet.numRates = 8;
11349
11350 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11351 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11352 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11353 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11354 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11355 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11356 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11357 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11358 }
11359 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 {
11361 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11363 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11364 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11365 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11366
11367 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11369 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11370 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11371 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11372 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11373 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11374 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11375 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11376 }
11377
11378 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11379 {
11380 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11381 }
11382 else
11383 {
11384 channel = operationChannel;
11385 }
11386
11387 break;
11388 }
11389 pParam->operationChn = channel;
11390 pParam->sirNwType = nwType;
11391}
11392
Jeff Johnson295189b2012-06-20 16:38:30 -070011393static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11394 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11395{
11396
11397 if( pParam )
11398 {
11399 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011400 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011401 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011402 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011403
11404 if( pIes )
11405 {
11406 if(pIes->SuppRates.present)
11407 {
11408 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11409 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011411 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 -070011412 pIes->SuppRates.num_rates);
11413 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11414 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011415 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11416 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011418 if (pIes->ExtSuppRates.present)
11419 {
11420 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11421 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11422 {
11423 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11424 SIR_MAC_RATESET_EID_MAX, resetting to \
11425 SIR_MAC_RATESET_EID_MAX"),
11426 pIes->ExtSuppRates.num_rates);
11427 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11428 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011429 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011430 pIes->ExtSuppRates.rates,
11431 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 if( pIes->SSID.present )
11434 {
11435 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011436 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11437 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 }
11439 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011440 }
11441 else
11442 {
11443 pParam->ssId.length = 0;
11444 pParam->operationalRateSet.numRates = 0;
11445 }
11446 }
11447}
11448
Jeff Johnson295189b2012-06-20 16:38:30 -070011449static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11450{
11451 tANI_U8 MaxRate = 0;
11452 tANI_U32 i;
11453 tANI_U8 *pRate;
11454
11455 pRate = pSirRateSet->rate;
11456 for ( i = 0; i < pSirRateSet->numRates; i++ )
11457 {
11458 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11459 }
11460
11461 // Save the max rate in the connected state information...
11462
11463 // modify LastRates variable as well
11464
11465 return;
11466}
11467
Jeff Johnson295189b2012-06-20 16:38:30 -070011468eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11469 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11470{
11471 eHalStatus status = eHAL_STATUS_SUCCESS;
11472 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 // Set the roaming substate to 'Start BSS attempt'...
11474 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011475#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11476 //Need to figure out whether we need to log WDS???
11477 if( CSR_IS_IBSS( pProfile ) )
11478 {
11479 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11481 if(pIbssLog)
11482 {
11483 if(pBssDesc)
11484 {
11485 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011486 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 }
11488 else
11489 {
11490 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11491 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011492 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 if(pProfile->ChannelInfo.numOfChannels == 0)
11494 {
11495 pIbssLog->channelSetting = AUTO_PICK;
11496 }
11497 else
11498 {
11499 pIbssLog->channelSetting = SPECIFIED;
11500 }
11501 pIbssLog->operatingChannel = pParam->operationChn;
11502 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11503 }
11504 }
11505#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11506 //Put RSN information in for Starting BSS
11507 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11508 pParam->pRSNIE = pProfile->pRSNReqIE;
11509
Jeff Johnson295189b2012-06-20 16:38:30 -070011510 pParam->privacy = pProfile->privacy;
11511 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11512 pParam->authType = pProfile->csr80211AuthType;
11513 pParam->beaconInterval = pProfile->beaconInterval;
11514 pParam->dtimPeriod = pProfile->dtimPeriod;
11515 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11516 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11517 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11518 {
11519 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11520 {
11521 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11522 }
11523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 pParam->protEnabled = pProfile->protEnabled;
11525 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11526 pParam->ht_protection = pProfile->cfg_protection;
11527 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011528
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11530 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011531 pParam->bssPersona = pProfile->csrPersona;
11532 // When starting an IBSS, start on the channel from the Profile.
11533 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 return (status);
11535}
11536
Jeff Johnson295189b2012-06-20 16:38:30 -070011537static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011538 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011539{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011540 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011541 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011543
11544 if(!pSession)
11545 {
11546 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11547 return;
11548 }
11549
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 if( pBssDesc )
11551 {
11552 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11553 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11554 //The following code has to be do after that.
11555 //For WDS station, use selfMac as the self BSSID
11556 if( CSR_IS_WDS_STA( pProfile ) )
11557 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011558 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11559 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 }
11561 }
11562 else
11563 {
11564 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 //Use the first SSID
11566 if(pProfile->SSIDs.numOfSSIDs)
11567 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011568 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11569 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 }
11571 //For WDS station, use selfMac as the self BSSID
11572 if( CSR_IS_WDS_STA( pProfile ) )
11573 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011574 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11575 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 }
11577 //Use the first BSSID
11578 else if( pProfile->BSSIDs.numOfBSSIDs )
11579 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011580 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11581 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 }
11583 else
11584 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011585 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011586 }
11587 }
11588 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 //Set operating channel in pProfile which will be used
11590 //in csrRoamSetBssConfigCfg() to determine channel bonding
11591 //mode and will be configured in CFG later
11592 pProfile->operationChannel = Channel;
11593
11594 if(Channel == 0)
11595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011596 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011597 }
11598 else
11599 {
11600
11601 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011602 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011603 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011604 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011605 {
11606 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11607 }
11608 else
11609 {
11610 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11611 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011612 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011613 pBssConfig->cbMode = cbMode;
11614 pSession->bssParams.cbMode = cbMode;
11615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 }
11617}
11618
Jeff Johnson295189b2012-06-20 16:38:30 -070011619static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11620 tANI_BOOLEAN *pfSameIbss )
11621{
11622 eHalStatus status = eHAL_STATUS_SUCCESS;
11623 tANI_BOOLEAN fSameIbss = FALSE;
11624
11625 if ( csrIsConnStateIbss( pMac, sessionId ) )
11626 {
11627 // Check if any profile parameter has changed ? If any profile parameter
11628 // has changed then stop old BSS and start a new one with new parameters
11629 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11630 {
11631 fSameIbss = TRUE;
11632 }
11633 else
11634 {
11635 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11636 }
11637 }
11638 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11639 {
11640 // Disassociate from the connected Infrastructure network...
11641 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11642 }
11643 else
11644 {
11645 tBssConfigParam *pBssConfig;
11646
Kiet Lam64c1b492013-07-12 13:56:44 +053011647 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11648 if ( NULL == pBssConfig )
11649 status = eHAL_STATUS_FAILURE;
11650 else
11651 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 if(HAL_STATUS_SUCCESS(status))
11653 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011654 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011655 // there is no Bss description before we start an IBSS so we need to adopt
11656 // all Bss configuration parameters from the Profile.
11657 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11658 if(HAL_STATUS_SUCCESS(status))
11659 {
11660 //save dotMode
11661 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11662 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011663 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011664 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11665 NULL, pBssConfig,
11666 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011667 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011668
11669 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 }//Allocate memory
11671 }
11672
11673 if(pfSameIbss)
11674 {
11675 *pfSameIbss = fSameIbss;
11676 }
11677 return( status );
11678}
11679
Jeff Johnson295189b2012-06-20 16:38:30 -070011680static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11681 tSirSmeNewBssInfo *pNewBss )
11682{
11683 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011684
11685 if(!pSession)
11686 {
11687 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11688 return;
11689 }
11690
Jeff Johnson295189b2012-06-20 16:38:30 -070011691 if( pNewBss )
11692 {
11693 // Set the operating channel.
11694 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11695 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011696 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11697 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 return;
11700}
11701
Jeff Johnson295189b2012-06-20 16:38:30 -070011702#ifdef FEATURE_WLAN_WAPI
11703eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11704 tANI_U32 numItems )
11705{
11706 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11707 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011710 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011711 return status;
11712 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011713 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011714 pSession = CSR_GET_SESSION( pMac, sessionId );
11715 if(numItems <= CSR_MAX_BKID_ALLOWED)
11716 {
11717 status = eHAL_STATUS_SUCCESS;
11718 //numItems may be 0 to clear the cache
11719 pSession->NumBkidCache = (tANI_U16)numItems;
11720 if(numItems && pBKIDCache)
11721 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011722 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11723 sizeof(tBkidCacheInfo) * numItems);
11724 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011725 }
11726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 return (status);
11728}
Jeff Johnson295189b2012-06-20 16:38:30 -070011729eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11730 tBkidCacheInfo *pBkidCache)
11731{
11732 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11733 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011736 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 return status;
11738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011739 pSession = CSR_GET_SESSION( pMac, sessionId );
11740 if(pNum && pBkidCache)
11741 {
11742 if(pSession->NumBkidCache == 0)
11743 {
11744 *pNum = 0;
11745 status = eHAL_STATUS_SUCCESS;
11746 }
11747 else if(*pNum >= pSession->NumBkidCache)
11748 {
11749 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11750 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011751 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 -070011752 pSession->NumBkidCache);
11753 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11754 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011755 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11756 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 *pNum = pSession->NumBkidCache;
11758 status = eHAL_STATUS_SUCCESS;
11759 }
11760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011761 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011762}
Jeff Johnson295189b2012-06-20 16:38:30 -070011763tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11764{
11765 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011766}
11767#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011768eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11769 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11770{
11771 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11772 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011773
11774 if(!pSession)
11775 {
11776 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11777 return eHAL_STATUS_FAILURE;
11778 }
11779
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011780 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11782 {
11783#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11784 {
11785 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011786 vos_mem_set(&secEvent,
11787 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11789 secEvent.encryptionModeMulticast =
11790 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11791 secEvent.encryptionModeUnicast =
11792 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011793 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 secEvent.authMode =
11795 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11796 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11797 }
11798#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 status = eHAL_STATUS_SUCCESS;
11800 //numItems may be 0 to clear the cache
11801 pSession->NumPmkidCache = (tANI_U16)numItems;
11802 if(numItems && pPMKIDCache)
11803 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011804 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11805 sizeof(tPmkidCacheInfo) * numItems);
11806 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 }
11808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 return (status);
11810}
11811
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011812eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11813 tANI_U8 *pBSSId )
11814{
11815 eHalStatus status = eHAL_STATUS_FAILURE;
11816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11817 tANI_BOOLEAN fMatchFound = FALSE;
11818 tANI_U32 Index;
11819 if(!pSession)
11820 {
11821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11822 return eHAL_STATUS_FAILURE;
11823 }
11824 do
11825 {
11826 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11827 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011828 smsLog(pMac, LOGW, "Delete PMKID for "
11829 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053011830 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011831 {
11832 fMatchFound = TRUE;
11833 break;
11834 }
11835 }
11836 if( !fMatchFound ) break;
Kiet Lamf2f201e2013-11-16 21:24:16 +053011837 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011838 status = eHAL_STATUS_SUCCESS;
11839 }
11840 while( 0 );
11841 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11842 fMatchFound, status);
11843 return status;
11844}
Jeff Johnson295189b2012-06-20 16:38:30 -070011845tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11846{
11847 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11848}
11849
Jeff Johnson295189b2012-06-20 16:38:30 -070011850eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11851{
11852 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11853 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011854
11855 if(!pSession)
11856 {
11857 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11858 return eHAL_STATUS_FAILURE;
11859 }
11860
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 if(pNum && pPmkidCache)
11862 {
11863 if(pSession->NumPmkidCache == 0)
11864 {
11865 *pNum = 0;
11866 status = eHAL_STATUS_SUCCESS;
11867 }
11868 else if(*pNum >= pSession->NumPmkidCache)
11869 {
11870 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011872 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 -070011873 pSession->NumPmkidCache);
11874 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11875 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011876 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11877 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 *pNum = pSession->NumPmkidCache;
11879 status = eHAL_STATUS_SUCCESS;
11880 }
11881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 return (status);
11883}
11884
Jeff Johnson295189b2012-06-20 16:38:30 -070011885eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11886{
11887 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11888 tANI_U32 len;
11889 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011890
11891 if(!pSession)
11892 {
11893 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11894 return eHAL_STATUS_FAILURE;
11895 }
11896
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 if(pLen)
11898 {
11899 len = *pLen;
11900 *pLen = pSession->nWpaRsnReqIeLength;
11901 if(pBuf)
11902 {
11903 if(len >= pSession->nWpaRsnReqIeLength)
11904 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011905 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11906 pSession->nWpaRsnReqIeLength);
11907 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011908 }
11909 }
11910 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 return (status);
11912}
11913
Jeff Johnson295189b2012-06-20 16:38:30 -070011914eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11915{
11916 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11917 tANI_U32 len;
11918 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011919
11920 if(!pSession)
11921 {
11922 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11923 return eHAL_STATUS_FAILURE;
11924 }
11925
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 if(pLen)
11927 {
11928 len = *pLen;
11929 *pLen = pSession->nWpaRsnRspIeLength;
11930 if(pBuf)
11931 {
11932 if(len >= pSession->nWpaRsnRspIeLength)
11933 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011934 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11935 pSession->nWpaRsnRspIeLength);
11936 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011937 }
11938 }
11939 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 return (status);
11941}
Jeff Johnson295189b2012-06-20 16:38:30 -070011942#ifdef FEATURE_WLAN_WAPI
11943eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11944{
11945 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11946 tANI_U32 len;
11947 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011948
11949 if(!pSession)
11950 {
11951 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11952 return eHAL_STATUS_FAILURE;
11953 }
11954
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 if(pLen)
11956 {
11957 len = *pLen;
11958 *pLen = pSession->nWapiReqIeLength;
11959 if(pBuf)
11960 {
11961 if(len >= pSession->nWapiReqIeLength)
11962 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011963 vos_mem_copy(pBuf, pSession->pWapiReqIE,
11964 pSession->nWapiReqIeLength);
11965 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 }
11967 }
11968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011969 return (status);
11970}
Jeff Johnson295189b2012-06-20 16:38:30 -070011971eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11972{
11973 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11974 tANI_U32 len;
11975 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011976
11977 if(!pSession)
11978 {
11979 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11980 return eHAL_STATUS_FAILURE;
11981 }
11982
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 if(pLen)
11984 {
11985 len = *pLen;
11986 *pLen = pSession->nWapiRspIeLength;
11987 if(pBuf)
11988 {
11989 if(len >= pSession->nWapiRspIeLength)
11990 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011991 vos_mem_copy(pBuf, pSession->pWapiRspIE,
11992 pSession->nWapiRspIeLength);
11993 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 }
11995 }
11996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 return (status);
11998}
11999#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012000eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12001{
12002 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12003 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012004
12005 if(!pSession)
12006 {
12007 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12008 return (retStatus);
12009 }
12010
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 if(CSR_IS_ROAMING(pSession))
12012 {
12013 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12014 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012016 return (retStatus);
12017}
12018
Jeff Johnson295189b2012-06-20 16:38:30 -070012019//This function remove the connected BSS from te cached scan result
12020eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12021 tCsrRoamConnectedProfile *pConnProfile)
12022{
12023 eHalStatus status = eHAL_STATUS_FAILURE;
12024 tCsrScanResultFilter *pScanFilter = NULL;
12025 tListElem *pEntry;
12026 tCsrScanResult *pResult;
12027 tDot11fBeaconIEs *pIes;
12028 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12030 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12031 {
12032 do
12033 {
12034 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012035 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12036 if ( NULL == pScanFilter )
12037 status = eHAL_STATUS_FAILURE;
12038 else
12039 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012041 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12042 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12043 if ( NULL == pScanFilter->BSSIDs.bssid )
12044 status = eHAL_STATUS_FAILURE;
12045 else
12046 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012048 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12049 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12051 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012053 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12054 if ( NULL == pScanFilter->SSIDs.SSIDList )
12055 status = eHAL_STATUS_FAILURE;
12056 else
12057 status = eHAL_STATUS_SUCCESS;
12058 if (!HAL_STATUS_SUCCESS(status)) break;
12059 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12060 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 }
12062 pScanFilter->authType.numEntries = 1;
12063 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12064 pScanFilter->BSSType = pConnProfile->BSSType;
12065 pScanFilter->EncryptionType.numEntries = 1;
12066 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12067 pScanFilter->mcEncryptionType.numEntries = 1;
12068 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12069 //We ignore the channel for now, BSSID should be enough
12070 pScanFilter->ChannelInfo.numOfChannels = 0;
12071 //Also ignore the following fields
12072 pScanFilter->uapsd_mask = 0;
12073 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12074 pScanFilter->countryCode[0] = 0;
12075 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 csrLLLock(&pMac->scan.scanResultList);
12077 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12078 while( pEntry )
12079 {
12080 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12081 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12082 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12083 pScanFilter, NULL, NULL, NULL, &pIes);
12084 //Release the IEs allocated by csrMatchBSS is needed
12085 if( !pResult->Result.pvIes )
12086 {
12087 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012088 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 }
12090 if(fMatch)
12091 {
12092 //We found the one
12093 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12094 {
12095 //Free the memory
12096 csrFreeScanResultEntry( pMac, pResult );
12097 }
12098 break;
12099 }
12100 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12101 }//while
12102 csrLLUnlock(&pMac->scan.scanResultList);
12103 }while(0);
12104 if(pScanFilter)
12105 {
12106 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012107 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012108 }
12109 }
12110 return (status);
12111}
12112
Jeff Johnson295189b2012-06-20 16:38:30 -070012113//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012114eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12115{
12116 eHalStatus status = eHAL_STATUS_SUCCESS;
12117 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12119 {
12120 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12121 {
12122 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12123 {
12124 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012125 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 status = eHAL_STATUS_CSR_WRONG_STATE;
12127 break;
12128 }
12129 if( csrIsConnStateInfra( pMac, sessionId ) )
12130 {
12131 if( chnId &&
12132 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012134 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12136 status = eHAL_STATUS_CSR_WRONG_STATE;
12137 break;
12138 }
12139 }
12140 }
12141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 return ( status );
12143}
12144
Jeff Johnson295189b2012-06-20 16:38:30 -070012145static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12146{
12147 eHalStatus status = eHAL_STATUS_SUCCESS;
12148 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12149 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012150
12151 if(!pSession)
12152 {
12153 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12154 return eHAL_STATUS_FAILURE;
12155 }
12156
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 if ( csrIsConnStateIbss( pMac, sessionId ) )
12158 {
12159 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12160 }
12161 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12162 {
12163 // Disassociate from the connected Infrastructure network...
12164 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12165 }
12166 else
12167 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12169 //Otherwise we need to add code to handle the
12170 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12171 //send stop_bss to PE, before we can continue.
12172 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012173 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012175 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12176 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 // there is no Bss description before we start an WDS so we need
12178 // to adopt all Bss configuration parameters from the Profile.
12179 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12180 if(HAL_STATUS_SUCCESS(status))
12181 {
12182 //Save profile for late use
12183 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012184 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12185 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012187 vos_mem_set(pSession->pCurRoamProfile,
12188 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012192 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012193 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12194 NULL, &bssConfig,
12195 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 }
12197 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012198
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 return( status );
12200}
12201
Jeff Johnson295189b2012-06-20 16:38:30 -070012202////////////////////Mail box
12203
Jeff Johnson295189b2012-06-20 16:38:30 -070012204//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12205//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012206static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12207 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12209{
12210 tCsrChannelSet channelGroup;
12211 tSirMacCapabilityInfo *pAP_capabilityInfo;
12212 tAniBool fTmp;
12213 tANI_BOOLEAN found = FALSE;
12214 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012215 tANI_S8 pwrLimit = 0;
12216 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12218 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12219 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12220 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012221 // 802.11h
12222 //We can do this because it is in HOST CPU order for now.
12223 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012224 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12225 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12226 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012227 fTmp = (tAniBool)pal_cpu_to_be32(1);
12228 }
12229 else
12230 fTmp = (tAniBool)0;
12231
12232 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012233 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 pBuf += sizeof(tAniBool);
12235 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012236 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012237 // This is required for 11k test VoWiFi Ent: Test 2.
12238 // We need the power capabilities for Assoc Req.
12239 // This macro is provided by the halPhyCfg.h. We pick our
12240 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012241 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12242 if (0 != pwrLimit)
12243 {
12244 *pBuf++ = pwrLimit;
12245 }
12246 else
12247 {
12248 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 size = sizeof(pMac->roam.validChannelList);
12251 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12252 {
12253 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12254 for ( i = 0; i < size; i++)
12255 {
12256 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12257
12258 }
12259 }
12260 else
12261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012262 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012263 *pBuf++ = 0; //tSirSupChnl->numChnl
12264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012265 //Check whether it is ok to enter UAPSD
12266#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12267 if( btcIsReadyForUapsd(pMac) )
12268#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12269 {
12270 *pBuf++ = uapsdMask;
12271 }
12272#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12273 else
12274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012275 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 *pBuf++ = 0;
12277 }
12278#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12279
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012281 vos_mem_copy(pBuf, pBssDescription,
12282 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12284}
12285
Jeff Johnson295189b2012-06-20 16:38:30 -070012286/*
12287 * The communication between HDD and LIM is thru mailbox (MB).
12288 * Both sides will access the data structure "tSirSmeJoinReq".
12289 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12290 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12291 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12292 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12293 */
12294eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012295 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012296{
12297 eHalStatus status = eHAL_STATUS_SUCCESS;
12298 tSirSmeJoinReq *pMsg;
12299 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012300 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 tANI_U16 msgLen, wTmp, ieLen;
12302 tSirMacRateSet OpRateSet;
12303 tSirMacRateSet ExRateSet;
12304 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12305 tANI_U32 dwTmp;
12306 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012307 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012308
12309 if(!pSession)
12310 {
12311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12312 return eHAL_STATUS_FAILURE;
12313 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012314 /* To satisfy klockworks */
12315 if (NULL == pBssDescription)
12316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012317 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012318 return eHAL_STATUS_FAILURE;
12319 }
12320
Jeff Johnson295189b2012-06-20 16:38:30 -070012321 do {
12322 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12323 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012324 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12326 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12327 // IE fields, but the length field in the bssDescription needs to be interpreted to
12328 // determine length of the IE fields.
12329 //
12330 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12331 // add in the length from the bssDescription (then add the size of the 'length' field
12332 // itself because that is NOT included in the length field).
12333 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12334 pBssDescription->length + sizeof( pBssDescription->length ) +
12335 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 +053012336 pMsg = vos_mem_malloc(msgLen);
12337 if (NULL == pMsg)
12338 status = eHAL_STATUS_FAILURE;
12339 else
12340 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012342 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012343 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 pMsg->length = pal_cpu_to_be16(msgLen);
12345 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 // sessionId
12347 *pBuf = (tANI_U8)sessionId;
12348 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 // transactionId
12350 *pBuf = 0;
12351 *( pBuf + 1 ) = 0;
12352 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 // ssId
12354 if( pIes->SSID.present && pIes->SSID.num_ssid )
12355 {
12356 // ssId len
12357 *pBuf = pIes->SSID.num_ssid;
12358 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012359 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012360 pBuf += pIes->SSID.num_ssid;
12361 }
12362 else
12363 {
12364 *pBuf = 0;
12365 pBuf++;
12366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012368 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12369 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 pBuf += sizeof(tSirMacAddr);
12371 // bsstype
12372 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12373 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012374 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 pBuf += sizeof(tSirBssType);
12376 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012377 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12378 if (pBssDescription->channelId <= 14 &&
12379 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12380 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12381 {
12382 //Need to disable VHT operation in 2.4 GHz band
12383 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12384 }
12385 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 //Persona
12388 *pBuf = (tANI_U8)pProfile->csrPersona;
12389 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012390 //CBMode
12391 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12392 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012393
12394 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012395 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12396
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 // uapsdPerAcBitmask
12398 *pBuf = pProfile->uapsd_mask;
12399 pBuf++;
12400
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012401
12402
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012404 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 {
12406 // OperationalRateSet
12407 if (OpRateSet.numRates) {
12408 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012409 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 pBuf += OpRateSet.numRates;
12411 } else *pBuf++ = 0;
12412 // ExtendedRateSet
12413 if (ExRateSet.numRates) {
12414 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012415 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012416 pBuf += ExRateSet.numRates;
12417 } else *pBuf++ = 0;
12418 }
12419 else
12420 {
12421 *pBuf++ = 0;
12422 *pBuf++ = 0;
12423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 // rsnIE
12425 if ( csrIsProfileWpa( pProfile ) )
12426 {
12427 // Insert the Wpa IE into the join request
12428 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12429 (tCsrWpaIe *)( wpaRsnIE ) );
12430 }
12431 else if( csrIsProfileRSN( pProfile ) )
12432 {
12433 // Insert the RSN IE into the join request
12434 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12435 (tCsrRSNIe *)( wpaRsnIE ) );
12436 }
12437#ifdef FEATURE_WLAN_WAPI
12438 else if( csrIsProfileWapi( pProfile ) )
12439 {
12440 // Insert the WAPI IE into the join request
12441 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12442 (tCsrWapiIe *)( wpaRsnIE ) );
12443 }
12444#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 else
12446 {
12447 ieLen = 0;
12448 }
12449 //remember the IE for future use
12450 if( ieLen )
12451 {
12452 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012454 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 -070012455 ieLen = DOT11F_IE_RSN_MAX_LEN;
12456 }
12457#ifdef FEATURE_WLAN_WAPI
12458 if( csrIsProfileWapi( pProfile ) )
12459 {
12460 //Check whether we need to allocate more memory
12461 if(ieLen > pSession->nWapiReqIeLength)
12462 {
12463 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12464 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012465 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012467 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12468 if (NULL == pSession->pWapiReqIE)
12469 status = eHAL_STATUS_FAILURE;
12470 else
12471 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 if(!HAL_STATUS_SUCCESS(status)) break;
12473 }
12474 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012475 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012477 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012479 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 pBuf += ieLen;
12481 }
12482 else//should be WPA/WPA2 otherwise
12483#endif /* FEATURE_WLAN_WAPI */
12484 {
12485 //Check whether we need to allocate more memory
12486 if(ieLen > pSession->nWpaRsnReqIeLength)
12487 {
12488 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12489 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012490 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012492 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12493 if (NULL == pSession->pWpaRsnReqIE)
12494 status = eHAL_STATUS_FAILURE;
12495 else
12496 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 if(!HAL_STATUS_SUCCESS(status)) break;
12498 }
12499 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012500 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012502 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012504 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 pBuf += ieLen;
12506 }
12507 }
12508 else
12509 {
12510 //free whatever old info
12511 pSession->nWpaRsnReqIeLength = 0;
12512 if(pSession->pWpaRsnReqIE)
12513 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012514 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 pSession->pWpaRsnReqIE = NULL;
12516 }
12517#ifdef FEATURE_WLAN_WAPI
12518 pSession->nWapiReqIeLength = 0;
12519 if(pSession->pWapiReqIE)
12520 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012521 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 pSession->pWapiReqIE = NULL;
12523 }
12524#endif /* FEATURE_WLAN_WAPI */
12525 //length is two bytes
12526 *pBuf = 0;
12527 *(pBuf + 1) = 0;
12528 pBuf += 2;
12529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012530#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012531 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012533 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 //length is two bytes
12535 *pBuf = 0;
12536 *(pBuf + 1) = 0;
12537 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012538 }
12539 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012541 // cckmIE
12542 if( csrIsProfileCCX( pProfile ) )
12543 {
12544 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012545#ifdef FEATURE_WLAN_CCX_UPLOAD
12546 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12547 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12548 pSession->suppCckmIeInfo.cckmIe, ieLen);
12549#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012550 ieLen = csrConstructCcxCckmIe( pMac,
12551 pSession,
12552 pProfile,
12553 pBssDescription,
12554 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 pSession->nWpaRsnReqIeLength,
12556 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012557#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012558 }
12559 else
12560 {
12561 ieLen = 0;
12562 }
12563 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12564 if( ieLen )
12565 {
12566 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12567 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012568 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012569 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012570 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012571 pBuf += ieLen;
12572 }
12573 else
12574 {
12575 //Indicate you have no CCKM IE
12576 //length is two bytes
12577 *pBuf = 0;
12578 *(pBuf + 1) = 0;
12579 pBuf += 2;
12580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 }
12582#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 // addIEScan
12584 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12585 {
12586 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 if(ieLen > pSession->nAddIEScanLength)
12588 {
12589 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12590 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012591 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012593 pSession->pAddIEScan = vos_mem_malloc(ieLen);
12594 if (NULL == pSession->pAddIEScan)
12595 status = eHAL_STATUS_FAILURE;
12596 else
12597 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 if(!HAL_STATUS_SUCCESS(status)) break;
12599 }
12600 pSession->nAddIEScanLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012601 vos_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012603 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012605 vos_mem_copy(pBuf, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 pBuf += ieLen;
12607 }
12608 else
12609 {
12610 pSession->nAddIEScanLength = 0;
12611 if(pSession->pAddIEScan)
12612 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012613 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 pSession->pAddIEScan = NULL;
12615 }
12616 *pBuf = 0;
12617 *(pBuf + 1) = 0;
12618 pBuf += 2;
12619 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 // addIEAssoc
12621 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12622 {
12623 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 if(ieLen > pSession->nAddIEAssocLength)
12625 {
12626 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012627 {
12628 vos_mem_free(pSession->pAddIEAssoc);
12629 }
12630 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12631 if (NULL == pSession->pAddIEAssoc)
12632 status = eHAL_STATUS_FAILURE;
12633 else
12634 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012638 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012640 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012642 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 pBuf += ieLen;
12644 }
12645 else
12646 {
12647 pSession->nAddIEAssocLength = 0;
12648 if(pSession->pAddIEAssoc)
12649 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012650 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 pSession->pAddIEAssoc = NULL;
12652 }
12653 *pBuf = 0;
12654 *(pBuf + 1) = 0;
12655 pBuf += 2;
12656 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012657
12658 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012660 //Unmask any AC in reassoc that is ACM-set
12661 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12662 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012664 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12665 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012666#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012667 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012668#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012669 uapsd_mask &= ~(acm_mask);
12670 }
12671 else
12672 {
12673 uapsd_mask = 0;
12674 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 }
12676 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012677
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012679 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012680 pBuf += sizeof(tANI_U32);
12681
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012683 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012684 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012685#ifdef WLAN_FEATURE_11W
12686 //MgmtEncryption
12687 if (pProfile->MFPEnabled)
12688 {
12689 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12690 }
12691 else
12692 {
12693 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12694 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012695 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012696 pBuf += sizeof(tANI_U32);
12697#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012698#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012699 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012700 if (csrIsProfile11r( pProfile )
12701#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012702 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12703 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012704#endif
12705 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012706 {
12707 // is11Rconnection;
12708 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012709 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012710 pBuf += sizeof(tAniBool);
12711 }
12712 else
12713 {
12714 // is11Rconnection;
12715 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012716 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012717 pBuf += sizeof(tAniBool);
12718 }
12719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012720#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012721
12722 // isCCXFeatureIniEnabled
12723 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12724 {
12725 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012726 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012727 pBuf += sizeof(tAniBool);
12728 }
12729 else
12730 {
12731 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012732 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012733 pBuf += sizeof(tAniBool);
12734 }
12735
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012736 /* A profile can not be both CCX and 11R. But an 802.11R AP
12737 * may be advertising support for CCX as well. So if we are
12738 * associating Open or explicitly CCX then we will get CCX.
12739 * If we are associating explictly 11R only then we will get
12740 * 11R.
12741 */
12742 if ((csrIsProfileCCX(pProfile) ||
12743 ((pIes->CCXVersion.present)
12744 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012745 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12746 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12747 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012748#ifdef WLAN_FEATURE_11W
12749 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12750#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012751 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012752 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12753 {
12754 // isCCXconnection;
12755 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012756 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012757 pBuf += sizeof(tAniBool);
12758 }
12759 else
12760 {
12761 //isCCXconnection;
12762 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012763 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012764 pBuf += sizeof(tAniBool);
12765 }
12766
12767 if (eWNI_SME_JOIN_REQ == messageType)
12768 {
12769 tCCXTspecInfo ccxTspec;
12770 // CCX-Tspec IEs in the ASSOC request is presently not supported
12771 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012772 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12773 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012774 pBuf += sizeof(tCCXTspecInfo);
12775 }
12776 else if (eWNI_SME_REASSOC_REQ == messageType)
12777 {
12778 if ((csrIsProfileCCX(pProfile) ||
12779 ((pIes->CCXVersion.present)
12780 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012781 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12782 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12783 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012784#ifdef WLAN_FEATURE_11W
12785 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12786#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012787 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012788 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 {
12790 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012792 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12794 *pBuf = ccxTspec.numTspecs;
12795 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 // Copy the TSPEC information only if present
12797 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012798 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12799 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 }
12801 pBuf += sizeof(ccxTspec.tspec);
12802 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012803 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 tCCXTspecInfo ccxTspec;
12806 // CCX-Tspec IEs in the ASSOC request is presently not supported
12807 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012808 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12809 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 pBuf += sizeof(tCCXTspecInfo);
12811 }
12812 }
12813#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012814#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012816 if (pMac->roam.configParam.isFastTransitionEnabled
12817#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012818 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012819#endif
12820 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012822 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012823 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012824 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 }
12826 else
12827 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012828 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012829 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012830 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 }
12832#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012833#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012834 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012835 {
12836 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012837 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012838 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012839 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012840 }
12841 else
12842 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012843 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012844 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012845 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012846 }
12847#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012848
12849 // txLdpcIniFeatureEnabled
12850 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12851 pBuf++;
12852
Kiran4a17ebe2013-01-31 10:43:43 -080012853 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12854 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12855 {
12856 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12857 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12858 csrApplyPower2Current(pMac);
12859 }
12860
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012861#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012862 // txBFIniFeatureEnabled
12863 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12864 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012865
12866 // txBFCsnValue
12867 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12868 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012869#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012870 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12871 pBuf++;
12872
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012873 //BssDesc
12874 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12875 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012876
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012877 status = palSendMBMessage(pMac->hHdd, pMsg );
12878 if(!HAL_STATUS_SUCCESS(status))
12879 {
12880 break;
12881 }
12882 else
12883 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012884#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012885 if (eWNI_SME_JOIN_REQ == messageType)
12886 {
12887 //Tush-QoS: notify QoS module that join happening
12888 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12889 }
12890 else if (eWNI_SME_REASSOC_REQ == messageType)
12891 {
12892 //Tush-QoS: notify QoS module that reassoc happening
12893 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012895#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012897 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012899}
12900
Jeff Johnson295189b2012-06-20 16:38:30 -070012901//
12902eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12903{
12904 eHalStatus status = eHAL_STATUS_SUCCESS;
12905 tSirSmeDisassocReq *pMsg;
12906 tANI_U8 *pBuf;
12907 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12909 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12910 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012912 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12913 if (NULL == pMsg)
12914 status = eHAL_STATUS_FAILURE;
12915 else
12916 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012918 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012919 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12920 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 pBuf = &pMsg->sessionId;
12922 // sessionId
12923 *pBuf++ = (tANI_U8)sessionId;
12924 // transactionId
12925 *pBuf = 0;
12926 *( pBuf + 1 ) = 0;
12927 pBuf += sizeof(tANI_U16);
12928
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012929 if ( (pSession->pCurRoamProfile != NULL) &&
12930 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12931 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 {
12933 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012934 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12935 sizeof( tSirMacAddr ));
12936 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012939 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12940 //perMacAddr is passed as bssId for softAP
12941 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 pBuf = pBuf + sizeof ( tSirMacAddr );
12943 }
12944 else
12945 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012947 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12948 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053012950 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
12951 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 if(!HAL_STATUS_SUCCESS(status))
12955 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012956 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 break;
12958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 // reasonCode
12960 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053012961 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
12962 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 if(!HAL_STATUS_SUCCESS(status))
12964 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012965 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 break;
12967 }
12968 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12970 Here we should not send the disassoc over the air to the AP */
12971 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12972#ifdef WLAN_FEATURE_VOWIFI_11R
12973 && csrRoamIs11rAssoc(pMac)
12974#endif
12975 )
12976 {
12977 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12978 }
12979 pBuf += sizeof(tANI_U8);
12980 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 return( status );
12983}
Jeff Johnson295189b2012-06-20 16:38:30 -070012984eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12985{
12986 eHalStatus status = eHAL_STATUS_SUCCESS;
12987 tSirSmeTkipCntrMeasReq *pMsg;
12988 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 do
12990 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012991 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
12992 if ( NULL == pMsg )
12993 status = eHAL_STATUS_FAILURE;
12994 else
12995 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012997 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12999 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 pBuf = &pMsg->sessionId;
13001 // sessionId
13002 *pBuf++ = (tANI_U8)sessionId;
13003 // transactionId
13004 *pBuf = 0;
13005 *( pBuf + 1 ) = 0;
13006 pBuf += sizeof(tANI_U16);
13007 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013008 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13009 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 pBuf = pBuf + sizeof ( tSirMacAddr );
13011 // bEnable
13012 *pBuf = (tANI_BOOLEAN)bEnable;
13013 if(!HAL_STATUS_SUCCESS(status))
13014 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013015 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 break;
13017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 return( status );
13021}
Jeff Johnson295189b2012-06-20 16:38:30 -070013022eHalStatus
13023csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13024 VOS_MODULE_ID modId, tSirMacAddr bssId,
13025 void *pUsrContext, void *pfnSapEventCallback,
13026 tANI_U8 *pAssocStasBuf )
13027{
13028 eHalStatus status = eHAL_STATUS_SUCCESS;
13029 tSirSmeGetAssocSTAsReq *pMsg;
13030 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13031 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013032 do
13033 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013034 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13035 if ( NULL == pMsg )
13036 status = eHAL_STATUS_FAILURE;
13037 else
13038 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013040 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 pBuf = (tANI_U8 *)&pMsg->bssId;
13043 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013045 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 // modId
13048 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013049 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 // pUsrContext
13052 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013053 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 // pfnSapEventCallback
13056 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013057 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 // pAssocStasBuf
13060 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013061 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013064 status = palSendMBMessage( pMac->hHdd, pMsg );
13065 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 return( status );
13067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013068eHalStatus
13069csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13070 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13071 {
13072 eHalStatus status = eHAL_STATUS_SUCCESS;
13073 tSirSmeGetWPSPBCSessionsReq *pMsg;
13074 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13075 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 do
13077 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13079 if ( NULL == pMsg )
13080 status = eHAL_STATUS_FAILURE;
13081 else
13082 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013084 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013087 VOS_ASSERT(pBuf);
13088
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 // pUsrContext
13091 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013092 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 // pSapEventCallback
13095 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013096 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013099 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013102 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 return( status );
13108}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013109
13110eHalStatus
13111csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13112{
13113 tpSirChangeBIParams pMsg;
13114 tANI_U16 len = 0;
13115 eHalStatus status = eHAL_STATUS_SUCCESS;
13116 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13117
13118 if(!pSession)
13119 {
13120 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13121 return eHAL_STATUS_FAILURE;
13122 }
13123
13124 //NO need to update the Beacon Params if update beacon parameter flag is not set
13125 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13126 return eHAL_STATUS_SUCCESS;
13127
13128 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13129
13130 /* Create the message and send to lim */
13131 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013132 pMsg = vos_mem_malloc(len);
13133 if ( NULL == pMsg )
13134 status = eHAL_STATUS_FAILURE;
13135 else
13136 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013137 if(HAL_STATUS_SUCCESS(status))
13138 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013139 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013140 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13141 pMsg->length = len;
13142
13143 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013144 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13145 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013146 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13147 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013148 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013149 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013150 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13151 status = palSendMBMessage(pMac->hHdd, pMsg);
13152 }
13153 return status;
13154}
13155
Jeff Johnson295189b2012-06-20 16:38:30 -070013156eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13157{
13158 eHalStatus status = eHAL_STATUS_SUCCESS;
13159 tSirSmeDeauthReq *pMsg;
13160 tANI_U8 *pBuf;
13161 tANI_U16 wTmp;
13162 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13163 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13164 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013165 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013166 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13167 if ( NULL == pMsg )
13168 status = eHAL_STATUS_FAILURE;
13169 else
13170 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013172 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13174 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13175 //sessionId
13176 pBuf = &pMsg->sessionId;
13177 *pBuf++ = (tANI_U8)sessionId;
13178
13179 //tansactionId
13180 *pBuf = 0;
13181 *(pBuf + 1 ) = 0;
13182 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13186 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013187 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13188 sizeof( pMsg->peerMacAddr ) );
13189 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pBuf = pBuf + sizeof(tSirMacAddr);
13191 }
13192 else
13193 {
13194 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013195 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13196 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 }
13199 if(!HAL_STATUS_SUCCESS(status))
13200 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013201 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 break;
13203 }
13204 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013205 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13206 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 pBuf = pBuf + sizeof(tSirMacAddr);
13208 if(!HAL_STATUS_SUCCESS(status))
13209 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013210 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 break;
13212 }
13213 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013214 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13215 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 if(!HAL_STATUS_SUCCESS(status))
13217 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013218 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 break;
13220 }
13221 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 return( status );
13224}
13225
Jeff Johnson295189b2012-06-20 16:38:30 -070013226eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13227{
13228 eHalStatus status = eHAL_STATUS_SUCCESS;
13229 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013231 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13232 if ( NULL == pMsg )
13233 status = eHAL_STATUS_FAILURE;
13234 else
13235 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013237 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13239 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13240 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013241 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13242 sizeof(pMsg->peerMacAddr));
13243 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 if(!HAL_STATUS_SUCCESS(status))
13245 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013246 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 break;
13248 }
13249//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013250 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13251 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 if(!HAL_STATUS_SUCCESS(status))
13253 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013254 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 break;
13256 }
13257//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 return( status );
13261}
13262
Jeff Johnson295189b2012-06-20 16:38:30 -070013263eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13264{
13265 eHalStatus status = eHAL_STATUS_SUCCESS;
13266 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013268 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13269 if ( NULL == pMsg )
13270 status = eHAL_STATUS_FAILURE;
13271 else
13272 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013274 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13276 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13277 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013278 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13279 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 if(!HAL_STATUS_SUCCESS(status))
13281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013282 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 break;
13284 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013285 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13286 sizeof(pMsg->peerMacAddr));
13287 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013288 if(!HAL_STATUS_SUCCESS(status))
13289 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013290 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 break;
13292 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 return( status );
13296}
Jeff Johnson295189b2012-06-20 16:38:30 -070013297eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13298{
13299 eHalStatus status = eHAL_STATUS_SUCCESS;
13300 tSirSmeAssocCnf *pMsg;
13301 tANI_U8 *pBuf;
13302 tSirResultCodes statusCode;
13303 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013305 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13306 if ( NULL == pMsg )
13307 status = eHAL_STATUS_FAILURE;
13308 else
13309 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013311 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013312 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13313 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 pBuf = (tANI_U8 *)&pMsg->statusCode;
13315 if(HAL_STATUS_SUCCESS(Halstatus))
13316 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13317 else
13318 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013319 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 pBuf += sizeof(tSirResultCodes);
13321 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013322 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13323 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 pBuf += sizeof (tSirMacAddr);
13325 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013326 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13327 sizeof(tSirMacAddr));
13328 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 pBuf += sizeof (tSirMacAddr);
13330 // aid
13331 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013332 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 pBuf += sizeof (tANI_U16);
13334 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013335 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13336 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 pBuf += sizeof (tSirMacAddr);
13338 // alternateChannelId
13339 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 status = palSendMBMessage( pMac->hHdd, pMsg );
13341 if(!HAL_STATUS_SUCCESS(status))
13342 {
13343 //pMsg is freed by palSendMBMessage
13344 break;
13345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 return( status );
13348}
Jeff Johnson295189b2012-06-20 16:38:30 -070013349eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13350 tpSirSmeAssocInd pAssocInd,
13351 eHalStatus Halstatus,
13352 tANI_U8 sessionId)
13353{
13354 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 tSirSmeAssocIndToUpperLayerCnf *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( tSirSmeAssocIndToUpperLayerCnf ));
13361 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13362 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013363
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13365 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13366
13367 pMsg->sessionId = sessionId;
13368
13369 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));
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 pBuf += sizeof (tSirMacAddr);
13379 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013380 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13381 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 pBuf += sizeof (tSirMacAddr);
13383 // StaId
13384 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013385 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 pBuf += sizeof (tANI_U16);
13387 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013388 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013389 pBuf += sizeof (tSirMacAddr);
13390 // alternateChannelId
13391 *pBuf = 11;
13392 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013393 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013394 //Wmm
13395 *pBuf = pAssocInd->wmmEnabledSta;
13396 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013398 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013401 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 //reassocReq
13404 *pBuf = pAssocInd->reassocReq;
13405 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13407 msgQ.bodyptr = pMsg;
13408 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013412}
Jeff Johnson295189b2012-06-20 16:38:30 -070013413
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013414eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13416 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13417 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13418 tANI_U8 *pKeyRsc )
13419{
13420 tSirSmeSetContextReq *pMsg;
13421 tANI_U16 msgLen;
13422 eHalStatus status = eHAL_STATUS_FAILURE;
13423 tAniEdType tmpEdType;
13424 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013425 tANI_U8 *pBuf = NULL;
13426 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13431 // key set. Since we only support upto one key, we always allocate memory for 1 key
13432 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13433 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13434 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13435 ( sizeof( pMsg->keyMaterial.key ) );
13436
Kiet Lam64c1b492013-07-12 13:56:44 +053013437 pMsg = vos_mem_malloc(msgLen);
13438 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13439 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13441 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 //sessionId
13443 pBuf = &pMsg->sessionId;
13444 *pBuf = (tANI_U8)sessionId;
13445 pBuf++;
13446 // transactionId
13447 *pBuf = 0;
13448 *(pBuf + 1) = 0;
13449 pBuf += sizeof(tANI_U16);
13450 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013451 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013452
13453 pBuf += sizeof(tSirMacAddr);
13454
13455 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013456 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13457 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013458
13459 pBuf += sizeof(tSirMacAddr);
13460
13461 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13463 // in the tSirKeyMaterial keyMaterial; field).
13464 //
13465 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13466 // shorter than this max size. Is LIM interpreting this ok ?
13467 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 -070013468 // set pMsg->keyMaterial.edType
13469 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013470 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 // set the pMsg->keyMaterial.numKeys field
13473 *p = numKeys;
13474 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 // set pSirKey->keyId = keyId;
13476 *p = keyId;
13477 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 // set pSirKey->unicast = (tANI_U8)fUnicast;
13479 *p = (tANI_U8)fUnicast;
13480 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 // set pSirKey->keyDirection = aniKeyDirection;
13482 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013483 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 p += sizeof(tAniKeyDirection);
13485 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013486 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 // set pSirKey->paeRole
13489 *p = paeRole; // 0 is Supplicant
13490 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 // set pSirKey->keyLength = keyLength;
13492 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 if ( keyLength && pKey )
13494 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013495 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 if(keyLength == 16)
13497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013498 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 -070013499 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13500 pKey[5], pKey[6], pKey[7], pKey[8],
13501 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13502 }
13503 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 return( status );
13507}
13508
Jeff Johnson295189b2012-06-20 16:38:30 -070013509eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13510 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13511{
13512 eHalStatus status;
13513 tSirSmeStartBssReq *pMsg;
13514 tANI_U8 *pBuf = NULL;
13515 tANI_U8 *wTmpBuf = NULL;
13516 tANI_U16 msgLen, wTmp;
13517 tANI_U32 dwTmp;
13518 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013519 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013522
13523 if(!pSession)
13524 {
13525 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13526 return eHAL_STATUS_FAILURE;
13527 }
13528
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 do {
13530 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13531 pSession->joinFailStatusCode.reasonCode = 0;
13532 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013533 pMsg = vos_mem_malloc(msgLen);
13534 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13535 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 //sessionId
13540 *pBuf = (tANI_U8)sessionId;
13541 pBuf++;
13542 // transactionId
13543 *pBuf = 0;
13544 *(pBuf + 1) = 0;
13545 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013547 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 pBuf += sizeof(tSirMacAddr);
13549 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013550 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 pBuf += sizeof(tSirMacAddr);
13552 // beaconInterval
13553 if( pBssDesc && pBssDesc->beaconInterval )
13554 {
13555 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 else if(pParam->beaconInterval)
13558 {
13559 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 else
13562 {
13563 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13564 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013565 if(csrIsconcurrentsessionValid (pMac, sessionId,
13566 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013567 == eHAL_STATUS_SUCCESS )
13568 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013569 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013570 pParam->bssPersona);
13571 //Update the beacon Interval
13572 pParam->beaconInterval = wTmp;
13573 }
13574 else
13575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013576 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013577 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013578 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013579 return status;
13580 }
13581
Kiet Lam64c1b492013-07-12 13:56:44 +053013582 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 pBuf += sizeof(tANI_U16);
13584 // dot11mode
13585 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13586 pBuf += 1;
13587 // bssType
13588 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013589 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 pBuf += sizeof(tSirBssType);
13591 // ssId
13592 if( pParam->ssId.length )
13593 {
13594 // ssId len
13595 *pBuf = pParam->ssId.length;
13596 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013597 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 pBuf += pParam->ssId.length;
13599 }
13600 else
13601 {
13602 *pBuf = 0;
13603 pBuf++;
13604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 // set the channel Id
13606 *pBuf = pParam->operationChn;
13607 pBuf++;
13608 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013609 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013610 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013611 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013612
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 // Set privacy
13614 *pBuf = pParam->privacy;
13615 pBuf++;
13616
13617 //Set Uapsd
13618 *pBuf = pParam->ApUapsdEnable;
13619 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 //Set SSID hidden
13621 *pBuf = pParam->ssidHidden;
13622 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13624 pBuf++;
13625
13626 //Ht protection Enable/Disable
13627 *pBuf = (tANI_U8)pParam->protEnabled;
13628 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 //Enable Beacons to Receive for OBSS protection Enable/Disable
13630 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13631 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 //set cfg related to protection
13633 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013634 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 // Set Auth type
13637 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013638 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 // Set DTIM
13641 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013642 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 // Set wps_state
13645 *pBuf = pParam->wps_state;
13646 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013647 // set isCoalesingInIBSSAllowed
13648 *pBuf = pMac->isCoalesingInIBSSAllowed;
13649 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 //Persona
13651 *pBuf = (tANI_U8)pParam->bssPersona;
13652 pBuf++;
13653
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013654 //txLdpcIniFeatureEnabled
13655 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13656 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013657
krunal soni4f087d22013-07-29 16:32:26 -070013658 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13660 {
13661 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013662 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 break;
13664 }
13665 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013666 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 pBuf += sizeof(tANI_U16);
13668 if( wTmp )
13669 {
13670 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013671 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 pBuf += wTmp;
13673 }
13674 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013675 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13678 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013679 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13680 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 pBuf += pParam->operationalRateSet.numRates ;
13682 *pBuf++ = pParam->extendedRateSet.numRates;
13683 if(0 != pParam->extendedRateSet.numRates)
13684 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013685 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13686 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 pBuf += pParam->extendedRateSet.numRates;
13688 }
krunal sonie9002db2013-11-25 14:24:17 -080013689
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13691 pMsg->length = pal_cpu_to_be16(msgLen);
13692
13693 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 return( status );
13696}
13697
Jeff Johnson295189b2012-06-20 16:38:30 -070013698eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13699{
13700 eHalStatus status = eHAL_STATUS_FAILURE;
13701 tSirSmeStopBssReq *pMsg;
13702 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13703 tANI_U8 *pBuf;
13704 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013705
13706 if(!pSession)
13707 {
13708 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13709 return eHAL_STATUS_FAILURE;
13710 }
13711
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013713 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13714 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13715 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13717 pBuf = &pMsg->sessionId;
13718 //sessionId
13719 *pBuf = (tANI_U8)sessionId;
13720 pBuf++;
13721 // transactionId
13722 *pBuf = 0;
13723 pBuf += sizeof(tANI_U16);
13724 //reason code
13725 *pBuf = 0;
13726 pBuf += sizeof(tSirResultCodes);
13727 // bssid
13728 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13729 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13730 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013731 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13732 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 }
13734 else
13735 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013736 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13737 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 }
13739 pBuf += sizeof(tSirMacAddr);
13740 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13741 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 status = palSendMBMessage( pMac->hHdd, pMsg );
13743#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013744 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13745 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13746 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13748 pMsg->reasonCode = 0;
13749 // bssid
13750 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13751 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13752 {
13753 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13754 }
13755 else
13756 {
13757 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13758 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013759 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 pMsg->transactionId = 0;
13761 pMsg->sessionId = (tANI_U8)sessionId;
13762 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13763 status = palSendMBMessage( pMac->hHdd, pMsg );
13764#endif
13765 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 return( status );
13767}
13768
Jeff Johnson295189b2012-06-20 16:38:30 -070013769eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13770 tCsrRoamModifyProfileFields *pModProfileFields,
13771 tANI_U32 *pRoamId, v_BOOL_t fForce)
13772{
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 eHalStatus status = eHAL_STATUS_FAILURE;
13774 tANI_U32 roamId = 0;
13775 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013777 (fForce || (!vos_mem_compare( &pModProfileFields,
13778 &pSession->connectedProfile.modifyProfileFields,
13779 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 {
13781 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13782 if(pRoamId)
13783 {
13784 *pRoamId = roamId;
13785 }
13786
Jeff Johnson295189b2012-06-20 16:38:30 -070013787 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13788 eCsrSmeIssuedReassocToSameAP, roamId,
13789 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 return status;
13792}
Jeff Johnson295189b2012-06-20 16:38:30 -070013793static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13794{
13795 eHalStatus status = eHAL_STATUS_SUCCESS;
13796 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013797 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13799 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13800 return (status);
13801}
Jeff Johnson295189b2012-06-20 16:38:30 -070013802eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13803{
13804 eHalStatus status = eHAL_STATUS_SUCCESS;
13805 tListElem *pEntry = NULL;
13806 tSmeCmd *pCommand = NULL;
13807 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 do
13809 {
13810 if(pMsg == NULL)
13811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013812 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 status = eHAL_STATUS_FAILURE;
13814 break;
13815 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13817 if(pEntry)
13818 {
13819 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13820 if(eSmeCommandAddStaSession == pCommand->command)
13821 {
13822 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013823 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 //Remove this command out of the active list
13827 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13828 {
13829 //Now put this command back on the avilable command list
13830 csrReleaseCommand(pMac, pCommand);
13831 }
13832 smeProcessPendingQueue( pMac );
13833 }
13834 else
13835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013836 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 -070013837 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 status = eHAL_STATUS_FAILURE;
13839 break;
13840 }
13841 }
13842 else
13843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013844 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 -070013845 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 status = eHAL_STATUS_FAILURE;
13847 break;
13848 }
13849 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013850 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013852eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13853 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013854{
13855 tSirSmeAddStaSelfReq *pMsg;
13856 tANI_U16 msgLen;
13857 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013859 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 pMsg = vos_mem_malloc(msgLen);
13861 if ( NULL == pMsg ) break;
13862 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13864 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013866 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013867 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13868
13869 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13870
Arif Hussain24bafea2013-11-15 15:10:03 -080013871 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
13872 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 return( status );
13876}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013877eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13878 tANI_U32 sessionId,
13879 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013880{
13881 eHalStatus status = eHAL_STATUS_SUCCESS;
13882 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 pCommand = csrGetCommandBuffer(pMac);
13884 if(NULL == pCommand)
13885 {
13886 status = eHAL_STATUS_RESOURCES;
13887 }
13888 else
13889 {
13890 pCommand->command = eSmeCommandAddStaSession;
13891 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013892 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13893 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013894 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13896 if( !HAL_STATUS_SUCCESS( status ) )
13897 {
13898 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013899 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 }
13901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 return (status);
13903}
Jeff Johnson295189b2012-06-20 16:38:30 -070013904eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13905{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013906 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013907}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013908eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13909 csrRoamCompleteCallback callback,
13910 void *pContext, tANI_U8 *pSelfMacAddr,
13911 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013912{
13913 eHalStatus status = eHAL_STATUS_SUCCESS;
13914 tANI_U32 i;
13915 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 *pbSessionId = CSR_SESSION_ID_INVALID;
13917 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13918 {
13919 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13920 {
13921 pSession = CSR_GET_SESSION( pMac, i );
13922 status = eHAL_STATUS_SUCCESS;
13923 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13924 pSession->sessionId = (tANI_U8)i;
13925 pSession->callback = callback;
13926 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013927 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013929 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13930 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013932 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013934 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 break;
13936 }
13937#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013938 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13939 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013941 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013943 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 break;
13945 }
13946#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013947 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 break;
13949 }
13950 }
13951 if( CSR_ROAM_SESSION_MAX == i )
13952 {
13953 //No session is available
13954 status = eHAL_STATUS_RESOURCES;
13955 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 return ( status );
13957}
Jeff Johnson295189b2012-06-20 16:38:30 -070013958eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13959{
13960 eHalStatus status = eHAL_STATUS_SUCCESS;
13961 tListElem *pEntry = NULL;
13962 tSmeCmd *pCommand = NULL;
13963 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 do
13965 {
13966 if(pMsg == NULL)
13967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013968 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 status = eHAL_STATUS_FAILURE;
13970 break;
13971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13973 if(pEntry)
13974 {
13975 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13976 if(eSmeCommandDelStaSession == pCommand->command)
13977 {
13978 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013980 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 //This session is done.
13982 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 if(pCommand->u.delStaSessionCmd.callback)
13984 {
13985
13986 status = sme_ReleaseGlobalLock( &pMac->sme );
13987 if ( HAL_STATUS_SUCCESS( status ) )
13988 {
13989 pCommand->u.delStaSessionCmd.callback(
13990 pCommand->u.delStaSessionCmd.pContext);
13991 status = sme_AcquireGlobalLock( &pMac->sme );
13992 if (! HAL_STATUS_SUCCESS( status ) )
13993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013994 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 return status;
13996 }
13997 }
13998 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013999 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 }
14001 }
14002
14003 //Remove this command out of the active list
14004 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14005 {
14006 //Now put this command back on the avilable command list
14007 csrReleaseCommand(pMac, pCommand);
14008 }
14009 smeProcessPendingQueue( pMac );
14010 }
14011 else
14012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014013 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 -070014014 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 status = eHAL_STATUS_FAILURE;
14016 break;
14017 }
14018 }
14019 else
14020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014021 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 -070014022 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 status = eHAL_STATUS_FAILURE;
14024 break;
14025 }
14026 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014028}
Jeff Johnson295189b2012-06-20 16:38:30 -070014029eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14030{
14031 tSirSmeDelStaSelfReq *pMsg;
14032 tANI_U16 msgLen;
14033 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14036 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014037 pMsg = vos_mem_malloc(msgLen);
14038 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14039 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14041 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014043 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14044 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014045 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 return( status );
14048}
Jeff Johnson295189b2012-06-20 16:38:30 -070014049eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14050 tSirMacAddr sessionMacAddr,
14051 csrRoamSessionCloseCallback callback,
14052 void *pContext)
14053{
14054 eHalStatus status = eHAL_STATUS_SUCCESS;
14055 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 pCommand = csrGetCommandBuffer(pMac);
14057 if(NULL == pCommand)
14058 {
14059 status = eHAL_STATUS_RESOURCES;
14060 }
14061 else
14062 {
14063 pCommand->command = eSmeCommandDelStaSession;
14064 pCommand->sessionId = (tANI_U8)sessionId;
14065 pCommand->u.delStaSessionCmd.callback = callback;
14066 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014067 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14068 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14070 if( !HAL_STATUS_SUCCESS( status ) )
14071 {
14072 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014073 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 }
14075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 return (status);
14077}
Jeff Johnson295189b2012-06-20 16:38:30 -070014078eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14079{
14080 return csrSendMBDelSelfStaReqMsg( pMac,
14081 pCommand->u.delStaSessionCmd.selfMacAddr );
14082}
Jeff Johnson295189b2012-06-20 16:38:30 -070014083static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14084{
14085 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14086 tListElem *pEntry, *pNext;
14087 tSmeCmd *pCommand;
14088 tDblLinkList localList;
14089
14090 vos_mem_zero(&localList, sizeof(tDblLinkList));
14091 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14092 {
14093 smsLog(pMac, LOGE, FL(" failed to open list"));
14094 return;
14095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 csrLLLock(pList);
14097 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14098 while(pEntry != NULL)
14099 {
14100 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14101 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14102 if(pCommand->sessionId == sessionId)
14103 {
14104 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14105 {
14106 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14107 }
14108 }
14109 pEntry = pNext;
14110 }
14111 csrLLUnlock(pList);
14112
14113 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14114 {
14115 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14116 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14117 }
14118 csrLLClose(&localList);
14119}
14120
Jeff Johnson295189b2012-06-20 16:38:30 -070014121void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14122{
14123 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14124 {
14125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 csrRoamStop(pMac, sessionId);
14127 csrFreeConnectBssDesc(pMac, sessionId);
14128 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14129 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014130 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014131#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014132 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014133#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014134 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14135 if (pMac->fScanOffload)
14136 {
14137 purgeSmeSessionCmdList(pMac, sessionId,
14138 &pMac->sme.smeScanCmdPendingList);
14139 }
14140
Jeff Johnson295189b2012-06-20 16:38:30 -070014141 purgeCsrSessionCmdList(pMac, sessionId);
14142 csrInitSession(pMac, sessionId);
14143 }
14144}
14145
Jeff Johnson295189b2012-06-20 16:38:30 -070014146eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14147 tANI_BOOLEAN fSync,
14148 csrRoamSessionCloseCallback callback,
14149 void *pContext )
14150{
14151 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14153 {
14154 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14155 if(fSync)
14156 {
14157 csrCleanupSession(pMac, sessionId);
14158 }
14159 else
14160 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014161 purgeSmeSessionCmdList(pMac, sessionId,
14162 &pMac->sme.smeCmdPendingList);
14163 if (pMac->fScanOffload)
14164 {
14165 purgeSmeSessionCmdList(pMac, sessionId,
14166 &pMac->sme.smeScanCmdPendingList);
14167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014168 purgeCsrSessionCmdList(pMac, sessionId);
14169 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14170 pSession->selfMacAddr, callback, pContext);
14171 }
14172 }
14173 else
14174 {
14175 status = eHAL_STATUS_INVALID_PARAMETER;
14176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 return ( status );
14178}
14179
Jeff Johnson295189b2012-06-20 16:38:30 -070014180static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14181{
14182 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014183
14184 if(!pSession)
14185 {
14186 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14187 return;
14188 }
14189
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14191 pSession->sessionId = CSR_SESSION_ID_INVALID;
14192 pSession->callback = NULL;
14193 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14195 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14196 csrFreeRoamProfile( pMac, sessionId );
14197 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14198 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14199 csrFreeConnectBssDesc(pMac, sessionId);
14200 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014201 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14202 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014203 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014204 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 pSession->pWpaRsnReqIE = NULL;
14206 }
14207 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014208 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014210 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 pSession->pWpaRsnRspIE = NULL;
14212 }
14213 pSession->nWpaRsnRspIeLength = 0;
14214#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014215 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014217 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 pSession->pWapiReqIE = NULL;
14219 }
14220 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014221 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014223 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 pSession->pWapiRspIE = NULL;
14225 }
14226 pSession->nWapiRspIeLength = 0;
14227#endif /* FEATURE_WLAN_WAPI */
Kiet Lam64c1b492013-07-12 13:56:44 +053014228 if (pSession->pAddIEScan)
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014230 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 pSession->pAddIEScan = NULL;
14232 }
14233 pSession->nAddIEScanLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014234 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014236 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014240}
14241
Jeff Johnson295189b2012-06-20 16:38:30 -070014242eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14243{
14244 eHalStatus status = eHAL_STATUS_FAILURE;
14245 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14247 {
14248 if( CSR_IS_SESSION_VALID( pMac, i ) )
14249 {
14250 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14251 {
14252 //Found it
14253 status = eHAL_STATUS_SUCCESS;
14254 *pSessionId = i;
14255 break;
14256 }
14257 }
14258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 return( status );
14260}
14261
Jeff Johnson295189b2012-06-20 16:38:30 -070014262//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14263//session because for IBSS, the bssid changes.
14264static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14265{
14266 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14267 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14269 {
14270 if( CSR_IS_SESSION_VALID( pMac, i ) )
14271 {
14272 pSession = CSR_GET_SESSION( pMac, i );
14273 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14274 {
14275 //Found it
14276 nRet = i;
14277 break;
14278 }
14279 }
14280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 return (nRet);
14282}
Jeff Johnson295189b2012-06-20 16:38:30 -070014283static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14284{
14285 /* Update the current BSS info in ho control block based on connected
14286 profile info from pmac global structure */
14287
Arif Hussain24bafea2013-11-15 15:10:03 -080014288 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14289 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 /* Check for user misconfig of RSSI trigger threshold */
14291 pMac->roam.configParam.vccRssiThreshold =
14292 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14293 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14294 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 /* Check for user misconfig of UL MAC Loss trigger threshold */
14296 pMac->roam.configParam.vccUlMacLossThreshold =
14297 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14298 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014299#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14300 {
14301 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 /* Indicate the neighbor roal algorithm about the connect indication */
14303 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14304 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14305 }
14306#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014307}
14308
Jeff Johnson295189b2012-06-20 16:38:30 -070014309static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14310{
14311 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014312
14313 if(!pSession)
14314 {
14315 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14316 return;
14317 }
14318
Jeff Johnson295189b2012-06-20 16:38:30 -070014319 //Only to handle the case for Handover on infra link
14320 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14321 {
14322 return;
14323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014324 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14325 csrRoamDeregStatisticsReq(pMac);
14326 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14327#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14328 /* Indicate the neighbor roal algorithm about the disconnect indication */
14329 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14330#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014331
14332 //Remove this code once SLM_Sessionization is supported
14333 //BMPS_WORKAROUND_NOT_NEEDED
14334 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014335 csrIsInfraApStarted( pMac ) &&
14336 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014337 {
14338 pMac->roam.configParam.doBMPSWorkaround = 0;
14339 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014340}
14341
Jeff Johnson295189b2012-06-20 16:38:30 -070014342void csrRoamTlStatsTimerHandler(void *pv)
14343{
14344 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14345 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14347
Jeff Johnsone7245742012-09-05 17:12:55 -070014348 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14349
Jeff Johnson295189b2012-06-20 16:38:30 -070014350#if 0
14351 // TODO Persession .???
14352 //req TL for stats
14353 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014355 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014356 }
14357 else
14358 {
14359 //save in SME
14360 csrRoamSaveStatsFromTl(pMac, tlStats);
14361 }
14362#endif
14363 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14364 {
14365 if(pMac->roam.tlStatsReqInfo.periodicity)
14366 {
14367 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014368 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14369 pMac->roam.tlStatsReqInfo.periodicity);
14370 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014372 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 return;
14374 }
14375 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14376 }
14377 }
14378}
Jeff Johnson295189b2012-06-20 16:38:30 -070014379void csrRoamPeStatsTimerHandler(void *pv)
14380{
14381 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14382 eHalStatus status;
14383 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14384 VOS_STATUS vosStatus;
14385 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 pPeStatsReqListEntry->timerRunning = FALSE;
14387 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14388 {
14389 // If we entered here, meaning the timer could not be successfully
14390 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14391
14392 /* Destroy the timer */
14393 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14394 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014396 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 }
14398
14399 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014400 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 pPeStatsReqListEntry = NULL;
14402 }
14403 else
14404 {
14405 if(!pPeStatsReqListEntry->rspPending)
14406 {
14407 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14408 pPeStatsReqListEntry->staId);
14409 if(!HAL_STATUS_SUCCESS(status))
14410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014411 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 }
14413 else
14414 {
14415 pPeStatsReqListEntry->rspPending = TRUE;
14416 }
14417 }
14418
14419 //send down a req
14420 if(pPeStatsReqListEntry->periodicity &&
14421 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14422 {
14423 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14424 if(ePMC_FULL_POWER == powerState)
14425 {
14426 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14427 {
14428 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14429 }
14430 }
14431 else
14432 {
14433 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14434 {
14435 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14436 }
14437 }
14438 //start timer
14439 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14440 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014442 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 return;
14444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 pPeStatsReqListEntry->timerRunning = TRUE;
14446
14447 }
14448
14449 }
14450}
Jeff Johnson295189b2012-06-20 16:38:30 -070014451void csrRoamStatsClientTimerHandler(void *pv)
14452{
14453 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14455 {
14456#if 0
14457 // TODO Stats fix for multisession
14458 //start the timer
14459 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14460
14461 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014463 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 }
14465#endif
14466 }
14467#if 0
14468 //send up the stats report
14469 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14470 pStaEntry->staId, pStaEntry->pContext);
14471#endif
14472}
14473
14474
14475
Jeff Johnson295189b2012-06-20 16:38:30 -070014476eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14477{
14478 tAniGetPEStatsReq *pMsg;
14479 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014480 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14481 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014483 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014484 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 }
14486 // need to initiate a stats request to PE
14487 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14488 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14489 pMsg->staId = staId;
14490 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014491 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 if(!HAL_STATUS_SUCCESS(status))
14493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014494 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014496 return status;
14497}
Jeff Johnson295189b2012-06-20 16:38:30 -070014498void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14499{
14500 tAniGetPEStatsRsp *pSmeStatsRsp;
14501 eHalStatus status = eHAL_STATUS_FAILURE;
14502 tListElem *pEntry = NULL;
14503 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14504 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14505 tANI_U32 tempMask = 0;
14506 tANI_U8 counter = 0;
14507 tANI_U8 *pStats = NULL;
14508 tANI_U32 length = 0;
14509 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014510 v_S7_t rssi = 0, snr = 0;
14511 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014512 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14514 if(pSmeStatsRsp->rc)
14515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014516 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 goto post_update;
14518 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 tempMask = pSmeStatsRsp->statsMask;
14520 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014521 /* subtract all statistics from this length, and after processing the entire
14522 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14523 * in this 'stats' message.
14524 */
14525 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 //new stats info from PE, fill up the stats strucutres in PMAC
14527 while(tempMask)
14528 {
14529 if(tempMask & 1)
14530 {
14531 switch(counter)
14532 {
14533 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014534 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014535 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14536 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 pStats += sizeof(tCsrSummaryStatsInfo);
14538 length -= sizeof(tCsrSummaryStatsInfo);
14539 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014541 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014542 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14543 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14545 length -= sizeof(tCsrGlobalClassAStatsInfo);
14546 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014548 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014549 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14550 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14552 length -= sizeof(tCsrGlobalClassBStatsInfo);
14553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014555 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014556 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14557 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14559 length -= sizeof(tCsrGlobalClassCStatsInfo);
14560 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014562 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14564 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014565 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14566 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 }
14568 else
14569 {
14570 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014571 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 VOS_ASSERT( 0 );
14573 }
14574 if(!HAL_STATUS_SUCCESS(status))
14575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014576 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 }
14578 pStats += sizeof(tCsrPerStaStatsInfo);
14579 length -= sizeof(tCsrPerStaStatsInfo);
14580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014582 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014583 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 }
14585 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 tempMask >>=1;
14587 counter++;
14588 }
14589 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14590 if (length != 0)
14591 {
14592 pRssi = (tANI_U32*)pStats;
14593 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014594 pStats += sizeof(tANI_U32);
14595 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 }
14597 else
14598 {
14599 /* If riva is not sending rssi, continue to use the hack */
14600 rssi = RSSI_HACK_BMPS;
14601 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014602
Jeff Johnson295189b2012-06-20 16:38:30 -070014603 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014604
14605 if (length != 0)
14606 {
14607 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014608 pStats += sizeof(tANI_U32);
14609 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014610 }
14611 else
14612 {
14613 linkCapacity = 0;
14614 }
14615
14616 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014617
14618 if (length != 0)
14619 {
14620 pSnr = (tANI_U32*)pStats;
14621 snr = (v_S7_t)*pSnr;
14622 }
14623 else
14624 {
14625 snr = SNR_HACK_BMPS;
14626 }
14627
14628 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014629post_update:
14630 //make sure to update the pe stats req list
14631 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14632 if(pEntry)
14633 {
14634 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14635 pPeStaEntry->rspPending = FALSE;
14636
14637 }
14638 //check the one timer cases
14639 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14640 if(pEntry)
14641 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014643 if(pTempStaEntry->timerExpired)
14644 {
14645 //send up the stats report
14646 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14647 pTempStaEntry->staId, pTempStaEntry->pContext);
14648 //also remove from the client list
14649 csrRoamRemoveStatListEntry(pMac, pEntry);
14650 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 }
14652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014653}
Jeff Johnson295189b2012-06-20 16:38:30 -070014654tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14655{
14656 tListElem *pEntry = NULL;
14657 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014659 if(!pEntry)
14660 {
14661 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014662 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014663 return NULL;
14664 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014665 while( pEntry )
14666 {
14667 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 if(pTempStaEntry->statsMask == statsMask)
14669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014670 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014671 break;
14672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014673 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14674 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014675 return pEntry;
14676}
14677
Jeff Johnson295189b2012-06-20 16:38:30 -070014678tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14679 tANI_BOOLEAN update)
14680{
14681 tListElem *pEntry;
14682 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 if(!pEntry)
14685 {
14686 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014687 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014688 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 return NULL;
14690 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 while( pEntry )
14692 {
14693 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14695 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014697 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 if(update)
14699 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014700 pTempStaEntry->periodicity = pStaEntry->periodicity;
14701 pTempStaEntry->callback = pStaEntry->callback;
14702 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 }
14704 break;
14705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 return pEntry;
14709}
Jeff Johnson295189b2012-06-20 16:38:30 -070014710tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14711{
14712 tListElem *pEntry;
14713 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014715 if(!pEntry)
14716 {
14717 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014718 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014719 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 return NULL;
14721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 while( pEntry )
14723 {
14724 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014727 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 break;
14729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14731 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 return pEntry;
14733}
Jeff Johnson295189b2012-06-20 16:38:30 -070014734eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14735 csrRoamLinkQualityIndCallback callback,
14736 void *pContext)
14737{
14738 pMac->roam.linkQualityIndInfo.callback = callback;
14739 pMac->roam.linkQualityIndInfo.context = pContext;
14740 if( NULL == callback )
14741 {
14742 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14743 }
14744 else
14745 {
14746 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 /* do we need to invoke the callback to notify client of initial value ?? */
14748 }
14749 return eHAL_STATUS_SUCCESS;
14750}
Jeff Johnson295189b2012-06-20 16:38:30 -070014751void csrRoamVccTrigger(tpAniSirGlobal pMac)
14752{
14753 eCsrRoamLinkQualityInd newVccLinkQuality;
14754 tANI_U32 ul_mac_loss = 0;
14755 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14757 /*-------------------------------------------------------------------------
14758 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014759 Check for a change in link quality and notify client if necessary
14760 -------------------------------------------------------------------------*/
14761 ul_mac_loss_trigger_threshold =
14762 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014763 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014764 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014766 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014768 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14770 }
14771 else
14772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014773 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14775 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014776 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14777 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014780 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014781 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014783 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 newVccLinkQuality );
14785
14786 /* we now invoke the callback once to notify client of initial value */
14787 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14788 pMac->roam.linkQualityIndInfo.context );
14789 //event: EVENT_WLAN_VCC
14790 }
14791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014792 pMac->roam.vccLinkQuality = newVccLinkQuality;
14793
Jeff Johnson295189b2012-06-20 16:38:30 -070014794}
Jeff Johnson295189b2012-06-20 16:38:30 -070014795VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14796 v_U8_t rssiNotification,
14797 void * context)
14798{
14799 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14800 eCsrRoamLinkQualityInd newVccLinkQuality;
14801 // TODO : Session info unavailable
14802 tANI_U32 sessionId = 0;
14803 VOS_STATUS status = VOS_STATUS_SUCCESS;
14804 /*-------------------------------------------------------------------------
14805 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 Check for a change in link quality and notify client if necessary
14807 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014808 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 pMac->roam.configParam.vccRssiThreshold);
14810 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014812 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 return VOS_STATUS_SUCCESS;
14814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14816 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014817 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14819 }
14820 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14821 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014822 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14824 }
14825 else
14826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014827 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014828 //Set to this so the code below won't do anything
14829 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 VOS_ASSERT(0);
14831 }
14832
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, "csrRoamVccTriggerRssiIndCallback: 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, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 /* we now invoke the callback once to notify client of initial value */
14841 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14842 pMac->roam.linkQualityIndInfo.context );
14843 //event: EVENT_WLAN_VCC
14844 }
14845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 return status;
14848}
Jeff Johnson295189b2012-06-20 16:38:30 -070014849tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14850 tDblLinkList *pStaList,
14851 tCsrStatsClientReqInfo *pStaEntry)
14852{
14853 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 //if same entity requested for same set of stats with different periodicity &
14855 // callback update it
14856 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14857 {
14858
Kiet Lam64c1b492013-07-12 13:56:44 +053014859 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14860 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 {
14862 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014863 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 return NULL;
14865 }
14866
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 pNewStaEntry->callback = pStaEntry->callback;
14868 pNewStaEntry->pContext = pStaEntry->pContext;
14869 pNewStaEntry->periodicity = pStaEntry->periodicity;
14870 pNewStaEntry->requesterId = pStaEntry->requesterId;
14871 pNewStaEntry->statsMask = pStaEntry->statsMask;
14872 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14873 pNewStaEntry->pMac = pStaEntry->pMac;
14874 pNewStaEntry->staId = pStaEntry->staId;
14875 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14876
14877 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14878 }
14879 return pNewStaEntry;
14880}
14881
Jeff Johnson295189b2012-06-20 16:38:30 -070014882tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14883 tDblLinkList *pStaList,
14884 tCsrPeStatsReqInfo *pStaEntry)
14885{
14886 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014887 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14888 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 {
14890 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014891 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 return NULL;
14893 }
14894
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14896 pNewStaEntry->numClient = pStaEntry->numClient;
14897 pNewStaEntry->periodicity = pStaEntry->periodicity;
14898 pNewStaEntry->statsMask = pStaEntry->statsMask;
14899 pNewStaEntry->pMac = pStaEntry->pMac;
14900 pNewStaEntry->staId = pStaEntry->staId;
14901 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14902 pNewStaEntry->rspPending = pStaEntry->rspPending;
14903
14904 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 return pNewStaEntry;
14906}
Jeff Johnson295189b2012-06-20 16:38:30 -070014907eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14908 tCsrRssiCallback callback,
14909 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14910{
14911 eHalStatus status = eHAL_STATUS_SUCCESS;
14912 vos_msg_t msg;
14913 tANI_U32 sessionId;
14914
14915 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014916 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014917 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14918 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014920 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014921 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14924
14925 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14926 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14927 pMsg->sessionId = sessionId;
14928 pMsg->staId = staId;
14929 pMsg->rssiCallback = callback;
14930 pMsg->pDevContext = pContext;
14931 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 msg.type = eWNI_SME_GET_RSSI_REQ;
14933 msg.bodyptr = pMsg;
14934 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014937 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014938 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014939 status = eHAL_STATUS_FAILURE;
14940 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014941 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 return status;
14943}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014944
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014945eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14946 tCsrSnrCallback callback,
14947 tANI_U8 staId, tCsrBssid bssId,
14948 void *pContext)
14949{
14950 eHalStatus status = eHAL_STATUS_SUCCESS;
14951 vos_msg_t msg;
14952 tANI_U32 sessionId;
14953
14954 tAniGetSnrReq *pMsg;
14955
14956 smsLog(pMac, LOG2, FL("called"));
14957
14958 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14959 if (NULL == pMsg )
14960 {
14961 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14962 return status;
14963 }
14964
14965 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14966
14967 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14968 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14969 pMsg->sessionId = sessionId;
14970 pMsg->staId = staId;
14971 pMsg->snrCallback = callback;
14972 pMsg->pDevContext = pContext;
14973 msg.type = eWNI_SME_GET_SNR_REQ;
14974 msg.bodyptr = pMsg;
14975 msg.reserved = 0;
14976
14977 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14978 {
14979 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14980 vos_mem_free((v_VOID_t *)pMsg);
14981 status = eHAL_STATUS_FAILURE;
14982 }
14983
14984 smsLog(pMac, LOG2, FL("returned"));
14985 return status;
14986}
14987
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014988#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14989eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14990 tCsrRssiCallback callback,
14991 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14992{
14993 eHalStatus status = eHAL_STATUS_SUCCESS;
14994 tAniGetRssiReq *pMsg;
14995
Kiet Lam64c1b492013-07-12 13:56:44 +053014996 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14997 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014998 {
14999 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053015000 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015001 }
15002 // need to initiate a stats request to PE
15003 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15004 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15005 pMsg->staId = staId;
15006 pMsg->rssiCallback = callback;
15007 pMsg->pDevContext = pContext;
15008 pMsg->pVosContext = pVosContext;
15009 status = palSendMBMessage(pMac->hHdd, pMsg );
15010 if(!HAL_STATUS_SUCCESS(status))
15011 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015012 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15013 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015014 status = eHAL_STATUS_FAILURE;
15015 }
15016 return status;
15017}
15018#endif
15019
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015020
15021
15022#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15023eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15024 tCsrTsmStatsCallback callback,
15025 tANI_U8 staId,
15026 tCsrBssid bssId,
15027 void *pContext,
15028 void* pVosContext,
15029 tANI_U8 tid)
15030{
15031 eHalStatus status = eHAL_STATUS_SUCCESS;
15032 tAniGetTsmStatsReq *pMsg = NULL;
15033
15034 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15035 if ( !HAL_STATUS_SUCCESS(status) )
15036 {
15037 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15038 return status;
15039 }
15040 // need to initiate a stats request to PE
15041 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15042 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15043 pMsg->staId = staId;
15044 pMsg->tid = tid;
15045 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15046 pMsg->tsmStatsCallback = callback;
15047 pMsg->pDevContext = pContext;
15048 pMsg->pVosContext = pVosContext;
15049 status = palSendMBMessage(pMac->hHdd, pMsg );
15050 if(!HAL_STATUS_SUCCESS(status))
15051 {
15052 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15053 //pMsg is freed by palSendMBMessage
15054 status = eHAL_STATUS_FAILURE;
15055 }
15056 return status;
15057}
15058#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15059
15060
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015061/* ---------------------------------------------------------------------------
15062 \fn csrGetTLSTAState
15063 \helper function to get teh TL STA State whenever the function is called.
15064
15065 \param staId - The staID to be passed to the TL
15066 to get the relevant TL STA State
15067 \return the state as tANI_U16
15068 ---------------------------------------------------------------------------*/
15069tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15070{
15071 WLANTL_STAStateType tlSTAState;
15072 tlSTAState = WLANTL_STA_INIT;
15073
15074 //request TL for STA State
15075 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15076 {
15077 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15078 }
15079
15080 return tlSTAState;
15081}
15082
Jeff Johnson295189b2012-06-20 16:38:30 -070015083eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15084 tANI_U32 statsMask,
15085 tCsrStatsCallback callback,
15086 tANI_U32 periodicity, tANI_BOOLEAN cache,
15087 tANI_U8 staId, void *pContext)
15088{
15089 tCsrStatsClientReqInfo staEntry;
15090 tCsrStatsClientReqInfo *pStaEntry = NULL;
15091 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15092 tListElem *pEntry = NULL;
15093 tANI_BOOLEAN found = FALSE;
15094 eHalStatus status = eHAL_STATUS_SUCCESS;
15095 tANI_BOOLEAN insertInClientList = FALSE;
15096 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015097 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015098
15099 if( csrIsAllSessionDisconnected(pMac) )
15100 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015101 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015102 return eHAL_STATUS_FAILURE;
15103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015104 if((!statsMask) && (!callback))
15105 {
15106 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015107 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 return eHAL_STATUS_FAILURE;
15109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 //for the search list method for deregister
15111 staEntry.requesterId = requesterId;
15112 staEntry.statsMask = statsMask;
15113 //requester wants to deregister or just an error
15114 if((statsMask) && (!callback))
15115 {
15116 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15117 if(!pEntry)
15118 {
15119 //msg
15120 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015121 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 return eHAL_STATUS_FAILURE;
15123 }
15124 else
15125 {
15126 //clean up & return
15127 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015128 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015130 pStaEntry->pPeStaEntry->numClient--;
15131 //check if we need to delete the entry from peStatsReqList too
15132 if(!pStaEntry->pPeStaEntry->numClient)
15133 {
15134 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015137
Jeff Johnson295189b2012-06-20 16:38:30 -070015138 //check if we need to stop the tl stats timer too
15139 pMac->roam.tlStatsReqInfo.numClient--;
15140 if(!pMac->roam.tlStatsReqInfo.numClient)
15141 {
15142 if(pMac->roam.tlStatsReqInfo.timerRunning)
15143 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015144 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15145 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015147 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 return eHAL_STATUS_FAILURE;
15149 }
15150 }
15151 pMac->roam.tlStatsReqInfo.periodicity = 0;
15152 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15153 }
15154 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 // Destroy the vos timer...
15156 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15157 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015159 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 csrRoamRemoveStatListEntry(pMac, pEntry);
15162 pStaEntry = NULL;
15163 return eHAL_STATUS_SUCCESS;
15164 }
15165 }
15166
15167 if(cache && !periodicity)
15168 {
15169 //return the cached stats
15170 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15171 }
15172 else
15173 {
15174 //add the request in the client req list
15175 staEntry.callback = callback;
15176 staEntry.pContext = pContext;
15177 staEntry.periodicity = periodicity;
15178 staEntry.pPeStaEntry = NULL;
15179 staEntry.staId = staId;
15180 staEntry.pMac = pMac;
15181 staEntry.timerExpired = FALSE;
15182
15183
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 //if periodic report requested with non cached result from PE/TL
15185 if(periodicity)
15186 {
15187
15188 //if looking for stats from PE
15189 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15190 {
15191
15192 //check if same request made already & waiting for rsp
15193 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15194 periodicity, &found, staId);
15195 if(!pPeStaEntry)
15196 {
15197 //bail out, maxed out on number of req for PE
15198 return eHAL_STATUS_FAILURE;
15199 }
15200 else
15201 {
15202 staEntry.pPeStaEntry = pPeStaEntry;
15203 }
15204
15205 }
15206 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15207 if(statsMask & (1 << eCsrGlobalClassDStats))
15208 {
15209 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15210 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015211 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015212 }
15213 else
15214 {
15215
15216 //update periodicity
15217 if(pMac->roam.tlStatsReqInfo.periodicity)
15218 {
15219 pMac->roam.tlStatsReqInfo.periodicity =
15220 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15221 }
15222 else
15223 {
15224 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15225 }
15226 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15227 {
15228 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15229 }
15230
15231 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15232 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015233 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015234 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015236 //req TL for class D stats
15237 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015239 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015240 }
15241 else
15242 {
15243 //save in SME
15244 csrRoamSaveStatsFromTl(pMac, pTlStats);
15245 }
15246 vos_mem_free(pTlStats);
15247 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015248 }
15249 else
15250 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015251 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015253
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 if(pMac->roam.tlStatsReqInfo.periodicity)
15255 {
15256 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015257 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15258 pMac->roam.tlStatsReqInfo.periodicity);
15259 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015261 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015262 return eHAL_STATUS_FAILURE;
15263 }
15264 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15265 }
15266 }
15267 }
15268 pMac->roam.tlStatsReqInfo.numClient++;
15269 }
15270
15271 insertInClientList = TRUE;
15272 }
15273 //if one time report requested with non cached result from PE/TL
15274 else if(!cache && !periodicity)
15275 {
15276 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15277 {
15278 //send down a req
15279 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15280 if(!HAL_STATUS_SUCCESS(status))
15281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015282 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 }
15284 //so that when the stats rsp comes back from PE we respond to upper layer
15285 //right away
15286 staEntry.timerExpired = TRUE;
15287 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 }
15289 if(statsMask & (1 << eCsrGlobalClassDStats))
15290 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015291 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015292 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015294 //req TL for class D stats
15295 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015297 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015298 }
15299 else
15300 {
15301 //save in SME
15302 csrRoamSaveStatsFromTl(pMac, pTlStats);
15303 }
15304 vos_mem_free(pTlStats);
15305 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 }
15307 else
15308 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015309 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015311
15312 }
15313 //if looking for stats from TL only
15314 if(!insertInClientList)
15315 {
15316 //return the stats
15317 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 if(insertInClientList)
15321 {
15322 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15323 if(!pStaEntry)
15324 {
15325 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015326 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015327 return eHAL_STATUS_FAILURE;
15328 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015329 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 //Init & start timer if needed
15331 if(periodicity)
15332 {
15333 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15334 csrRoamStatsClientTimerHandler, pStaEntry );
15335 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015337 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 return eHAL_STATUS_FAILURE;
15339 }
15340 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15341 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015343 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 return eHAL_STATUS_FAILURE;
15345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 }
15349 return eHAL_STATUS_SUCCESS;
15350}
15351
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015352#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15353
15354static tSirRetStatus
15355csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15356 tANI_U8* pBD,
15357 tANI_U8 type,
15358 tANI_U8 subType,
15359 tSirMacAddr peerAddr,
15360 tSirMacAddr selfMacAddr)
15361{
15362 tSirRetStatus statusCode = eSIR_SUCCESS;
15363 tpSirMacMgmtHdr pMacHdr;
15364
15365 /* Prepare MAC management header */
15366 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15367
15368 /* Prepare FC */
15369 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15370 pMacHdr->fc.type = type;
15371 pMacHdr->fc.subType = subType;
15372
15373 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015374 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15375 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015376
15377 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15378
15379 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015380 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15381 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015382 return statusCode;
15383} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15384
15385static tSirRetStatus
15386csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15387 tANI_U8 nChannelNum,
15388 tANI_U32 dot11mode,
15389 tSirMacAddr selfMacAddr,
15390 tANI_U8 *pFrame,
15391 tANI_U16 *pusLen)
15392{
15393 tDot11fProbeRequest pr;
15394 tANI_U32 nStatus, nBytes, nPayload;
15395 tSirRetStatus nSirStatus;
15396 /*Bcast tx*/
15397 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15398 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15399
15400
Kiet Lam64c1b492013-07-12 13:56:44 +053015401 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015402
15403 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15404
15405 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15406 {
15407 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15408 }
15409
15410
15411 if (IS_DOT11_MODE_HT(dot11mode))
15412 {
15413 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15414 }
15415
15416
15417 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15418 if ( DOT11F_FAILED( nStatus ) )
15419 {
15420 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15421 "Failed to calculate the packed size f"
15422 "or a Probe Request (0x%08x).\n", nStatus );
15423
15424
15425 nPayload = sizeof( tDot11fProbeRequest );
15426 }
15427 else if ( DOT11F_WARNED( nStatus ) )
15428 {
15429 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15430 "There were warnings while calculating"
15431 "the packed size for a Probe Request ("
15432 "0x%08x).\n", nStatus );
15433 }
15434
15435 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15436
15437 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015438 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015439
15440
15441 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015442 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015443
15444 if ( eSIR_SUCCESS != nSirStatus )
15445 {
15446 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15447 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15448 nSirStatus );
15449 return nSirStatus;
15450 }
15451
15452
15453 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15454 sizeof( tSirMacMgmtHdr ),
15455 nPayload, &nPayload );
15456 if ( DOT11F_FAILED( nStatus ) )
15457 {
15458 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15459 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15460 return eSIR_FAILURE;
15461 }
15462 else if ( DOT11F_WARNED( nStatus ) )
15463 {
15464 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015465 "There were warnings while packing a Probe Request (0x%08x).\n",
15466 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015467 }
15468
15469 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15470 return eSIR_SUCCESS;
15471}
15472
15473eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15474{
15475 vos_msg_t msg;
15476 tSirRoamOffloadScanReq *pRequestBuf;
15477 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15478 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015479 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015480 tANI_U8 *ChannelList = NULL;
15481 tANI_U32 sessionId;
15482 eHalStatus status = eHAL_STATUS_SUCCESS;
15483 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015484 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015485 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015486 eCsrBand eBand;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015487 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15488
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015489 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015490 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015491 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015492 return eHAL_STATUS_FAILURE;
15493 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015494
15495 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15496 {
15497 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15498 return eHAL_STATUS_FAILURE;
15499 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015500 status = csrRoamGetSessionIdFromBSSID(pMac,
15501 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15502 &sessionId);
15503 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15504 * It is important to ensure that the command is passed down to the FW only
15505 * if the Infra Station is in a connected state.A connected station could also be
15506 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15507 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15508 * irrespective of whichever state we are in.*/
15509 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15510 (command != ROAM_SCAN_OFFLOAD_STOP))
15511 {
15512 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15513 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15514 return eHAL_STATUS_FAILURE;
15515 }
15516
15517 if ( !HAL_STATUS_SUCCESS( status ) )
15518 {
15519 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15520 return eHAL_STATUS_FAILURE;
15521 }
15522 pSession = CSR_GET_SESSION( pMac, sessionId );
15523 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15524 if (NULL == pRequestBuf)
15525 {
15526 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15527 return eHAL_STATUS_FAILED_ALLOC;
15528 }
15529
Kiet Lam64c1b492013-07-12 13:56:44 +053015530 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015531 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15532 * host driver reloads, but Riva still up and running*/
15533 if(command == ROAM_SCAN_OFFLOAD_STOP)
15534 pRequestBuf->RoamScanOffloadEnabled = 0;
15535 else
15536 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015537 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15538 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015539 sizeof(tCsrBssid));
15540 pRequestBuf->ConnectedNetwork.ssId.length =
15541 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15542 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15543 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15544 pRequestBuf->ConnectedNetwork.ssId.length);
15545 pRequestBuf->ConnectedNetwork.authentication =
15546 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15547 pRequestBuf->ConnectedNetwork.encryption =
15548 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15549 pRequestBuf->ConnectedNetwork.mcencryption =
15550 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15551 pRequestBuf->LookupThreshold =
15552 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15553 pRequestBuf->RoamRssiDiff =
15554 pMac->roam.configParam.RoamRssiDiff;
15555 pRequestBuf->Command = command;
15556 pRequestBuf->StartScanReason = reason;
15557 pRequestBuf->NeighborScanTimerPeriod =
15558 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15559 pRequestBuf->NeighborRoamScanRefreshPeriod =
15560 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15561 pRequestBuf->NeighborScanChannelMinTime =
15562 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15563 pRequestBuf->NeighborScanChannelMaxTime =
15564 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15565 pRequestBuf->EmptyRefreshScanPeriod =
15566 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015567 /* MAWC feature */
15568 pRequestBuf->MAWCEnabled =
15569 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015570#ifdef FEATURE_WLAN_CCX
15571 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15572#endif
15573 if (
15574#ifdef FEATURE_WLAN_CCX
15575 ((pNeighborRoamInfo->isCCXAssoc) &&
15576 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15577 eANI_BOOLEAN_FALSE)) ||
15578 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15579#endif // CCX
15580 currChannelListInfo->numOfChannels == 0)
15581 {
15582
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015583 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15584 * Give Preference to INI Channels.*/
15585 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15586 {
15587 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15588 /*The INI channels need to be filtered with respect to the current
15589 * band that is supported.*/
15590 eBand = pMac->roam.configParam.bandCapability;
15591 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015592 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015593 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15594 "Invalid band, No operation carried out (Band %d)", eBand);
15595 vos_mem_free(pRequestBuf);
15596 return eHAL_STATUS_FAILURE;
15597 }
15598 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15599 {
15600 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15601 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15602 (eCSR_BAND_ALL == eBand))
15603 {
15604 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15605 csrRoamIsChannelValid(pMac, *ChannelList) &&
15606 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15607 {
15608 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15609 }
15610 }
15611 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015612 }
15613 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15614 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015615 }
15616 else
15617 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015618 ChannelList = pMac->scan.occupiedChannels.channelList;
15619 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15620 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015621 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15622 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15623 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015624 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015625 }
15626 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015627 }
15628 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15629 /* If the profile changes as to what it was earlier, inform the FW through
15630 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15631 * for the earlier profile and try to learn them afresh.*/
15632 if (reason == REASON_FLUSH_CHANNEL_LIST)
15633 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15634 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015635 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15636 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15637 else
15638 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015639 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015640 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015641 }
15642#ifdef FEATURE_WLAN_CCX
15643 else
15644 {
15645 /* If CCX is enabled, and a neighbor Report is received,then
15646 * Ignore the INI Channels or the Occupied Channel List. Consider
15647 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015648 if (currChannelListInfo->numOfChannels != 0)
15649 {
15650 ChannelList = currChannelListInfo->ChannelList;
15651 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015652 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015653 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15654 {
15655 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15656 }
15657 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015658 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015659 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15660 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15661 }
15662 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015663#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015664 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15665 {
15666 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15667 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15668 }
15669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15670 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15671 pRequestBuf->ChannelCacheType,
15672 pRequestBuf->ConnectedNetwork.ChannelCount,
15673 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015674 num_channels = 0;
15675 ChannelList = NULL;
15676
15677 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015678 host_channels = sizeof(pMac->roam.validChannelList);
15679 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015680 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015681 ChannelList = pMac->roam.validChannelList;
15682 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015683 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015684 else
15685 {
15686 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15687 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015688 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015689 return eHAL_STATUS_FAILURE;
15690 }
15691 for(i=0; i<pMac->roam.numValidChannels; i++)
15692 {
15693 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15694 {
15695 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15696 }
15697 ChannelList++;
15698 }
15699 pRequestBuf->ValidChannelCount = num_channels;
15700
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015701 pRequestBuf->MDID.mdiePresent =
15702 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15703 pRequestBuf->MDID.mobilityDomain =
15704 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015705 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15706
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015707 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015708 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
15709 * where RFS is the RF Switching time. It is twice RFS to consider the
15710 * time to go off channel and return to the home channel. */
15711 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
15712 {
15713 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
15714 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
15715 " Hence enforcing home away time to disable (0)",
15716 __func__, pRequestBuf->HomeAwayTime,
15717 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
15718 pRequestBuf->HomeAwayTime = 0;
15719 }
15720 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015721
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015722 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15723 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15724 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15725 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15726 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15727
15728 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15729 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015730 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015731 msg.reserved = 0;
15732 msg.bodyptr = pRequestBuf;
15733 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15734 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015735 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15736 vos_mem_free(pRequestBuf);
15737 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015738 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015739 else
15740 {
15741 if (ROAM_SCAN_OFFLOAD_START == command)
15742 bRoamScanOffloadStarted = VOS_TRUE;
15743 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15744 bRoamScanOffloadStarted = VOS_FALSE;
15745 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015746
15747 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15748 return status;
15749}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015750
15751eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15752{
15753 switch(reason)
15754 {
15755 case 0:
15756 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15757 break;
15758 case REASON_OS_REQUESTED_ROAMING_NOW:
15759 csrNeighborRoamProceedWithHandoffReq(pMac);
15760 break;
15761 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015762 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 -070015763 }
15764 return eHAL_STATUS_SUCCESS;
15765}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015766#endif
15767
Jeff Johnson295189b2012-06-20 16:38:30 -070015768tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15769 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15770{
15771 tANI_BOOLEAN found = FALSE;
15772 eHalStatus status = eHAL_STATUS_SUCCESS;
15773 tCsrPeStatsReqInfo staEntry;
15774 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15775 tListElem *pStaEntry = NULL;
15776 VOS_STATUS vosStatus;
15777 tPmcPowerState powerState;
15778 *pFound = FALSE;
15779
15780 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15781 if(pStaEntry)
15782 {
15783 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15784 if(pTempStaEntry->periodicity)
15785 {
15786 pTempStaEntry->periodicity =
15787 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15788 }
15789 else
15790 {
15791 pTempStaEntry->periodicity = periodicity;
15792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 pTempStaEntry->numClient++;
15794 found = TRUE;
15795 }
15796 else
15797 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015798 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 staEntry.numClient = 1;
15800 staEntry.periodicity = periodicity;
15801 staEntry.pMac = pMac;
15802 staEntry.rspPending = FALSE;
15803 staEntry.staId = staId;
15804 staEntry.statsMask = statsMask;
15805 staEntry.timerRunning = FALSE;
15806 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15807 if(!pTempStaEntry)
15808 {
15809 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015810 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015811 return NULL;
15812 }
15813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015814 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15815 if(ePMC_FULL_POWER == powerState)
15816 {
15817 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15818 {
15819 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15820 }
15821 }
15822 else
15823 {
15824 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15825 {
15826 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15827 }
15828 }
15829 if(!pTempStaEntry->timerRunning)
15830 {
15831 //send down a req in case of one time req, for periodic ones wait for timer to expire
15832 if(!pTempStaEntry->rspPending &&
15833 !pTempStaEntry->periodicity)
15834 {
15835 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15836 if(!HAL_STATUS_SUCCESS(status))
15837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015838 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 }
15840 else
15841 {
15842 pTempStaEntry->rspPending = TRUE;
15843 }
15844 }
15845 if(pTempStaEntry->periodicity)
15846 {
15847 if(!found)
15848 {
15849
15850 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15851 csrRoamPeStatsTimerHandler, pTempStaEntry );
15852 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015854 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015855 return NULL;
15856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 }
15858 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015859 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015860 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15861 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015863 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 return NULL;
15865 }
15866 pTempStaEntry->timerRunning = TRUE;
15867 }
15868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015869 *pFound = found;
15870 return pTempStaEntry;
15871}
15872
Jeff Johnson295189b2012-06-20 16:38:30 -070015873/*
15874 pStaEntry is no longer invalid upon the return of this function.
15875*/
15876static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15877{
15878 if(pEntry)
15879 {
15880 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15881 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015882 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015884 }
15885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015886
15887void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15888{
15889 tListElem *pEntry;
15890 tCsrPeStatsReqInfo *pTempStaEntry;
15891 VOS_STATUS vosStatus;
15892 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015893 if(!pEntry)
15894 {
15895 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015896 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015897 return;
15898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015899 while( pEntry )
15900 {
15901 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015904 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015905 if(pTempStaEntry->timerRunning)
15906 {
15907 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15908 /* If we are not able to stop the timer here, just remove
15909 * the entry from the linked list. Destroy the timer object
15910 * and free the memory in the timer CB
15911 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015912 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015913 {
15914 /* the timer is successfully stopped */
15915 pTempStaEntry->timerRunning = FALSE;
15916
15917 /* Destroy the timer */
15918 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15919 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015921 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 }
15923 }
15924 else
15925 {
15926 // the timer could not be stopped. Hence destroy and free the
15927 // memory for the PE stat entry in the timer CB.
15928 pTempStaEntry->timerStopFailed = TRUE;
15929 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015931
15932 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15933 {
15934 // Only free the memory if we could stop the timer successfully
15935 if(!pTempStaEntry->timerStopFailed)
15936 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015937 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015938 pTempStaEntry = NULL;
15939 }
15940 break;
15941 }
15942
15943 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15944 }
15945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015946 return;
15947}
15948
15949
Jeff Johnsone7245742012-09-05 17:12:55 -070015950void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015951{
15952
Jeff Johnsone7245742012-09-05 17:12:55 -070015953 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15954 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15955 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15956 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15957 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15958 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15959 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015960 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015961 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15962 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15963 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15964 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15965 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15966 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015967 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015968 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15969 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015970
15971}
15972
Jeff Johnson295189b2012-06-20 16:38:30 -070015973void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15974 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15975{
15976 tANI_U8 stats[500];
15977 tANI_U8 *pStats = NULL;
15978 tANI_U32 tempMask = 0;
15979 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015980 if(!callback)
15981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015982 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015983 return;
15984 }
15985 if(!statsMask)
15986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015987 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 return;
15989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015990 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015991 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015992 while(tempMask)
15993 {
15994 if(tempMask & 1)
15995 {
15996 //new stats info from PE, fill up the stats strucutres in PMAC
15997 switch(counter)
15998 {
15999 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016000 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016001 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16002 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016003 pStats += sizeof(tCsrSummaryStatsInfo);
16004 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016005 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016006 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016007 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16008 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016009 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016010 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016011 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016012 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016013 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16014 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016015 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016017 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016018 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016019 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16020 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016021 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016023 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016024 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016025 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16026 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016027 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016030 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016031 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16032 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016034 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016036 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 }
16039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 tempMask >>=1;
16041 counter++;
16042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016044}
16045
Jeff Johnson295189b2012-06-20 16:38:30 -070016046eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16047{
16048 tListElem *pEntry = NULL;
16049 tListElem *pPrevEntry = NULL;
16050 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16051 eHalStatus status = eHAL_STATUS_SUCCESS;
16052 VOS_STATUS vosStatus;
16053 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 if(!pEntry)
16055 {
16056 //list empty
16057 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016058 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016059 return status;
16060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016061 while( pEntry )
16062 {
16063 if(pPrevEntry)
16064 {
16065 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16066 //send up the stats report
16067 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16068 pTempStaEntry->staId, pTempStaEntry->pContext);
16069 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016071 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016072 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16073 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016074 pTempStaEntry->pPeStaEntry->numClient--;
16075 //check if we need to delete the entry from peStatsReqList too
16076 if(!pTempStaEntry->pPeStaEntry->numClient)
16077 {
16078 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016081 //check if we need to stop the tl stats timer too
16082 pMac->roam.tlStatsReqInfo.numClient--;
16083 if(!pMac->roam.tlStatsReqInfo.numClient)
16084 {
16085 if(pMac->roam.tlStatsReqInfo.timerRunning)
16086 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016087 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16088 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016090 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016091 //we will continue
16092 }
16093 }
16094 pMac->roam.tlStatsReqInfo.periodicity = 0;
16095 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016097 if (pTempStaEntry->periodicity)
16098 {
16099 //While creating StaEntry in csrGetStatistics,
16100 //Initializing and starting timer only when periodicity is set.
16101 //So Stop and Destroy timer only when periodicity is set.
16102
Jeff Johnsone7245742012-09-05 17:12:55 -070016103 vos_timer_stop( &pTempStaEntry->timer );
16104 // Destroy the vos timer...
16105 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16106 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016108 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016110 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016111
Jeff Johnson295189b2012-06-20 16:38:30 -070016112
16113 pPrevEntry = pEntry;
16114 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16115 }
16116 //the last one
16117 if(pPrevEntry)
16118 {
16119 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16120 //send up the stats report
16121 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16122 pTempStaEntry->staId, pTempStaEntry->pContext);
16123 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16124 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016125 return status;
16126
16127}
16128
Jeff Johnson295189b2012-06-20 16:38:30 -070016129eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16130 tRequestFullPowerReason *pReason,
16131 tANI_BOOLEAN *pfNeedPower )
16132{
16133 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16134 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16135 tPmcState pmcState;
16136 eHalStatus status = eHAL_STATUS_SUCCESS;
16137 // TODO : Session info unavailable
16138 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016139 if( pfNeedPower )
16140 {
16141 *pfNeedPower = eANI_BOOLEAN_FALSE;
16142 }
16143 //We only handle CSR commands
16144 if( !(eSmeCsrCommandMask & pCommand->command) )
16145 {
16146 return eHAL_STATUS_SUCCESS;
16147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016148 //Check PMC state first
16149 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016150 switch( pmcState )
16151 {
16152 case REQUEST_IMPS:
16153 case IMPS:
16154 if( eSmeCommandScan == pCommand->command )
16155 {
16156 switch( pCommand->u.scanCmd.reason )
16157 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016158#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16159 case eCsrScanGetLfrResult:
16160#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016161 case eCsrScanGetResult:
16162 case eCsrScanBGScanAbort:
16163 case eCsrScanBGScanEnable:
16164 case eCsrScanGetScanChnInfo:
16165 //Internal process, no need for full power
16166 fNeedFullPower = eANI_BOOLEAN_FALSE;
16167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016168 default:
16169 //Other scans are real scan, ask for power
16170 fNeedFullPower = eANI_BOOLEAN_TRUE;
16171 break;
16172 } //switch
16173 }
16174 else
16175 {
16176 //ask for power for roam and status change
16177 fNeedFullPower = eANI_BOOLEAN_TRUE;
16178 }
16179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016180 case REQUEST_BMPS:
16181 case BMPS:
16182 case REQUEST_START_UAPSD:
16183 case UAPSD:
16184 //We treat WOWL same as BMPS
16185 case REQUEST_ENTER_WOWL:
16186 case WOWL:
16187 if( eSmeCommandRoam == pCommand->command )
16188 {
16189 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16190 tCsrScanResult *pScanResult;
16191 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016192 switch ( pCommand->u.roamCmd.roamReason )
16193 {
16194 case eCsrForcedDisassoc:
16195 case eCsrForcedDisassocMICFailure:
16196 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16197 fNeedFullPower = eANI_BOOLEAN_TRUE;
16198 break;
16199 case eCsrSmeIssuedDisassocForHandoff:
16200 case eCsrForcedDeauth:
16201 case eCsrHddIssuedReassocToSameAP:
16202 case eCsrSmeIssuedReassocToSameAP:
16203 fNeedFullPower = eANI_BOOLEAN_TRUE;
16204 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 case eCsrCapsChange:
16206 fNeedFullPower = eANI_BOOLEAN_TRUE;
16207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016208 default:
16209 //Check whether the profile is already connected. If so, no need for full power
16210 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16211 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16212 {
16213 //Only need to check the first one
16214 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16215 if( pEntry )
16216 {
16217 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16218#if 0
16219 // TODO : Session Specific info pConnectBssDesc
16220 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16221 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16222 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16223 {
16224 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16225 // with Authenticating first. To force this, stop the current association (Disassociate) and
16226 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16227 // a new Association.
16228 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16229 {
16230 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16231 {
16232 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16233 //No need for full power
16234 //Set the flag so the code later can avoid to do the above
16235 //check again.
16236 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16237 break;
16238 }
16239 }
16240 }
16241#endif
16242 }
16243 }
16244 //If we are here, full power is needed
16245 fNeedFullPower = eANI_BOOLEAN_TRUE;
16246 break;
16247 }
16248 }
16249 else if( eSmeCommandWmStatusChange == pCommand->command )
16250 {
16251 //need full power for all
16252 fNeedFullPower = eANI_BOOLEAN_TRUE;
16253 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16254 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016255#ifdef FEATURE_WLAN_TDLS
16256 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16257 {
16258 //TDLS link is getting established. need full power
16259 fNeedFullPower = eANI_BOOLEAN_TRUE;
16260 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16261 }
16262#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016264 case REQUEST_STOP_UAPSD:
16265 case REQUEST_EXIT_WOWL:
16266 if( eSmeCommandRoam == pCommand->command )
16267 {
16268 fNeedFullPower = eANI_BOOLEAN_TRUE;
16269 switch ( pCommand->u.roamCmd.roamReason )
16270 {
16271 case eCsrForcedDisassoc:
16272 case eCsrForcedDisassocMICFailure:
16273 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16274 break;
16275 default:
16276 break;
16277 }
16278 }
16279 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 case STOPPED:
16281 case REQUEST_STANDBY:
16282 case STANDBY:
16283 case LOW_POWER:
16284 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016285 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016286 status = eHAL_STATUS_FAILURE;
16287 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016288 case FULL_POWER:
16289 case REQUEST_FULL_POWER:
16290 default:
16291 //No need to ask for full power. This has to be FULL_POWER state
16292 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016293 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 if( pReason )
16295 {
16296 *pReason = reason;
16297 }
16298 if( pfNeedPower )
16299 {
16300 *pfNeedPower = fNeedFullPower;
16301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016302 return ( status );
16303}
16304
Jeff Johnson295189b2012-06-20 16:38:30 -070016305static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16306{
16307 eHalStatus status = eHAL_STATUS_SUCCESS;
16308 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16309 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016311 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16312 {
16313 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016315 return ( status );
16316}
16317
Jeff Johnson295189b2012-06-20 16:38:30 -070016318tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16319{
16320 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 if( pCmd )
16322 {
16323 pMac->roam.sPendingCommands++;
16324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016325 return ( pCmd );
16326}
16327
Jeff Johnson295189b2012-06-20 16:38:30 -070016328void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16329{
16330 if (pMac->roam.sPendingCommands > 0)
16331 {
16332 //All command allocated through csrGetCommandBuffer need to
16333 //decrement the pending count when releasing.
16334 pMac->roam.sPendingCommands--;
16335 smeReleaseCommand( pMac, pCommand );
16336 }
16337 else
16338 {
16339 smsLog(pMac, LOGE, FL( "no pending commands"));
16340 VOS_ASSERT(0);
16341 }
16342}
16343
Jeff Johnson295189b2012-06-20 16:38:30 -070016344//Return SUCCESS is the command is queued, failed
16345eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16346{
16347 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016348 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16349 {
16350 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16351 pCommand->u.scanCmd.reason);
16352 return eHAL_STATUS_CSR_WRONG_STATE;
16353 }
16354
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016355 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16356 {
16357 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16358 &pCommand->Link, LL_ACCESS_LOCK);
16359 // process the command queue...
16360 smeProcessPendingQueue(pMac);
16361 status = eHAL_STATUS_SUCCESS;
16362 goto end;
16363 }
16364
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 //We can call request full power first before putting the command into pending Q
16366 //because we are holding SME lock at this point.
16367 status = csrRequestFullPower( pMac, pCommand );
16368 if( HAL_STATUS_SUCCESS( status ) )
16369 {
16370 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016371 //make sure roamCmdPendingList is not empty first
16372 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16373 if( fNoCmdPending )
16374 {
16375 smePushCommand( pMac, pCommand, fHighPriority );
16376 }
16377 else
16378 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016379 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016380 //no list lock is needed since SME lock is held
16381 if( !fHighPriority )
16382 {
16383 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16384 }
16385 else {
16386 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16387 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016389 }
16390 else if( eHAL_STATUS_PMC_PENDING == status )
16391 {
16392 //no list lock is needed since SME lock is held
16393 if( !fHighPriority )
16394 {
16395 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16396 }
16397 else {
16398 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16399 }
16400 //Let caller know the command is queue
16401 status = eHAL_STATUS_SUCCESS;
16402 }
16403 else
16404 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016405 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016407 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016409end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016410 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016411}
Jeff Johnson295189b2012-06-20 16:38:30 -070016412eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16413{
16414 eHalStatus status = eHAL_STATUS_SUCCESS;
16415 tSirUpdateAPWPSIEsReq *pMsg;
16416 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16417
16418 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16419 if (NULL == pSession)
16420 {
16421 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16422 return eHAL_STATUS_FAILURE;
16423 }
16424
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 do
16426 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016427 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16428 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16429 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016430 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16431
16432 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016433 VOS_ASSERT(pBuf);
16434
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016436 // transactionId
16437 *pBuf = 0;
16438 *( pBuf + 1 ) = 0;
16439 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016441 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16442 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016444 //sessionId
16445 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016447 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016451 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 return ( status );
16453}
Jeff Johnson295189b2012-06-20 16:38:30 -070016454eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16455{
16456 eHalStatus status = eHAL_STATUS_SUCCESS;
16457 tSirUpdateAPWPARSNIEsReq *pMsg;
16458 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016459 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16460 if (NULL == pSession)
16461 {
16462 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16463 return eHAL_STATUS_FAILURE;
16464 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 do
16466 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016467 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16468 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16469 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016470 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 pBuf = (tANI_U8 *)&pMsg->transactionId;
16472 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016473 // transactionId
16474 *pBuf = 0;
16475 *( pBuf + 1 ) = 0;
16476 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016477 VOS_ASSERT(pBuf);
16478
Jeff Johnson295189b2012-06-20 16:38:30 -070016479 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016480 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16481 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016482 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016483 // sessionId
16484 *pBuf++ = (tANI_U8)sessionId;
16485
16486 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016487 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016491 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016492 return ( status );
16493}
Jeff Johnson295189b2012-06-20 16:38:30 -070016494
16495#ifdef WLAN_FEATURE_VOWIFI_11R
16496//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16497eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16498{
16499 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16500 tpSirFTPreAuthReq pftPreAuthReq;
16501 tANI_U16 auth_req_len = 0;
16502 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016503 auth_req_len = sizeof(tSirFTPreAuthReq);
16504 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016505 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 {
16507 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16508 return eHAL_STATUS_RESOURCES;
16509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016510 // Save the SME Session ID here. We need it while processing the preauth response
16511 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016512 vos_mem_zero(pftPreAuthReq, auth_req_len);
16513
16514 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16515 sizeof(pBssDescription->length) + pBssDescription->length);
16516
16517 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16518
16519 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16520
Kiet Lam64c1b492013-07-12 13:56:44 +053016521 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16522 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16523 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16524 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016525
Jeff Johnson295189b2012-06-20 16:38:30 -070016526#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016527 if (csrRoamIs11rAssoc(pMac) &&
16528 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016529 {
16530 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016531 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16532 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 }
16534 else
16535#endif
16536 {
16537 pftPreAuthReq->ft_ies_length = 0;
16538 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016539 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16540 sizeof(pBssDescription->length) + pBssDescription->length);
16541 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016542 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16543}
Jeff Johnson295189b2012-06-20 16:38:30 -070016544/*--------------------------------------------------------------------------
16545 * This will receive and process the FT Pre Auth Rsp from the current
16546 * associated ap.
16547 *
16548 * This will invoke the hdd call back. This is so that hdd can now
16549 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16550 ------------------------------------------------------------------------*/
16551void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16552{
16553 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16554 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016555#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016556 tCsrRoamInfo roamInfo;
16557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016558
16559#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016560 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016561#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016562#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016563 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016564 if (status != eHAL_STATUS_SUCCESS) {
16565 /*
16566 * Bail out if pre-auth was not even processed.
16567 */
16568 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16569 return;
16570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016571#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016572 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16573 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16574 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016575 // Implies a success
16576 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016577 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16578 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016579 /* No need to notify qos module if this is a non 11r roam*/
16580 if (csrRoamIs11rAssoc(pMac))
16581 {
16582 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16585 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016586 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16587 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016588 if (eHAL_STATUS_SUCCESS != status)
16589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016590 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016591 return;
16592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016593 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016594 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16595 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016596 if (csrRoamIs11rAssoc(pMac))
16597 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16598 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16599
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016600#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16601 if (csrRoamIsCCXAssoc(pMac))
16602 {
16603 /* read TSF */
16604 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16605
16606 // Save the bssid from the received response
16607 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16608 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16609 }
16610#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016611#ifdef FEATURE_WLAN_LFR
16612 // If Legacy Fast Roaming is enabled, signal the supplicant
16613 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016614 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016615 {
16616 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016617 vos_mem_copy((void *)&roamInfo.bssid,
16618 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016619 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16620 }
16621
16622#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016623
16624 // Done with it, init it.
16625 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16626}
16627#endif
16628#ifdef FEATURE_WLAN_BTAMP_UT_RF
16629void csrRoamJoinRetryTimerHandler(void *pv)
16630{
16631 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16632 tpAniSirGlobal pMac = pInfo->pMac;
16633 tANI_U32 sessionId = pInfo->sessionId;
16634 tCsrRoamSession *pSession;
16635
16636 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016638 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 pSession = CSR_GET_SESSION( pMac, sessionId );
16640 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16641 {
16642 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016644 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016645 }
16646 }
16647 }
16648}
Jeff Johnson295189b2012-06-20 16:38:30 -070016649eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16650{
16651 eHalStatus status = eHAL_STATUS_FAILURE;
16652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16653
16654 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016656 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016657 pSession->maxRetryCount--;
16658 pSession->joinRetryTimerInfo.pMac = pMac;
16659 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016660 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16661 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016663 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016664 }
16665 }
16666 else
16667 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016668 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016669 pSession->maxRetryCount);
16670 }
16671
16672 return (status);
16673}
Jeff Johnson295189b2012-06-20 16:38:30 -070016674eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16675{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016676 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16678 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016679 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016680 }
16681
16682 return eHAL_STATUS_SUCCESS;
16683}
16684#endif
16685
16686
16687/*
16688 pBuf points to the beginning of the message
16689 LIM packs disassoc rsp as below,
16690 messageType - 2 bytes
16691 messageLength - 2 bytes
16692 sessionId - 1 byte
16693 transactionId - 2 bytes (tANI_U16)
16694 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16695 peerMacAddr - 6 bytes
16696 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16697*/
16698static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16699{
16700 if(pBuf && pRsp)
16701 {
16702 pBuf += 4; //skip type and length
16703 pRsp->sessionId = *pBuf++;
16704 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16705 pBuf += 2;
16706 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16707 pBuf += 4;
16708 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16709 }
16710}
16711
Jeff Johnsond13512a2012-07-17 11:42:19 -070016712eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16713{
16714 static uNvTables nvTables;
16715 eHalStatus status = eHAL_STATUS_SUCCESS;
16716 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16717
16718 /* read the country code from NV and use it */
16719 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16720 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016721 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16722 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016723 return status;
16724 }
16725 else
16726 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016727 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016728 status = eHAL_STATUS_FAILURE;
16729 return status;
16730 }
16731}
16732
16733eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16734{
Kiet Lam64c1b492013-07-12 13:56:44 +053016735 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016736 return eHAL_STATUS_SUCCESS;
16737}
schang86c22c42013-03-13 18:41:24 -070016738
16739eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16740{
16741 tSirSetTxPowerReq *pMsg = NULL;
16742 eHalStatus status = eHAL_STATUS_SUCCESS;
16743 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16744
16745 if (!pSession)
16746 {
16747 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16748 return eHAL_STATUS_FAILURE;
16749 }
16750
Kiet Lam64c1b492013-07-12 13:56:44 +053016751 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16752 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16753 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16754 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16755 pMsg->length = sizeof(tSirSetTxPowerReq);
16756 pMsg->mwPower = mW;
16757 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16758 sizeof(tSirMacAddr));
16759 status = palSendMBMessage(pMac->hHdd, pMsg);
16760 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016761 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016762 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16763 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016764 }
16765 return status;
16766}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016767
16768/* Returns whether a session is in VOS_STA_MODE...or not */
16769tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16770{
16771 tCsrRoamSession *pSession = NULL;
16772 pSession = CSR_GET_SESSION ( pMac, sessionId );
16773 if(!pSession)
16774 {
16775 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16776 return eANI_BOOLEAN_FALSE;
16777 }
16778 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16779 {
16780 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16781 return eANI_BOOLEAN_FALSE;
16782 }
16783 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16784 {
16785 return eANI_BOOLEAN_FALSE;
16786 }
16787 /* There is a possibility that the above check may fail,because
16788 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16789 * when it is connected.So,we may sneak through the above check even
16790 * if we are not a STA mode INFRA station. So, if we sneak through
16791 * the above condition, we can use the following check if we are
16792 * really in STA Mode.*/
16793
16794 if ( NULL != pSession->pCurRoamProfile )
16795 {
16796 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16797 {
16798 return eANI_BOOLEAN_TRUE;
16799 } else {
16800 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16801 return eANI_BOOLEAN_FALSE;
16802 }
16803 }
16804
16805 return eANI_BOOLEAN_FALSE;
16806}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016807
16808#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16809eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16810 tCsrHandoffRequest *pHandoffInfo)
16811{
16812 eHalStatus status = eHAL_STATUS_SUCCESS;
16813 vos_msg_t msg;
16814
16815 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016816 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16817 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016818 {
16819 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016820 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016821 }
16822 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16823 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16824 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16825 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016826 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016827 pHandoffInfo->bssid,
16828 6);
16829 msg.type = eWNI_SME_HANDOFF_REQ;
16830 msg.bodyptr = pMsg;
16831 msg.reserved = 0;
16832 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16833 {
16834 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016835 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016836 status = eHAL_STATUS_FAILURE;
16837 }
16838 return status;
16839}
16840#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016841
16842#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16843/* ---------------------------------------------------------------------------
16844 \fn csrSetCCKMIe
16845 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16846 data structure and this IE will be packed inside reassociation request
16847 \param pMac - pMac global structure
16848 \param sessionId - Current session id
16849 \param pCckmIe - pointer to CCKM IE data
16850 \param ccKmIeLen - length of the CCKM IE
16851 \- return Success or failure
16852 -------------------------------------------------------------------------*/
16853VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16854 const tANI_U8 *pCckmIe,
16855 const tANI_U8 ccKmIeLen)
16856{
16857 eHalStatus status = eHAL_STATUS_SUCCESS;
16858 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16859
16860 if (!pSession)
16861 {
16862 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16863 return eHAL_STATUS_FAILURE;
16864 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053016865 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016866 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16867 return status;
16868}
16869
16870/* ---------------------------------------------------------------------------
16871 \fn csrRoamReadTSF
16872 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16873 probe response reception from the hand off AP to arrive at the latest TSF value.
16874 \param pMac - pMac global structure
16875 \param pTimestamp - output TSF timestamp
16876 \- return Success or failure
16877 -------------------------------------------------------------------------*/
16878VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16879{
16880 eHalStatus status = eHAL_STATUS_SUCCESS;
16881 tCsrNeighborRoamBSSInfo handoffNode;
16882 tANI_U32 timer_diff = 0;
16883 tANI_U32 timeStamp[2];
16884 tpSirBssDescription pBssDescription = NULL;
16885
16886 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16887 pBssDescription = handoffNode.pBssDescription;
16888
16889 // Get the time diff in milli seconds
16890 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16891 // Convert msec to micro sec timer
16892 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16893
16894 timeStamp[0] = pBssDescription->timeStamp[0];
16895 timeStamp[1] = pBssDescription->timeStamp[1];
16896
16897 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16898
Kiet Lamf2f201e2013-11-16 21:24:16 +053016899 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016900 sizeof (tANI_U32) * 2);
16901 return status;
16902}
16903
16904#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16905