blob: 80c199dc9efcc9f6d50c9fdb3934c379b5b28cec [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 */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#ifdef FEATURE_WLAN_CCX
85#include "csrCcx.h"
86#endif /* FEATURE_WLAN_CCX */
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 {
326 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
327 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
328 status = eHAL_STATUS_SUCCESS;
329 }
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 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 WDA_SetRegDomain(pMac, regId);
342 pMac->scan.domainIdDefault = regId;
343 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
345 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
346 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 }while(0);
348
349 return (status);
350}
351
Jeff Johnson295189b2012-06-20 16:38:30 -0700352eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
353{
354 eHalStatus status = eHAL_STATUS_SUCCESS;
355 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
356 v_REGDOMAIN_t regId;
357 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 if(NULL == apCntryCode)
359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800360 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return eHAL_STATUS_FAILURE;
362 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700363 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 /* To get correct Regulatory domain from NV table
365 * 2 character Country code should be used
366 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700367 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
368/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700370
371 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800373 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700374 return eHAL_STATUS_FAILURE;
375 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700376*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
378 if (status != eHAL_STATUS_SUCCESS)
379 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700380 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 return status;
382 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 status = WDA_SetRegDomain(hHal, regId);
384 if (status != eHAL_STATUS_SUCCESS)
385 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700386 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 return status;
388 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 pMac->scan.domainIdDefault = regId;
390 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 /* Clear CC field */
392 palFillMemory( pMac->hHdd,
393 pMac->scan.countryCodeDefault,
394 WNI_CFG_COUNTRY_CODE_LEN,
395 0 );
396 /* Copy 2 or 3 bytes country code */
397 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
398 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 /* If 2 bytes country code, 3rd byte must be filled with space */
400 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
401 {
402 palFillMemory( pMac->hHdd,
403 pMac->scan.countryCodeDefault + 2,
404 1,
405 0x20 );
406 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700407 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
408 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
409 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 return status;
411}
Jeff Johnson295189b2012-06-20 16:38:30 -0700412eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
413{
414 eHalStatus status = eHAL_STATUS_SUCCESS;
415 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
416 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
418 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
420 {
421 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
422 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
423 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
424 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
425 }
426 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
427
428 return status;
429}
Jeff Johnson295189b2012-06-20 16:38:30 -0700430eHalStatus csrClose(tpAniSirGlobal pMac)
431{
432 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800433
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 csrRoamClose(pMac);
435 csrScanClose(pMac);
436 csrLLClose(&pMac->roam.statsClientReqList);
437 csrLLClose(&pMac->roam.peStatsReqList);
438 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 /* DeInit Globals */
440 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 return (status);
442}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530443
444eHalStatus csrUpdateChannelList(tCsrScanStruct *pScan)
445{
446 tSirUpdateChanList *pChanList;
447 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
448 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
449 (sizeof(tSirUpdateChanParam) * (numChan - 1));
450 vos_msg_t msg;
451 tANI_U8 i;
452
453 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
454 if (!pChanList)
455 {
456 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
457 "Failed to allocate memory for tSirUpdateChanList");
458 return eHAL_STATUS_FAILED_ALLOC;
459 }
460
461 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
462 msg.reserved = 0;
463 msg.bodyptr = pChanList;
464 pChanList->numChan = numChan;
465 for (i = 0; i < pChanList->numChan; i++)
466 {
467 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
468 pChanList->chanParam[i].pwr = pScan->defaultPowerTable[i].pwr;
469 }
470
471 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
472 {
473 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
474 "%s: Failed to post msg to WDA", __func__);
475 vos_mem_free(pChanList);
476 return eHAL_STATUS_FAILURE;
477 }
478
479 return eHAL_STATUS_SUCCESS;
480}
481
Jeff Johnson295189b2012-06-20 16:38:30 -0700482eHalStatus csrStart(tpAniSirGlobal pMac)
483{
484 eHalStatus status = eHAL_STATUS_SUCCESS;
485 tANI_U32 i;
486
487 do
488 {
489 //save the global vos context
490 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
491 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
492 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
493
494 status = csrRoamStart(pMac);
495 if(!HAL_STATUS_SUCCESS(status)) break;
496 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
497 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
498 if(!HAL_STATUS_SUCCESS(status)) break;
499 pMac->roam.sPendingCommands = 0;
500 csrScanEnable(pMac);
501#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
502 status = csrNeighborRoamInit(pMac);
503#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
504 pMac->roam.tlStatsReqInfo.numClient = 0;
505 pMac->roam.tlStatsReqInfo.periodicity = 0;
506 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
507 //init the link quality indication also
508 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
509 if(!HAL_STATUS_SUCCESS(status))
510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800511 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 break;
513 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530514
515 if (pMac->fScanOffload)
516 {
517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
518 "Scan offload is enabled, update default chan list");
519 status = csrUpdateChannelList(&pMac->scan);
520 }
521
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523#if defined(ANI_LOGDUMP)
524 csrDumpInit(pMac);
525#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 return (status);
527}
528
Jeff Johnson295189b2012-06-20 16:38:30 -0700529eHalStatus csrStop(tpAniSirGlobal pMac)
530{
531 tANI_U32 sessionId;
532 tANI_U32 i;
533
534 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
535 {
536 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
537 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 csrScanDisable(pMac);
539 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
540 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
542
543#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
544 csrNeighborRoamClose(pMac);
545#endif
546 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 // deregister from PMC since we register during csrStart()
548 // (ignore status since there is nothing we can do if it fails)
549 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 //Reset the domain back to the deault
551 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800552 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
554 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
555 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530556 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
558 }
559
560 return (eHAL_STATUS_SUCCESS);
561}
562
Jeff Johnson295189b2012-06-20 16:38:30 -0700563eHalStatus csrReady(tpAniSirGlobal pMac)
564{
565 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 csrScanGetSupportedChannels( pMac );
567 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
568 //use it to init the background scan list
569 csrInitBGScanChannelList(pMac);
570 /* HDD issues the init scan */
571 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800572 /* If the gScanAgingTime is set to '0' then scan results aging timeout
573 based on timer feature is not enabled*/
574 if(0 != pMac->scan.scanResultCfgAgingTime )
575 {
576 csrScanStartResultCfgAgingTimer(pMac);
577 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 //Store the AC weights in TL for later use
579 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 status = csrInitChannelList( pMac );
581 if ( ! HAL_STATUS_SUCCESS( status ) )
582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800583 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 status );
585 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 return (status);
587}
Jeff Johnson295189b2012-06-20 16:38:30 -0700588void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
589{
590 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
592 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
593}
Jeff Johnson295189b2012-06-20 16:38:30 -0700594void csrSetGlobalCfgs( tpAniSirGlobal pMac )
595{
Jeff Johnsone7245742012-09-05 17:12:55 -0700596
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
598 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
599 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
600 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
601 NULL, eANI_BOOLEAN_FALSE);
602 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700603 /* 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
604 * Once session is established we will use the session related params stored in PE session for CB mode
605 */
606 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
608
609 //Update the operating mode to configured value during initialization,
610 //So that client can advertise full capabilities in Probe request frame.
611 csrSetDefaultDot11Mode( pMac );
612}
613
Jeff Johnson295189b2012-06-20 16:38:30 -0700614eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
615{
616 eHalStatus status = eHAL_STATUS_SUCCESS;
617 tANI_U32 i;
618 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 do
620 {
621 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
622 {
623 pSession = CSR_GET_SESSION( pMac, i );
624 pSession->roamingTimerInfo.pMac = pMac;
625 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
626 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
628 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530629 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
630 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530632 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800634 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 break;
636 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530637 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
638 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
639 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800641 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 return eHAL_STATUS_FAILURE;
643 }
644 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 return (status);
646}
647
Jeff Johnson295189b2012-06-20 16:38:30 -0700648eHalStatus csrRoamClose(tpAniSirGlobal pMac)
649{
650 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
652 {
653 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
654 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530655 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
656 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
657 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
658 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 return (eHAL_STATUS_SUCCESS);
660}
661
Jeff Johnson295189b2012-06-20 16:38:30 -0700662eHalStatus csrRoamStart(tpAniSirGlobal pMac)
663{
664 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 return (eHAL_STATUS_SUCCESS);
666}
667
Jeff Johnson295189b2012-06-20 16:38:30 -0700668void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
669{
670 csrRoamStopRoamingTimer(pMac, sessionId);
671 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
672 csrRoamDeregStatisticsReq(pMac);
673}
Jeff Johnson295189b2012-06-20 16:38:30 -0700674eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
675{
676 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800677 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 {
679 status = eHAL_STATUS_SUCCESS;
680 *pState = pMac->roam.roamSession[sessionId].connectState;
681 }
682 return (status);
683}
684
Jeff Johnson295189b2012-06-20 16:38:30 -0700685eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
686{
687 eHalStatus status = eHAL_STATUS_FAILURE;
688 tANI_U32 size = 0;
689 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700690
691 if(!pSession)
692 {
693 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
694 return eHAL_STATUS_FAILURE;
695 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700696
697 if(pProfile)
698 {
699 if(pSession->pConnectBssDesc)
700 {
701 do
702 {
703 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
704 if(size)
705 {
706 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
707 if(HAL_STATUS_SUCCESS(status))
708 {
709 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
710 }
711 else
712 break;
713 }
714 else
715 {
716 pProfile->pBssDesc = NULL;
717 }
718 pProfile->AuthType = pSession->connectedProfile.AuthType;
719 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
720 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
721 pProfile->BSSType = pSession->connectedProfile.BSSType;
722 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
723 pProfile->CBMode = pSession->connectedProfile.CBMode;
724 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
725 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
726#ifdef WLAN_FEATURE_VOWIFI_11R
727 if (pSession->connectedProfile.MDID.mdiePresent)
728 {
729 pProfile->MDID.mdiePresent = 1;
730 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
731 }
732 else
733 {
734 pProfile->MDID.mdiePresent = 0;
735 pProfile->MDID.mobilityDomain = 0;
736 }
737#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700738#ifdef FEATURE_WLAN_CCX
739 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
741 {
742 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
743 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
744 pProfile->ccxCckmInfo.reassoc_req_num=
745 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
746 pProfile->ccxCckmInfo.krk_plumbed =
747 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
748 }
749#endif
750 }while(0);
751 }
752 }
753
754 return (status);
755}
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
758{
759 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700760
761 if((csrIsConnStateConnected(pMac, sessionId)) ||
762 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 {
764 if(pProfile)
765 {
766 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
767 }
768 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 return (status);
770}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700771
Jeff Johnson295189b2012-06-20 16:38:30 -0700772eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
773{
774 eHalStatus status = eHAL_STATUS_SUCCESS;
775
776 if(pProfile->pBssDesc)
777 {
778 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
779 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700780 if(pProfile->pAddIEAssoc)
781 {
782 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
783 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
785 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
786 return (status);
787}
788
Jeff Johnson295189b2012-06-20 16:38:30 -0700789static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
790{
791 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 if( pConnectedInfo->pbFrames )
793 {
794 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
795 pConnectedInfo->pbFrames = NULL;
796 }
797 pConnectedInfo->nBeaconLength = 0;
798 pConnectedInfo->nAssocReqLength = 0;
799 pConnectedInfo->nAssocRspLength = 0;
800 pConnectedInfo->staId = 0;
801#ifdef WLAN_FEATURE_VOWIFI_11R
802 pConnectedInfo->nRICRspLength = 0;
803#endif
804#ifdef FEATURE_WLAN_CCX
805 pConnectedInfo->nTspecIeLength = 0;
806#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 return ( status );
808}
809
Jeff Johnson295189b2012-06-20 16:38:30 -0700810
811
Jeff Johnsone7245742012-09-05 17:12:55 -0700812
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700813void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
814{
815 csrReinitPreauthCmd(pMac, pCommand);
816 csrReleaseCommand( pMac, pCommand );
817}
818
Jeff Johnson295189b2012-06-20 16:38:30 -0700819void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
820{
821 csrReinitRoamCmd(pMac, pCommand);
822 csrReleaseCommand( pMac, pCommand );
823}
824
Jeff Johnson295189b2012-06-20 16:38:30 -0700825void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
826{
827 csrReinitScanCmd(pMac, pCommand);
828 csrReleaseCommand( pMac, pCommand );
829}
830
Jeff Johnson295189b2012-06-20 16:38:30 -0700831void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
832{
833 csrReinitWmStatusChangeCmd(pMac, pCommand);
834 csrReleaseCommand( pMac, pCommand );
835}
836
Jeff Johnson295189b2012-06-20 16:38:30 -0700837void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
838{
839 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
843{
844 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
845}
846
Jeff Johnson295189b2012-06-20 16:38:30 -0700847void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
848{
849 csrReinitSetKeyCmd(pMac, pCommand);
850 csrReleaseCommand( pMac, pCommand );
851}
Jeff Johnson295189b2012-06-20 16:38:30 -0700852void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
853{
854 csrReinitRemoveKeyCmd(pMac, pCommand);
855 csrReleaseCommand( pMac, pCommand );
856}
Jeff Johnson295189b2012-06-20 16:38:30 -0700857void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
858{
859
860 if( eSmeCsrCommandMask & pCommand->command )
861 {
862 switch (pCommand->command)
863 {
864 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800865 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800866 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700867 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 if (NULL != pCommand->u.scanCmd.callback)
869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800870 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
872 }
873 csrReleaseCommandScan( pMac, pCommand );
874 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 case eSmeCommandRoam:
876 csrReleaseCommandRoam( pMac, pCommand );
877 break;
878
879 case eSmeCommandWmStatusChange:
880 csrReleaseCommandWmStatusChange( pMac, pCommand );
881 break;
882
883 case eSmeCommandSetKey:
884 csrReleaseCommandSetKey( pMac, pCommand );
885 break;
886
887 case eSmeCommandRemoveKey:
888 csrReleaseCommandRemoveKey( pMac, pCommand );
889 break;
890
891 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800892 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 csrReleaseCommand( pMac, pCommand );
894 break;
895 }
896 }
897}
898
Jeff Johnson295189b2012-06-20 16:38:30 -0700899void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
900{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800901 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700902
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 if(pMac->roam.curSubState[sessionId] == NewSubstate)
904 {
905 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700906 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 pMac->roam.curSubState[sessionId] = NewSubstate;
908}
909
Jeff Johnson295189b2012-06-20 16:38:30 -0700910eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
911{
912 eCsrRoamState PreviousState;
913
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530914 smsLog( pMac, LOG1, "CSR RoamState[%hu]: [ %d <== %d ]", sessionId,
915 NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916
917 PreviousState = pMac->roam.curState[sessionId];
918
919 if ( NewRoamState != pMac->roam.curState[sessionId] )
920 {
921 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
922 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
923 {
924 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
925 }
926
927 pMac->roam.curState[sessionId] = NewRoamState;
928 }
929 return( PreviousState );
930}
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
933{
934 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 if(catOffset)
936 {
937 pMac->roam.configParam.bCatRssiOffset = catOffset;
938 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
939 {
940 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
941 }
942 }
943}
944
Jeff Johnson295189b2012-06-20 16:38:30 -0700945static void initConfigParam(tpAniSirGlobal pMac)
946{
947 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
949 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
950 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700951
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
953 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
954 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
955 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
956 pMac->roam.configParam.HeartbeatThresh24 = 40;
957 pMac->roam.configParam.HeartbeatThresh50 = 40;
958 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
959 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
960 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700961 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 pMac->roam.configParam.RTSThreshold = 2346;
963 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
964 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
965 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
966 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
967 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
968 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
969 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
970 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
971 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
972 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
973 {
974 pMac->roam.configParam.BssPreferValue[i] = i;
975 }
976 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
977 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
978 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
979 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
981 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
982 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
983 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
984 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
985 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800986 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
987 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700988 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700989#ifdef WLAN_AP_STA_CONCURRENCY
990 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
991 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
992 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
993 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
994 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700995 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
996 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700997#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
999 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1000 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1001 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001002#ifdef WLAN_FEATURE_VOWIFI_11R
1003 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001005#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1006 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1007 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1008 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1009 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1010 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1011 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1012 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1013 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1014 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1015 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1016 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001017 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001018#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001019#ifdef WLAN_FEATURE_11AC
1020 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1021#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
1023 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1024 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001025
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001026 //Remove this code once SLM_Sessionization is supported
1027 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001028 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001029
Jeff Johnsone7245742012-09-05 17:12:55 -07001030}
Jeff Johnson295189b2012-06-20 16:38:30 -07001031eCsrBand csrGetCurrentBand(tHalHandle hHal)
1032{
1033 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1034 return pMac->roam.configParam.bandCapability;
1035}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001036
1037#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001038/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001039 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001040*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001041eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001042{
1043 eHalStatus status = eHAL_STATUS_SUCCESS;
1044 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1045
1046 /* Free up the memory first (if required) */
1047 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1048 {
1049 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1050 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001051 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001052 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001053 return status;
1054}
1055
1056
1057
1058/*
1059 This function flushes the roam scan cache and creates fresh cache
1060 based on the input channel list
1061*/
1062eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1063 const tANI_U8 *pChannelList,
1064 const tANI_U8 numChannels)
1065{
1066 eHalStatus status = eHAL_STATUS_SUCCESS;
1067 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1068
Srinivas Girigowdade697412013-02-14 16:31:48 -08001069 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1070
1071 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1072 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1073
1074 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1075 {
1076 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1077 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1078 return eHAL_STATUS_RESOURCES;
1079 }
1080
1081 /* Update the roam global structure */
1082 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1083 pChannelList,
1084 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1085 return status;
1086}
1087
1088/* This function modifies the bgscan channel list set via config ini or
1089 runtime, whenever the band changes.
1090 if the band is auto, then no operation is performed on the channel list
1091 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1092 if the band is 5G, then make sure channel list contains only 5G valid channels
1093*/
1094eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1095 eCsrBand eBand)
1096{
1097 eHalStatus status = eHAL_STATUS_SUCCESS;
1098 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1099 tANI_U8 outNumChannels = 0;
1100 tANI_U8 inNumChannels = 0;
1101 tANI_U8 *inPtr = NULL;
1102 tANI_U8 i = 0;
1103 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1104
1105 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1106
1107 {
1108 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1109 "No update required for channel list "
1110 "either cfg.ini channel list is not set up or "
1111 "auto band (Band %d)", eBand);
1112 return status;
1113 }
1114
1115 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1116 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1117 if (eCSR_BAND_24 == eBand)
1118 {
1119 for (i = 0; i < inNumChannels; i++)
1120 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001121 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001122 {
1123 ChannelList[outNumChannels++] = inPtr[i];
1124 }
1125 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001126 csrFlushBgScanRoamChannelList(pMac);
1127 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001128 }
1129 else if (eCSR_BAND_5G == eBand)
1130 {
1131 for (i = 0; i < inNumChannels; i++)
1132 {
1133 /* Add 5G Non-DFS channel */
1134 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001135 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001136 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1137 {
1138 ChannelList[outNumChannels++] = inPtr[i];
1139 }
1140 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001141 csrFlushBgScanRoamChannelList(pMac);
1142 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001143 }
1144 else if (eCSR_BAND_ALL == eBand)
1145 {
1146 for (i = 0; i < inNumChannels; i++)
1147 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001148 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001149 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1150 {
1151 ChannelList[outNumChannels++] = inPtr[i];
1152 }
1153 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001154 csrFlushBgScanRoamChannelList(pMac);
1155 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001156 }
1157 else
1158 {
1159 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1160 "Invalid band, No operation carried out (Band %d)", eBand);
1161 status = eHAL_STATUS_INVALID_PARAMETER;
1162 }
1163
1164 return status;
1165}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001166#endif
1167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1169{
1170 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1171 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1173 (eBand == eCSR_BAND_24))
1174 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001175 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001177 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001178 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 pMac->roam.configParam.uCfgDot11Mode, eBand);
1180 return eHAL_STATUS_INVALID_PARAMETER;
1181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1183 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1184 (eBand == eCSR_BAND_5G))
1185 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001186 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001188 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001189 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 pMac->roam.configParam.uCfgDot11Mode, eBand);
1191 return eHAL_STATUS_INVALID_PARAMETER;
1192 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001193 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001194 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001195 pMac->roam.configParam.eBand = eBand;
1196 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001198#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1199 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1200#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 status = csrInitGetChannels( pMac );
1202 if (eHAL_STATUS_SUCCESS == status)
1203 csrInitChannelList( hHal );
1204 return status;
1205}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001206
1207
Jeff Johnsone7245742012-09-05 17:12:55 -07001208/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1209 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1210 * Ideally we should have kept the ini value and enum value same and representing the same
1211 * cb values as in 11n standard i.e.
1212 * Set to 1 (SCA) if the secondary channel is above the primary channel
1213 * Set to 3 (SCB) if the secondary channel is below the primary channel
1214 * Set to 0 (SCN) if no secondary channel is present
1215 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1216 * 0 - secondary none
1217 * 1 - secondary LOW
1218 * 2 - secondary HIGH
1219 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1220 * The enum values are as follows:
1221 * PHY_SINGLE_CHANNEL_CENTERED = 0
1222 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1223 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1224 */
1225ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1226{
1227
1228 ePhyChanBondState phyCbState;
1229 switch (cbIniValue) {
1230 // secondary none
1231 case 0:
1232 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1233 break;
1234 // secondary LOW
1235 case 1:
1236 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1237 break;
1238 // secondary HIGH
1239 case 2:
1240 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1241 break;
1242#ifdef WLAN_FEATURE_11AC
1243 case 3:
1244 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1245 break;
1246 case 4:
1247 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1248 break;
1249 case 5:
1250 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1251 break;
1252 case 6:
1253 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1254 break;
1255 case 7:
1256 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1257 break;
1258 case 8:
1259 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1260 break;
1261 case 9:
1262 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1263 break;
1264#endif
1265 default:
1266 // If an invalid value is passed, disable CHANNEL BONDING
1267 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1268 break;
1269 }
1270 return phyCbState;
1271}
1272
1273v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1274{
1275
1276 v_U32_t cbIniValue;
1277 switch (phyCbState) {
1278 // secondary none
1279 case PHY_SINGLE_CHANNEL_CENTERED:
1280 cbIniValue = 0;
1281 break;
1282 // secondary LOW
1283 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1284 cbIniValue = 1;
1285 break;
1286 // secondary HIGH
1287 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1288 cbIniValue = 2;
1289 break;
1290#ifdef WLAN_FEATURE_11AC
1291 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1292 cbIniValue = 3;
1293 break;
1294 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1295 cbIniValue = 4;
1296 break;
1297 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1298 cbIniValue = 5;
1299 break;
1300 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1301 cbIniValue = 6;
1302 break;
1303 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1304 cbIniValue = 7;
1305 break;
1306 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1307 cbIniValue = 8;
1308 break;
1309 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1310 cbIniValue = 9;
1311 break;
1312#endif
1313 default:
1314 // return some invalid value
1315 cbIniValue = 10;
1316 break;
1317 }
1318 return cbIniValue;
1319}
Jeff Johnson295189b2012-06-20 16:38:30 -07001320
1321eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1322{
1323 eHalStatus status = eHAL_STATUS_SUCCESS;
1324
1325 if(pParam)
1326 {
1327 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1328 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1329 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1330 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1331 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1332 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1333
1334 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001335 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1336
Jeff Johnsone7245742012-09-05 17:12:55 -07001337 /* channelBondingMode5GHz plays a dual role right now
1338 * 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
1339 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1340 */
1341 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001343 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001344 }
1345 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1346 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001348 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 }
1350 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1352 pMac->roam.configParam.phyMode = pParam->phyMode;
1353 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1354 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1355 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1356 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1357 pMac->roam.configParam.TxRate = pParam->TxRate;
1358 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1359 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1360 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1361 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1362 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001363 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001364 //if HDD passed down non zero values then only update,
1365 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001366 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 {
1368 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1369 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001370 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 {
1372 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1373 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001374 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 {
1376 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1377 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001378 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 {
1380 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1381 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001382 if (pParam->nActiveMaxChnTimeBtc)
1383 {
1384 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1385 }
1386 if (pParam->nActiveMinChnTimeBtc)
1387 {
1388 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1389 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001390#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001391 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001392 {
1393 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1394 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001395 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001396 {
1397 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1398 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001399 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001400 {
1401 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1402 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001403 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001404 {
1405 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1406 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001407 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001408 {
1409 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1410 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001411 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001412 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001413 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1414 }
1415 if (pParam->nNumP2PChanCombinedConc)
1416 {
1417 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001418 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001419#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001421 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 {
1423 //Change the unit from second to microsecond
1424 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1426 {
1427 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1428 }
1429 else
1430 {
1431 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1432 }
1433 }
1434 else
1435 {
1436 pMac->roam.configParam.impsSleepTime = 0;
1437 }
1438 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1440 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 //if HDD passed down non zero values for age params, then only update,
1442 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001443 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 {
1445 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 if(pParam->scanAgeTimeNCNPS)
1448 {
1449 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 if(pParam->scanAgeTimeNCPS)
1452 {
1453 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 if(pParam->scanAgeTimeCNPS)
1456 {
1457 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1458 }
1459 if(pParam->scanAgeTimeCPS)
1460 {
1461 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1462 }
1463
1464 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1465 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1466 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1467 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1468 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1469 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1471 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1473 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1474 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1475 //Assign this before calling CsrInit11dInfo
1476 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 if( csrIs11dSupported( pMac ) )
1478 {
1479 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1480 }
1481 else
1482 {
1483 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1484 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001485
1486 /* Initialize the power + channel information if 11h is enabled.
1487 If 11d is enabled this information has already been initialized */
1488 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1489 {
1490 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1491 }
1492
1493
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301494#ifdef WLAN_FEATURE_VOWIFI_11R
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001496 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001497#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001498#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001500 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001501 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001502 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001503 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001504 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001505 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001506 pMac->roam.configParam.nProbes = pParam->nProbes;
1507 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001509#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1510 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001511 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001512#endif
1513#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001514 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1515#endif
1516
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301517#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1519#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001520#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1521 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001522 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1523 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1524 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1525 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1526 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1527 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1528 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1529 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 {
1531 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001532 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 -07001533 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1534 {
1535 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1536 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001537 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 }
1539#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1541 pMac->scan.fValidateList = pParam->fValidateList;
1542 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1543 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001544 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001546 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1547 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1548 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1549 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1550 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1551 * single session
1552 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001553 //Remove this code once SLM_Sessionization is supported
1554 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001555 pMac->roam.configParam.doBMPSWorkaround = 0;
1556
Jeff Johnsone7245742012-09-05 17:12:55 -07001557#ifdef WLAN_FEATURE_11AC
1558 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001559 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001560 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001561 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001562#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001563 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001564
1565 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 }
1567
1568 return status;
1569}
1570
Jeff Johnson295189b2012-06-20 16:38:30 -07001571eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1572{
1573 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 if(pParam)
1575 {
1576 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1577 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1578 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1579 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1580 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1581 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001582 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1583 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1585 pParam->phyMode = pMac->roam.configParam.phyMode;
1586 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1587 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1588 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1589 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1590 pParam->TxRate = pMac->roam.configParam.TxRate;
1591 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1592 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1593 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1594 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1595 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1597 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1598 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1599 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001600 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1601 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1602 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001603#ifdef WLAN_AP_STA_CONCURRENCY
1604 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1605 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1606 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1607 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1608 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001609 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1610 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 //Change the unit from microsecond to second
1613 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1614 pParam->eBand = pMac->roam.configParam.eBand;
1615 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1616 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1617 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1618 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1619 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1620 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1621 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1622 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1623 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1624 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1625 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1626 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1627 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1629 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1630 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1631 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1633 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1634 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1635 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1636 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001638 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001639 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001640 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641
1642#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1643 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1644#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001645#ifdef WLAN_FEATURE_11AC
1646 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001647 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001648 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001649 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001650#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001651#ifdef WLAN_FEATURE_VOWIFI_11R
1652 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1653#endif
1654#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1655 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1656 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1657 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1658 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1659 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001660 pParam->nProbes = pMac->roam.configParam.nProbes;
1661 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001662#endif
1663#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1664 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1665 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1666#endif
1667#ifdef FEATURE_WLAN_LFR
1668 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1669#endif
1670
1671#ifdef FEATURE_WLAN_CCX
1672 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1673#endif
1674#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1675 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1676 {
1677 int i;
1678 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1679 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1680 {
1681 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1682 }
1683 smsLog( pMac, LOG1, "");
1684 }
1685#endif
1686
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001687 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001688
krunal soni5afa96c2013-09-06 22:19:02 -07001689 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
1690
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 csrSetChannels(pMac, pParam);
1692
1693 status = eHAL_STATUS_SUCCESS;
1694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 return (status);
1696}
1697
Jeff Johnson295189b2012-06-20 16:38:30 -07001698eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1699{
1700 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1701 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1702 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1703 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 do
1705 {
1706 if(eCSR_BAND_24 == eBand)
1707 {
1708 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1709 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1710 }
1711 if(eCSR_BAND_5G == eBand)
1712 {
1713 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1714 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1715 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1716 )
1717 {
1718 break;
1719 }
1720 }
1721 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1722 {
1723 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1724 }
1725 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1726 {
1727 newPhyMode = eCSR_DOT11_MODE_AUTO;
1728 }
1729 else
1730 {
1731 //Check for dual band and higher capability first
1732 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1733 {
1734 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1735 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1736 }
1737 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1738 {
1739 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1740 if(eCSR_BAND_24 == eBand) break;
1741 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1742 eBand = eCSR_BAND_5G;
1743 }
1744 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1745 {
1746 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1747 if(eCSR_BAND_5G == eBand) break;
1748 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1749 eBand = eCSR_BAND_24;
1750 }
1751 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1752 {
1753 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1754 if(eCSR_BAND_5G == eBand) break;
1755 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1756 eBand = eCSR_BAND_24;
1757 }
1758 else if(eCSR_DOT11_MODE_11n & phyMode)
1759 {
1760 newPhyMode = eCSR_DOT11_MODE_11n;
1761 }
1762 else if(eCSR_DOT11_MODE_abg & phyMode)
1763 {
1764 newPhyMode = eCSR_DOT11_MODE_abg;
1765 }
1766 else if(eCSR_DOT11_MODE_11a & phyMode)
1767 {
1768 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1769 {
1770 if(eCSR_BAND_ALL == eBand)
1771 {
1772 newPhyMode = eCSR_DOT11_MODE_abg;
1773 }
1774 else
1775 {
1776 //bad setting
1777 break;
1778 }
1779 }
1780 else
1781 {
1782 newPhyMode = eCSR_DOT11_MODE_11a;
1783 eBand = eCSR_BAND_5G;
1784 }
1785 }
1786 else if(eCSR_DOT11_MODE_11g & phyMode)
1787 {
1788 newPhyMode = eCSR_DOT11_MODE_11g;
1789 eBand = eCSR_BAND_24;
1790 }
1791 else if(eCSR_DOT11_MODE_11b & phyMode)
1792 {
1793 newPhyMode = eCSR_DOT11_MODE_11b;
1794 eBand = eCSR_BAND_24;
1795 }
1796 else
1797 {
1798 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001799 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 newPhyMode = eCSR_DOT11_MODE_AUTO;
1801 }
1802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 //Done validating
1804 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 //Now we need to check whether a restart is needed.
1806 if(eBand != pMac->roam.configParam.eBand)
1807 {
1808 fRestartNeeded = eANI_BOOLEAN_TRUE;
1809 break;
1810 }
1811 if(newPhyMode != pMac->roam.configParam.phyMode)
1812 {
1813 fRestartNeeded = eANI_BOOLEAN_TRUE;
1814 break;
1815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 if(HAL_STATUS_SUCCESS(status))
1818 {
1819 pMac->roam.configParam.eBand = eBand;
1820 pMac->roam.configParam.phyMode = newPhyMode;
1821 if(pfRestartNeeded)
1822 {
1823 *pfRestartNeeded = fRestartNeeded;
1824 }
1825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 return (status);
1827}
1828
Jeff Johnson295189b2012-06-20 16:38:30 -07001829void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1830{
1831 tANI_U8 Index;
1832 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 // for dual band NICs, don't need to trim the channel list....
1834 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1835 {
1836 // 2.4 GHz band operation requires the channel list to be trimmed to
1837 // the 2.4 GHz channels only...
1838 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1839 {
1840 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1841 Index++ )
1842 {
1843 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1844 {
1845 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1846 cChannels++;
1847 }
1848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1850 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1851 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1852 // only if we need to.
1853 //
1854 // The amount of memory to clear is the number of channesl that we trimmed
1855 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1856
1857 if ( pChannelList->numChannels > cChannels )
1858 {
1859 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1860 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1861
1862 }
1863
1864 pChannelList->numChannels = cChannels;
1865 }
1866 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1867 {
1868 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1869 {
1870 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1871 {
1872 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1873 cChannels++;
1874 }
1875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1877 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1878 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1879 // only if we need to.
1880 //
1881 // The amount of memory to clear is the number of channesl that we trimmed
1882 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1883 if ( pChannelList->numChannels > cChannels )
1884 {
1885 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1886 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1887 }
1888
1889 pChannelList->numChannels = cChannels;
1890 }
1891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001892}
Jeff Johnson295189b2012-06-20 16:38:30 -07001893#define INFRA_AP_DEFAULT_CHANNEL 6
1894eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1895{
1896 tANI_U8 index= 0;
1897 eHalStatus status = eHAL_STATUS_FAILURE;
1898 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1899 {
1900 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1901 status = eHAL_STATUS_SUCCESS;
1902 break;
1903 }
1904 }
1905 return status;
1906}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001907
1908eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1909{
1910 eHalStatus status = eHAL_STATUS_SUCCESS;
1911 tANI_U8 num20MHzChannelsFound = 0;
1912 VOS_STATUS vosStatus;
1913 tANI_U8 num40MHzChannelsFound = 0;
1914 tANI_U8 Index = 0;
1915 tANI_U8 channelList = 0;
1916
1917 // Updating the defaultpower Table for changed Domain Id
1918 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1919 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1920
1921 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1922 {
1923 smsLog( pMac, LOGE, FL("failed to get channels"));
1924 status = eHAL_STATUS_FAILURE;
1925 }
1926 else
1927 {
1928 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1929 {
1930 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1931 }
1932
1933 // Move the only 5GHZ channel list to the global data,
1934 // As 2.4GHZ list coming from the AP for the changed domain
1935 // structure -- this will be used as the scan list
1936 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1937 {
1938 // If Channel is 5GHz just break the for loop
1939 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1940 break;
1941 }
1942 // Update the 5G channels from nv.bin
1943 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1944 {
1945 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1946 {
Krunal Sonia75019a2013-05-01 01:08:22 -07001947 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1948 {
1949 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1950 channelList++;
1951 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001952 }
1953 }
1954
1955 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1956 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1957 // Filling the remaining index as Zero Just for causion
1958 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1959 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1960 }
1961 return status;
1962}
1963
1964eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1965{
1966 eHalStatus status = eHAL_STATUS_SUCCESS;
1967 tANI_U8 num20MHzChannelsFound = 0;
1968 VOS_STATUS vosStatus;
1969 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05301970 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001971 tANI_U8 num40MHzChannelsFound = 0;
1972 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1973 tANI_U8 channelList = 0;
1974
1975 // Read the scan channel list (including the power limit) from EEPROM
1976 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1977 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1978
1979 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1980 {
1981 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1982 status = eHAL_STATUS_FAILURE;
1983 }
1984 else
1985 {
1986 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1987 {
1988 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1989 }
1990
1991 // Move the 2.4GHZ channel list only to the global data,
1992 // As 5GHz list been provided by AP as part of 11d IE
1993 // structure -- this will be used as the scan list
1994 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1995 {
1996 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1997 {
1998 // First taking the 5GHz channel list backup
1999 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2000 nuum5GchannelListBackup++;
2001 }
2002 }
2003 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302004 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002005 {
2006 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302007 {
2008 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2009 numChan++;
2010 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002011 }
2012 // Restoring the Backed up 5 GHZ channels
2013 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2014 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302015 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002016 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302017 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2018 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002019 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002020 }
2021
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302022 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2023 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002024 }
2025 return (status);
2026}
2027
Jeff Johnson295189b2012-06-20 16:38:30 -07002028eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2029{
2030 eHalStatus status = eHAL_STATUS_SUCCESS;
2031 tANI_U8 num20MHzChannelsFound = 0;
2032 VOS_STATUS vosStatus;
2033 tANI_U8 Index = 0;
2034 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002035
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 //TODO: this interface changed to include the 40MHz channel list
2038 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2039 // Read the scan channel list (including the power limit) from EEPROM
2040 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2041 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2042 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002044 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002045 status = eHAL_STATUS_FAILURE;
2046 }
2047 else
2048 {
2049 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2050 {
2051 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2052 }
2053 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2054 // Move the channel list to the global data
2055 // structure -- this will be used as the scan list
2056 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2057 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 }
2060 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2061 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2062 {
2063 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2064 }
2065 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2066 {
2067 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2068 }
2069 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 return (status);
2072}
2073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074eHalStatus csrInitChannelList( tHalHandle hHal )
2075{
2076 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2077 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2079 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002080 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2081 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002083 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002084
2085 return (status);
2086}
Jeff Johnson295189b2012-06-20 16:38:30 -07002087eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2088 tCsrUpdateConfigParam *pUpdateConfigParam)
2089{
2090 eHalStatus status = eHAL_STATUS_FAILURE;
2091 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2093 status = CsrInit11dInfo(pMac, ps11dinfo);
2094 return status;
2095}
2096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2098{
2099 eHalStatus status = eHAL_STATUS_FAILURE;
2100 tANI_U8 index;
2101 tANI_U32 count=0;
2102 tSirMacChanInfo *pChanInfo;
2103 tSirMacChanInfo *pChanInfoStart;
2104 tANI_BOOLEAN applyConfig = TRUE;
2105
2106 if(!ps11dinfo)
2107 {
2108 return (status);
2109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2111 {
2112 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2113 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2114 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2115 if(!HAL_STATUS_SUCCESS(status)) return (status);
2116 }
2117 else
2118 {
2119 //No change
2120 return (eHAL_STATUS_SUCCESS);
2121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 //legacy maintenance
2123 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2124 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2125 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 //Tush: at csropen get this initialized with default, during csr reset if this
2127 // already set with some value no need initilaize with default again
2128 if(0 == pMac->scan.countryCodeCurrent[0])
2129 {
2130 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2131 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2132 if(!HAL_STATUS_SUCCESS(status)) return (status);
2133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 // need to add the max power channel list
2135 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2136 {
2137 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2138 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002139 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2140 {
2141 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2142 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2143 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2144 pChanInfo++;
2145 count++;
2146 }
2147 if(count)
2148 {
2149 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2150 }
2151 palFreeMemory(pMac->hHdd, pChanInfoStart);
2152 }
2153 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2154 if( HAL_STATUS_SUCCESS(status) )
2155 {
2156 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2157 {
2158 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2159 {
2160 applyConfig = FALSE;
2161 }
2162 }
2163
2164 if(TRUE == applyConfig)
2165 {
2166 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002167 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002168 }
2169
2170 }
2171 return (status);
2172}
2173/* Initialize the Channel + Power List in the local cache and in the CFG */
2174eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2175{
2176 tANI_U8 index;
2177 tANI_U32 count=0;
2178 tSirMacChanInfo *pChanInfo;
2179 tSirMacChanInfo *pChanInfoStart;
2180
2181 if(!ps11dinfo || !pMac)
2182 {
2183 return eHAL_STATUS_FAILURE;
2184 }
2185
2186 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2187 {
2188 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2189 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190
2191 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2192 {
2193 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2194 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2195 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2196 pChanInfo++;
2197 count++;
2198 }
2199 if(count)
2200 {
2201 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2202 }
2203 palFreeMemory(pMac->hHdd, pChanInfoStart);
2204 }
2205
Jeff Johnsone7245742012-09-05 17:12:55 -07002206 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002207}
2208
2209//pCommand may be NULL
2210//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2211void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2212{
2213 tListElem *pEntry, *pNextEntry;
2214 tSmeCmd *pDupCommand;
2215 tDblLinkList localList;
2216
2217 vos_mem_zero(&localList, sizeof(tDblLinkList));
2218 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2219 {
2220 smsLog(pMac, LOGE, FL(" failed to open list"));
2221 return;
2222 }
2223 csrLLLock( &pMac->sme.smeCmdPendingList );
2224 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2225 while( pEntry )
2226 {
2227 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2228 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 // Remove the previous command if..
2230 // - the new roam command is for the same RoamReason...
2231 // - the new roam command is a NewProfileList.
2232 // - the new roam command is a Forced Dissoc
2233 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2234 if (
2235 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2236 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002237 /* This peermac check is requried for Softap/GO scenarios
2238 * For STA scenario below OR check will suffice as pCommand will
2239 * always be NULL for STA scenarios
2240 */
2241 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2243 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2244 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2245 ||
2246 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002247 ( (sessionId == pDupCommand->sessionId) &&
2248 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 ((eCsrForcedDisassoc == eRoamReason) ||
2250 (eCsrHddIssued == eRoamReason))
2251 )
2252 )
2253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002254 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 // Remove the 'stale' roam command from the pending list...
2256 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2257 {
2258 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2259 }
2260 }
2261 pEntry = pNextEntry;
2262 }
2263 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2264
2265 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2266 {
2267 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2268 //Tell caller that the command is cancelled
2269 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2270 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2271 csrReleaseCommandRoam(pMac, pDupCommand);
2272 }
2273 csrLLClose(&localList);
2274}
Jeff Johnson295189b2012-06-20 16:38:30 -07002275eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2276 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2277{
2278 eHalStatus status = eHAL_STATUS_SUCCESS;
2279#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2280 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2281#endif
2282 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2284 {
2285 pSession = CSR_GET_SESSION( pMac, sessionId );
2286 }
2287 else
2288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002289 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 VOS_ASSERT(0);
2291 return eHAL_STATUS_FAILURE;
2292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002295 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002297 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2298 /*
2299 * Decrement bRefAssocStartCnt for FT reassoc failure.
2300 * Reason: For FT reassoc failures, we first call
2301 * csrRoamCallCallback before notifying a failed roam
2302 * completion through csrRoamComplete. The latter in
2303 * turn calls csrRoamProcessResults which tries to
2304 * once again call csrRoamCallCallback if bRefAssocStartCnt
2305 * is non-zero. Since this is redundant for FT reassoc
2306 * failure, decrement bRefAssocStartCnt.
2307 */
2308 pSession->bRefAssocStartCnt--;
2309 }
2310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 if ( (pSession == NULL) ||
2312 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002314 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 return eHAL_STATUS_FAILURE;
2316 }
2317
2318 if(NULL != pSession->callback)
2319 {
2320 if( pRoamInfo )
2321 {
2322 pRoamInfo->sessionId = (tANI_U8)sessionId;
2323 }
2324
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302325 /* avoid holding the global lock when making the roaming callback, original change came
2326 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2327 is possible on other OS ports where the callback may need to take locks to protect
2328 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2330 that may actually depend on the lock being held */
2331 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2332 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2333 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2334 }
2335 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2336 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2337#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2338 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2339 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2340 {
2341 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2342 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2343 if(NULL != pRoamInfo->pBssDesc)
2344 {
2345 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2346 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2349 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2350 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2351 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2352 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2353 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2356 {
2357 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2358 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2359 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 if(eCSR_ROAM_RESULT_FORCED == u2)
2362 {
2363 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2364 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2365 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2368 {
2369 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2370 connectionStatus.reason = eCSR_REASON_DISASSOC;
2371 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2374 {
2375 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2376 connectionStatus.reason = eCSR_REASON_DEAUTH;
2377 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002379#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2380
2381 return (status);
2382}
Jeff Johnson295189b2012-06-20 16:38:30 -07002383// Returns whether handoff is currently in progress or not
2384tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2385{
2386#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2387 return csrNeighborRoamIsHandoffInProgress(pMac);
2388#else
2389 return eANI_BOOLEAN_FALSE;
2390#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002391}
Jeff Johnson295189b2012-06-20 16:38:30 -07002392eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2393 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2394{
2395 eHalStatus status = eHAL_STATUS_SUCCESS;
2396 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2397 tANI_U16 reasonCode;
2398 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002399
2400 if(!pSession)
2401 {
2402 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2403 return eHAL_STATUS_FAILURE;
2404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002405
2406 //Restore AC weight in case we change it
2407 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2408 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002409 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 -07002410 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2411 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2412 }
2413
2414 if ( fMICFailure )
2415 {
2416 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2417 }
2418 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2419 {
2420 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002421 }
2422 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 {
2424 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002426#ifdef WLAN_FEATURE_VOWIFI_11R
2427 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2428 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2429 {
2430 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2431 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002432 }
2433 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002434#endif
2435 if(pSession->pConnectBssDesc)
2436 {
2437 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2438 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002439
Jeff Johnson295189b2012-06-20 16:38:30 -07002440
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002441 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2442 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2443 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2444
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2446
2447 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2448
2449 if(HAL_STATUS_SUCCESS(status))
2450 {
2451 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002452#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2453 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2454 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2455 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002456 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2458 }
2459#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002460 }
2461 else
2462 {
2463 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2464 }
2465
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 return (status);
2467}
Jeff Johnson295189b2012-06-20 16:38:30 -07002468
Jeff Johnson295189b2012-06-20 16:38:30 -07002469/* ---------------------------------------------------------------------------
2470 \fn csrRoamIssueDisassociateStaCmd
2471 \brief csr function that HDD calls to disassociate a associated station
2472 \param sessionId - session Id for Soft AP
2473 \param pPeerMacAddr - MAC of associated station to delete
2474 \param reason - reason code, be one of the tSirMacReasonCodes
2475 \return eHalStatus
2476 ---------------------------------------------------------------------------*/
2477eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2478 tANI_U32 sessionId,
2479 tANI_U8 *pPeerMacAddr,
2480 tANI_U32 reason)
2481{
2482 eHalStatus status = eHAL_STATUS_SUCCESS;
2483 tSmeCmd *pCommand;
2484
2485 do
2486 {
2487 pCommand = csrGetCommandBuffer( pMac );
2488 if ( !pCommand )
2489 {
2490 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2491 status = eHAL_STATUS_RESOURCES;
2492 break;
2493 }
2494 pCommand->command = eSmeCommandRoam;
2495 pCommand->sessionId = (tANI_U8)sessionId;
2496 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2497 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2498 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2499 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2500 if( !HAL_STATUS_SUCCESS( status ) )
2501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002502 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 csrReleaseCommandRoam( pMac, pCommand );
2504 }
2505 }while(0);
2506
2507 return status;
2508}
2509
2510
Jeff Johnson295189b2012-06-20 16:38:30 -07002511/* ---------------------------------------------------------------------------
2512 \fn csrRoamIssueDeauthSta
2513 \brief csr function that HDD calls to delete a associated station
2514 \param sessionId - session Id for Soft AP
2515 \param pPeerMacAddr - MAC of associated station to delete
2516 \param reason - reason code, be one of the tSirMacReasonCodes
2517 \return eHalStatus
2518 ---------------------------------------------------------------------------*/
2519eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2520 tANI_U32 sessionId,
2521 tANI_U8 *pPeerMacAddr,
2522 tANI_U32 reason)
2523{
2524 eHalStatus status = eHAL_STATUS_SUCCESS;
2525 tSmeCmd *pCommand;
2526
2527 do
2528 {
2529 pCommand = csrGetCommandBuffer( pMac );
2530 if ( !pCommand )
2531 {
2532 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2533 status = eHAL_STATUS_RESOURCES;
2534 break;
2535 }
2536 pCommand->command = eSmeCommandRoam;
2537 pCommand->sessionId = (tANI_U8)sessionId;
2538 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2539 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2540 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2541 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2542 if( !HAL_STATUS_SUCCESS( status ) )
2543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002544 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 csrReleaseCommandRoam( pMac, pCommand );
2546 }
2547 }while(0);
2548
2549 return status;
2550}
Jeff Johnson295189b2012-06-20 16:38:30 -07002551eHalStatus
2552csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2553 tANI_BOOLEAN bEnable )
2554{
2555 eHalStatus status = eHAL_STATUS_FAILURE;
2556 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2557 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 if (!pSession)
2559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002560 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 return (status);
2562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 if (pSession->pConnectBssDesc)
2564 {
2565 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2566 }
2567 else
2568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002569 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 return (status);
2571 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002572 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302574 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2576 return (status);
2577}
Jeff Johnson295189b2012-06-20 16:38:30 -07002578eHalStatus
2579csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2580 VOS_MODULE_ID modId, void *pUsrContext,
2581 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2582{
2583 eHalStatus status = eHAL_STATUS_SUCCESS;
2584 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2585 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 if (!pSession)
2587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002588 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 return (status);
2590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 if(pSession->pConnectBssDesc)
2592 {
2593 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2594 }
2595 else
2596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002597 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 return (status);
2599 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002600 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2602 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2604 return (status);
2605}
Jeff Johnson295189b2012-06-20 16:38:30 -07002606eHalStatus
2607csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2608 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2609{
2610 eHalStatus status = eHAL_STATUS_SUCCESS;
2611 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2612 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2613
2614 if (!pSession)
2615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002616 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 return (status);
2618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 if(pSession->pConnectBssDesc)
2620 {
2621 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2622 }
2623 else
2624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002625 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 return (status);
2627 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002628 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2630 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2631
2632 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2633
2634 return (status);
2635}
Jeff Johnson295189b2012-06-20 16:38:30 -07002636eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2637{
2638 eHalStatus status = eHAL_STATUS_SUCCESS;
2639 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2640 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002641
2642 if (!pSession)
2643 {
2644 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2645 return eHAL_STATUS_FAILURE;
2646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002647
2648 if(pSession->pConnectBssDesc)
2649 {
2650 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2651 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002652 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2654 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2656
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302657 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002658 if(!HAL_STATUS_SUCCESS(status))
2659 {
2660 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2661 }
2662
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 return (status);
2664}
2665
Jeff Johnson295189b2012-06-20 16:38:30 -07002666eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2667{
2668 eHalStatus status = eHAL_STATUS_SUCCESS;
2669 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2670 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002671
2672 if(!pSession)
2673 {
2674 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2675 return eHAL_STATUS_FAILURE;
2676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002677
2678 // If no BSS description was found in this connection (happens with start IBSS), then
2679 // nix the BSS description that we keep around for the connected BSS) and get out...
2680 if(NULL == pBssDesc)
2681 {
2682 csrFreeConnectBssDesc(pMac, sessionId);
2683 }
2684 else
2685 {
2686 size = pBssDesc->length + sizeof( pBssDesc->length );
2687 if(NULL != pSession->pConnectBssDesc)
2688 {
2689 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2690 {
2691 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2692 csrFreeConnectBssDesc(pMac, sessionId);
2693 }
2694 }
2695 if(NULL == pSession->pConnectBssDesc)
2696 {
2697 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2698 }
2699 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2700 {
2701 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2702 }
2703 }
2704
2705 return (status);
2706}
2707
Jeff Johnson295189b2012-06-20 16:38:30 -07002708eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2709 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2710 tDot11fBeaconIEs *pIes)
2711{
2712 eHalStatus status = eHAL_STATUS_SUCCESS;
2713 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302715 if (pIes == NULL)
2716 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002717
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 do
2719 {
2720 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2721 //get qos
2722 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2723 //get SSID
2724 if(pIes->SSID.present)
2725 {
2726 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2727 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2728 }
2729 else
2730 pBssConfig->SSID.length = 0;
2731 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002733 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 //Return failed if profile doesn't have an SSID either.
2735 if(pProfile->SSIDs.numOfSSIDs == 0)
2736 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002737 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 status = eHAL_STATUS_FAILURE;
2739 break;
2740 }
2741 }
2742 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2743 {
2744 pBssConfig->eBand = eCSR_BAND_5G;
2745 }
2746 else
2747 {
2748 pBssConfig->eBand = eCSR_BAND_24;
2749 }
2750 //phymode
2751 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2752 {
2753 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2754 }
2755 else
2756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002757 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 //force it
2759 if(eCSR_BAND_24 == pBssConfig->eBand)
2760 {
2761 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2762 }
2763 else
2764 {
2765 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2766 }
2767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 //Qos
2769 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2770 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2771 {
2772 //Joining BSS is not 11n capable and WMM is disabled on client.
2773 //Disable QoS and WMM
2774 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2775 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302776
2777 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302778 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302779 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2780 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2781 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2782 {
2783 //Joining BSS is 11n capable and WMM is disabled on AP.
2784 //Assume all HT AP's are QOS AP's and enable WMM
2785 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2786 }
2787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 //auth type
2789 switch( pProfile->negotiatedAuthType )
2790 {
2791 default:
2792 case eCSR_AUTH_TYPE_WPA:
2793 case eCSR_AUTH_TYPE_WPA_PSK:
2794 case eCSR_AUTH_TYPE_WPA_NONE:
2795 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2796 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2797 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 case eCSR_AUTH_TYPE_SHARED_KEY:
2799 pBssConfig->authType = eSIR_SHARED_KEY;
2800 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 case eCSR_AUTH_TYPE_AUTOSWITCH:
2802 pBssConfig->authType = eSIR_AUTO_SWITCH;
2803 break;
2804 }
2805 //short slot time
2806 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2807 {
2808 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2809 }
2810 else
2811 {
2812 pBssConfig->uShortSlotTime = 0;
2813 }
2814 if(pBssConfig->BssCap.ibss)
2815 {
2816 //We don't support 11h on IBSS
2817 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2818 }
2819 else
2820 {
2821 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2822 }
2823 //power constraint
2824 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2825 //heartbeat
2826 if ( CSR_IS_11A_BSS( pBssDesc ) )
2827 {
2828 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2829 }
2830 else
2831 {
2832 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2833 }
2834 //Join timeout
2835 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002836 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 if ( pBssDesc->beaconInterval )
2838 {
2839 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002840 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 }
2842 else
2843 {
2844 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2845 }
2846 //validate CB
2847 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2848 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 return (status);
2850}
2851
Jeff Johnson295189b2012-06-20 16:38:30 -07002852static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2853 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2854{
2855 eHalStatus status = eHAL_STATUS_SUCCESS;
2856 tANI_U8 operationChannel = 0;
2857 tANI_U8 qAPisEnabled = FALSE;
2858 //SSID
2859 pBssConfig->SSID.length = 0;
2860 if(pProfile->SSIDs.numOfSSIDs)
2861 {
2862 //only use the first one
2863 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2864 }
2865 else
2866 {
2867 //SSID must present
2868 return eHAL_STATUS_FAILURE;
2869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 //Settomg up the capabilities
2871 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2872 {
2873 pBssConfig->BssCap.ibss = 1;
2874 }
2875 else
2876 {
2877 pBssConfig->BssCap.ess = 1;
2878 }
2879 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2880 {
2881 pBssConfig->BssCap.privacy = 1;
2882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 pBssConfig->eBand = pMac->roam.configParam.eBand;
2884 //phymode
2885 if(pProfile->ChannelInfo.ChannelList)
2886 {
2887 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2890 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 //QOS
2892 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 if ( pBssConfig->BssCap.ess == 1 )
2894 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 /*For Softap case enable WMM*/
2896 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2897 qAPisEnabled = TRUE;
2898 }
2899 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2901 qAPisEnabled = TRUE;
2902 } else {
2903 qAPisEnabled = FALSE;
2904 }
2905 } else {
2906 qAPisEnabled = TRUE;
2907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2909 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2910 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2911 )
2912 {
2913 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2914 } else {
2915 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2916 }
2917
2918 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002919 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 {
2921 default:
2922 case eCSR_AUTH_TYPE_WPA:
2923 case eCSR_AUTH_TYPE_WPA_PSK:
2924 case eCSR_AUTH_TYPE_WPA_NONE:
2925 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2926 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2927 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 case eCSR_AUTH_TYPE_SHARED_KEY:
2929 pBssConfig->authType = eSIR_SHARED_KEY;
2930 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 case eCSR_AUTH_TYPE_AUTOSWITCH:
2932 pBssConfig->authType = eSIR_AUTO_SWITCH;
2933 break;
2934 }
2935 //short slot time
2936 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2937 {
2938 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2939 }
2940 else
2941 {
2942 pBssConfig->uShortSlotTime = 0;
2943 }
2944 //power constraint. We don't support 11h on IBSS
2945 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2946 pBssConfig->uPowerLimit = 0;
2947 //heartbeat
2948 if ( eCSR_BAND_5G == pBssConfig->eBand )
2949 {
2950 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2951 }
2952 else
2953 {
2954 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2955 }
2956 //Join timeout
2957 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002958
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 return (status);
2960}
Jeff Johnson295189b2012-06-20 16:38:30 -07002961static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2962{
2963 eHalStatus status = eHAL_STATUS_FAILURE;
2964 tDot11fBeaconIEs *pIes = NULL;
2965
2966 do
2967 {
2968 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2969 {
2970 //err msg
2971 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002972 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 break;
2974 }
2975 //check if the AP is QAP & it supports APSD
2976 if( CSR_IS_QOS_BSS(pIes) )
2977 {
2978 return eHAL_STATUS_SUCCESS;
2979 }
2980 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 return status;
2982}
2983
Jeff Johnson295189b2012-06-20 16:38:30 -07002984void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2985{
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2987 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2988 // See !!Note: below in this function...
2989 tANI_U32 PrivacyEnabled = 0;
2990 tANI_U32 RsnEnabled = 0;
2991 tANI_U32 WepDefaultKeyId = 0;
2992 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2993 tANI_U32 Key0Length = 0;
2994 tANI_U32 Key1Length = 0;
2995 tANI_U32 Key2Length = 0;
2996 tANI_U32 Key3Length = 0;
2997
2998 // Reserve for the biggest key
2999 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3000 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3001 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3002 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3003
3004 switch ( pProfile->negotiatedUCEncryptionType )
3005 {
3006 case eCSR_ENCRYPT_TYPE_NONE:
3007
3008 // for NO encryption, turn off Privacy and Rsn.
3009 PrivacyEnabled = 0;
3010 RsnEnabled = 0;
3011
3012 // WEP key length and Wep Default Key ID don't matter in this case....
3013
3014 // clear out the WEP keys that may be hanging around.
3015 Key0Length = 0;
3016 Key1Length = 0;
3017 Key2Length = 0;
3018 Key3Length = 0;
3019
3020 break;
3021
3022 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303023 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003024
3025 // Privacy is ON. NO RSN for Wep40 static key.
3026 PrivacyEnabled = 1;
3027 RsnEnabled = 0;
3028
3029 // Set the Wep default key ID.
3030 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 // Wep key size if 5 bytes (40 bits).
3032 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3033
3034 // set encryption keys in the CFG database or clear those that are not present in this profile.
3035 if ( pProfile->Keys.KeyLength[0] )
3036 {
3037 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3038 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3039 }
3040 else
3041 {
3042 Key0Length = 0;
3043 }
3044
3045 if ( pProfile->Keys.KeyLength[1] )
3046 {
3047 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3048 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3049 }
3050 else
3051 {
3052 Key1Length = 0;
3053 }
3054
3055 if ( pProfile->Keys.KeyLength[2] )
3056 {
3057 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3058 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3059 }
3060 else
3061 {
3062 Key2Length = 0;
3063 }
3064
3065 if ( pProfile->Keys.KeyLength[3] )
3066 {
3067 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3068 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3069 }
3070 else
3071 {
3072 Key3Length = 0;
3073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 break;
3075
3076 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303077 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003078
3079 // Privacy is ON. NO RSN for Wep40 static key.
3080 PrivacyEnabled = 1;
3081 RsnEnabled = 0;
3082
3083 // Set the Wep default key ID.
3084 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3085
3086 // Wep key size if 13 bytes (104 bits).
3087 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3088
3089 // set encryption keys in the CFG database or clear those that are not present in this profile.
3090 if ( pProfile->Keys.KeyLength[0] )
3091 {
3092 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3093 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3094 }
3095 else
3096 {
3097 Key0Length = 0;
3098 }
3099
3100 if ( pProfile->Keys.KeyLength[1] )
3101 {
3102 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3103 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3104 }
3105 else
3106 {
3107 Key1Length = 0;
3108 }
3109
3110 if ( pProfile->Keys.KeyLength[2] )
3111 {
3112 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3113 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3114 }
3115 else
3116 {
3117 Key2Length = 0;
3118 }
3119
3120 if ( pProfile->Keys.KeyLength[3] )
3121 {
3122 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3123 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3124 }
3125 else
3126 {
3127 Key3Length = 0;
3128 }
3129
3130 break;
3131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 case eCSR_ENCRYPT_TYPE_TKIP:
3133 case eCSR_ENCRYPT_TYPE_AES:
3134#ifdef FEATURE_WLAN_WAPI
3135 case eCSR_ENCRYPT_TYPE_WPI:
3136#endif /* FEATURE_WLAN_WAPI */
3137 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3138 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3139 PrivacyEnabled = (0 != fPrivacy);
3140
3141 // turn on RSN enabled for WPA associations
3142 RsnEnabled = 1;
3143
3144 // WEP key length and Wep Default Key ID don't matter in this case....
3145
3146 // clear out the static WEP keys that may be hanging around.
3147 Key0Length = 0;
3148 Key1Length = 0;
3149 Key2Length = 0;
3150 Key3Length = 0;
3151
3152 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 default:
3154 PrivacyEnabled = 0;
3155 RsnEnabled = 0;
3156 break;
3157 }
3158
3159 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3160 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3161 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3162 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3163 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3164 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3165 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3166 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3167}
3168
Jeff Johnson295189b2012-06-20 16:38:30 -07003169static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3170{
3171 tANI_U32 len = 0;
3172 if(pSSID->length <= WNI_CFG_SSID_LEN)
3173 {
3174 len = pSSID->length;
3175 }
3176 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3177}
3178
Jeff Johnson295189b2012-06-20 16:38:30 -07003179eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3180{
3181 eHalStatus status = eHAL_STATUS_SUCCESS;
3182 tANI_U32 QoSEnabled;
3183 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 // set the CFG enable/disable variables based on the qosType being configured...
3185 switch( qosType )
3186 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3188 QoSEnabled = FALSE;
3189 WmeEnabled = TRUE;
3190 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3192 QoSEnabled = FALSE;
3193 WmeEnabled = TRUE;
3194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3196 QoSEnabled = FALSE;
3197 WmeEnabled = TRUE;
3198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3200 QoSEnabled = TRUE;
3201 WmeEnabled = FALSE;
3202 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 case eCSR_MEDIUM_ACCESS_11e_HCF:
3204 QoSEnabled = TRUE;
3205 WmeEnabled = FALSE;
3206 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 default:
3208 case eCSR_MEDIUM_ACCESS_DCF:
3209 QoSEnabled = FALSE;
3210 WmeEnabled = FALSE;
3211 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 }
3213 //save the WMM setting for later use
3214 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3216 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 return (status);
3218}
Jeff Johnson295189b2012-06-20 16:38:30 -07003219static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3220 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3221{
3222 eHalStatus status = eHAL_STATUS_FAILURE;
3223 int i;
3224 eCsrCfgDot11Mode cfgDot11Mode;
3225 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3227 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003229
3230 if( NULL != pIes )
3231 {
3232 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 // Originally, we thought that for 11a networks, the 11a rates are always
3234 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3235 // appear in the Operational Rate set. Consequently, in either case, we
3236 // would blindly put the rates we support into our Operational Rate set
3237 // (including the basic rates, which we have already verified are
3238 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 // However, it turns out that this is not always the case. Some AP's
3240 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3241 // too. Now, we're a little more careful:
3242 pDstRate = pOpRateSet->rate;
3243 if(pIes->SuppRates.present)
3244 {
3245 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3246 {
3247 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3248 {
3249 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003250 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 }
3252 }
3253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3255 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3256 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3257 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3258 {
3259 // If there are Extended Rates in the beacon, we will reflect those
3260 // extended rates that we support in out Extended Operational Rate
3261 // set:
3262 pDstRate = pExRateSet->rate;
3263 if(pIes->ExtSuppRates.present)
3264 {
3265 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3266 {
3267 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3268 {
3269 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3270 pExRateSet->numRates++;
3271 }
3272 }
3273 }
3274 }
3275 }//Parsing BSSDesc
3276 else
3277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003278 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 }
3280 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3281 return status;
3282}
3283
3284static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3285 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3286{
3287 int i;
3288 tANI_U8 *pDstRate;
3289 eCsrCfgDot11Mode cfgDot11Mode;
3290 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3291 tANI_U32 OperationalRatesLength = 0;
3292 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3293 tANI_U32 ExtendedOperationalRatesLength = 0;
3294 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3295 tANI_U32 ProprietaryOperationalRatesLength = 0;
3296 tANI_U32 PropRatesEnable = 0;
3297 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3298 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 if( NULL != pIes )
3301 {
3302 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 // Originally, we thought that for 11a networks, the 11a rates are always
3304 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3305 // appear in the Operational Rate set. Consequently, in either case, we
3306 // would blindly put the rates we support into our Operational Rate set
3307 // (including the basic rates, which we have already verified are
3308 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 // However, it turns out that this is not always the case. Some AP's
3310 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3311 // too. Now, we're a little more careful:
3312 pDstRate = OperationalRates;
3313 if(pIes->SuppRates.present)
3314 {
3315 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3316 {
3317 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3318 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3319 {
3320 *pDstRate++ = pIes->SuppRates.rates[ i ];
3321 OperationalRatesLength++;
3322 }
3323 }
3324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3326 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3327 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3328 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3329 {
3330 // If there are Extended Rates in the beacon, we will reflect those
3331 // extended rates that we support in out Extended Operational Rate
3332 // set:
3333 pDstRate = ExtendedOperationalRates;
3334 if(pIes->ExtSuppRates.present)
3335 {
3336 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3337 {
3338 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3339 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3340 {
3341 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3342 ExtendedOperationalRatesLength++;
3343 }
3344 }
3345 }
3346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 // Enable proprietary MAC features if peer node is Airgo node and STA
3348 // user wants to use them
3349 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3350 {
3351 PropRatesEnable = 1;
3352 }
3353 else
3354 {
3355 PropRatesEnable = 0;
3356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 // For ANI network companions, we need to populate the proprietary rate
3358 // set with any proprietary rates we found in the beacon, only if user
3359 // allows them...
3360 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3361 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3362 {
3363 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3364 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3365 {
3366 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3367 }
3368 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3369 }
3370 else {
3371 // No proprietary modes...
3372 ProprietaryOperationalRatesLength = 0;
3373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 /* Get MCS Rate */
3375 pDstRate = MCSRateIdxSet;
3376 if ( pIes->HTCaps.present )
3377 {
3378 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3379 {
3380 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3381 {
3382 MCSRateLength++;
3383 *pDstRate++ = i;
3384 }
3385 }
3386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 // Set the operational rate set CFG variables...
3388 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3389 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3390 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3391 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3392 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3393 ProprietaryOperationalRates,
3394 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3395 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3396 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3397 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3398 }//Parsing BSSDesc
3399 else
3400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003401 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 }
3403}
3404
Jeff Johnson295189b2012-06-20 16:38:30 -07003405static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3406 tCsrRoamProfile *pProfile )
3407{
3408 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3409 { 8,
3410 { SIR_MAC_RATE_6,
3411 SIR_MAC_RATE_9,
3412 SIR_MAC_RATE_12,
3413 SIR_MAC_RATE_18,
3414 SIR_MAC_RATE_24,
3415 SIR_MAC_RATE_36,
3416 SIR_MAC_RATE_48,
3417 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3419 { 4,
3420 { SIR_MAC_RATE_1,
3421 SIR_MAC_RATE_2,
3422 SIR_MAC_RATE_5_5,
3423 SIR_MAC_RATE_11 } } };
3424
3425
3426 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3427 { SIR_MAC_RATE_72,
3428 SIR_MAC_RATE_96,
3429 SIR_MAC_RATE_108 } };
3430 eCsrCfgDot11Mode cfgDot11Mode;
3431 eCsrBand eBand;
3432 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3433 tANI_U32 OperationalRatesLength = 0;
3434 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3435 tANI_U32 ExtendedOperationalRatesLength = 0;
3436 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3437 tANI_U32 ProprietaryOperationalRatesLength = 0;
3438 tANI_U32 PropRatesEnable = 0;
3439 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 if(pProfile->ChannelInfo.ChannelList)
3441 {
3442 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3446 // networks, the 11b rates appear in the Operational Rate set. In either case,
3447 // we can blindly put the rates we support into our Operational Rate set
3448 // (including the basic rates, which we have already verified are supported
3449 // earlier in the roaming decision).
3450 if ( eCSR_BAND_5G == eBand )
3451 {
3452 // 11a rates into the Operational Rate Set.
3453 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3454 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3455 palCopyMemory( pMac->hHdd, OperationalRates,
3456 DefaultSupportedRates11a.supportedRateSet.rate,
3457 OperationalRatesLength );
3458
3459 // Nothing in the Extended rate set.
3460 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 // populate proprietary rates if user allows them
3462 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3463 {
3464 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3465 sizeof(*DefaultSupportedPropRates.propRate);
3466 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3467 DefaultSupportedPropRates.propRate,
3468 ProprietaryOperationalRatesLength );
3469 }
3470 else
3471 {
3472 // No proprietary modes
3473 ProprietaryOperationalRatesLength = 0;
3474 }
3475 }
3476 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3477 {
3478 // 11b rates into the Operational Rate Set.
3479 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3480 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3481 palCopyMemory( pMac->hHdd, OperationalRates,
3482 DefaultSupportedRates11b.supportedRateSet.rate,
3483 OperationalRatesLength );
3484 // Nothing in the Extended rate set.
3485 ExtendedOperationalRatesLength = 0;
3486 // No proprietary modes
3487 ProprietaryOperationalRatesLength = 0;
3488 }
3489 else
3490 {
3491 // 11G
3492
3493 // 11b rates into the Operational Rate Set.
3494 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3495 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3496 palCopyMemory( pMac->hHdd, OperationalRates,
3497 DefaultSupportedRates11b.supportedRateSet.rate,
3498 OperationalRatesLength );
3499
3500 // 11a rates go in the Extended rate set.
3501 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3502 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3503 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3504 DefaultSupportedRates11a.supportedRateSet.rate,
3505 ExtendedOperationalRatesLength );
3506
3507 // populate proprietary rates if user allows them
3508 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3509 {
3510 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3511 sizeof(*DefaultSupportedPropRates.propRate);
3512 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3513 DefaultSupportedPropRates.propRate,
3514 ProprietaryOperationalRatesLength );
3515 }
3516 else
3517 {
3518 // No proprietary modes
3519 ProprietaryOperationalRatesLength = 0;
3520 }
3521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3523 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3524 {
3525 PropRatesEnable = 1;
3526 }
3527 else
3528 {
3529 PropRatesEnable = 0;
3530 }
3531
3532 // Set the operational rate set CFG variables...
3533 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3534 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3535 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3536 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3537 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3538 ProprietaryOperationalRates,
3539 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3540 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003541}
Jeff Johnson295189b2012-06-20 16:38:30 -07003542void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3543{
3544 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003545
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3547 tANI_U32 sessionId;
3548 tSmeCmd *pCommand = NULL;
3549
3550 if(NULL == pEntry)
3551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003552 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 return;
3554 }
3555 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3556 sessionId = pCommand->sessionId;
3557
3558 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3559 {
3560 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3561 }
3562}
3563
Jeff Johnson295189b2012-06-20 16:38:30 -07003564//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3565tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3566{
3567 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3568 {
3569 return (WNI_CFG_PHY_MODE_11B);
3570 }
3571 else
3572 {
3573 if(eCSR_BAND_24 == band)
3574 return (WNI_CFG_PHY_MODE_11G);
3575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 return (WNI_CFG_PHY_MODE_11A);
3577}
Jeff Johnson295189b2012-06-20 16:38:30 -07003578
Jeff Johnsone7245742012-09-05 17:12:55 -07003579
3580#ifdef WLAN_FEATURE_11AC
3581ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3582{
3583 switch ( aniCBMode )
3584 {
3585 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3586 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3587 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3588 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3589 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3590 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3591 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3592 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3593 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003594 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003595 return PHY_SINGLE_CHANNEL_CENTERED;
3596 }
3597}
3598#endif
3599
Jeff Johnson295189b2012-06-20 16:38:30 -07003600//pIes may be NULL
3601eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3602 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303603 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003604{
3605 eHalStatus status = eHAL_STATUS_SUCCESS;
3606 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3607 tANI_U8 channel = 0;
3608 //Make sure we have the domain info for the BSS we try to connect to.
3609 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303610 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303612 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 {
3614 //Make sure the 11d info from this BSSDesc can be applied
3615 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303616 if (VOS_TRUE == resetCountry)
3617 {
3618 csrApplyCountryInformation(pMac, FALSE);
3619 }
3620 else
3621 {
3622 csrApplyCountryInformation(pMac, TRUE);
3623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 }
Kiran4a17ebe2013-01-31 10:43:43 -08003625 if ((csrIs11dSupported (pMac)) && pIes)
3626 {
3627 if (!pIes->Country.present)
3628 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 //Qos
3632 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3633 //SSID
3634 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3635 //fragment threshold
3636 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3637 //RTS threshold
3638 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3639
3640 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3641
3642 //Auth type
3643 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3644 //encryption type
3645 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3646 //short slot time
3647 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 //11d
3649 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3650 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3651 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 /*//11h
3653 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3654 */
3655 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3656 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003657
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003658 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 {
3660 channel = pProfile->operationChannel;
3661 }
3662 else
3663 {
3664 if(pBssDesc)
3665 {
3666 channel = pBssDesc->channelId;
3667 }
3668 }
3669 if(0 != channel)
3670 {
3671 if(CSR_IS_CHANNEL_24GHZ(channel))
3672 {//for now if we are on 2.4 Ghz, CB will be always disabled
3673 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3674 }
3675 else
3676 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003677 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 }
3679 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003680#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003681 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3682 // in function csrConvertCBIniValueToPhyCBState()
3683 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3684 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003685 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003686 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003687 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003688 }
3689 else
3690 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003691 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003692 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003693 }
3694 else
3695#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3697 //Rate
3698 //Fixed Rate
3699 if(pBssDesc)
3700 {
3701 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3702 }
3703 else
3704 {
3705 csrSetCfgRateSetFromProfile(pMac, pProfile);
3706 }
3707 //Make this the last CFG to set. The callback will trigger a join_req
3708 //Join time out
3709 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3710
3711 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return (status);
3713}
3714
Jeff Johnson295189b2012-06-20 16:38:30 -07003715eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3716 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3717{
3718 eHalStatus status;
3719 tBssConfigParam *pBssConfig;
3720 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003721
3722 if(!pSession)
3723 {
3724 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3725 return eHAL_STATUS_FAILURE;
3726 }
3727
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3729 if(HAL_STATUS_SUCCESS(status))
3730 {
3731 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3732 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3733 if(HAL_STATUS_SUCCESS(status))
3734 {
3735 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003736 /* This will allow to pass cbMode during join req */
3737 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 //For IBSS, we need to prepare some more information
3739 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 )
3742 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003743 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 }
3745 // If we are in an IBSS, then stop the IBSS...
3746 ////Not worry about WDS connection for now
3747 if ( csrIsConnStateIbss( pMac, sessionId ) )
3748 {
3749 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3750 }
3751 else
3752 {
3753 // if we are in an Infrastructure association....
3754 if ( csrIsConnStateInfra( pMac, sessionId ) )
3755 {
3756 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3757 // across SSIDs (roaming to a new SSID)... //
3758 //Not worry about WDS connection for now
3759 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303760 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 {
3762 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303763 status = csrRoamIssueDisassociate( pMac, sessionId,
3764 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303766 else
3767 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3769 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303770 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303772 // Set parameters for this Bss.
3773 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3774 pBssDesc, pBssConfig,
3775 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303779 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 {
3781 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3782 // Nothing to stop.
3783 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303785 )
3786 {
3787 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3788 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3789 // Set parameters for this Bss.
3790 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3791 pBssDesc, pBssConfig,
3792 pIes, is11rRoamingFlag);
3793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 }
3795 }
3796 }//Success getting BSS config info
3797 palFreeMemory(pMac->hHdd, pBssConfig);
3798 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 return (status);
3800}
3801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3803 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3804{
3805 eCsrJoinState eRoamState = eCsrContinueRoaming;
3806 eHalStatus status;
3807 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3808 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003810
3811 if(!pSession)
3812 {
3813 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3814 return (eCsrStopRoaming);
3815 }
3816
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 if( CSR_IS_WDS_STA( pProfile ) )
3818 {
3819 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3820 if( !HAL_STATUS_SUCCESS( status ) )
3821 {
3822 eRoamState = eCsrStopRoaming;
3823 }
3824 }
3825 else
3826 {
3827 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3828 {
3829 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3830 return (eCsrStopRoaming);
3831 }
3832 if ( csrIsInfraBssDesc( pBssDesc ) )
3833 {
3834 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3835 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3836 // have changed and handle the changes (without disturbing the current association).
3837
3838 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3839 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3840 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3841 )
3842 {
3843 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3844 // with Authenticating first. To force this, stop the current association (Disassociate) and
3845 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3846 // a new Association.
3847 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003849 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3851 {
3852 eRoamState = eCsrReassocToSelfNoCapChange;
3853 }
3854 else
3855 {
3856 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 //The key changes
3858 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3859 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3860 if(HAL_STATUS_SUCCESS(status))
3861 {
3862 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003863 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303865 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3866 pBssDesc, &bssConfig,
3867 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 if(!HAL_STATUS_SUCCESS(status))
3869 {
3870 eRoamState = eCsrStopRoaming;
3871 }
3872 }
3873 else
3874 {
3875 eRoamState = eCsrStopRoaming;
3876 }
3877 }//same profile
3878 }
3879 else
3880 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303881 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003884 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303888 }
3889 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 {
3891 // 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 +05303892 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 // work much better.
3894 //
3895 //
3896 // stop the existing network before attempting to join the new network...
3897 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3898 {
3899 eRoamState = eCsrStopRoaming;
3900 }
3901 }
3902 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303903 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 {
3905 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3906 {
3907 eRoamState = eCsrStopRoaming;
3908 }
3909 }
3910 if( pIesLocal && !pScanResult->pvIes )
3911 {
3912 palFreeMemory(pMac->hHdd, pIesLocal);
3913 }
3914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 return( eRoamState );
3916}
3917
Jeff Johnson295189b2012-06-20 16:38:30 -07003918eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3919 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3920{
3921 eHalStatus status = eHAL_STATUS_SUCCESS;
3922 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3924 roamInfo.pBssDesc = pBssDesc;
3925 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3926 return (status);
3927}
Jeff Johnson295189b2012-06-20 16:38:30 -07003928//In case no matching BSS is found, use whatever default we can find
3929static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3930{
3931 //Need to get all negotiated types in place first
3932 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003933 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 {
3935 default:
3936 case eCSR_AUTH_TYPE_WPA:
3937 case eCSR_AUTH_TYPE_WPA_PSK:
3938 case eCSR_AUTH_TYPE_WPA_NONE:
3939 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3940 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3941 break;
3942
3943 case eCSR_AUTH_TYPE_SHARED_KEY:
3944 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3945 break;
3946
3947 case eCSR_AUTH_TYPE_AUTOSWITCH:
3948 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3949 break;
3950 }
3951 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3952 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3953 //In this case, the multicast encryption needs to follow the uncast ones.
3954 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3955 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3956}
3957
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003958
3959static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3960{
3961 switch(pCommand->u.roamCmd.roamReason)
3962 {
3963 case eCsrLostLink1:
3964 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3965 break;
3966 case eCsrLostLink2:
3967 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3968 break;
3969 case eCsrLostLink3:
3970 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3971 break;
3972 default:
3973 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3974 pCommand->u.roamCmd.roamReason);
3975 break;
3976 }
3977}
3978
Jeff Johnson295189b2012-06-20 16:38:30 -07003979static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3980{
3981 eHalStatus status;
3982 tCsrScanResult *pScanResult = NULL;
3983 eCsrJoinState eRoamState = eCsrStopRoaming;
3984 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3985 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3986 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3987#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3988 v_U8_t acm_mask = 0;
3989#endif
3990 tANI_U32 sessionId = pCommand->sessionId;
3991 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3992 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3993 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003994
3995 if(!pSession)
3996 {
3997 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3998 return (eCsrStopRoaming);
3999 }
4000
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 do
4002 {
4003 // Check for Cardbus eject condition, before trying to Roam to any BSS
4004 //***if( !balIsCardPresent(pAdapter) ) break;
4005
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004006 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4007 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 if(NULL != pBSSList)
4009 {
4010 // When handling AP's capability change, continue to associate to
4011 // same BSS and make sure pRoamBssEntry is not Null.
4012 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4013 {
4014 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4015 {
4016 //Try the first BSS
4017 pCommand->u.roamCmd.pLastRoamBss = NULL;
4018 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4019 }
4020 else
4021 {
4022 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4023 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4024 {
4025 //Done with all the BSSs
4026 //In this case, will tell HDD the completion
4027 break;
4028 }
4029 else
4030 {
4031 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004032 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4034 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4035 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4036 pRoamInfo = &roamInfo;
4037 }
4038 }
4039 while(pCommand->u.roamCmd.pRoamBssEntry)
4040 {
4041 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 /*If concurrency enabled take the concurrent connected channel first. */
4043 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004044 if (vos_concurrent_sessions_running() &&
4045 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 {
4047 concurrentChannel =
4048 csrGetConcurrentOperationChannel(pMac);
4049 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004050 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 if ((concurrentChannel) &&
4052 (concurrentChannel ==
4053 pScanResult->Result.BssDescriptor.channelId))
4054 {
4055 //make this 0 because we do not want the
4056 //below check to pass as we don't want to
4057 //connect on other channel
4058 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4059 FL("Concurrent channel match =%d"),
4060 concurrentChannel);
4061 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
4063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004064
4065 if (!concurrentChannel)
4066 {
4067
4068 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4069 sessionId, &pScanResult->Result.BssDescriptor,
4070 pCommand->u.roamCmd.roamId)))
4071 {
4072 //Ok to roam this
4073 break;
4074 }
4075 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004076 else
4077 {
4078 eRoamState = eCsrStopRoamingDueToConcurrency;
4079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4081 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4082 {
4083 //Done with all the BSSs
4084 fDone = eANI_BOOLEAN_TRUE;
4085 break;
4086 }
4087 }
4088 if(fDone)
4089 {
4090 break;
4091 }
4092 }
4093 }
4094 //We have something to roam, tell HDD when it is infra.
4095 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4096 //For WDS, the indication is eCSR_ROAM_WDS_IND
4097 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4098 {
4099 if(pRoamInfo)
4100 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004101 if(pSession->bRefAssocStartCnt)
4102 {
4103 pSession->bRefAssocStartCnt--;
4104 //Complete the last association attemp because a new one is about to be tried
4105 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4106 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004108 }
4109 }
4110 /* If the roaming has stopped, not to continue the roaming command*/
4111 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4112 {
4113 //No need to complete roaming here as it already completes
4114 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4115 pCommand->u.roamCmd.roamReason);
4116 eRoamState = eCsrStopRoaming;
4117 csrSetAbortRoamingCommand(pMac, pCommand);
4118 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 }
4120 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4121 if(pScanResult)
4122 {
4123 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004126 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 fDone = eANI_BOOLEAN_TRUE;
4128 eRoamState = eCsrStopRoaming;
4129 break;
4130 }
4131 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4132 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4133 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4134 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4135 CSR_IS_QOS_BSS(pIesLocal) &&
4136 CSR_IS_UAPSD_BSS(pIesLocal) )
4137 {
4138#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4140 pIesLocal);
4141 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4142#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 }
4144 else
4145 {
4146 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4147 }
4148 if( pIesLocal && !pScanResult->Result.pvIes)
4149 {
4150 palFreeMemory(pMac->hHdd, pIesLocal);
4151 }
4152 }
4153 else
4154 {
4155 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4156 }
4157 roamInfo.pProfile = pProfile;
4158 pSession->bRefAssocStartCnt++;
4159 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4160 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4163 {
4164 // If this is a start IBSS profile, then we need to start the IBSS.
4165 if ( CSR_IS_START_IBSS(pProfile) )
4166 {
4167 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 // Attempt to start this IBSS...
4169 csrRoamAssignDefaultParam( pMac, pCommand );
4170 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4171 if(HAL_STATUS_SUCCESS(status))
4172 {
4173 if ( fSameIbss )
4174 {
4175 eRoamState = eCsrStartIbssSameIbss;
4176 }
4177 else
4178 {
4179 eRoamState = eCsrContinueRoaming;
4180 }
4181 }
4182 else
4183 {
4184 //it somehow fail need to stop
4185 eRoamState = eCsrStopRoaming;
4186 }
4187 break;
4188 }
4189 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 )
4192 {
4193 // Attempt to start this WDS...
4194 csrRoamAssignDefaultParam( pMac, pCommand );
4195 /* For AP WDS, we dont have any BSSDescription */
4196 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4197 if(HAL_STATUS_SUCCESS(status))
4198 {
4199 eRoamState = eCsrContinueRoaming;
4200 }
4201 else
4202 {
4203 //it somehow fail need to stop
4204 eRoamState = eCsrStopRoaming;
4205 }
4206 }
4207 else
4208 {
4209 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004210 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 eRoamState = eCsrStopRoaming;
4212 break;
4213 }
4214 }
4215 else //We have BSS
4216 {
4217 //Need to assign these value because they are used in csrIsSameProfile
4218 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4219 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4220 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4221 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4222 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4223 {
4224 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4225 {
4226 eRoamState = eCsrStartIbssSameIbss;
4227 break;
4228 }
4229 }
4230 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4231 {
4232 //trying to connect to the one already connected
4233 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4234 eRoamState = eCsrReassocToSelfNoCapChange;
4235 break;
4236 }
4237 // Attempt to Join this Bss...
4238 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4239 break;
4240 }
4241
4242 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4244 {
4245 //Need to indicate association_completion if association_start has been done
4246 if(pSession->bRefAssocStartCnt > 0)
4247 {
4248 pSession->bRefAssocStartCnt--;
4249 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004250 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4252 eCSR_ROAM_ASSOCIATION_COMPLETION,
4253 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4254 }
4255 }
4256
4257 return( eRoamState );
4258}
4259
Jeff Johnson295189b2012-06-20 16:38:30 -07004260static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4261{
4262 eHalStatus status = eHAL_STATUS_SUCCESS;
4263 eCsrJoinState RoamState;
4264 tANI_U32 sessionId = pCommand->sessionId;
4265
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 //***if( hddIsRadioStateOn( pAdapter ) )
4267 {
4268 // Attept to join a Bss...
4269 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004270
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004272 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 {
4274 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 // and if connected in Infrastructure mode...
4276 if ( csrIsConnStateInfra(pMac, sessionId) )
4277 {
4278 //... then we need to issue a disassociation
4279 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4280 if(!HAL_STATUS_SUCCESS(status))
4281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004282 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 //roam command is completed by caller in the failed case
4284 fComplete = eANI_BOOLEAN_TRUE;
4285 }
4286 }
4287 else if( csrIsConnStateIbss(pMac, sessionId) )
4288 {
4289 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4290 if(!HAL_STATUS_SUCCESS(status))
4291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004292 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 //roam command is completed by caller in the failed case
4294 fComplete = eANI_BOOLEAN_TRUE;
4295 }
4296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4298 {
4299 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4300 if(!HAL_STATUS_SUCCESS(status))
4301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004302 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 //roam command is completed by caller in the failed case
4304 fComplete = eANI_BOOLEAN_TRUE;
4305 }
4306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 else
4308 {
4309 fComplete = eANI_BOOLEAN_TRUE;
4310 }
4311 if(fComplete)
4312 {
4313 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004314 if(eCsrStopRoamingDueToConcurrency == RoamState)
4315 {
4316 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4317 }
4318 else
4319 {
4320 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 }
4323 }
4324 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4325 {
4326 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4327 }
4328 else if ( eCsrStartIbssSameIbss == RoamState )
4329 {
4330 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4331 }
4332 }//hddIsRadioStateOn
4333
4334 return status;
4335}
Jeff Johnson295189b2012-06-20 16:38:30 -07004336eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4337{
4338 tANI_U32 sessionId;
4339 tCsrRoamSession *pSession;
4340 tCsrScanResult *pScanResult = NULL;
4341 tSirBssDescription *pBssDesc = NULL;
4342 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 sessionId = pCommand->sessionId;
4344 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004345
4346 if(!pSession)
4347 {
4348 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4349 return eHAL_STATUS_FAILURE;
4350 }
4351
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4353 {
4354 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004355 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4357 return eHAL_STATUS_FAILURE;
4358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 if (pCommand->u.roamCmd.pRoamBssEntry)
4360 {
4361 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4362 pBssDesc = &pScanResult->Result.BssDescriptor;
4363 }
4364 else
4365 {
4366 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004367 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4369 return eHAL_STATUS_FAILURE;
4370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4372 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4373 return status;
4374}
4375
Jeff Johnson295189b2012-06-20 16:38:30 -07004376eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4377{
4378 eHalStatus status = eHAL_STATUS_SUCCESS;
4379 tCsrRoamInfo roamInfo;
4380 tANI_U32 sessionId = pCommand->sessionId;
4381 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004382
4383 if(!pSession)
4384 {
4385 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4386 return eHAL_STATUS_FAILURE;
4387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004388
4389 switch ( pCommand->u.roamCmd.roamReason )
4390 {
4391 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004393 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 case eCsrSmeIssuedDisassocForHandoff:
4396 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4397#if 0 // TODO : Confirm this change
4398 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4399#else
4400 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4401#endif
4402
4403 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004406 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004410 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 case eCsrHddIssuedReassocToSameAP:
4413 case eCsrSmeIssuedReassocToSameAP:
4414 {
4415 tDot11fBeaconIEs *pIes = NULL;
4416
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 if( pSession->pConnectBssDesc )
4418 {
4419 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4420 if(!HAL_STATUS_SUCCESS(status) )
4421 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004422 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 }
4424 else
4425 {
4426 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4427 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4428 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4430 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4431 pSession->bRefAssocStartCnt++;
4432 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4433 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4434
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004435 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004436 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4437 &pCommand->u.roamCmd.roamProfile );
4438 if(!HAL_STATUS_SUCCESS(status))
4439 {
4440 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004441 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004442 }
4443
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 palFreeMemory(pMac->hHdd, pIes);
4445 pIes = NULL;
4446 }
4447 }
4448 break;
4449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004451 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4453 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4454 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004456 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4458 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 case eCsrStopBss:
4461 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4462 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4463 break;
4464
4465 case eCsrForcedDisassocSta:
4466 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4467 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4468 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4469 pCommand->u.roamCmd.reason);
4470 break;
4471
4472 case eCsrForcedDeauthSta:
4473 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4474 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4475 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4476 pCommand->u.roamCmd.reason);
4477 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004478
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004479 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004480 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004481 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4482 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004483 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004484
4485 default:
4486 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4487
4488 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4489 {
4490 //Remember the roaming profile
4491 csrFreeRoamProfile(pMac, sessionId);
4492 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4493 {
4494 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4495 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4496 }
4497 }
4498
4499 //At this point, original uapsd_mask is saved in pCurRoamProfile
4500 //uapsd_mask in the pCommand may change from this point on.
4501
4502 // Attempt to roam with the new scan results (if we need to..)
4503 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004504 if(!HAL_STATUS_SUCCESS(status))
4505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004506 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 break;
4509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 return (status);
4511}
4512
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004513void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4514{
4515 pCommand->u.roamCmd.pLastRoamBss = NULL;
4516 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4517 //Because u.roamCmd is union and share with scanCmd and StatusChange
4518 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4519}
4520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4522{
4523 if(pCommand->u.roamCmd.fReleaseBssList)
4524 {
4525 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4526 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4527 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4528 }
4529 if(pCommand->u.roamCmd.fReleaseProfile)
4530 {
4531 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4532 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4533 }
4534 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4535 //Because u.roamCmd is union and share with scanCmd and StatusChange
4536 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4537}
4538
Jeff Johnson295189b2012-06-20 16:38:30 -07004539void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4540{
4541 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4542}
Jeff Johnson295189b2012-06-20 16:38:30 -07004543void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4544{
4545 tListElem *pEntry;
4546 tSmeCmd *pCommand;
4547 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004548 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4550 if ( pEntry )
4551 {
4552 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 // If the head of the queue is Active and it is a ROAM command, remove
4554 // and put this on the Free queue.
4555 if ( eSmeCommandRoam == pCommand->command )
4556 {
4557 //we need to process the result first before removing it from active list because state changes
4558 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4559 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4560 if( fReleaseCommand )
4561 {
4562 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4563 {
4564 csrReleaseCommandRoam( pMac, pCommand );
4565 }
4566 else
4567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004568 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004569 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 }
4571 }
4572 else
4573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004574 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004575 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 }
4577 }
4578 else
4579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004580 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 }
4582 }
4583 else
4584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004585 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 if( fReleaseCommand )
4588 {
4589 smeProcessPendingQueue( pMac );
4590 }
4591}
4592
Jeff Johnson295189b2012-06-20 16:38:30 -07004593void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4594{
4595 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004596 if(!pSession)
4597 {
4598 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4599 return;
4600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4602 pSession->NumPmkidCandidate = 0;
4603}
Jeff Johnson295189b2012-06-20 16:38:30 -07004604#ifdef FEATURE_WLAN_WAPI
4605void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4606{
4607 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004608 if(!pSession)
4609 {
4610 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4611 return;
4612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4614 pSession->NumBkidCandidate = 0;
4615}
4616#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004617extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4618
Jeff Johnson295189b2012-06-20 16:38:30 -07004619static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4620 tSirBssDescription *pSirBssDesc,
4621 tDot11fBeaconIEs *pIes)
4622{
4623 eHalStatus status = eHAL_STATUS_SUCCESS;
4624 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4625 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004626
4627 if(!pSession)
4628 {
4629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4630 return eHAL_STATUS_FAILURE;
4631 }
4632
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 if((eCSR_AUTH_TYPE_WPA == authType) ||
4634 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4635 (eCSR_AUTH_TYPE_RSN == authType) ||
4636 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4637#if defined WLAN_FEATURE_VOWIFI_11R
4638 ||
4639 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4640 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4641#endif /* FEATURE_WLAN_WAPI */
4642#ifdef FEATURE_WLAN_WAPI
4643 ||
4644 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4645 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4646#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004647#ifdef WLAN_FEATURE_11W
4648 ||
4649 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4650#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 )
4652 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004655 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 }
4657 if( pIesLocal )
4658 {
4659 tANI_U32 nIeLen;
4660 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 if((eCSR_AUTH_TYPE_RSN == authType) ||
4662#if defined WLAN_FEATURE_VOWIFI_11R
4663 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4664 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4665#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004666#if defined WLAN_FEATURE_11W
4667 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4668#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4670 {
4671 if(pIesLocal->RSN.present)
4672 {
4673 //Calculate the actual length
4674 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4675 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4676 + 2 //akm_suite_count
4677 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4678 + 2; //reserved
4679 if( pIesLocal->RSN.pmkid_count )
4680 {
4681 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4682 }
4683 //nIeLen doesn't count EID and length fields
4684 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4685 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004686 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4688 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4689 //copy upto akm_suites
4690 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004691 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4692 pIeBuf += sizeof(pIesLocal->RSN.version);
4693 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4694 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4695 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4696 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 if( pIesLocal->RSN.pwise_cipher_suite_count )
4698 {
4699 //copy pwise_cipher_suites
4700 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4701 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4702 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4703 }
4704 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4705 pIeBuf += 2;
4706 if( pIesLocal->RSN.akm_suite_count )
4707 {
4708 //copy akm_suites
4709 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4710 pIesLocal->RSN.akm_suite_count * 4);
4711 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4712 }
4713 //copy the rest
4714 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4715 pIesLocal->RSN.akm_suite_count * 4,
4716 2 + pIesLocal->RSN.pmkid_count * 4);
4717 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4718 }
4719 }
4720 }
4721 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4722 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4723 {
4724 if(pIesLocal->WPA.present)
4725 {
4726 //Calculate the actual length
4727 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4728 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4729 + 2 //auth_suite_count
4730 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4731 // The WPA capabilities follows the Auth Suite (two octects)--
4732 // this field is optional, and we always "send" zero, so just
4733 // remove it. This is consistent with our assumptions in the
4734 // frames compiler; c.f. bug 15234:
4735 //nIeLen doesn't count EID and length fields
4736 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4737 {
4738 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4739 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4740 pIeBuf = pSession->pWpaRsnRspIE + 2;
4741 //Copy WPA OUI
4742 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4743 pIeBuf += 4;
4744 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4745 pIesLocal->WPA.unicast_cipher_count * 4);
4746 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4747 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4748 pIesLocal->WPA.auth_suite_count * 4);
4749 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4750 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4751 }
4752 }
4753 }
4754#ifdef FEATURE_WLAN_WAPI
4755 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4756 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4757 {
4758 if(pIesLocal->WAPI.present)
4759 {
4760 //Calculate the actual length
4761 nIeLen = 4 //version + akm_suite_count
4762 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4763 + 2 //pwise_cipher_suite_count
4764 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4765 + 6; //gp_cipher_suite + preauth + reserved
4766 if( pIesLocal->WAPI.bkid_count )
4767 {
4768 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4769 }
4770
4771 //nIeLen doesn't count EID and length fields
4772 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4773 {
4774 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4775 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4776 pIeBuf = pSession->pWapiRspIE + 2;
4777 //copy upto akm_suite_count
lukez3c809222013-05-03 10:23:02 -07004778 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 pIeBuf += 4;
4780 if( pIesLocal->WAPI.akm_suite_count )
4781 {
4782 //copy akm_suites
4783 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4784 pIesLocal->WAPI.akm_suite_count * 4);
4785 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4786 }
4787 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4788 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4790 {
4791 //copy pwise_cipher_suites
4792 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4793 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4794 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4795 }
lukez3c809222013-05-03 10:23:02 -07004796 //gp_cipher_suite
4797 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite, 4);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304798 //preauth + reserved
4799 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite + 4, 2);
4800 //bkid_count
4801 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 pIeBuf += 8;
4803 if( pIesLocal->WAPI.bkid_count )
4804 {
4805 //copy akm_suites
4806 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4807 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4808 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304809 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 }
4812 }
4813#endif /* FEATURE_WLAN_WAPI */
4814 if( !pIes )
4815 {
4816 //locally allocated
4817 palFreeMemory(pMac->hHdd, pIesLocal);
4818 }
4819 }
4820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 return (status);
4822}
4823
Jeff Johnson295189b2012-06-20 16:38:30 -07004824static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4825{
4826 v_U8_t bACWeights[WLANTL_MAX_AC];
4827 v_U8_t paramBk, paramBe, paramVi, paramVo;
4828 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4830 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4831 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4832 //This doesn't address the case where the lower AC needs a real higher weight
4833 if( pIEs->WMMParams.present )
4834 {
4835 //no change to the lowest ones
4836 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4837 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4838 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4839 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4840 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4841 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4842 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4843 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4844 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4845 {
4846 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4847 fWeightChange = VOS_TRUE;
4848 }
4849 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4850 {
4851 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4852 fWeightChange = VOS_TRUE;
4853 }
4854 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4855 {
4856 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4857 fWeightChange = VOS_TRUE;
4858 }
4859 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4860 {
4861 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4862 fWeightChange = VOS_TRUE;
4863 }
4864 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4865 {
4866 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4867 fWeightChange = VOS_TRUE;
4868 }
4869 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4870 {
4871 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4872 fWeightChange = VOS_TRUE;
4873 }
4874 if(fWeightChange)
4875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004876 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 bACWeights[2], bACWeights[3]);
4878 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4879 }
4880 }
4881}
Jeff Johnson295189b2012-06-20 16:38:30 -07004882#ifdef WLAN_FEATURE_VOWIFI_11R
4883//Returns whether the current association is a 11r assoc or not
4884tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4885{
4886#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4887 return csrNeighborRoamIs11rAssoc(pMac);
4888#else
4889 return eANI_BOOLEAN_FALSE;
4890#endif
4891}
4892#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004893#ifdef FEATURE_WLAN_CCX
4894//Returns whether the current association is a CCX assoc or not
4895tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4896{
4897#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4898 return csrNeighborRoamIsCCXAssoc(pMac);
4899#else
4900 return eANI_BOOLEAN_FALSE;
4901#endif
4902}
4903#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004904#ifdef FEATURE_WLAN_LFR
4905//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304906tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004907{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304908 tCsrRoamSession *pSession = NULL;
4909
4910 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4911 {
4912 pSession = CSR_GET_SESSION( pMac, sessionId );
4913 if (NULL != pSession->pCurRoamProfile)
4914 {
4915 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4916 {
4917 return eANI_BOOLEAN_FALSE;
4918 }
4919 }
4920 }
4921
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004922#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4923 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4924 {
4925 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
4926 }
4927 else
4928#endif
4929 {
4930 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004931 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004932 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004933}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004934
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004935#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4936//Returns whether "FW based BG scan" is currently enabled...or not
4937tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4938{
4939 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4940}
4941#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004942#endif
4943
Jeff Johnson295189b2012-06-20 16:38:30 -07004944//Return true means the command can be release, else not
4945static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4946 eCsrRoamCompleteResult Result, void *Context )
4947{
4948 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4949 tSirBssDescription *pSirBssDesc = NULL;
4950 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4951 tCsrScanResult *pScanResult = NULL;
4952 tCsrRoamInfo roamInfo;
4953 sme_QosAssocInfo assocInfo;
4954 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4955 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4956 tDot11fBeaconIEs *pIes = NULL;
4957 tANI_U32 sessionId = pCommand->sessionId;
4958 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4959 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4960 eRoamCmdStatus roamStatus;
4961 eCsrRoamResult roamResult;
4962 eHalStatus status;
4963 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004965
Jeff Johnson32d95a32012-09-10 13:15:23 -07004966 if(!pSession)
4967 {
4968 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4969 return eANI_BOOLEAN_FALSE;
4970 }
4971
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004972 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 switch( Result )
4974 {
4975 case eCsrJoinSuccess:
4976 // reset the IDLE timer
4977 // !!
4978 // !! fall through to the next CASE statement here is intentional !!
4979 // !!
4980 case eCsrReassocSuccess:
4981 if(eCsrReassocSuccess == Result)
4982 {
4983 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4984 }
4985 else
4986 {
4987 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4988 }
4989 // Success Join Response from LIM. Tell NDIS we are connected and save the
4990 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004991 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4993 //always free the memory here
4994 if(pSession->pWpaRsnRspIE)
4995 {
4996 pSession->nWpaRsnRspIeLength = 0;
4997 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4998 pSession->pWpaRsnRspIE = NULL;
4999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005000#ifdef FEATURE_WLAN_WAPI
5001 if(pSession->pWapiRspIE)
5002 {
5003 pSession->nWapiRspIeLength = 0;
5004 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
5005 pSession->pWapiRspIE = NULL;
5006 }
5007#endif /* FEATURE_WLAN_WAPI */
5008#ifdef FEATURE_WLAN_BTAMP_UT_RF
5009 //Reset counter so no join retry is needed.
5010 pSession->maxRetryCount = 0;
5011 csrRoamStopJoinRetryTimer(pMac, sessionId);
5012#endif
5013 /* This creates problem since we have not saved the connected profile.
5014 So moving this after saving the profile
5015 */
5016 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5017 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5018 {
5019 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5020 }
5021 else
5022 {
5023 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 //Use the last connected bssdesc for reassoc-ing to the same AP.
5026 //NOTE: What to do when reassoc to a different AP???
5027 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5028 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5029 {
5030 pSirBssDesc = pSession->pConnectBssDesc;
5031 if(pSirBssDesc)
5032 {
5033 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5034 }
5035 }
5036 else
5037 {
5038
5039 if(pCommand->u.roamCmd.pRoamBssEntry)
5040 {
5041 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5042 if(pScanResult != NULL)
5043 {
5044 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5045 //this can be NULL
5046 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5047 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5048 }
5049 }
5050 }
5051 if( pSirBssDesc )
5052 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5055 //Save WPA/RSN IE
5056 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5057#ifdef FEATURE_WLAN_CCX
5058 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5059#endif
5060
5061 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5062 // substate change.
5063 // Moving even save profile above so that below mentioned conditon is also met.
5064 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5065 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5067 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5068 // will be dropped for the security context may not be set properly.
5069 //
5070 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5071 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5072 //
5073 // this reordering was done on titan_prod_usb branch and is being replicated here.
5074 //
5075
5076 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5077 !pProfile->bWPSAssociation)
5078 {
5079 // Issue the set Context request to LIM to establish the Unicast STA context
5080 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5081 pProfile->negotiatedUCEncryptionType,
5082 pSirBssDesc, &(pSirBssDesc->bssId),
5083 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005085 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5087 }
5088 // Issue the set Context request to LIM to establish the Broadcast STA context
5089 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5090 pSirBssDesc, &BroadcastMac,
5091 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5092 }
5093 else
5094 {
5095 //Need to wait for supplicant authtication
5096 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 //Set the subestate to WaitForKey in case authentiation is needed
5098 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5099
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 if(pProfile->bWPSAssociation)
5101 {
5102 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5103 }
5104 else
5105 {
5106 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5107 }
5108
5109 //Save sessionId in case of timeout
5110 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5111 //This time should be long enough for the rest of the process plus setting key
5112 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5113 {
5114 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005115 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5117 }
5118 }
5119
5120 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5121 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005122 if(Context)
5123 {
5124 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5125 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5127 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5128#ifdef WLAN_FEATURE_VOWIFI_11R
5129 len += pJoinRsp->parsedRicRspLen;
5130#endif /* WLAN_FEATURE_VOWIFI_11R */
5131#ifdef FEATURE_WLAN_CCX
5132 len += pJoinRsp->tspecIeLen;
5133#endif
5134 if(len)
5135 {
5136 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5137 (void **)&pSession->connectedInfo.pbFrames, len)))
5138 {
5139 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5140 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5141 {
5142 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5143 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5144 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5145#ifdef WLAN_FEATURE_VOWIFI_11R
5146 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5147#endif /* WLAN_FEATURE_VOWIFI_11R */
5148#ifdef FEATURE_WLAN_CCX
5149 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5150#endif
5151 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5152 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5153 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5154 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5155 }
5156 else
5157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005158 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005159 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5161 pSession->connectedInfo.pbFrames = NULL;
5162 }
5163 }
5164 }
5165 if(pCommand->u.roamCmd.fReassoc)
5166 {
5167 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5168 }
5169 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5170 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5171 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5172 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5173 }
5174 else
5175 {
5176 if(pCommand->u.roamCmd.fReassoc)
5177 {
5178 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5179 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5180 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5181 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5182 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5183 }
5184 }
5185#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5186 // Indicate SME-QOS with reassoc success event, only after
5187 // copying the frames
5188 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5189#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 roamInfo.pBssDesc = pSirBssDesc;
5191 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5192 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5193#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5194 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5195#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5196 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5198 //It may be better to let QoS do this????
5199 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5200 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005201 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5203 pmcStartUapsd( pMac, NULL, NULL );
5204 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305205 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5207 if( pSession->bRefAssocStartCnt > 0 )
5208 {
5209 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005210 //Remove this code once SLM_Sessionization is supported
5211 //BMPS_WORKAROUND_NOT_NEEDED
5212 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005213 {
5214 pMac->roam.configParam.doBMPSWorkaround = 1;
5215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5217 }
5218
5219 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 // reset the PMKID candidate list
5221 csrResetPMKIDCandidateList( pMac, sessionId );
5222 //Update TL's AC weight base on the current EDCA parameters
5223 //These parameters may change in the course of the connection, that sictuation
5224 //is not taken care here. This change is mainly to address a WIFI WMM test where
5225 //BE has a equal or higher TX priority than VI.
5226 //We only do this for infra link
5227 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5228 {
5229 csrCheckAndUpdateACWeight(pMac, pIes);
5230 }
5231#ifdef FEATURE_WLAN_WAPI
5232 // reset the BKID candidate list
5233 csrResetBKIDCandidateList( pMac, sessionId );
5234#endif /* FEATURE_WLAN_WAPI */
5235 }
5236 else
5237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005238 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 csrScanCancelIdleScan(pMac);
5241 //Not to signal link up because keys are yet to be set.
5242 //The linkup function will overwrite the sub-state that we need to keep at this point.
5243 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5244 {
5245 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5248 //enough to let security and DHCP handshake succeed before entry into BMPS
5249 if (pmcShouldBmpsTimerRun(pMac))
5250 {
5251 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5252 != eHAL_STATUS_SUCCESS)
5253 {
5254 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5255 }
5256 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 break;
5259
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 case eCsrStartBssSuccess:
5261 // on the StartBss Response, LIM is returning the Bss Description that we
5262 // are beaconing. Add this Bss Description to our scan results and
5263 // chain the Profile to this Bss Description. On a Start BSS, there was no
5264 // detected Bss description (no partner) so we issued the Start Bss to
5265 // start the Ibss without any Bss description. Lim was kind enough to return
5266 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005267 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5271 if( CSR_IS_IBSS( pProfile ) )
5272 {
5273 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 else if (CSR_IS_INFRA_AP(pProfile))
5276 {
5277 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 else
5280 {
5281 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5282 }
5283 if( !CSR_IS_WDS_STA( pProfile ) )
5284 {
5285 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005289 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 roamInfo.pBssDesc = pSirBssDesc;
5291 //We need to associate_complete it first, becasue Associate_start already indicated.
5292 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5293 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5294 break;
5295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005298 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 }
5300 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5301 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5302 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5303 if(pSirBssDesc)
5304 {
5305 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5306 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5307 }
5308 //We are doen with the IEs so free it
5309 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005310#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5311 {
5312 vos_log_ibss_pkt_type *pIbssLog;
5313 tANI_U32 bi;
5314
5315 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5316 if(pIbssLog)
5317 {
5318 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5319 {
5320 //We start the IBSS (didn't find any matched IBSS out there)
5321 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5322 }
5323 else
5324 {
5325 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5326 }
5327 if(pSirBssDesc)
5328 {
5329 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5330 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5331 }
5332 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5333 {
5334 //***U8 is not enough for beacon interval
5335 pIbssLog->beaconInterval = (v_U8_t)bi;
5336 }
5337 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5338 }
5339 }
5340#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5341 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5342 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5344 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5346 csrRoamIssueSetContextReq( pMac, sessionId,
5347 pProfile->negotiatedMCEncryptionType,
5348 pSirBssDesc, &BroadcastMac,
5349 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5350 }
5351 }
5352 else
5353 {
5354 //Keep the state to eCSR_ROAMING_STATE_JOINING
5355 //Need to send join_req.
5356 if(pCommand->u.roamCmd.pRoamBssEntry)
5357 {
5358 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5359 {
5360 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5361 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5362 // Set the roaming substate to 'join attempt'...
5363 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005364 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 }
5366 }
5367 else
5368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005369 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 VOS_ASSERT( 0 );
5371 }
5372 }
5373 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5374 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5375 //trigger the connection start indication in Vista
5376 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5377 {
5378 roamStatus = eCSR_ROAM_IBSS_IND;
5379 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5380 if( CSR_IS_WDS( pProfile ) )
5381 {
5382 roamStatus = eCSR_ROAM_WDS_IND;
5383 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 if( CSR_IS_INFRA_AP( pProfile ) )
5386 {
5387 roamStatus = eCSR_ROAM_INFRA_IND;
5388 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005390
5391 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5392 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5393 //trigger the connection start indication in Vista
5394 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5395 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5396 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005397 //We start the IBSS (didn't find any matched IBSS out there)
5398 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005400 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005401 //Remove this code once SLM_Sessionization is supported
5402 //BMPS_WORKAROUND_NOT_NEEDED
5403 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005404 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005405 {
5406 pMac->roam.configParam.doBMPSWorkaround = 1;
5407 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005408
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5410 }
5411
5412 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005413
5414 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 {
5416 //need to send stop BSS because we fail to send join_req
5417 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5418 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5419 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 case eCsrStartBssFailure:
5423#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5424 {
5425 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5427 if(pIbssLog)
5428 {
5429 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5430 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5431 }
5432 }
5433#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 roamStatus = eCSR_ROAM_IBSS_IND;
5435 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5436 if( CSR_IS_WDS( pProfile ) )
5437 {
5438 roamStatus = eCSR_ROAM_WDS_IND;
5439 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 if( CSR_IS_INFRA_AP( pProfile ) )
5442 {
5443 roamStatus = eCSR_ROAM_INFRA_IND;
5444 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 if(Context)
5447 {
5448 pSirBssDesc = (tSirBssDescription *)Context;
5449 }
5450 else
5451 {
5452 pSirBssDesc = NULL;
5453 }
5454 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5455 roamInfo.pBssDesc = pSirBssDesc;
5456 //We need to associate_complete it first, becasue Associate_start already indicated.
5457 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5458 csrSetDefaultDot11Mode( pMac );
5459 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 case eCsrSilentlyStopRoaming:
5461 // We are here because we try to start the same IBSS
5462 //No message to PE
5463 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005464 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5466 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5467 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5468 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5469 if( roamInfo.pBssDesc )
5470 {
5471 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5472 }
5473 //Since there is no change in the current state, simply pass back no result otherwise
5474 //HDD may be mistakenly mark to disconnected state.
5475 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5476 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 case eCsrSilentlyStopRoamingSaveState:
5479 //We are here because we try to connect to the same AP
5480 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005481 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5483
5484 //to aviod resetting the substate to NONE
5485 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5486 //No need to change substate to wai_for_key because there is no state change
5487 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5488 if( roamInfo.pBssDesc )
5489 {
5490 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5493 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5494 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5495 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5496 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5497 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5498 roamInfo.staId = pSession->connectedInfo.staId;
5499 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 pSession->bRefAssocStartCnt--;
5502 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5503 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5504 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 case eCsrReassocFailure:
5507#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5508 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5509#endif
5510 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005511 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 csrFreeConnectBssDesc(pMac, sessionId);
5513 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5514 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5515 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5516 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5517 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5518 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5519 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5520 eCSR_ROAM_WDS_IND,
5521 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5522 //Need to issue stop_bss
5523 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 case eCsrJoinFailure:
5525 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005526 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 default:
5528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005529 smsLog(pMac, LOGW, FL("receives no association indication"));
5530 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005531 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5533 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5534 {
5535 //do not free for the other profiles as we need to send down stop BSS later
5536 csrFreeConnectBssDesc(pMac, sessionId);
5537 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5538 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5539 csrSetDefaultDot11Mode( pMac );
5540 }
5541
5542 switch( pCommand->u.roamCmd.roamReason )
5543 {
5544 // If this transition is because of an 802.11 OID, then we transition
5545 // back to INIT state so we sit waiting for more OIDs to be issued and
5546 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005547 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 case eCsrSmeIssuedAssocToSimilarAP:
5549 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005550 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5552 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5553 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5554 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5555 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005556 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5557
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 /* Defeaturize this later if needed */
5559#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5560 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5561 if (csrRoamIsHandoffInProgress(pMac))
5562 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 /* Should indicate neighbor roam algorithm about the connect failure here */
5564 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005566#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 if(pSession->bRefAssocStartCnt > 0)
5568 {
5569 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005570 if(eCsrJoinFailureDueToConcurrency == Result)
5571 {
5572 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5573 eCSR_ROAM_ASSOCIATION_COMPLETION,
5574 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5575 }
5576 else
5577 {
5578 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 eCSR_ROAM_ASSOCIATION_COMPLETION,
5580 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005583 else
5584 {
5585 /* bRefAssocStartCnt is not incremented when
5586 * eRoamState == eCsrStopRoamingDueToConcurrency
5587 * in csrRoamJoinNextBss API. so handle this in
5588 * else case by sending assoc failure
5589 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005590 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005591 pCommand->u.scanCmd.roamId,
5592 eCSR_ROAM_ASSOCIATION_FAILURE,
5593 eCSR_ROAM_RESULT_FAILURE);
5594 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005595 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005596#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5597 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5598#endif
5599 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5600 csrScanStartIdleScan(pMac);
5601#ifdef FEATURE_WLAN_BTAMP_UT_RF
5602 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5603 //BT activity and not able to recevie WLAN traffic. Retry the join
5604 if( CSR_IS_WDS_STA(pProfile) )
5605 {
5606 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5607 }
5608#endif
5609 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 case eCsrHddIssuedReassocToSameAP:
5611 case eCsrSmeIssuedReassocToSameAP:
5612 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5613
5614 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5615#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5616 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5617#endif
5618 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5619 csrScanStartIdleScan(pMac);
5620 break;
5621 case eCsrForcedDisassoc:
5622 case eCsrForcedDeauth:
5623 case eCsrSmeIssuedIbssJoinFailure:
5624 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5625
5626 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5627 {
5628 // Notify HDD that IBSS join failed
5629 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5630 }
5631 else
5632 {
5633 csrRoamCallCallback(pMac, sessionId, NULL,
5634 pCommand->u.roamCmd.roamId,
5635 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5636 }
5637#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5638 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5639#endif
5640 csrRoamLinkDown(pMac, sessionId);
5641 csrScanStartIdleScan(pMac);
5642 break;
5643 case eCsrForcedIbssLeave:
5644 csrRoamCallCallback(pMac, sessionId, NULL,
5645 pCommand->u.roamCmd.roamId,
5646 eCSR_ROAM_IBSS_LEAVE,
5647 eCSR_ROAM_RESULT_IBSS_STOP);
5648 break;
5649 case eCsrForcedDisassocMICFailure:
5650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5651
5652 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5653#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5654 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5655#endif
5656 csrScanStartIdleScan(pMac);
5657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 case eCsrStopBss:
5659 csrRoamCallCallback(pMac, sessionId, NULL,
5660 pCommand->u.roamCmd.roamId,
5661 eCSR_ROAM_INFRA_IND,
5662 eCSR_ROAM_RESULT_INFRA_STOPPED);
5663 break;
5664 case eCsrForcedDisassocSta:
5665 case eCsrForcedDeauthSta:
5666 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5667 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5668 {
5669 pSession = CSR_GET_SESSION(pMac, sessionId);
5670 if (!pSession)
5671 break;
5672
5673 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5674 {
5675 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5676 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5677 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5678 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5679 roamInfo.statusCode = eSIR_SME_SUCCESS;
5680 status = csrRoamCallCallback(pMac, sessionId,
5681 &roamInfo, pCommand->u.roamCmd.roamId,
5682 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5683 }
5684 }
5685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 case eCsrLostLink1:
5687 // if lost link roam1 failed, then issue lost link Scan2 ...
5688 csrScanRequestLostLink2(pMac, sessionId);
5689 break;
5690 case eCsrLostLink2:
5691 // if lost link roam2 failed, then issue lost link scan3 ...
5692 csrScanRequestLostLink3(pMac, sessionId);
5693 break;
5694 case eCsrLostLink3:
5695 default:
5696 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5697
5698 //We are done with one round of lostlink roaming here
5699 csrScanHandleFailedLostlink3(pMac, sessionId);
5700 break;
5701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 break;
5703 }
5704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 return ( fReleaseCommand );
5706}
5707
Jeff Johnson295189b2012-06-20 16:38:30 -07005708eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5709{
5710 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 return (status);
5712}
5713
Jeff Johnson295189b2012-06-20 16:38:30 -07005714eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5715{
5716 eHalStatus status = eHAL_STATUS_SUCCESS;
5717 tANI_U32 size = 0;
5718
5719 do
5720 {
5721 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5722 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5723 {
5724 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5725 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5726 if(!HAL_STATUS_SUCCESS(status))
5727 {
5728 break;
5729 }
5730 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5731 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5732 }
5733 if(pSrcProfile->SSIDs.numOfSSIDs)
5734 {
5735 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5736 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5737 if(!HAL_STATUS_SUCCESS(status))
5738 {
5739 break;
5740 }
5741 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5742 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5743 }
5744 if(pSrcProfile->nWPAReqIELength)
5745 {
5746 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5747 if(!HAL_STATUS_SUCCESS(status))
5748 {
5749 break;
5750 }
5751 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5752 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5753 }
5754 if(pSrcProfile->nRSNReqIELength)
5755 {
5756 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5757 if(!HAL_STATUS_SUCCESS(status))
5758 {
5759 break;
5760 }
5761 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5762 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5763 }
5764#ifdef FEATURE_WLAN_WAPI
5765 if(pSrcProfile->nWAPIReqIELength)
5766 {
5767 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5768 if(!HAL_STATUS_SUCCESS(status))
5769 {
5770 break;
5771 }
5772 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5773 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5774 }
5775#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 if(pSrcProfile->nAddIEScanLength)
5777 {
5778 status = palAllocateMemory(pMac->hHdd,
5779 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5780 if(!HAL_STATUS_SUCCESS(status))
5781 {
5782 break;
5783 }
5784 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5785 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5786 pSrcProfile->nAddIEScanLength);
5787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 if(pSrcProfile->nAddIEAssocLength)
5789 {
5790 status = palAllocateMemory(pMac->hHdd,
5791 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5792 if(!HAL_STATUS_SUCCESS(status))
5793 {
5794 break;
5795 }
5796 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5797 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5798 pSrcProfile->nAddIEAssocLength);
5799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005800 if(pSrcProfile->ChannelInfo.ChannelList)
5801 {
5802 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5803 if(!HAL_STATUS_SUCCESS(status))
5804 {
5805 break;
5806 }
5807 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5808 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 pDstProfile->AuthType = pSrcProfile->AuthType;
5811 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5812 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5813 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5814 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5815 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005816#ifdef WLAN_FEATURE_11W
5817 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5818 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5819 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5820#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 pDstProfile->BSSType = pSrcProfile->BSSType;
5822 pDstProfile->phyMode = pSrcProfile->phyMode;
5823 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5824
5825#ifdef FEATURE_WLAN_WAPI
5826 if(csrIsProfileWapi(pSrcProfile))
5827 {
5828 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5829 {
5830 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5831 }
5832 }
5833#endif /* FEATURE_WLAN_WAPI */
5834 pDstProfile->CBMode = pSrcProfile->CBMode;
5835 /*Save the WPS info*/
5836 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5837 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 pDstProfile->privacy = pSrcProfile->privacy;
5840 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5841 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5842 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5843 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5844 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5845 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5846 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5847 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5848 pDstProfile->wps_state = pSrcProfile->wps_state;
5849 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005851#ifdef WLAN_FEATURE_VOWIFI_11R
5852 if (pSrcProfile->MDID.mdiePresent)
5853 {
5854 pDstProfile->MDID.mdiePresent = 1;
5855 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5856 }
5857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005858 }while(0);
5859
5860 if(!HAL_STATUS_SUCCESS(status))
5861 {
5862 csrReleaseProfile(pMac, pDstProfile);
5863 pDstProfile = NULL;
5864 }
5865
5866 return (status);
5867}
Jeff Johnson295189b2012-06-20 16:38:30 -07005868eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5869{
5870 eHalStatus status = eHAL_STATUS_SUCCESS;
5871 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5872 do
5873 {
5874 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5875 if(pSrcProfile->bssid)
5876 {
5877 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5878 if(!HAL_STATUS_SUCCESS(status))
5879 {
5880 break;
5881 }
5882 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5883 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5884 }
5885 if(pSrcProfile->SSID.ssId)
5886 {
5887 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5888 if(!HAL_STATUS_SUCCESS(status))
5889 {
5890 break;
5891 }
5892 pDstProfile->SSIDs.numOfSSIDs = 1;
5893 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5894 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5895 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5896 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005897 if(pSrcProfile->nAddIEAssocLength)
5898 {
5899 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5900 if(!HAL_STATUS_SUCCESS(status))
5901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005902 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005903 break;
5904 }
5905 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5906 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5907 pSrcProfile->nAddIEAssocLength);
5908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5910 if(!HAL_STATUS_SUCCESS(status))
5911 {
5912 break;
5913 }
5914 pDstProfile->ChannelInfo.numOfChannels = 1;
5915 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 pDstProfile->AuthType.numEntries = 1;
5917 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5918 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5919 pDstProfile->EncryptionType.numEntries = 1;
5920 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5921 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5922 pDstProfile->mcEncryptionType.numEntries = 1;
5923 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5924 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5925 pDstProfile->BSSType = pSrcProfile->BSSType;
5926 pDstProfile->CBMode = pSrcProfile->CBMode;
5927 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5928#ifdef WLAN_FEATURE_VOWIFI_11R
5929 if (pSrcProfile->MDID.mdiePresent)
5930 {
5931 pDstProfile->MDID.mdiePresent = 1;
5932 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5933 }
5934#endif
5935
5936 }while(0);
5937
5938 if(!HAL_STATUS_SUCCESS(status))
5939 {
5940 csrReleaseProfile(pMac, pDstProfile);
5941 pDstProfile = NULL;
5942 }
5943
5944 return (status);
5945}
5946
Jeff Johnson295189b2012-06-20 16:38:30 -07005947eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5948 tScanResultHandle hBSSList,
5949 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5950 tANI_BOOLEAN fClearScan)
5951{
5952 eHalStatus status = eHAL_STATUS_SUCCESS;
5953 tSmeCmd *pCommand;
5954
5955 pCommand = csrGetCommandBuffer(pMac);
5956 if(NULL == pCommand)
5957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005958 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 status = eHAL_STATUS_RESOURCES;
5960 }
5961 else
5962 {
5963 if( fClearScan )
5964 {
5965 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305966 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 }
5968 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5969 if(NULL == pProfile)
5970 {
5971 //We can roam now
5972 //Since pProfile is NULL, we need to build our own profile, set everything to default
5973 //We can only support open and no encryption
5974 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5975 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5976 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5977 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5978 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5979 }
5980 else
5981 {
5982 //make a copy of the profile
5983 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5984 if(HAL_STATUS_SUCCESS(status))
5985 {
5986 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5987 }
5988 }
5989 pCommand->command = eSmeCommandRoam;
5990 pCommand->sessionId = (tANI_U8)sessionId;
5991 pCommand->u.roamCmd.hBSSList = hBSSList;
5992 pCommand->u.roamCmd.roamId = roamId;
5993 pCommand->u.roamCmd.roamReason = reason;
5994 //We need to free the BssList when the command is done
5995 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5996 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5998 FL("CSR PERSONA=%d"),
5999 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6001 if( !HAL_STATUS_SUCCESS( status ) )
6002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006003 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 csrReleaseCommandRoam( pMac, pCommand );
6005 }
6006 }
6007
6008 return (status);
6009}
Jeff Johnson295189b2012-06-20 16:38:30 -07006010eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6011 tCsrRoamModifyProfileFields *pMmodProfileFields,
6012 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6013{
6014 eHalStatus status = eHAL_STATUS_SUCCESS;
6015 tSmeCmd *pCommand;
6016
6017 pCommand = csrGetCommandBuffer(pMac);
6018 if(NULL == pCommand)
6019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006020 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 status = eHAL_STATUS_RESOURCES;
6022 }
6023 else
6024 {
6025 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306026 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 if(pProfile)
6028 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 //This is likely trying to reassoc to different profile
6030 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6031 //make a copy of the profile
6032 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6033 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 }
6035 else
6036 {
6037 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6038 //how to update WPA/WPA2 info in roamProfile??
6039 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 if(HAL_STATUS_SUCCESS(status))
6042 {
6043 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6044 }
6045 pCommand->command = eSmeCommandRoam;
6046 pCommand->sessionId = (tANI_U8)sessionId;
6047 pCommand->u.roamCmd.roamId = roamId;
6048 pCommand->u.roamCmd.roamReason = reason;
6049 //We need to free the BssList when the command is done
6050 //For reassoc there is no BSS list, so the boolean set to false
6051 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6052 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6053 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6055 if( !HAL_STATUS_SUCCESS( status ) )
6056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006057 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6059 csrReleaseCommandRoam( pMac, pCommand );
6060 }
6061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 return (status);
6063}
6064
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006065eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6066 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306067// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006068{
6069 eHalStatus status = eHAL_STATUS_SUCCESS;
6070 tSmeCmd *pCommand;
6071
6072 pCommand = csrGetCommandBuffer(pMac);
6073 if(NULL == pCommand)
6074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006075 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006076 status = eHAL_STATUS_RESOURCES;
6077 }
6078 else
6079 {
6080 if(pBssDescription)
6081 {
6082 //copy over the parameters we need later
6083 pCommand->command = eSmeCommandRoam;
6084 pCommand->sessionId = (tANI_U8)sessionId;
6085 pCommand->u.roamCmd.roamReason = reason;
6086 //this is the important parameter
6087 //in this case we are using this field for the "next" BSS
6088 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6089 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6090 if( !HAL_STATUS_SUCCESS( status ) )
6091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006092 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006093 csrReleaseCommandPreauth( pMac, pCommand );
6094 }
6095 }
6096 else
6097 {
6098 //Return failure
6099 status = eHAL_STATUS_RESOURCES;
6100 }
6101 }
6102 return (status);
6103}
6104
6105eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6106{
6107 tListElem *pEntry;
6108 tSmeCmd *pCommand;
6109 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6110 if ( pEntry )
6111 {
6112 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6113 if ( (eSmeCommandRoam == pCommand->command) &&
6114 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6115 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006116 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006117 pCommand->command, pCommand->u.roamCmd.roamReason);
6118 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6119 csrReleaseCommandPreauth( pMac, pCommand );
6120 }
6121 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006122 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006123 pCommand->command, pCommand->u.roamCmd.roamReason);
6124 }
6125 }
6126 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006127 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006128 }
6129 smeProcessPendingQueue( pMac );
6130 return eHAL_STATUS_SUCCESS;
6131}
6132
Jeff Johnson295189b2012-06-20 16:38:30 -07006133eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6134 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6135{
6136 eHalStatus status = eHAL_STATUS_FAILURE;
6137 tScanResultHandle hBSSList;
6138 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6140 if(HAL_STATUS_SUCCESS(status))
6141 {
6142 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6143 if(pRoamId)
6144 {
6145 *pRoamId = roamId;
6146 }
6147 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6148 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6149 if(!HAL_STATUS_SUCCESS(status))
6150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006151 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 csrScanResultPurge(pMac, hBSSList);
6153 }
6154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 return (status);
6156}
6157
Jeff Johnson295189b2012-06-20 16:38:30 -07006158eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6159 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6160{
6161 eHalStatus status = eHAL_STATUS_SUCCESS;
6162 tScanResultHandle hBSSList;
6163 tCsrScanResultFilter *pScanFilter;
6164 tANI_U32 roamId = 0;
6165 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 if (NULL == pProfile)
6168 {
6169 smsLog(pMac, LOGP, FL("No profile specified"));
6170 return eHAL_STATUS_FAILURE;
6171 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006172 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 if( CSR_IS_WDS( pProfile ) &&
6175 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006177 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006178 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 return status;
6180 }
6181 csrRoamCancelRoaming(pMac, sessionId);
6182 csrScanRemoveFreshScanCommand(pMac, sessionId);
6183 csrScanCancelIdleScan(pMac);
6184 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306185 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6187 {
6188 csrScanDisable(pMac);
6189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6191 //Check whether ssid changes
6192 if(csrIsConnStateConnected(pMac, sessionId))
6193 {
6194 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6195 {
6196 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6197 }
6198 }
6199#ifdef FEATURE_WLAN_BTAMP_UT_RF
6200 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6201#endif
6202 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006204 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6206 if(pRoamId)
6207 {
6208 roamId = *pRoamId;
6209 }
6210 if(!HAL_STATUS_SUCCESS(status))
6211 {
6212 fCallCallback = eANI_BOOLEAN_TRUE;
6213 }
6214 }
6215 else
6216 {
6217 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6218 if(HAL_STATUS_SUCCESS(status))
6219 {
6220 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6221 //Try to connect to any BSS
6222 if(NULL == pProfile)
6223 {
6224 //No encryption
6225 pScanFilter->EncryptionType.numEntries = 1;
6226 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6227 }//we don't have a profile
6228 else
6229 {
6230 //Here is the profile we need to connect to
6231 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6232 }//We have a profile
6233 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6234 if(pRoamId)
6235 {
6236 *pRoamId = roamId;
6237 }
6238
6239 if(HAL_STATUS_SUCCESS(status))
6240 {
6241 /*Save the WPS info*/
6242 if(NULL != pProfile)
6243 {
6244 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6245 }
6246 else
6247 {
6248 pScanFilter->bWPSAssociation = 0;
6249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 do
6251 {
6252 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 )
6255 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006256 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6258 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6259 if(!HAL_STATUS_SUCCESS(status))
6260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006261 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 fCallCallback = eANI_BOOLEAN_TRUE;
6263 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006264 else
6265 {
6266 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 break;
6269 }
6270 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006271 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 if(HAL_STATUS_SUCCESS(status))
6273 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6275 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6276 if(!HAL_STATUS_SUCCESS(status))
6277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006278 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 csrScanResultPurge(pMac, hBSSList);
6280 fCallCallback = eANI_BOOLEAN_TRUE;
6281 }
6282 }//Have scan result
6283 else if(NULL != pProfile)
6284 {
6285 //Check whether it is for start ibss
6286 if(CSR_IS_START_IBSS(pProfile))
6287 {
6288 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6289 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6290 if(!HAL_STATUS_SUCCESS(status))
6291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006292 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 fCallCallback = eANI_BOOLEAN_TRUE;
6294 }
6295 }
6296 else
6297 {
6298 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006299 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 if(!HAL_STATUS_SUCCESS(status))
6301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006302 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 fCallCallback = eANI_BOOLEAN_TRUE;
6304 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006305 else
6306 {
6307 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 }
6310 }
6311 else
6312 {
6313 fCallCallback = eANI_BOOLEAN_TRUE;
6314 }
6315 } while (0);
6316 if(NULL != pProfile)
6317 {
6318 //we need to free memory for filter if profile exists
6319 csrFreeScanFilter(pMac, pScanFilter);
6320 }
6321 }//Got the scan filter from profile
6322
6323 palFreeMemory(pMac->hHdd, pScanFilter);
6324 }//allocated memory for pScanFilter
6325 }//No Bsslist coming in
6326 //tell the caller if we fail to trigger a join request
6327 if( fCallCallback )
6328 {
6329 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6330 }
6331
6332 return (status);
6333}
Jeff Johnson295189b2012-06-20 16:38:30 -07006334eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6335 tCsrRoamModifyProfileFields modProfileFields,
6336 tANI_U32 *pRoamId)
6337{
6338 eHalStatus status = eHAL_STATUS_SUCCESS;
6339 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6340 tANI_U32 roamId = 0;
6341 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 if (NULL == pProfile)
6343 {
6344 smsLog(pMac, LOGP, FL("No profile specified"));
6345 return eHAL_STATUS_FAILURE;
6346 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006347 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 -07006348 csrRoamCancelRoaming(pMac, sessionId);
6349 csrScanRemoveFreshScanCommand(pMac, sessionId);
6350 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306351 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 if(csrIsConnStateConnected(pMac, sessionId))
6354 {
6355 if(pProfile)
6356 {
6357 if(pProfile->SSIDs.numOfSSIDs &&
6358 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6359 {
6360 fCallCallback = eANI_BOOLEAN_FALSE;
6361 }
6362 else
6363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006364 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 }
6366 }
6367 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6368 &pSession->connectedProfile.modifyProfileFields,
6369 sizeof(tCsrRoamModifyProfileFields)))
6370 {
6371 fCallCallback = eANI_BOOLEAN_FALSE;
6372 }
6373 else
6374 {
6375 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006376 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 }
6378 }
6379 else
6380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006381 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 if(!fCallCallback)
6384 {
6385 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6386 if(pRoamId)
6387 {
6388 *pRoamId = roamId;
6389 }
6390
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6392 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 }
6394 else
6395 {
6396 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6397 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 return status;
6400}
Jeff Johnson295189b2012-06-20 16:38:30 -07006401eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6402{
6403 eHalStatus status = eHAL_STATUS_FAILURE;
6404 tScanResultHandle hBSSList = NULL;
6405 tCsrScanResultFilter *pScanFilter = NULL;
6406 tANI_U32 roamId;
6407 tCsrRoamProfile *pProfile = NULL;
6408 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006409
6410 if(!pSession)
6411 {
6412 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6413 return eHAL_STATUS_FAILURE;
6414 }
6415
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 do
6417 {
6418 if(pSession->pCurRoamProfile)
6419 {
6420 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306421 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6423 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6424 if(!HAL_STATUS_SUCCESS(status))
6425 break;
6426 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6427 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6428 if(!HAL_STATUS_SUCCESS(status))
6429 break;
6430 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6431 if(!HAL_STATUS_SUCCESS(status))
6432 {
6433 break;
6434 }
6435 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6436 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6437 if(!HAL_STATUS_SUCCESS(status))
6438 {
6439 break;
6440 }
6441 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6442 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6443 if(HAL_STATUS_SUCCESS(status))
6444 {
6445 //we want to put the last connected BSS to the very beginning, if possible
6446 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6447 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6448 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6449 if(!HAL_STATUS_SUCCESS(status))
6450 {
6451 csrScanResultPurge(pMac, hBSSList);
6452 break;
6453 }
6454 }
6455 else
6456 {
6457 //Do a scan on this profile
6458 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006459 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 if(!HAL_STATUS_SUCCESS(status))
6461 {
6462 break;
6463 }
6464 }
6465 }//We have a profile
6466 else
6467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006468 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006469 break;
6470 }
6471 }while(0);
6472 if(pScanFilter)
6473 {
6474 csrFreeScanFilter(pMac, pScanFilter);
6475 palFreeMemory(pMac->hHdd, pScanFilter);
6476 }
6477 if(NULL != pProfile)
6478 {
6479 csrReleaseProfile(pMac, pProfile);
6480 palFreeMemory(pMac->hHdd, pProfile);
6481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 return (status);
6483}
Jeff Johnson295189b2012-06-20 16:38:30 -07006484eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6485{
6486 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 if(csrIsConnStateConnected(pMac, sessionId))
6488 {
6489 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6490 if(HAL_STATUS_SUCCESS(status))
6491 {
6492 status = csrRoamJoinLastProfile(pMac, sessionId);
6493 }
6494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 return (status);
6496}
6497
Jeff Johnson295189b2012-06-20 16:38:30 -07006498eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6499{
6500 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006501 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 csrRoamCancelRoaming(pMac, sessionId);
6503 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6504 if(csrIsConnStateDisconnected(pMac, sessionId))
6505 {
6506 status = csrRoamJoinLastProfile(pMac, sessionId);
6507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 return (status);
6509}
6510
Jeff Johnson295189b2012-06-20 16:38:30 -07006511eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6512{
6513 eHalStatus status = eHAL_STATUS_SUCCESS;
6514 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6515 eCsrRoamSubState NewSubstate;
6516 tANI_U32 sessionId = pCommand->sessionId;
6517
6518 // change state to 'Roaming'...
6519 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6520
6521 if ( csrIsConnStateIbss( pMac, sessionId ) )
6522 {
6523 // If we are in an IBSS, then stop the IBSS...
6524 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6525 fComplete = (!HAL_STATUS_SUCCESS(status));
6526 }
6527 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006529 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 -07006530 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6531 //Restore AC weight in case we change it
6532 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6533 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6534 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6535 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6536 {
6537 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6538 }
6539 if( fDisassoc )
6540 {
6541 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6542 }
6543 else
6544 {
6545 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6546 }
6547 fComplete = (!HAL_STATUS_SUCCESS(status));
6548 }
6549 else if ( csrIsConnStateWds( pMac, sessionId ) )
6550 {
6551 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6552 {
6553 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6554 fComplete = (!HAL_STATUS_SUCCESS(status));
6555 }
6556 //This has to be WDS station
6557 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6558 {
6559
6560 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6561 if( fDisassoc )
6562 {
6563 status = csrRoamIssueDisassociate( pMac, sessionId,
6564 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6565 fComplete = (!HAL_STATUS_SUCCESS(status));
6566 }
6567 }
6568 } else {
6569 // we got a dis-assoc request while not connected to any peer
6570 // just complete the command
6571 fComplete = eANI_BOOLEAN_TRUE;
6572 status = eHAL_STATUS_FAILURE;
6573 }
6574 if(fComplete)
6575 {
6576 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6577 }
6578
6579 if(HAL_STATUS_SUCCESS(status))
6580 {
6581 if ( csrIsConnStateInfra( pMac, sessionId ) )
6582 {
6583 //Set the state to disconnect here
6584 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6585 }
6586 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006587 else
6588 {
6589 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 return (status);
6592}
6593
Jeff Johnson295189b2012-06-20 16:38:30 -07006594/* This is been removed from latest code base */
6595/*
6596static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6597{
6598 eHalStatus status;
6599 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6601 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 return ( status );
6603}
6604*/
6605
Jeff Johnson295189b2012-06-20 16:38:30 -07006606eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6607{
6608 eHalStatus status = eHAL_STATUS_SUCCESS;
6609 tSmeCmd *pCommand;
6610 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 do
6612 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006613 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 pCommand = csrGetCommandBuffer( pMac );
6615 if ( !pCommand )
6616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006617 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 status = eHAL_STATUS_RESOURCES;
6619 break;
6620 }
6621 //Change the substate in case it is wait-for-key
6622 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6623 {
6624 csrRoamStopWaitForKeyTimer( pMac );
6625 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6626 }
6627 pCommand->command = eSmeCommandRoam;
6628 pCommand->sessionId = (tANI_U8)sessionId;
6629 switch ( reason )
6630 {
6631 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6632 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 case eCSR_DISCONNECT_REASON_DEAUTH:
6635 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 case eCSR_DISCONNECT_REASON_HANDOFF:
6638 fHighPriority = eANI_BOOLEAN_TRUE;
6639 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6640 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6642 case eCSR_DISCONNECT_REASON_DISASSOC:
6643 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6646 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6647 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6649 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6650 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 default:
6652 break;
6653 }
6654 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6655 if( !HAL_STATUS_SUCCESS( status ) )
6656 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006657 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 csrReleaseCommandRoam( pMac, pCommand );
6659 }
6660 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 return( status );
6662}
6663
Jeff Johnson295189b2012-06-20 16:38:30 -07006664eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6665{
6666 eHalStatus status = eHAL_STATUS_SUCCESS;
6667 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 pCommand = csrGetCommandBuffer( pMac );
6669 if ( NULL != pCommand )
6670 {
6671 //Change the substate in case it is wait-for-key
6672 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6673 {
6674 csrRoamStopWaitForKeyTimer( pMac );
6675 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6676 }
6677 pCommand->command = eSmeCommandRoam;
6678 pCommand->sessionId = (tANI_U8)sessionId;
6679 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6680 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6681 if( !HAL_STATUS_SUCCESS( status ) )
6682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006683 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 csrReleaseCommandRoam( pMac, pCommand );
6685 }
6686 }
6687 else
6688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006689 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 status = eHAL_STATUS_RESOURCES;
6691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 return ( status );
6693}
6694
Jeff Johnson295189b2012-06-20 16:38:30 -07006695eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6696{
6697 eHalStatus status = eHAL_STATUS_SUCCESS;
6698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006699
6700 if(!pSession)
6701 {
6702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6703 return eHAL_STATUS_FAILURE;
6704 }
6705
Jeff Johnson295189b2012-06-20 16:38:30 -07006706#ifdef FEATURE_WLAN_BTAMP_UT_RF
6707 //Stop te retry
6708 pSession->maxRetryCount = 0;
6709 csrRoamStopJoinRetryTimer(pMac, sessionId);
6710#endif
6711 //Not to call cancel roaming here
6712 //Only issue disconnect when necessary
6713 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6714 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6715 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6716
6717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006718 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 return (status);
6722}
6723
Jeff Johnson295189b2012-06-20 16:38:30 -07006724eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6725{
6726 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006727
6728 if(!pSession)
6729 {
6730 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6731 return eHAL_STATUS_FAILURE;
6732 }
6733
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6736
6737 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6738}
6739
Jeff Johnson295189b2012-06-20 16:38:30 -07006740eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6741 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6742{
6743 eHalStatus status = eHAL_STATUS_SUCCESS;
6744 tDot11fBeaconIEs *pIesTemp = pIes;
6745 tANI_U8 index;
6746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6747 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006748
6749 if(!pSession)
6750 {
6751 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6752 return eHAL_STATUS_FAILURE;
6753 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006754
6755 if(pConnectProfile->pAddIEAssoc)
6756 {
6757 palFreeMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc);
6758 pConnectProfile->pAddIEAssoc = NULL;
6759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6761 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6762 pConnectProfile->AuthInfo = pProfile->AuthType;
6763 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6764 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6765 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6766 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6767 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6768 pConnectProfile->BSSType = pProfile->BSSType;
6769 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6770 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006771 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6772
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006774
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006775 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6776 if(pProfile->nAddIEAssocLength)
6777 {
6778 status = palAllocateMemory(pMac->hHdd,
6779 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6780 if(!HAL_STATUS_SUCCESS(status))
6781 {
6782 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6783 return eHAL_STATUS_FAILURE;
6784 }
6785 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6786 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6787 pProfile->nAddIEAssocLength);
6788 }
6789
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 //Save bssid
6791 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6792#ifdef WLAN_FEATURE_VOWIFI_11R
6793 if (pSirBssDesc->mdiePresent)
6794 {
6795 pConnectProfile->MDID.mdiePresent = 1;
6796 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6797 }
6798#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006799 if( NULL == pIesTemp )
6800 {
6801 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006803#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006804 if ((csrIsProfileCCX(pProfile) ||
6805 ((pIesTemp->CCXVersion.present)
6806 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6807 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6808 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6809 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006810#ifdef WLAN_FEATURE_11W
6811 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6812#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306813 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006814 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 {
6816 pConnectProfile->isCCXAssoc = 1;
6817 }
6818#endif
6819 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 if(HAL_STATUS_SUCCESS(status))
6821 {
6822 if(pIesTemp->SSID.present)
6823 {
6824 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6825 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6826 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6827 }
6828
6829 //Save the bss desc
6830 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306831
6832 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306834 //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 -07006835 pConnectProfile->qap = TRUE;
6836 }
6837 else
6838 {
6839 pConnectProfile->qap = FALSE;
6840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 if ( NULL == pIes )
6842 {
6843 //Free memory if it allocated locally
6844 palFreeMemory(pMac->hHdd, pIesTemp);
6845 }
6846 }
6847 //Save Qos connection
6848 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6849
6850 if(!HAL_STATUS_SUCCESS(status))
6851 {
6852 csrFreeConnectBssDesc(pMac, sessionId);
6853 }
6854 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6855 {
6856 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6857 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6858 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6859 {
6860 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6861 break;
6862 }
6863 pConnectProfile->handoffPermitted = FALSE;
6864 }
6865
6866 return (status);
6867}
6868
Jeff Johnson295189b2012-06-20 16:38:30 -07006869static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6870{
6871 tListElem *pEntry = NULL;
6872 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 //The head of the active list is the request we sent
6874 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6875 if(pEntry)
6876 {
6877 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006879 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6880 {
6881 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6882 {
6883#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6884 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6885#endif
6886 }
6887 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6888 }
6889 else
6890 {
6891 tANI_U32 roamId = 0;
6892 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006893 if(!pSession)
6894 {
6895 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6896 return;
6897 }
6898
Jeff Johnson295189b2012-06-20 16:38:30 -07006899
6900 //The head of the active list is the request we sent
6901 //Try to get back the same profile and roam again
6902 if(pCommand)
6903 {
6904 roamId = pCommand->u.roamCmd.roamId;
6905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6907 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006908 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006909#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6910 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6911 if (csrRoamIsHandoffInProgress(pMac))
6912 {
6913 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6914 /* Should indicate neighbor roam algorithm about the connect failure here */
6915 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6916 }
6917#endif
6918 if (pCommand)
6919 {
6920 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6921 {
6922 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6923 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6924 csrRoamReissueRoamCommand(pMac);
6925 }
6926 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6927 {
6928 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6929 }
6930 else
6931 {
6932 csrRoam(pMac, pCommand);
6933 }
6934 }
6935 else
6936 {
6937 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6938 }
6939 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6940}
6941
Jeff Johnson295189b2012-06-20 16:38:30 -07006942eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6943 tDot11fBeaconIEs *pIes,
6944 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6945{
6946 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006947 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6949 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6950
6951 // Set the roaming substate to 'join attempt'...
6952 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006954 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 return (status);
6956}
6957
Jeff Johnson295189b2012-06-20 16:38:30 -07006958static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6959 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6960{
6961 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 // Set the roaming substate to 'join attempt'...
6963 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6964
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006965 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006966
6967 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006968 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006969}
6970
Jeff Johnson295189b2012-06-20 16:38:30 -07006971void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6972{
6973 tListElem *pEntry;
6974 tSmeCmd *pCommand;
6975 tCsrRoamInfo roamInfo;
6976 tANI_U32 sessionId;
6977 tCsrRoamSession *pSession;
6978
6979 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6980 if(pEntry)
6981 {
6982 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6983 if ( eSmeCommandRoam == pCommand->command )
6984 {
6985 sessionId = pCommand->sessionId;
6986 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006987
6988 if(!pSession)
6989 {
6990 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6991 return;
6992 }
6993
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 if( pCommand->u.roamCmd.fStopWds )
6995 {
6996 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6997 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6998 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6999 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7002 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7003 eCSR_ROAM_WDS_IND,
7004 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007005 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7006 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7007 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7008 eCSR_ROAM_INFRA_IND,
7009 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7010 }
7011
Jeff Johnson295189b2012-06-20 16:38:30 -07007012
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007015 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7017 }
7018 }
7019 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007021 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7023 }
7024 }
7025 else
7026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007027 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 }
7029 }
7030 else
7031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007032 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 }
7034}
7035
Jeff Johnson295189b2012-06-20 16:38:30 -07007036tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7037{
7038 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7039 tListElem *pEntry;
7040 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 //alwasy lock active list before locking pending list
7042 csrLLLock( &pMac->sme.smeCmdActiveList );
7043 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7044 if(pEntry)
7045 {
7046 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7047 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7048 {
7049 fRet = eANI_BOOLEAN_TRUE;
7050 }
7051 }
7052 if(eANI_BOOLEAN_FALSE == fRet)
7053 {
7054 csrLLLock(&pMac->sme.smeCmdPendingList);
7055 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7056 while(pEntry)
7057 {
7058 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7059 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7060 {
7061 fRet = eANI_BOOLEAN_TRUE;
7062 break;
7063 }
7064 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7065 }
7066 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7067 }
7068 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 return (fRet);
7070}
7071
Jeff Johnson295189b2012-06-20 16:38:30 -07007072tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7073{
7074 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7075 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7077 {
7078 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7079 {
7080 break;
7081 }
7082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 return ( fRet );
7084}
7085
Jeff Johnson295189b2012-06-20 16:38:30 -07007086tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7087{
7088 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 //alwasy lock active list before locking pending list
7090 csrLLLock( &pMac->sme.smeCmdActiveList );
7091 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7092 if(eANI_BOOLEAN_FALSE == fRet)
7093 {
7094 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7095 }
7096 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007097 return (fRet);
7098}
7099
Jeff Johnson295189b2012-06-20 16:38:30 -07007100tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7101{
7102 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7103 tListElem *pEntry;
7104 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 //alwasy lock active list before locking pending list
7106 csrLLLock( &pMac->sme.smeCmdActiveList );
7107 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7108 if( pEntry )
7109 {
7110 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7111 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7112 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7113 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7114 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7115 {
7116 fRet = eANI_BOOLEAN_TRUE;
7117 }
7118 }
7119 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 return (fRet);
7121}
Jeff Johnson295189b2012-06-20 16:38:30 -07007122eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7123{
7124 eHalStatus status = eHAL_STATUS_SUCCESS;
7125 tSmeCmd *pCommand = NULL;
7126 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7127 tANI_BOOLEAN fRemoveCmd = FALSE;
7128 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 // Delete the old assoc command. All is setup for reassoc to be serialized
7130 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7131 if ( pEntry )
7132 {
7133 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7134 if ( !pCommand )
7135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007136 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 return eHAL_STATUS_RESOURCES;
7138 }
7139 if ( eSmeCommandRoam == pCommand->command )
7140 {
7141 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7142 {
7143 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7144 }
7145 else
7146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007147 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 }
7149 if (fRemoveCmd == FALSE)
7150 {
7151 // Implies we did not get the serialized assoc command we
7152 // were expecting
7153 pCommand = NULL;
7154 }
7155 }
7156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 if(NULL == pCommand)
7158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007159 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 return eHAL_STATUS_RESOURCES;
7161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 do
7163 {
7164 //Change the substate in case it is wait-for-key
7165 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7166 {
7167 csrRoamStopWaitForKeyTimer( pMac );
7168 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7169 }
7170 pCommand->command = eSmeCommandRoam;
7171 pCommand->sessionId = (tANI_U8)sessionId;
7172 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7174 if( !HAL_STATUS_SUCCESS( status ) )
7175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007176 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 csrReleaseCommandRoam( pMac, pCommand );
7178 }
7179 } while( 0 );
7180
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 return( status );
7182}
7183static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7184{
7185 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7186 tCsrScanResult *pScanResult = NULL;
7187 tSirBssDescription *pBssDesc = NULL;
7188 tSmeCmd *pCommand = NULL;
7189 tANI_U32 sessionId;
7190 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 if(NULL == pEntry)
7192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007193 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 return;
7195 }
7196 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7197 sessionId = pCommand->sessionId;
7198 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007199
7200 if(!pSession)
7201 {
7202 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7203 return;
7204 }
7205
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7207 {
7208 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007209 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007210 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7211 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007212 /* If the roaming has stopped, not to continue the roaming command*/
7213 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7214 {
7215 //No need to complete roaming here as it already completes
7216 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7217 pCommand->u.roamCmd.roamReason);
7218 csrSetAbortRoamingCommand( pMac, pCommand );
7219 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 else
7222 {
7223 if ( CCM_IS_RESULT_SUCCESS(result) )
7224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007225 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 // Successfully set the configuration parameters for the new Bss. Attempt to
7227 // join the roaming Bss.
7228 if(pCommand->u.roamCmd.pRoamBssEntry)
7229 {
7230 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7231 pBssDesc = &pScanResult->Result.BssDescriptor;
7232 }
7233 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7234 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 )
7237 {
7238 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7239 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7240 pBssDesc, pCommand->u.roamCmd.roamId )))
7241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007242 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 //We need to complete the command
7244 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7245 }
7246 }
7247 else
7248 {
7249 if (!pCommand->u.roamCmd.pRoamBssEntry)
7250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007251 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 //We need to complete the command
7253 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7254 return;
7255 }
7256 // If we are roaming TO an Infrastructure BSS...
7257 VOS_ASSERT(pScanResult != NULL);
7258 if ( csrIsInfraBssDesc( pBssDesc ) )
7259 {
7260 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7262 {
7263 // ..and currently in an Infrastructure connection....
7264 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7265 {
7266 // ...and the SSIDs are equal, then we Reassoc.
7267 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7268 pIesLocal ) )
7269 // ..and currently in an infrastructure connection
7270 {
7271 // then issue a Reassoc.
7272 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7273 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7274 &pCommand->u.roamCmd.roamProfile );
7275 }
7276 else
7277 {
7278
7279 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7280 // previously associated AP.
7281 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7282 pIesLocal,
7283 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7284 {
7285 //try something else
7286 csrRoam( pMac, pCommand );
7287 }
7288 }
7289 }
7290 else
7291 {
7292 eHalStatus status = eHAL_STATUS_SUCCESS;
7293
7294 /* We need to come with other way to figure out that this is because of HO in BMP
7295 The below API will be only available for Android as it uses a different HO algorithm */
7296 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7297 * use join request */
7298#ifdef WLAN_FEATURE_VOWIFI_11R
7299 if (csrRoamIsHandoffInProgress(pMac) &&
7300 csrRoamIs11rAssoc(pMac))
7301 {
7302 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7303 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7304 }
7305 else
7306#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007307#ifdef FEATURE_WLAN_CCX
7308 if (csrRoamIsHandoffInProgress(pMac) &&
7309 csrRoamIsCCXAssoc(pMac))
7310 {
7311 // Now serialize the reassoc command.
7312 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7313 }
7314 else
7315#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007316#ifdef FEATURE_WLAN_LFR
7317 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307318 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007319 {
7320 // Now serialize the reassoc command.
7321 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7322 }
7323 else
7324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007325 // else we are not connected and attempting to Join. Issue the
7326 // Join request.
7327 {
7328 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7329 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7330 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7331 }
7332 if(!HAL_STATUS_SUCCESS(status))
7333 {
7334 //try something else
7335 csrRoam( pMac, pCommand );
7336 }
7337 }
7338 if( !pScanResult->Result.pvIes )
7339 {
7340 //Locally allocated
7341 palFreeMemory(pMac->hHdd, pIesLocal);
7342 }
7343 }
7344 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7345 else
7346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007347 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 }
7349 }//else
7350 }//if ( WNI_CFG_SUCCESS == result )
7351 else
7352 {
7353 // In the event the configuration failed, for infra let the roam processor
7354 //attempt to join something else...
7355 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7356 {
7357 csrRoam(pMac, pCommand);
7358 }
7359 else
7360 {
7361 //We need to complete the command
7362 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7363 {
7364 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7365 }
7366 else
7367 {
7368 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7369 }
7370 }
7371 }
7372 }//we have active entry
7373}
7374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7376{
7377 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007378 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007381 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7383 // join the new one...
7384 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7386 }
7387 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007388 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 /***profHandleLostLinkAfterReset(pAdapter);
7390 // In the event the authenticate fails, let the roam processor attempt to join something else...
7391 roamRoam( pAdapter );***/
7392 }
7393}
7394
Jeff Johnson295189b2012-06-20 16:38:30 -07007395static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7396{
7397 eCsrRoamCompleteResult result;
7398 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7399 tCsrRoamInfo roamInfo;
7400 tANI_U32 roamId = 0;
7401
7402 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007404 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 /* Defeaturize this part later if needed */
7407#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7408 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7409 * we need the response contents while processing the result in csrRoamProcessResults() */
7410 if (csrRoamIsHandoffInProgress(pMac))
7411 {
7412 /* Need to dig more on indicating events to SME QoS module */
7413 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7414 csrRoamComplete( pMac, result, pSmeJoinRsp);
7415 }
7416 else
7417#endif
7418 {
7419 csrRoamComplete( pMac, result, NULL );
7420 }
7421 }
7422 /* Should we handle this similar to handling the join failure? Is it ok
7423 * to call csrRoamComplete() with state as CsrJoinFailure */
7424 else
7425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007426 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 result = eCsrReassocFailure;
7428#ifdef WLAN_FEATURE_VOWIFI_11R
7429 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7430 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7431 {
7432 // Inform HDD to turn off FT flag in HDD
7433 if (pNeighborRoamInfo)
7434 {
7435 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7436 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7437 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007438 /*
7439 * Since the above callback sends a disconnect
7440 * to HDD, we should clean-up our state
7441 * machine as well to be in sync with the upper
7442 * layers. There is no need to send a disassoc
7443 * since: 1) we will never reassoc to the current
7444 * AP in LFR, and 2) there is no need to issue a
7445 * disassoc to the AP with which we were trying
7446 * to reassoc.
7447 */
7448 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7449 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 }
7451 }
7452#endif
7453 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7454 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7455 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7456 //The disassoc rsp message will remove the command from active list
7457 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7458 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7459 {
7460 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7461 }
7462 }
7463}
7464
Jeff Johnson295189b2012-06-20 16:38:30 -07007465static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7466{
Jeff Johnson295189b2012-06-20 16:38:30 -07007467#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7468 {
7469 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7471 if(pIbssLog)
7472 {
7473 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7474 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7475 {
7476 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7477 }
7478 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7479 }
7480 }
7481#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7483 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7484 {
7485 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7486 }
7487 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7488 {
7489 csrRoamReissueRoamCommand(pMac);
7490 }
7491}
7492
Jeff Johnson295189b2012-06-20 16:38:30 -07007493void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7494{
7495 tSirResultCodes statusCode;
7496#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7497 tScanResultHandle hBSSList;
7498 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7499 eHalStatus status;
7500 tCsrRoamInfo roamInfo;
7501 tCsrScanResultFilter *pScanFilter = NULL;
7502 tANI_U32 roamId = 0;
7503 tCsrRoamProfile *pCurRoamProfile = NULL;
7504 tListElem *pEntry = NULL;
7505 tSmeCmd *pCommand = NULL;
7506#endif
7507 tANI_U32 sessionId;
7508 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007509
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 tSirSmeDisassocRsp SmeDisassocRsp;
7511
7512 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7513 sessionId = SmeDisassocRsp.sessionId;
7514 statusCode = SmeDisassocRsp.statusCode;
7515
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007516 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007517
7518 if ( csrIsConnStateInfra( pMac, sessionId ) )
7519 {
7520 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007522 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007523
7524 if(!pSession)
7525 {
7526 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7527 return;
7528 }
7529
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7531 {
7532 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7533 }
7534 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7535 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7536 {
7537 if ( eSIR_SME_SUCCESS == statusCode )
7538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007539 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7541 }
7542 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007546 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007547#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007548 /*
7549 * First ensure if the roam profile is in the scan cache.
7550 * If not, post a reassoc failure and disconnect.
7551 */
7552 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7553 if(HAL_STATUS_SUCCESS(status))
7554 {
7555 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7556 status = csrRoamPrepareFilterFromProfile(pMac,
7557 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7558 if(!HAL_STATUS_SUCCESS(status))
7559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007560 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007561 __func__, status);
7562 goto POST_ROAM_FAILURE;
7563 }
7564 else
7565 {
7566 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7567 if (!HAL_STATUS_SUCCESS(status))
7568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007569 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007570 __func__, status);
7571 goto POST_ROAM_FAILURE;
7572 }
7573 }
7574 }
7575 else
7576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007577 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007578 __func__, status);
7579 goto POST_ROAM_FAILURE;
7580 }
7581
7582 /*
7583 * After ensuring that the roam profile is in the scan result list,
7584 * dequeue the command from the active list.
7585 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7587 if ( pEntry )
7588 {
7589 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007590 /* If the head of the queue is Active and it is a ROAM command, remove
7591 * and put this on the Free queue.
7592 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 if ( eSmeCommandRoam == pCommand->command )
7594 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007595
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007596 /*
7597 * we need to process the result first before removing it from active list
7598 * because state changes still happening insides roamQProcessRoamResults so
7599 * no other roam command should be issued.
7600 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7602 if(pCommand->u.roamCmd.fReleaseProfile)
7603 {
7604 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7605 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 else
7610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007611 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007612 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 }
7614 }
7615 else
7616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007617 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 }
7619 }
7620 else
7621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007622 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007624
7625 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007626 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7627
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007628 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7629 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7630 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007631
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007632 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7633 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007634
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007635 /* Copy the connected profile to apply the same for this connection as well */
7636 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7637 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007639 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7640 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7641 //make sure to put it at the head of the cmd queue
7642 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7643 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7644 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7645
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 if(!HAL_STATUS_SUCCESS(status))
7647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007648 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007649 __func__, status);
7650 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 }
7652
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007653 /* Notify sub-modules like QoS etc. that handoff happening */
7654 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007655 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007656 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 csrFreeScanFilter(pMac, pScanFilter);
7658 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007659 return;
7660 }
7661
7662POST_ROAM_FAILURE:
7663 if (pScanFilter)
7664 {
7665 csrFreeScanFilter(pMac, pScanFilter);
7666 palFreeMemory( pMac->hHdd, pScanFilter );
7667 }
7668 if (pCurRoamProfile)
7669 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7670
7671 /* Inform the upper layers that the reassoc failed */
7672 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7673 csrRoamCallCallback(pMac, sessionId,
7674 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7675
7676 /*
7677 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7678 * Upon success, we would re-enter this routine after receiving the disassoc
7679 * response and will fall into the reassoc fail sub-state. And, eventually
7680 * call csrRoamComplete which would remove the roam command from SME active
7681 * queue.
7682 */
7683 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7684 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007686 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007687 __func__, status);
7688 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007690#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007691
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7693 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7694 {
7695 // Disassoc due to Reassoc failure falls into this codepath....
7696 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7697 }
7698 else
7699 {
7700 if ( eSIR_SME_SUCCESS == statusCode )
7701 {
7702 // Successfully disassociated from the 'old' Bss...
7703 //
7704 // We get Disassociate response in three conditions.
7705 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7706 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7707 // Infrastructure network.
7708 // - Third is where we are doing an Infra to Infra roam between networks with different
7709 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7710
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007711 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 }
7713 else
7714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007715 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 }
7717 //We are not done yet. Get the data and continue roaming
7718 csrRoamReissueRoamCommand(pMac);
7719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007720}
7721
Jeff Johnson295189b2012-06-20 16:38:30 -07007722static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7723{
7724 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007726 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7728 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7729 {
7730 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7731 }
7732 else
7733 {
7734 if ( eSIR_SME_SUCCESS == statusCode )
7735 {
7736 // Successfully deauth from the 'old' Bss...
7737 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007738 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007739 }
7740 else
7741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007742 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 }
7744 //We are not done yet. Get the data and continue roaming
7745 csrRoamReissueRoamCommand(pMac);
7746 }
7747}
7748
Jeff Johnson295189b2012-06-20 16:38:30 -07007749static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7750{
7751 eCsrRoamCompleteResult result;
7752
7753 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007755 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 result = eCsrStartBssSuccess;
7757 }
7758 else
7759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007760 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 //Let csrRoamComplete decide what to do
7762 result = eCsrStartBssFailure;
7763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007765}
7766
Jeff Johnson295189b2012-06-20 16:38:30 -07007767/*
7768 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7769 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7770 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7771 For the messages where sender allocates memory for specific structures, then it can be
7772 cast accordingly.
7773*/
7774void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7775{
7776 tSirSmeRsp *pSmeRsp;
7777 tSmeIbssPeerInd *pIbssPeerInd;
7778 tCsrRoamInfo roamInfo;
7779 // TODO Session Id need to be acquired in this function
7780 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007782 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 pSmeRsp->messageType, pSmeRsp->messageType,
7784 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 pSmeRsp->messageType = (pSmeRsp->messageType);
7786 pSmeRsp->length = (pSmeRsp->length);
7787 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007788 switch (pSmeRsp->messageType)
7789 {
7790
7791 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7792 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7793 {
7794 //We sent a JOIN_REQ
7795 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7796 }
7797 break;
7798
7799 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7800 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7801 {
7802 //We sent a AUTH_REQ
7803 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7804 }
7805 break;
7806
7807 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7808 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7809 {
7810 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7811 }
7812 break;
7813
7814 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7815 {
7816 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7817 }
7818 break;
7819
7820 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7821 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7822 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7823 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7824 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7825 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7826//HO
7827 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007829 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7831 }
7832 break;
7833
7834 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7835 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7836 {
7837 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7838 }
7839 break;
7840
7841 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7842 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7843 {
7844 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7845 }
7846 break;
7847
7848 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7849 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7850 {
7851 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7855 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7856 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007857 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7859 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7860 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7861 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7862 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7863 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7864 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7865 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007868 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 pSmeRsp->messageType, pSmeRsp->messageType,
7870 pMac->roam.curSubState[pSmeRsp->sessionId] );
7871
7872 //If we are connected, check the link status change
7873 if(!csrIsConnStateDisconnected(pMac, sessionId))
7874 {
7875 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7876 }
7877 break;
7878 }
7879}
7880
Jeff Johnson295189b2012-06-20 16:38:30 -07007881void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7882{
7883 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 switch (pSirMsg->messageType)
7885 {
7886 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007887 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 csrRoamStatsRspProcessor( pMac, pSirMsg );
7889 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7891 {
7892 tCsrRoamSession *pSession;
7893 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7894 tCsrRoamInfo roamInfo;
7895 tCsrRoamInfo *pRoamInfo = NULL;
7896 tANI_U32 sessionId;
7897 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007898 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7900 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7902 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7903 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007904
7905 if(!pSession)
7906 {
7907 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7908 return;
7909 }
7910
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7912 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7914 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7915 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7917 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7919 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7922 {
7923 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7924 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7925 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7926 }
7927 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7928 {
7929 vos_sleep( 100 );
7930 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7931 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7932 }
7933
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 }
7935 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 default:
7937 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7938 break;
7939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007940}
7941
Jeff Johnson295189b2012-06-20 16:38:30 -07007942eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7943 tSirBssDescription *pBssDescription,
7944 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7945 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7946 tANI_U8 keyId, tANI_U16 keyLength,
7947 tANI_U8 *pKey, tANI_U8 paeRole )
7948{
7949 eHalStatus status = eHAL_STATUS_SUCCESS;
7950 tAniEdType edType;
7951
7952 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7953 {
7954 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7955 }
7956
7957 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7958
7959 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7960 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7961 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7962 addKey )
7963 {
7964 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007965 setKey.encType = EncryptType;
7966 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7967 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7968 setKey.paeRole = paeRole; //0 for supplicant
7969 setKey.keyId = keyId; // Kye index
7970 setKey.keyLength = keyLength;
7971 if( keyLength )
7972 {
7973 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7974 }
7975 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007977 return (status);
7978}
7979
Jeff Johnson295189b2012-06-20 16:38:30 -07007980static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7981 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7982{
7983 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7984 tSmeCmd *pCommand = NULL;
7985#ifdef FEATURE_WLAN_CCX
7986 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7987#endif /* FEATURE_WLAN_CCX */
7988
7989 do
7990 {
7991 pCommand = csrGetCommandBuffer(pMac);
7992 if(NULL == pCommand)
7993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007994 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 status = eHAL_STATUS_RESOURCES;
7996 break;
7997 }
7998 pCommand->command = eSmeCommandSetKey;
7999 pCommand->sessionId = (tANI_U8)sessionId;
8000 // validate the key length, Adjust if too long...
8001 // for static WEP the keys are not set thru' SetContextReq
8002 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8003 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8004 {
8005 //KeyLength maybe 0 for static WEP
8006 if( pSetKey->keyLength )
8007 {
8008 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008010 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008011 break;
8012 }
8013
8014 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
8015 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
8016 }
8017 }
8018 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8019 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8020 {
8021 //KeyLength maybe 0 for static WEP
8022 if( pSetKey->keyLength )
8023 {
8024 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008026 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 break;
8028 }
8029
8030 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8031 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8032 }
8033 }
8034 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8035 {
8036 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008038 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 break;
8040 }
8041 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8042 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8043 }
8044 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8045 {
8046 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008048 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 break;
8050 }
8051 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8052 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8053 }
8054#ifdef FEATURE_WLAN_WAPI
8055 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8056 {
8057 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008059 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008060 break;
8061 }
8062 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8063 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8064 }
8065#endif /* FEATURE_WLAN_WAPI */
8066#ifdef FEATURE_WLAN_CCX
8067 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8068 {
8069 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8070 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008071 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 break;
8073 }
8074 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8075 pSession->ccxCckmInfo.reassoc_req_num=1;
8076 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8077 status = eHAL_STATUS_SUCCESS;
8078 break;
8079 }
8080#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008081
Jeff Johnson295189b2012-06-20 16:38:30 -07008082#ifdef WLAN_FEATURE_11W
8083 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008084 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008086 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008088 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 break;
8090 }
8091 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008092 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 }
8094#endif
8095 status = eHAL_STATUS_SUCCESS;
8096 pCommand->u.setKeyCmd.roamId = roamId;
8097 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8098 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8099 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8100 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8101 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8102 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8103 //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
8104
8105 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8106 if( !HAL_STATUS_SUCCESS( status ) )
8107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008108 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 }
8110 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 // Free the command if there has been a failure, or it is a
8112 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008113 if ( ( NULL != pCommand ) &&
8114 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008115#ifdef FEATURE_WLAN_CCX
8116 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8117#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008118 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 {
8120 csrReleaseCommandSetKey( pMac, pCommand );
8121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 return( status );
8123}
8124
Jeff Johnson295189b2012-06-20 16:38:30 -07008125eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8126 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8127{
8128 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8129 tSmeCmd *pCommand = NULL;
8130 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 do
8132 {
8133 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008135 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 status = eHAL_STATUS_CSR_WRONG_STATE;
8137 break;
8138 }
8139 pCommand = csrGetCommandBuffer(pMac);
8140 if(NULL == pCommand)
8141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008142 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 status = eHAL_STATUS_RESOURCES;
8144 break;
8145 }
8146 pCommand->command = eSmeCommandRemoveKey;
8147 pCommand->sessionId = (tANI_U8)sessionId;
8148 pCommand->u.removeKeyCmd.roamId = roamId;
8149 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8150 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8151 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8152 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8153 {
8154 //in this case, put it to the end of the Q incase there is a set key pending.
8155 fImediate = eANI_BOOLEAN_FALSE;
8156 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008157 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 pRemoveKey->encType, pRemoveKey->keyId,
8159 pCommand->u.removeKeyCmd.peerMac[0],
8160 pCommand->u.removeKeyCmd.peerMac[1],
8161 pCommand->u.removeKeyCmd.peerMac[2],
8162 pCommand->u.removeKeyCmd.peerMac[3],
8163 pCommand->u.removeKeyCmd.peerMac[4],
8164 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8166 if( !HAL_STATUS_SUCCESS( status ) )
8167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008168 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 break;
8170 }
8171 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8173 {
8174 csrReleaseCommandRemoveKey( pMac, pCommand );
8175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 return (status );
8177}
8178
Jeff Johnson295189b2012-06-20 16:38:30 -07008179eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8180{
8181 eHalStatus status;
8182 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8183 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8184 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8185 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008186#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8188 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008189 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 {
8191 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8192 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8193 {
8194 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8195 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8196 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8197 }
8198 else
8199 {
8200 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8201 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8202 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8203 }
8204 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
lukez3c809222013-05-03 10:23:02 -07008205 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 {
8207 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 //It has to be static WEP here
8209 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8210 {
8211 setKeyEvent.keyId = (v_U8_t)defKeyId;
8212 }
8213 }
8214 else
8215 {
8216 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8217 }
8218 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8219 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8220 }
8221#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 if( csrIsSetKeyAllowed(pMac, sessionId) )
8223 {
8224 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8225 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8226 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8227 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8228 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8229 pCommand->u.setKeyCmd.keyRsc);
8230 }
8231 else
8232 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008233 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 //Set this status so the error handling take care of the case.
8235 status = eHAL_STATUS_CSR_WRONG_STATE;
8236 }
8237 if( !HAL_STATUS_SUCCESS(status) )
8238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008239 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008241#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008242 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 {
8244 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8245 {
8246 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8247 }
8248 else
8249 {
8250 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8251 }
8252 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8253 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8254 }
8255#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 return ( status );
8258}
8259
Jeff Johnson295189b2012-06-20 16:38:30 -07008260eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8261{
8262 eHalStatus status;
8263 tpSirSmeRemoveKeyReq pMsg = NULL;
8264 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8265 tANI_U8 *p;
8266 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008267#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8268 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8269 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8271 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8272 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8273 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8274 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8275 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8276 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8277 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8278#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 if( csrIsSetKeyAllowed(pMac, sessionId) )
8280 {
8281 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8282 }
8283 else
8284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008285 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 //Set the error status so error handling kicks in below
8287 status = eHAL_STATUS_CSR_WRONG_STATE;
8288 }
8289 if( HAL_STATUS_SUCCESS( status ) )
8290 {
8291 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8292 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8293 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 pMsg->sessionId = (tANI_U8)sessionId;
8295 pMsg->transactionId = 0;
8296 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8297 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8298 // bssId - copy from session Info
8299 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8300 p += sizeof(tSirMacAddr);
8301 // peerMacAddr
8302 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8303 p += sizeof(tSirMacAddr);
8304 // edType
8305 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8306 p++;
8307 // weptype
8308 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8309 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8310 {
8311 *p = (tANI_U8)eSIR_WEP_STATIC;
8312 }
8313 else
8314 {
8315 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8316 }
8317 p++;
8318 //keyid
8319 *p = pCommand->u.removeKeyCmd.keyId;
8320 p++;
8321 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 status = palSendMBMessage(pMac->hHdd, pMsg);
8323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 if( !HAL_STATUS_SUCCESS( status ) )
8325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008326 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008327#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8328 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008329 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8331#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 return ( status );
8335}
8336
Jeff Johnson295189b2012-06-20 16:38:30 -07008337eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8338{
8339 eHalStatus status;
8340
8341 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8342 {
8343 status = eHAL_STATUS_CSR_WRONG_STATE;
8344 }
8345 else
8346 {
8347 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 return ( status );
8350}
8351
Jeff Johnson295189b2012-06-20 16:38:30 -07008352/*
8353 Prepare a filter base on a profile for parsing the scan results.
8354 Upon successful return, caller MUST call csrFreeScanFilter on
8355 pScanFilter when it is done with the filter.
8356*/
8357eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8358 tCsrScanResultFilter *pScanFilter)
8359{
8360 eHalStatus status = eHAL_STATUS_SUCCESS;
8361 tANI_U32 size = 0;
8362 tANI_U8 index = 0;
8363
8364 do
8365 {
8366 if(pProfile->BSSIDs.numOfBSSIDs)
8367 {
8368 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8369 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8370 if(!HAL_STATUS_SUCCESS(status))
8371 {
8372 break;
8373 }
8374 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8375 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8376 }
8377 if(pProfile->SSIDs.numOfSSIDs)
8378 {
8379 if( !CSR_IS_WDS_STA( pProfile ) )
8380 {
8381 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8382 }
8383 else
8384 {
8385 //For WDS station
8386 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8387 pScanFilter->SSIDs.numOfSSIDs = 1;
8388 }
8389 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8390 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8391 if(!HAL_STATUS_SUCCESS(status))
8392 {
8393 break;
8394 }
8395 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8396 }
8397 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8398 {
8399 pScanFilter->ChannelInfo.numOfChannels = 0;
8400 pScanFilter->ChannelInfo.ChannelList = NULL;
8401 }
8402 else if(pProfile->ChannelInfo.numOfChannels)
8403 {
8404 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8405 pScanFilter->ChannelInfo.numOfChannels = 0;
8406 if(HAL_STATUS_SUCCESS(status))
8407 {
8408 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8409 {
8410 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8411 {
8412 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8413 = pProfile->ChannelInfo.ChannelList[index];
8414 pScanFilter->ChannelInfo.numOfChannels++;
8415 }
8416 else
8417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008418 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 }
8421 }
8422 else
8423 {
8424 break;
8425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 }
8427 else
8428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008429 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 status = eHAL_STATUS_FAILURE;
8431 break;
8432 }
8433 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8434 pScanFilter->authType = pProfile->AuthType;
8435 pScanFilter->EncryptionType = pProfile->EncryptionType;
8436 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8437 pScanFilter->BSSType = pProfile->BSSType;
8438 pScanFilter->phyMode = pProfile->phyMode;
8439#ifdef FEATURE_WLAN_WAPI
8440 //check if user asked for WAPI with 11n or auto mode, in that case modify
8441 //the phymode to 11g
8442 if(csrIsProfileWapi(pProfile))
8443 {
8444 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8445 {
8446 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8447 }
8448 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8449 {
8450 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8451 }
8452 if(!pScanFilter->phyMode)
8453 {
8454 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8455 }
8456 }
8457#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 /*Save the WPS info*/
8459 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 if( pProfile->countryCode[0] )
8461 {
8462 //This causes the matching function to use countryCode as one of the criteria.
8463 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8464 WNI_CFG_COUNTRY_CODE_LEN );
8465 }
8466#ifdef WLAN_FEATURE_VOWIFI_11R
8467 if (pProfile->MDID.mdiePresent)
8468 {
8469 pScanFilter->MDID.mdiePresent = 1;
8470 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8471 }
8472#endif
8473
8474 }while(0);
8475
8476 if(!HAL_STATUS_SUCCESS(status))
8477 {
8478 csrFreeScanFilter(pMac, pScanFilter);
8479 }
8480
8481 return(status);
8482}
8483
Jeff Johnson295189b2012-06-20 16:38:30 -07008484tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8485 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8486{
8487 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8488 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 do
8490 {
8491 // Validate the type is ok...
8492 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8493 pCommand = csrGetCommandBuffer( pMac );
8494 if ( !pCommand )
8495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008496 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 break;
8498 }
8499 //Change the substate in case it is waiting for key
8500 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8501 {
8502 csrRoamStopWaitForKeyTimer( pMac );
8503 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8504 }
8505 pCommand->command = eSmeCommandWmStatusChange;
8506 pCommand->sessionId = (tANI_U8)sessionId;
8507 pCommand->u.wmStatusChangeCmd.Type = Type;
8508 if ( eCsrDisassociated == Type )
8509 {
8510 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8511 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8512 }
8513 else
8514 {
8515 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8516 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8517 }
8518 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8519 {
8520 fCommandQueued = eANI_BOOLEAN_TRUE;
8521 }
8522 else
8523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008524 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 csrReleaseCommandWmStatusChange( pMac, pCommand );
8526 }
8527
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8529 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 return( fCommandQueued );
8532}
8533
Jeff Johnson295189b2012-06-20 16:38:30 -07008534static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8535{
8536 v_S7_t rssi = 0;
8537 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8538 if(pGetRssiReq)
8539 {
8540 if(NULL != pGetRssiReq->pVosContext)
8541 {
8542 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8543 }
8544 else
8545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008546 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 return;
8548 }
8549
8550 if(NULL != pGetRssiReq->rssiCallback)
8551 {
8552 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8553 }
8554 else
8555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008556 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 return;
8558 }
8559 }
8560 else
8561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008562 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 }
8564 return;
8565}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308566
8567static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8568{
8569 tANI_S8 snr = 0;
8570 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8571
8572 if (pGetSnrReq)
8573 {
8574 if (VOS_STATUS_SUCCESS !=
8575 WDA_GetSnr(pGetSnrReq->staId, &snr))
8576 {
8577 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8578 return;
8579 }
8580
8581 if (pGetSnrReq->snrCallback)
8582 {
8583 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8584 pGetSnrReq->pDevContext);
8585 }
8586 else
8587 {
8588 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8589 return;
8590 }
8591 }
8592 else
8593 {
8594 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8595 }
8596 return;
8597}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008598#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8599void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8600{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008601 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8602
Jeff Johnson36d483b2013-04-08 11:08:53 -07008603 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008604 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008605 /* Get roam Rssi request is backed up and passed back to the response,
8606 Extract the request message to fetch callback */
8607 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8608 v_S7_t rssi = pRoamRssiRsp->rssi;
8609
8610 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008611 {
8612 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8613 reqBkp->rssiCallback = NULL;
8614 vos_mem_free(reqBkp);
8615 }
8616 else
8617 {
8618 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8619 if (NULL != reqBkp)
8620 {
8621 vos_mem_free(reqBkp);
8622 }
8623 }
8624 }
8625 else
8626 {
8627 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8628 }
8629 return;
8630}
8631#endif
8632
Jeff Johnsone7245742012-09-05 17:12:55 -07008633static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8634{
8635 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8636 if(pTlRssiInd)
8637 {
8638 if(NULL != pTlRssiInd->tlCallback)
8639 {
8640 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008641 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008642 }
8643 else
8644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008645 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008646 }
8647 }
8648 else
8649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008650 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008651 }
8652 return;
8653}
Jeff Johnson295189b2012-06-20 16:38:30 -07008654
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308655eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8656{
8657 tpSirResetAPCapsChange pMsg;
8658 tANI_U16 len;
8659 eHalStatus status = eHAL_STATUS_SUCCESS;
8660
8661 /* Create the message and send to lim */
8662 len = sizeof(tSirResetAPCapsChange);
8663 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8664 if (HAL_STATUS_SUCCESS(status))
8665 {
8666 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8667 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8668 pMsg->length = len;
8669 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8670 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8671 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8672 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8673 status = palSendMBMessage(pMac->hHdd, pMsg);
8674 }
8675 else
8676 {
8677 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8678 }
8679 return status;
8680}
8681
Jeff Johnson295189b2012-06-20 16:38:30 -07008682void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8683{
8684 tSirSmeAssocInd *pAssocInd;
8685 tSirSmeDisassocInd *pDisassocInd;
8686 tSirSmeDeauthInd *pDeauthInd;
8687 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8688 tSirSmeNewBssInfo *pNewBss;
8689 tSmeIbssPeerInd *pIbssPeerInd;
8690 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8691 tSirSmeApNewCaps *pApNewCaps;
8692 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8693 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8694 tCsrRoamInfo *pRoamInfo = NULL;
8695 tCsrRoamInfo roamInfo;
8696 eHalStatus status;
8697 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8698 tCsrRoamSession *pSession = NULL;
8699 tpSirSmeSwitchChannelInd pSwitchChnInd;
8700 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008701 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 pSirMsg->messageType = (pSirMsg->messageType);
8703 pSirMsg->length = (pSirMsg->length);
8704 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 switch( pSirMsg->messageType )
8707 {
8708 case eWNI_SME_ASSOC_IND:
8709 {
8710 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008711 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8713 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8714 if( HAL_STATUS_SUCCESS( status ) )
8715 {
8716 pSession = CSR_GET_SESSION(pMac, sessionId);
8717
Jeff Johnson32d95a32012-09-10 13:15:23 -07008718 if(!pSession)
8719 {
8720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8721 return;
8722 }
8723
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 pRoamInfo = &roamInfo;
8725
8726 // Required for indicating the frames to upper layer
8727 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8728 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8729
8730 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8731 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8732 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8733 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8734
8735 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8736 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8737 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8738
8739 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8740 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8742 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8744 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8747 {
8748 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8749 {
8750 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8751 pSession->pConnectBssDesc,
8752 &(pRoamInfo->peerMac),
8753 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8754 pRoamInfo->fAuthRequired = FALSE;
8755 }
8756 else
8757 {
8758 pRoamInfo->fAuthRequired = TRUE;
8759 }
8760 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8761 if (!HAL_STATUS_SUCCESS(status))
8762 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 /* Send Association completion message to PE */
8765 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8766
8767 /* send a message to CSR itself just to avoid the EAPOL frames going
8768 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8770 {
8771 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8774 {
8775 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8776 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8777 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
8780 }
8781 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008783 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 // Check if AP dis-associated us because of MIC failure. If so,
8785 // then we need to take action immediately and not wait till the
8786 // the WmStatusChange requests is pushed and processed
8787 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8788 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8789 if( HAL_STATUS_SUCCESS( status ) )
8790 {
8791 // If we are in neighbor preauth done state then on receiving
8792 // disassoc or deauth we dont roam instead we just disassoc
8793 // from current ap and then go to disconnected state
8794 // This happens for CCX and 11r FT connections ONLY.
8795#ifdef WLAN_FEATURE_VOWIFI_11R
8796 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8797 {
8798 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8799 }
8800#endif
8801#ifdef FEATURE_WLAN_CCX
8802 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8803 {
8804 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8805 }
8806#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008807#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308808 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008809 {
8810 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8811 }
8812#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 pSession = CSR_GET_SESSION( pMac, sessionId );
8814
Jeff Johnson32d95a32012-09-10 13:15:23 -07008815 if(!pSession)
8816 {
8817 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8818 return;
8819 }
8820
Jeff Johnson295189b2012-06-20 16:38:30 -07008821 if ( csrIsConnStateInfra( pMac, sessionId ) )
8822 {
8823 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008825#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8826 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8827#endif
8828 csrRoamLinkDown(pMac, sessionId);
8829 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8831 {
8832
8833 pRoamInfo = &roamInfo;
8834
8835 pRoamInfo->statusCode = pDisassocInd->statusCode;
8836 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8837
8838 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8839
8840 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8841 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8842
8843 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008844
8845 /*
8846 * STA/P2P client got disassociated so remove any pending deauth
8847 * commands in sme pending list
8848 */
8849 pCommand.command = eSmeCommandRoam;
8850 pCommand.sessionId = (tANI_U8)sessionId;
8851 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8852 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8853 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 }
8856 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008858 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008859 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8860 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8861 if( HAL_STATUS_SUCCESS( status ) )
8862 {
8863 // If we are in neighbor preauth done state then on receiving
8864 // disassoc or deauth we dont roam instead we just disassoc
8865 // from current ap and then go to disconnected state
8866 // This happens for CCX and 11r FT connections ONLY.
8867#ifdef WLAN_FEATURE_VOWIFI_11R
8868 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8869 {
8870 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8871 }
8872#endif
8873#ifdef FEATURE_WLAN_CCX
8874 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8875 {
8876 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8877 }
8878#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008879#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308880 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008881 {
8882 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8883 }
8884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 pSession = CSR_GET_SESSION( pMac, sessionId );
8886
Jeff Johnson32d95a32012-09-10 13:15:23 -07008887 if(!pSession)
8888 {
8889 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8890 return;
8891 }
8892
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 if ( csrIsConnStateInfra( pMac, sessionId ) )
8894 {
8895 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008897#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8898 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8899#endif
8900 csrRoamLinkDown(pMac, sessionId);
8901 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8903 {
8904
8905 pRoamInfo = &roamInfo;
8906
8907 pRoamInfo->statusCode = pDeauthInd->statusCode;
8908 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8909
8910 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8911
8912 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8913 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8914
8915 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 }
8918 break;
8919
8920 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 -08008921 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8923 //Update with the new channel id.
8924 //The channel id is hidden in the statusCode.
8925 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8926 if( HAL_STATUS_SUCCESS( status ) )
8927 {
8928 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008929 if(!pSession)
8930 {
8931 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8932 return;
8933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8935 if(pSession->pConnectBssDesc)
8936 {
8937 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8938 }
8939 }
8940 break;
8941
8942 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008943 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 {
8945 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8946 sessionId = pDeauthRsp->sessionId;
8947 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8948 {
8949 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008950 if(!pSession)
8951 {
8952 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8953 return;
8954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8956 {
8957 pRoamInfo = &roamInfo;
8958 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8959 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8960 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8961 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8962 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8963 }
8964 }
8965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 break;
8967
8968 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008969 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008970 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008971 {
8972 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8973 sessionId = pDisassocRsp->sessionId;
8974 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8975 {
8976 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008977 if(!pSession)
8978 {
8979 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8980 return;
8981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8983 {
8984 pRoamInfo = &roamInfo;
8985 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8986 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8987 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8988 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8989 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8990 }
8991 }
8992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 case eWNI_SME_MIC_FAILURE_IND:
8995 {
8996 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8997 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8998 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07008999
9000 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9001 if( HAL_STATUS_SUCCESS( status ) )
9002 {
9003 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9004 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9005 pRoamInfo = &roamInfo;
9006 if(pMicInd->info.multicast)
9007 {
9008 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9009 }
9010 else
9011 {
9012 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9013 }
9014 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9015 }
9016
Jeff Johnson295189b2012-06-20 16:38:30 -07009017#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9018 {
lukez3c809222013-05-03 10:23:02 -07009019 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009020 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009021 if(!pSession)
9022 {
9023 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9024 return;
9025 }
lukez3c809222013-05-03 10:23:02 -07009026
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
9028 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9029 secEvent.encryptionModeMulticast =
9030 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9031 secEvent.encryptionModeUnicast =
9032 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9033 secEvent.authMode =
9034 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9035 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
9036 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9037 }
9038#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Leo Chang9b01ad92013-09-12 17:26:56 -07009039
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 }
9041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9043 {
9044 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9045 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009046 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009047
9048 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9049 if( HAL_STATUS_SUCCESS( status ) )
9050 {
9051 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9052 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9053 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9054 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9055 }
9056 }
9057 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009058
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9060 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9061 switch( pStatusChangeMsg->statusChangeCode )
9062 {
9063 case eSIR_SME_IBSS_ACTIVE:
9064 sessionId = csrFindIbssSession( pMac );
9065 if( CSR_SESSION_ID_INVALID != sessionId )
9066 {
9067 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009068 if(!pSession)
9069 {
9070 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9071 return;
9072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9074 if(pSession->pConnectBssDesc)
9075 {
9076 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9077 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9078 pRoamInfo = &roamInfo;
9079 }
9080 else
9081 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009082 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 }
9084 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9085 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9086 }
9087 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009088 case eSIR_SME_IBSS_INACTIVE:
9089 sessionId = csrFindIbssSession( pMac );
9090 if( CSR_SESSION_ID_INVALID != sessionId )
9091 {
9092 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009093 if(!pSession)
9094 {
9095 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9096 return;
9097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9099 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9100 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9101 }
9102 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9104 sessionId = csrFindIbssSession( pMac );
9105 if( CSR_SESSION_ID_INVALID != sessionId )
9106 {
9107 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009108 if(!pSession)
9109 {
9110 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9111 return;
9112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 // update the connection state information
9114 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009115#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9116 {
9117 vos_log_ibss_pkt_type *pIbssLog;
9118 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9120 if(pIbssLog)
9121 {
9122 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9123 if(pNewBss)
9124 {
9125 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9126 if(pNewBss->ssId.length)
9127 {
9128 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9129 }
9130 pIbssLog->operatingChannel = pNewBss->channelNumber;
9131 }
9132 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9133 {
9134 //***U8 is not enough for beacon interval
9135 pIbssLog->beaconInterval = (v_U8_t)bi;
9136 }
9137 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9138 }
9139 }
9140#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009142
9143 if ((eCSR_ENCRYPT_TYPE_NONE ==
9144 pSession->connectedProfile.EncryptionType ))
9145 {
9146 csrRoamIssueSetContextReq( pMac, sessionId,
9147 pSession->connectedProfile.EncryptionType,
9148 pSession->pConnectBssDesc,
9149 &Broadcastaddr,
9150 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9153 roamStatus = eCSR_ROAM_IBSS_IND;
9154 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9155 pRoamInfo = &roamInfo;
9156 //This BSSID is th ereal BSSID, let's save it
9157 if(pSession->pConnectBssDesc)
9158 {
9159 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009162 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 // detection by LIM that the capabilities of the associated AP have changed.
9165 case eSIR_SME_AP_CAPS_CHANGED:
9166 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009167 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9169 if( HAL_STATUS_SUCCESS( status ) )
9170 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009171 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9172 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309173 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009174 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9175 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9176 )
9177 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309178 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9179 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009180 }
9181 else
9182 {
9183 smsLog(pMac, LOGW,
9184 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009185 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009186 pMac->roam.curState[sessionId],
9187 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309188 /* We ignore the caps change event if CSR is not in full connected state.
9189 * Send one event to PE to reset limSentCapsChangeNtf
9190 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9191 * otherwise lim cannot send any CAPS change events to SME */
9192 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009194 }
9195 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309196
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 default:
9198 roamStatus = eCSR_ROAM_FAILED;
9199 result = eCSR_ROAM_RESULT_NONE;
9200 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 } // end switch on statusChangeCode
9202 if(eCSR_ROAM_RESULT_NONE != result)
9203 {
9204 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9205 }
9206 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 case eWNI_SME_IBSS_NEW_PEER_IND:
9208 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009209#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9210 {
9211 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9213 if(pIbssLog)
9214 {
9215 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9216 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9217 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9218 }
9219 }
9220#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 sessionId = csrFindIbssSession( pMac );
9222 if( CSR_SESSION_ID_INVALID != sessionId )
9223 {
9224 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009225
9226 if(!pSession)
9227 {
9228 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9229 return;
9230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9232 if(pSession->pConnectBssDesc)
9233 {
9234 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9235 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9236 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9237 {
9238 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9239 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9240 if(HAL_STATUS_SUCCESS(status))
9241 {
9242 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9243 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9244 roamInfo.nBeaconLength);
9245 }
9246 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9247 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9248 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9249 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9250 pSession->pConnectBssDesc->length);
9251 if(HAL_STATUS_SUCCESS(status))
9252 {
9253 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9254 pSession->pConnectBssDesc->length);
9255 }
9256 if(HAL_STATUS_SUCCESS(status))
9257 {
9258 pRoamInfo = &roamInfo;
9259 }
9260 else
9261 {
9262 if(roamInfo.pbFrames)
9263 {
9264 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9265 }
9266 if(roamInfo.pBssDesc)
9267 {
9268 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9269 }
9270 }
9271 }
9272 else
9273 {
9274 pRoamInfo = &roamInfo;
9275 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009276 if ((eCSR_ENCRYPT_TYPE_NONE ==
9277 pSession->connectedProfile.EncryptionType ))
9278 {
9279 csrRoamIssueSetContextReq( pMac, sessionId,
9280 pSession->connectedProfile.EncryptionType,
9281 pSession->pConnectBssDesc,
9282 &(pIbssPeerInd->peerAddr),
9283 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 }
9286 else
9287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009288 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 }
9290 //send up the sec type for the new peer
9291 if (pRoamInfo)
9292 {
9293 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9294 }
9295 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9296 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9297 if(pRoamInfo)
9298 {
9299 if(roamInfo.pbFrames)
9300 {
9301 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9302 }
9303 if(roamInfo.pBssDesc)
9304 {
9305 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9306 }
9307 }
9308 }
9309 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009310 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9311 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9312 sessionId = csrFindIbssSession( pMac );
9313 if( CSR_SESSION_ID_INVALID != sessionId )
9314 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009315#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9316 {
9317 vos_log_ibss_pkt_type *pIbssLog;
9318
9319 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9320 if(pIbssLog)
9321 {
9322 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9323 if(pIbssPeerInd)
9324 {
9325 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9326 }
9327 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9328 }
9329 }
9330#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009331 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9333 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9334 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9335 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9336 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9337 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9338 }
9339 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 case eWNI_SME_SETCONTEXT_RSP:
9341 {
9342 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9343 tListElem *pEntry;
9344 tSmeCmd *pCommand;
9345
9346 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9347 if ( pEntry )
9348 {
9349 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9350 if ( eSmeCommandSetKey == pCommand->command )
9351 {
9352 sessionId = pCommand->sessionId;
9353 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009354
9355 if(!pSession)
9356 {
9357 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9358 return;
9359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009360
9361#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9362 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9363 {
9364 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9365 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9366 if( pRsp->peerMacAddr[0] & 0x01 )
9367 {
9368 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9369 }
9370 else
9371 {
9372 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9373 }
9374 setKeyEvent.encryptionModeMulticast =
9375 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9376 setKeyEvent.encryptionModeUnicast =
9377 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9378 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9379 setKeyEvent.authMode =
9380 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009381 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 {
9383 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9384 }
9385 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9386 }
9387#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9388 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9389 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009390 csrRoamStopWaitForKeyTimer( pMac );
9391
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 //We are done with authentication, whethere succeed or not
9393 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 //We do it here because this linkup function is not called after association
9395 //when a key needs to be set.
9396 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9397 {
9398 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9399 }
9400 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009401 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 {
9403 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009404 //Make sure we install the GTK before indicating to HDD as authenticated
9405 //This is to prevent broadcast packets go out after PTK and before GTK.
9406 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9407 sizeof(tSirMacAddr) ) )
9408 {
Yathish9f22e662012-12-10 14:21:35 -08009409#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9410 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9411 {
9412 tpSirSetActiveModeSetBncFilterReq pMsg;
9413 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9414 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9415 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9416 pMsg->seesionId = sessionId;
9417 status = palSendMBMessage(pMac->hHdd, pMsg );
9418 }
9419#endif
9420 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009421 }
9422 else
9423 {
9424 result = eCSR_ROAM_RESULT_NONE;
9425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 pRoamInfo = &roamInfo;
9427 }
9428 else
9429 {
9430 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009431 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9433 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9434 }
9435 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9436 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9438 // can go ahead and initiate the TSPEC if any are pending
9439 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009440#ifdef FEATURE_WLAN_CCX
9441 //Send Adjacent AP repot to new AP.
9442 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9443 pSession->isPrevApInfoValid &&
9444 pSession->connectedProfile.isCCXAssoc)
9445 {
9446#ifdef WLAN_FEATURE_VOWIFI
9447 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9448#endif
9449 pSession->isPrevApInfoValid = FALSE;
9450 }
9451#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9453 {
9454 csrReleaseCommandSetKey( pMac, pCommand );
9455 }
9456 }
9457 else
9458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009459 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 }
9461 }
9462 else
9463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009464 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 smeProcessPendingQueue( pMac );
9467 }
9468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 case eWNI_SME_REMOVEKEY_RSP:
9470 {
9471 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9472 tListElem *pEntry;
9473 tSmeCmd *pCommand;
9474
9475 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9476 if ( pEntry )
9477 {
9478 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9479 if ( eSmeCommandRemoveKey == pCommand->command )
9480 {
9481 sessionId = pCommand->sessionId;
9482 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009483
9484 if(!pSession)
9485 {
9486 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9487 return;
9488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009489#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9490 {
9491 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9492 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9493 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9494 removeKeyEvent.encryptionModeMulticast =
9495 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9496 removeKeyEvent.encryptionModeUnicast =
9497 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9498 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9499 removeKeyEvent.authMode =
9500 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009501 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 {
9503 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9504 }
9505 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9506 }
9507#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009508 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 {
9510 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9511 result = eCSR_ROAM_RESULT_NONE;
9512 pRoamInfo = &roamInfo;
9513 }
9514 else
9515 {
9516 result = eCSR_ROAM_RESULT_FAILURE;
9517 }
9518 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9519 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9520 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9521 {
9522 csrReleaseCommandRemoveKey( pMac, pCommand );
9523 }
9524 }
9525 else
9526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009527 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 }
9529 }
9530 else
9531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009532 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 smeProcessPendingQueue( pMac );
9535 }
9536 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009538 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 csrRoamStatsRspProcessor( pMac, pSirMsg );
9540 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009541#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9542 case eWNI_SME_GET_ROAM_RSSI_RSP:
9543 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9544 csrRoamRssiRspProcessor( pMac, pSirMsg );
9545 break;
9546#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009548 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 csrUpdateRssi( pMac, pSirMsg );
9550 break;
9551
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309552 case eWNI_SME_GET_SNR_REQ:
9553 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9554 csrUpdateSnr(pMac, pSirMsg);
9555 break;
9556
Jeff Johnson295189b2012-06-20 16:38:30 -07009557#ifdef WLAN_FEATURE_VOWIFI_11R
9558 case eWNI_SME_FT_PRE_AUTH_RSP:
9559 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9560 break;
9561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9563 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009564 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 -07009565 sessionId = pSmeMaxAssocInd->sessionId;
9566 roamInfo.sessionId = sessionId;
9567 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9568 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9569 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9570 break;
9571
9572 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009573 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 btampEstablishLogLinkHdlr( pSirMsg );
9575 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009576 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009577 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009578 csrRoamRssiIndHdlr( pMac, pSirMsg );
9579 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009580#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9581 case eWNI_SME_CANDIDATE_FOUND_IND:
9582 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9583 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9584 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009585 case eWNI_SME_HANDOFF_REQ:
9586 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9587 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9588 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009590
9591 default:
9592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009594}
9595
Jeff Johnson295189b2012-06-20 16:38:30 -07009596void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9597 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9598{
9599 if(pSession)
9600 {
9601 if(pSession->bRefAssocStartCnt)
9602 {
9603 pSession->bRefAssocStartCnt--;
9604 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9605 //Need to call association_completion because there is an assoc_start pending.
9606 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9607 eCSR_ROAM_ASSOCIATION_COMPLETION,
9608 eCSR_ROAM_RESULT_FAILURE);
9609 }
9610 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9611 }
9612 else
9613 {
9614 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9615 }
9616}
9617
9618
9619eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9620{
9621 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9623 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9624 {
9625 status = csrScanRequestLostLink1( pMac, sessionId );
9626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 return(status);
9628}
9629
Jeff Johnson295189b2012-06-20 16:38:30 -07009630//return a boolean to indicate whether roaming completed or continue.
9631tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9632 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9633{
9634 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9635 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9636 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9637 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009638 if(!pSession)
9639 {
9640 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9641 return eANI_BOOLEAN_FALSE;
9642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 //Check whether time is up
9644 if(pSession->fCancelRoaming || fForce ||
9645 ((curTime - pSession->roamingStartTime) > roamTime) ||
9646 eCsrReassocRoaming == pSession->roamingReason ||
9647 eCsrDynamicRoaming == pSession->roamingReason)
9648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009649 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9651 {
9652 //roaming is cancelled, tell HDD to indicate disconnect
9653 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9654 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9655 //to be eSIR_BEACON_MISSED
9656 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9657 {
9658 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9659 }
9660 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9661 {
9662 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9663 }
9664 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9665 {
9666 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9667 }
9668 else
9669 {
9670 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9671 }
9672 }
9673 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9674 pSession->roamingReason = eCsrNotRoaming;
9675 }
9676 else
9677 {
9678 pSession->roamResult = roamResult;
9679 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9680 {
9681 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9682 pSession->roamingReason = eCsrNotRoaming;
9683 }
9684 else
9685 {
9686 fCompleted = eANI_BOOLEAN_FALSE;
9687 }
9688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 return(fCompleted);
9690}
9691
Jeff Johnson295189b2012-06-20 16:38:30 -07009692void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9693{
9694 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009695
9696 if(!pSession)
9697 {
9698 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9699 return;
9700 }
9701
Jeff Johnson295189b2012-06-20 16:38:30 -07009702 if(CSR_IS_ROAMING(pSession))
9703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009704 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9706 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9707 {
9708 //No need to do anything in here because the handler takes care of it
9709 }
9710 else
9711 {
9712 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9713 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9714 //Roaming is stopped after here
9715 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9716 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05309717 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 csrRoamStopRoamingTimer(pMac, sessionId);
9719 }
9720 }
9721}
9722
Jeff Johnson295189b2012-06-20 16:38:30 -07009723void csrRoamRoamingTimerHandler(void *pv)
9724{
9725 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9726 tpAniSirGlobal pMac = pInfo->pMac;
9727 tANI_U32 sessionId = pInfo->sessionId;
9728 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009729
9730 if(!pSession)
9731 {
9732 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9733 return;
9734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009735
9736 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9737 {
9738 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9739 {
9740 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9741 pSession->roamingReason = eCsrNotRoaming;
9742 }
9743 }
9744}
9745
Jeff Johnson295189b2012-06-20 16:38:30 -07009746eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9747{
9748 eHalStatus status;
9749 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009750
9751 if(!pSession)
9752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009753 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009754 return eHAL_STATUS_FAILURE;
9755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009756
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009757 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309759 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009760
9761 return (status);
9762}
9763
Jeff Johnson295189b2012-06-20 16:38:30 -07009764eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9765{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309766 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -07009767}
9768
Jeff Johnson295189b2012-06-20 16:38:30 -07009769void csrRoamWaitForKeyTimeOutHandler(void *pv)
9770{
9771 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9772 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009773 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9774
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009775 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009776 pMac->roam.neighborRoamInfo.neighborRoamState,
9777 pMac->roam.curSubState[pInfo->sessionId]);
9778
Jeff Johnson295189b2012-06-20 16:38:30 -07009779 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9780 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009781#ifdef FEATURE_WLAN_LFR
9782 if (csrNeighborRoamIsHandoffInProgress(pMac))
9783 {
9784 /*
9785 * Enable heartbeat timer when hand-off is in progress
9786 * and Key Wait timer expired.
9787 */
9788 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009789 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009790 pMac->roam.configParam.HeartbeatThresh24);
9791 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9792 pMac->roam.configParam.HeartbeatThresh24,
9793 NULL, eANI_BOOLEAN_FALSE);
9794 }
9795#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009796 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07009797
Jeff Johnson295189b2012-06-20 16:38:30 -07009798 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07009799 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
9800 {
9801 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
9802 pInfo->sessionId);
9803 }
9804
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009805 if (pSession)
9806 {
9807 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9808 {
9809 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9810 smeProcessPendingQueue(pMac);
9811 }
9812 else
9813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009814 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009815 __func__);
9816 }
9817 }
9818 else
9819 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009820 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 }
9823
9824}
9825
Jeff Johnson295189b2012-06-20 16:38:30 -07009826eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9827{
9828 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009829#ifdef FEATURE_WLAN_LFR
9830 if (csrNeighborRoamIsHandoffInProgress(pMac))
9831 {
9832 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009833 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009834 __func__,
9835 pMac->roam.neighborRoamInfo.neighborRoamState,
9836 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9837 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9838 }
9839#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009840 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309841 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009842
9843 return (status);
9844}
9845
Jeff Johnson295189b2012-06-20 16:38:30 -07009846eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9847{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009848 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009849 pMac->roam.neighborRoamInfo.neighborRoamState,
9850 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9851#ifdef FEATURE_WLAN_LFR
9852 if (csrNeighborRoamIsHandoffInProgress(pMac))
9853 {
9854 /*
9855 * Enable heartbeat timer when hand-off is in progress
9856 * and Key Wait timer got stopped for some reason
9857 */
9858 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009859 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009860 pMac->roam.configParam.HeartbeatThresh24);
9861 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9862 pMac->roam.configParam.HeartbeatThresh24,
9863 NULL, eANI_BOOLEAN_FALSE);
9864 }
9865#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309866 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009867}
9868
Jeff Johnson295189b2012-06-20 16:38:30 -07009869void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9870 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9871{
9872 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9873 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009874 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9875 /* To silence the KW tool Null chaeck is added */
9876 if(!pSession)
9877 {
9878 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9879 return;
9880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009881
9882 if(pCommand)
9883 {
9884 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9888 {
9889 //if success, force roaming completion
9890 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9891 }
9892 else
9893 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009894 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009895 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009896 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9897 }
9898}
9899
Jeff Johnson295189b2012-06-20 16:38:30 -07009900eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9901{
9902 eHalStatus status = eHAL_STATUS_SUCCESS;
9903 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9904 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9905 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9906 tCsrRoamInfo *pRoamInfo = NULL;
9907 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009908 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009910 /* To silence the KW tool Null chaeck is added */
9911 if(!pSession)
9912 {
9913 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9914 return eHAL_STATUS_FAILURE;
9915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009917 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9919 if ( eWNI_SME_DISASSOC_IND == type )
9920 {
9921 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9922 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9923 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009924 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 }
9926 else if ( eWNI_SME_DEAUTH_IND == type )
9927 {
9928 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9929 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9930 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009931 /* Convert into proper reason code */
9932 pSession->joinFailStatusCode.reasonCode =
9933 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309934 0 : pDeauthIndMsg->reasonCode;
9935 /* cfg layer expects 0 as reason code if
9936 the driver dosent know the reason code
9937 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 }
9939 else
9940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009941 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009943 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 }
9945
9946 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 {
9949 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9950 }
9951
9952 if ( eWNI_SME_DISASSOC_IND == type )
9953 {
9954 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9955 }
9956 else if ( eWNI_SME_DEAUTH_IND == type )
9957 {
9958 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009960 if(!HAL_STATUS_SUCCESS(status))
9961 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009962 //If fail to send confirmation to PE, not to trigger roaming
9963 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 }
9965
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009966 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9968 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9969 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 if( eWNI_SME_DISASSOC_IND == type)
9971 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009972 //staMacAddr
9973 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9974 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 else if( eWNI_SME_DEAUTH_IND == type )
9977 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009978 //staMacAddr
9979 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9980 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9981 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009982 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009983
9984 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9985 that we are roaming. But if we cannot possibly roam, or if we are unable to
9986 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009987 if(fToRoam)
9988 {
9989 //Only remove the connected BSS in infrastructure mode
9990 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9991 //Not to do anying for lostlink with WDS
9992 if( pMac->roam.configParam.nRoamingTime )
9993 {
9994 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9995 ( eWNI_SME_DEAUTH_IND == type ) ?
9996 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9997 {
9998 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9999 //For IBSS, we need to give some more info to HDD
10000 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10001 {
10002 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10003 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10004 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10005 }
10006 else
10007 {
10008 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10009 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010010 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10012 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10013 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10014 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10015 }
10016 else
10017 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010018 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 fToRoam = eANI_BOOLEAN_FALSE;
10020 }
10021 }
10022 else
10023 {
10024 //We are told not to roam, indicate lostlink
10025 fToRoam = eANI_BOOLEAN_FALSE;
10026 }
10027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 if(!fToRoam)
10029 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010030 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010031 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010032 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010033 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10034 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10035 * csrRoamCheckForLinkStatusChange API.
10036 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010037 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10038 }
10039
10040 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 Still enable idle scan for polling in case concurrent sessions are running */
10042 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10043 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010044 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 }
10046 }
10047
10048 return (status);
10049}
10050
Jeff Johnson295189b2012-06-20 16:38:30 -070010051eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10052{
10053 eHalStatus status = eHAL_STATUS_SUCCESS;
10054 tListElem *pEntry = NULL;
10055 tSmeCmd *pCommand = NULL;
10056 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010057
10058 if(!pSession)
10059 {
10060 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10061 return eHAL_STATUS_FAILURE;
10062 }
10063
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 //Only remove the connected BSS in infrastructure mode
10066 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10067 if(pMac->roam.configParam.nRoamingTime)
10068 {
10069 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10070 {
10071 //before starting the lost link logic release the roam command for handoff
10072 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10073 if(pEntry)
10074 {
10075 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10076 }
10077 if(pCommand)
10078 {
10079 if (( eSmeCommandRoam == pCommand->command ) &&
10080 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10081 {
10082 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10083 {
10084 csrReleaseCommandRoam( pMac, pCommand );
10085 }
10086 }
10087 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010088 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 }
10090 }
10091 else
10092 {
10093 //We are told not to roam, indicate lostlink
10094 status = eHAL_STATUS_FAILURE;
10095 }
10096
10097 return (status);
10098}
Jeff Johnson295189b2012-06-20 16:38:30 -070010099void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10100{
10101 tListElem *pEntry;
10102 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10104 if ( pEntry )
10105 {
10106 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10107 if ( eSmeCommandWmStatusChange == pCommand->command )
10108 {
10109 // Nothing to process in a Lost Link completion.... It just kicks off a
10110 // roaming sequence.
10111 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10112 {
10113 csrReleaseCommandWmStatusChange( pMac, pCommand );
10114 }
10115 else
10116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010117 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 }
10119
10120 }
10121 else
10122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010123 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 }
10125 }
10126 else
10127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010128 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 smeProcessPendingQueue( pMac );
10131}
10132
Jeff Johnson295189b2012-06-20 16:38:30 -070010133void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10134{
10135 eHalStatus status = eHAL_STATUS_FAILURE;
10136 tSirSmeRsp *pSirSmeMsg;
10137 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010138
10139 if(!pSession)
10140 {
10141 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10142 return;
10143 }
10144
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 switch ( pCommand->u.wmStatusChangeCmd.Type )
10146 {
10147 case eCsrDisassociated:
10148 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10149 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 case eCsrDeauthenticated:
10152 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10153 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010156 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 break;
10158 }
10159 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10160 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10161 {
10162 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10163 {
10164 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010165 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 }
10167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010168 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10169 // command here since there is nothing else to do.
10170 csrRoamWmStatusChangeComplete( pMac );
10171}
10172
Jeff Johnson295189b2012-06-20 16:38:30 -070010173//This function returns band and mode information.
10174//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10175//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010176static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10177 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010178{
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10180 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10181 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010183
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 //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 -070010185 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10186 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10187 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10188 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010189 {
10190 switch( pMac->roam.configParam.uCfgDot11Mode )
10191 {
10192 case eCSR_CFG_DOT11_MODE_11A:
10193 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10194 eBand = eCSR_BAND_5G;
10195 break;
10196 case eCSR_CFG_DOT11_MODE_11B:
10197 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10198 eBand = eCSR_BAND_24;
10199 break;
10200 case eCSR_CFG_DOT11_MODE_11G:
10201 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10202 eBand = eCSR_BAND_24;
10203 break;
10204 case eCSR_CFG_DOT11_MODE_11N:
10205 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010206 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10207 break;
10208#ifdef WLAN_FEATURE_11AC
10209 case eCSR_CFG_DOT11_MODE_11AC:
10210 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10211 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010212 /* If the operating channel is in 2.4 GHz band, check for
10213 * INI item to disable VHT operation in 2.4 GHz band
10214 */
10215 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10216 !pMac->roam.configParam.enableVhtFor24GHz)
10217 {
10218 /* Disable 11AC operation */
10219 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10220 }
10221 else
10222 {
10223 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10224 }
10225 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010226 }
10227 else
10228 {
10229 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10230 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10231 }
10232 break;
10233 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10234 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10235 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010236 /* If the operating channel is in 2.4 GHz band, check for
10237 * INI item to disable VHT operation in 2.4 GHz band
10238 */
10239 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10240 !pMac->roam.configParam.enableVhtFor24GHz)
10241 {
10242 /* Disable 11AC operation */
10243 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10244 }
10245 else
10246 {
10247 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10248 }
10249 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010250 }
10251 else
10252 {
10253 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10254 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10255 }
10256 break;
10257#endif
10258 case eCSR_CFG_DOT11_MODE_AUTO:
10259 eBand = pMac->roam.configParam.eBand;
10260 if (eCSR_BAND_24 == eBand)
10261 {
10262 // WiFi tests require IBSS networks to start in 11b mode
10263 // without any change to the default parameter settings
10264 // on the adapter. We use ACU to start an IBSS through
10265 // creation of a startIBSS profile. This startIBSS profile
10266 // has Auto MACProtocol and the adapter property setting
10267 // for dot11Mode is also AUTO. So in this case, let's
10268 // start the IBSS network in 11b mode instead of 11g mode.
10269 // So this is for Auto=profile->MacProtocol && Auto=Global.
10270 // dot11Mode && profile->channel is < 14, then start the IBSS
10271 // in b mode.
10272 //
10273 // Note: we used to have this start as an 11g IBSS for best
10274 // performance... now to specify that the user will have to
10275 // set the do11Mode in the property page to 11g to force it.
10276 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10277 }
10278 else
10279 {
10280#ifdef WLAN_FEATURE_11AC
10281 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10282 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010283 /* If the operating channel is in 2.4 GHz band, check for
10284 * INI item to disable VHT operation in 2.4 GHz band
10285 */
10286 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10287 !pMac->roam.configParam.enableVhtFor24GHz)
10288 {
10289 /* Disable 11AC operation */
10290 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10291 }
10292 else
10293 {
10294 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10295 }
10296 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010297 }
10298 else
10299 {
10300 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10301 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10302 }
10303#else
10304 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10305 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10306#endif
10307 }
10308 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010309 default:
10310 // Global dot11 Mode setting is 11a/b/g.
10311 // use the channel number to determine the Mode setting.
10312 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10313 {
10314 eBand = pMac->roam.configParam.eBand;
10315 if(eCSR_BAND_24 == eBand)
10316 {
10317 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10318 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10319 }
10320 else
10321 {
10322 //prefer 5GHz
10323 eBand = eCSR_BAND_5G;
10324 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10325 }
10326 }
10327 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10328 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010329 // WiFi tests require IBSS networks to start in 11b mode
10330 // without any change to the default parameter settings
10331 // on the adapter. We use ACU to start an IBSS through
10332 // creation of a startIBSS profile. This startIBSS profile
10333 // has Auto MACProtocol and the adapter property setting
10334 // for dot11Mode is also AUTO. So in this case, let's
10335 // start the IBSS network in 11b mode instead of 11g mode.
10336 // So this is for Auto=profile->MacProtocol && Auto=Global.
10337 // dot11Mode && profile->channel is < 14, then start the IBSS
10338 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010339 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010340 // Note: we used to have this start as an 11g IBSS for best
10341 // performance... now to specify that the user will have to
10342 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010343 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10344 eBand = eCSR_BAND_24;
10345 }
10346 else
10347 {
10348 // else, it's a 5.0GHz channel. Set mode to 11a.
10349 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10350 eBand = eCSR_BAND_5G;
10351 }
10352 break;
10353 }//switch
10354 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10355 else
10356 {
10357 //dot11 mode is set, lets pick the band
10358 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10359 {
10360 // channel is Auto also.
10361 eBand = pMac->roam.configParam.eBand;
10362 if(eCSR_BAND_ALL == eBand)
10363 {
10364 //prefer 5GHz
10365 eBand = eCSR_BAND_5G;
10366 }
10367 }
10368 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10369 {
10370 eBand = eCSR_BAND_24;
10371 }
10372 else
10373 {
10374 eBand = eCSR_BAND_5G;
10375 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010376 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010377 if(pBand)
10378 {
10379 *pBand = eBand;
10380 }
10381
10382 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010383 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010384 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10385 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010386
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010387 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10388 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 -070010389 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010390#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010391 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010392#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010393 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10394 {
10395 //We cannot do 11n here
10396 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10397 {
10398 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10399 }
10400 else
10401 {
10402 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10403 }
10404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 return( cfgDot11Mode );
10406}
10407
Jeff Johnson295189b2012-06-20 16:38:30 -070010408eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10409{
10410 eHalStatus status;
10411 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010412
10413 if(!pSession)
10414 {
10415 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10416 return eHAL_STATUS_FAILURE;
10417 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010418
10419#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10420 {
10421 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010422 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10423 if(pIbssLog)
10424 {
10425 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10426 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10427 }
10428 }
10429#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 // Set the roaming substate to 'stop Bss request'...
10431 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10432
10433 // attempt to stop the Bss (reason code is ignored...)
10434 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010435 if(!HAL_STATUS_SUCCESS(status))
10436 {
10437 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10438 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 return (status);
10440}
10441
Jeff Johnson295189b2012-06-20 16:38:30 -070010442//pNumChan is a caller allocated space with the sizeof pChannels
10443eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10444{
10445
10446 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10447 (tANI_U8 *)pChannels,
10448 pNumChan));
10449}
10450
Kiran4a17ebe2013-01-31 10:43:43 -080010451tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10452{
10453 tANI_U32 cfgLength = 0;
10454 tANI_U16 cfgId = 0;
10455 tPowerdBm maxTxPwr = 0;
10456 tANI_U8 *pCountryInfo = NULL;
10457 eHalStatus status;
10458 tANI_U8 count = 0;
10459 tANI_U8 firstChannel;
10460 tANI_U8 maxChannels;
10461
10462 if (CSR_IS_CHANNEL_5GHZ(channel))
10463 {
10464 cfgId = WNI_CFG_MAX_TX_POWER_5;
10465 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10466 }
10467 else if (CSR_IS_CHANNEL_24GHZ(channel))
10468 {
10469 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10470 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10471 }
10472 else
10473 return maxTxPwr;
10474
10475 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10476 if (status != eHAL_STATUS_SUCCESS)
10477 {
10478 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10479 FL("%s: palAllocateMemory() failed, status = %d"),
10480 __FUNCTION__, status);
10481 goto error;
10482 }
10483 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10484 if (status != eHAL_STATUS_SUCCESS)
10485 {
10486 goto error;
10487 }
10488 /* Identify the channel and maxtxpower */
10489 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10490 {
10491 firstChannel = pCountryInfo[count++];
10492 maxChannels = pCountryInfo[count++];
10493 maxTxPwr = pCountryInfo[count++];
10494
10495 if ((channel >= firstChannel) &&
10496 (channel < (firstChannel + maxChannels)))
10497 {
10498 break;
10499 }
10500 }
10501
10502error:
10503 if (NULL != pCountryInfo)
10504 palFreeMemory(pMac->hHdd, pCountryInfo);
10505
10506 return maxTxPwr;
10507}
10508
10509
Jeff Johnson295189b2012-06-20 16:38:30 -070010510tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10511{
10512 tANI_BOOLEAN fValid = FALSE;
10513 tANI_U32 idxValidChannels;
10514 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10515
10516 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10517 {
10518 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10519 {
10520 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10521 {
10522 fValid = TRUE;
10523 break;
10524 }
10525 }
10526 }
10527 pMac->roam.numValidChannels = len;
10528 return fValid;
10529}
10530
Jeff Johnson295189b2012-06-20 16:38:30 -070010531tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10532{
10533 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10534 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10536 {
10537 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10538 {
10539 fValid = eANI_BOOLEAN_TRUE;
10540 break;
10541 }
10542 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010543 return (fValid);
10544}
10545
Jeff Johnson295189b2012-06-20 16:38:30 -070010546//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010547 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010548{
Jeff Johnsone7245742012-09-05 17:12:55 -070010549 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010550 tANI_U8 centerChn;
10551 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10553 {
10554 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10555 }
10556 else
10557 {
10558 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10559 }
10560 //Figure what the other side's CB mode
10561 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10562 {
10563 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10564 {
10565 if(pIes->HTInfo.present)
10566 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010567 /* This is called during INFRA STA/CLIENT and should use the merged value of
10568 * supported channel width and recommended tx width as per standard
10569 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010570 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010571 pIes->HTCaps.supportedChannelWidthSet,
10572 pIes->HTInfo.recommendedTxWidthSet,
10573 pIes->HTInfo.secondaryChannelOffset);
10574
10575 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10576 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010578 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10579 switch (eRet) {
10580 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10581 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10582 break;
10583 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10584 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10585 break;
10586 case PHY_SINGLE_CHANNEL_CENTERED:
10587 default:
10588 centerChn = primaryChn;
10589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010591 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010593 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010594 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010595 }
10596 }
10597 }
10598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 return eRet;
10600}
Jeff Johnson295189b2012-06-20 16:38:30 -070010601tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10602{
10603 tANI_BOOLEAN fFound = FALSE;
10604 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10606 {
10607 if( pCipherList->encryptionType[idx] == encryptionType )
10608 {
10609 fFound = TRUE;
10610 break;
10611 }
10612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 return fFound;
10614}
Jeff Johnson295189b2012-06-20 16:38:30 -070010615tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10616{
10617 tANI_BOOLEAN fFound = FALSE;
10618 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10620 {
10621 if( pAuthList->authType[idx] == authType )
10622 {
10623 fFound = TRUE;
10624 break;
10625 }
10626 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 return fFound;
10628}
Jeff Johnson295189b2012-06-20 16:38:30 -070010629tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10630{
10631 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10632 tCsrScanResultFilter *pScanFilter = NULL;
10633 eHalStatus status = eHAL_STATUS_SUCCESS;
10634
10635 if(pProfile1 && pProfile2)
10636 {
10637 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10638 if(HAL_STATUS_SUCCESS(status))
10639 {
10640 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10641 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10642 if(HAL_STATUS_SUCCESS(status))
10643 {
10644 fCheck = eANI_BOOLEAN_FALSE;
10645 do
10646 {
10647 tANI_U32 i;
10648 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10649 {
10650 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10651 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10652 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10653 if ( fCheck ) break;
10654 }
10655 if(!fCheck)
10656 {
10657 break;
10658 }
10659 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10660 || pProfile2->BSSType != pProfile1->BSSType
10661 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10662 )
10663 {
10664 fCheck = eANI_BOOLEAN_FALSE;
10665 break;
10666 }
10667#ifdef WLAN_FEATURE_VOWIFI_11R
10668 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10669 {
10670 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10671 {
10672 fCheck = eANI_BOOLEAN_FALSE;
10673 break;
10674 }
10675 }
10676#endif
10677 //Match found
10678 fCheck = eANI_BOOLEAN_TRUE;
10679 }while(0);
10680 csrFreeScanFilter(pMac, pScanFilter);
10681 }
10682 palFreeMemory(pMac->hHdd, pScanFilter);
10683 }
10684 }
10685
10686 return (fCheck);
10687}
10688
Jeff Johnson295189b2012-06-20 16:38:30 -070010689tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10690{
10691 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10692 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 do
10694 {
10695 //Only check for static WEP
10696 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10697 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10698 {
10699 fCheck = eANI_BOOLEAN_TRUE;
10700 break;
10701 }
10702 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10703 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10704 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10705 {
10706 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10707 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10708 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10709 {
10710 break;
10711 }
10712 }
10713 if( i == CSR_MAX_NUM_KEY)
10714 {
10715 fCheck = eANI_BOOLEAN_TRUE;
10716 }
10717 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 return (fCheck);
10719}
10720
Jeff Johnson295189b2012-06-20 16:38:30 -070010721//IBSS
10722
Jeff Johnson295189b2012-06-20 16:38:30 -070010723tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10724{
10725 tANI_U8 channel = 0;
10726 tANI_U32 idx;
10727 tANI_U32 idxValidChannels;
10728 tANI_BOOLEAN fFound = FALSE;
10729 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10730
10731 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10732 {
10733 channel = pMac->roam.configParam.AdHocChannel5G;
10734 if(!csrRoamIsChannelValid(pMac, channel))
10735 {
10736 channel = 0;
10737 }
10738 }
10739 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10740 {
10741 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10742 {
10743 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10744 {
10745 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10746 {
10747 fFound = TRUE;
10748 channel = csrStartIbssChannels50[ idx ];
10749 }
10750 }
10751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010752 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10753 if (!fFound)
10754 {
10755 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10756 {
10757 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10758 {
10759 channel = csrStartIbssChannels50[ idx ];
10760 break;
10761 }
10762 }
10763 }
10764 }//if
10765
10766 return( channel );
10767}
10768
Jeff Johnson295189b2012-06-20 16:38:30 -070010769tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10770{
10771 tANI_U8 channel = 1;
10772 tANI_U32 idx;
10773 tANI_U32 idxValidChannels;
10774 tANI_BOOLEAN fFound = FALSE;
10775 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10776
10777 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10778 {
10779 channel = pMac->roam.configParam.AdHocChannel24;
10780 if(!csrRoamIsChannelValid(pMac, channel))
10781 {
10782 channel = 0;
10783 }
10784 }
10785
10786 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10787 {
10788 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10789 {
10790 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10791 {
10792 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10793 {
10794 fFound = TRUE;
10795 channel = csrStartIbssChannels24[ idx ];
10796 }
10797 }
10798 }
10799 }
10800
10801 return( channel );
10802}
10803
Jeff Johnson295189b2012-06-20 16:38:30 -070010804static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10805 tCsrRoamStartBssParams *pParam )
10806{
10807 eCsrCfgDot11Mode cfgDot11Mode;
10808 eCsrBand eBand;
10809 tANI_U8 channel = 0;
10810 tSirNwType nwType;
10811 tANI_U8 operationChannel = 0;
10812
10813 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10814 {
10815 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10816 }
10817
Jeff Johnson295189b2012-06-20 16:38:30 -070010818 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010819
Jeff Johnson295189b2012-06-20 16:38:30 -070010820 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10821 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10822 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10823 )
10824 {
10825 /* This should never happen */
10826 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010827 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 pProfile->csrPersona);
10829 VOS_ASSERT(0);
10830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010831 switch( cfgDot11Mode )
10832 {
10833 case eCSR_CFG_DOT11_MODE_11G:
10834 nwType = eSIR_11G_NW_TYPE;
10835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 case eCSR_CFG_DOT11_MODE_11B:
10837 nwType = eSIR_11B_NW_TYPE;
10838 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 case eCSR_CFG_DOT11_MODE_11A:
10840 nwType = eSIR_11A_NW_TYPE;
10841 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 default:
10843 case eCSR_CFG_DOT11_MODE_11N:
10844 case eCSR_CFG_DOT11_MODE_TAURUS:
10845 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10846 if(eCSR_BAND_24 == eBand)
10847 {
10848 nwType = eSIR_11G_NW_TYPE;
10849 }
10850 else
10851 {
10852 nwType = eSIR_11A_NW_TYPE;
10853 }
10854 break;
10855 }
10856
10857 pParam->extendedRateSet.numRates = 0;
10858
10859 switch ( nwType )
10860 {
10861 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010862 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 case eSIR_11A_NW_TYPE:
10864
10865 pParam->operationalRateSet.numRates = 8;
10866
10867 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10868 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10869 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10870 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10871 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10872 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10873 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10874 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10875
10876 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10877 {
10878 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10879 if( 0 == channel &&
10880 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10881 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10882 )
10883 {
10884 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10885 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10886 nwType = eSIR_11B_NW_TYPE;
10887 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10888 pParam->operationalRateSet.numRates = 4;
10889 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10890 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10891 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10892 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10893 }
10894 }
10895 else
10896 {
10897 channel = operationChannel;
10898 }
10899 break;
10900
10901 case eSIR_11B_NW_TYPE:
10902 pParam->operationalRateSet.numRates = 4;
10903 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10904 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10905 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10906 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10908 {
10909 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10910 }
10911 else
10912 {
10913 channel = operationChannel;
10914 }
10915
10916 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010918 /* For P2P Client and P2P GO, disable 11b rates */
10919 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10920 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10921 )
10922 {
10923 pParam->operationalRateSet.numRates = 8;
10924
10925 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10926 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10927 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10928 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10929 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10930 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10931 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10932 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10933 }
10934 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 {
10936 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10938 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10939 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10940 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10941
10942 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010943 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10944 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10945 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10946 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10947 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10948 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10949 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10950 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10951 }
10952
10953 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10954 {
10955 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10956 }
10957 else
10958 {
10959 channel = operationChannel;
10960 }
10961
10962 break;
10963 }
10964 pParam->operationChn = channel;
10965 pParam->sirNwType = nwType;
10966}
10967
Jeff Johnson295189b2012-06-20 16:38:30 -070010968static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10969 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10970{
10971
10972 if( pParam )
10973 {
10974 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010975 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 pParam->operationChn = pBssDesc->channelId;
10977 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10978
10979 if( pIes )
10980 {
10981 if(pIes->SuppRates.present)
10982 {
10983 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10984 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010986 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 -070010987 pIes->SuppRates.num_rates);
10988 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10989 }
10990 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10991 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10992 }
10993 if( pIes->SSID.present )
10994 {
10995 pParam->ssId.length = pIes->SSID.num_ssid;
10996 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10997 }
10998 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010999 }
11000 else
11001 {
11002 pParam->ssId.length = 0;
11003 pParam->operationalRateSet.numRates = 0;
11004 }
11005 }
11006}
11007
Jeff Johnson295189b2012-06-20 16:38:30 -070011008static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11009{
11010 tANI_U8 MaxRate = 0;
11011 tANI_U32 i;
11012 tANI_U8 *pRate;
11013
11014 pRate = pSirRateSet->rate;
11015 for ( i = 0; i < pSirRateSet->numRates; i++ )
11016 {
11017 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11018 }
11019
11020 // Save the max rate in the connected state information...
11021
11022 // modify LastRates variable as well
11023
11024 return;
11025}
11026
Jeff Johnson295189b2012-06-20 16:38:30 -070011027eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11028 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11029{
11030 eHalStatus status = eHAL_STATUS_SUCCESS;
11031 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011032 // Set the roaming substate to 'Start BSS attempt'...
11033 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011034#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11035 //Need to figure out whether we need to log WDS???
11036 if( CSR_IS_IBSS( pProfile ) )
11037 {
11038 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11040 if(pIbssLog)
11041 {
11042 if(pBssDesc)
11043 {
11044 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
11045 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
11046 }
11047 else
11048 {
11049 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11050 }
11051 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11052 pParam->ssId.length);
11053 if(pProfile->ChannelInfo.numOfChannels == 0)
11054 {
11055 pIbssLog->channelSetting = AUTO_PICK;
11056 }
11057 else
11058 {
11059 pIbssLog->channelSetting = SPECIFIED;
11060 }
11061 pIbssLog->operatingChannel = pParam->operationChn;
11062 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11063 }
11064 }
11065#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11066 //Put RSN information in for Starting BSS
11067 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11068 pParam->pRSNIE = pProfile->pRSNReqIE;
11069
Jeff Johnson295189b2012-06-20 16:38:30 -070011070 pParam->privacy = pProfile->privacy;
11071 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11072 pParam->authType = pProfile->csr80211AuthType;
11073 pParam->beaconInterval = pProfile->beaconInterval;
11074 pParam->dtimPeriod = pProfile->dtimPeriod;
11075 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11076 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11077 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11078 {
11079 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11080 {
11081 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11082 }
11083 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011084 pParam->protEnabled = pProfile->protEnabled;
11085 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11086 pParam->ht_protection = pProfile->cfg_protection;
11087 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011088
Jeff Johnson295189b2012-06-20 16:38:30 -070011089 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11090 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 pParam->bssPersona = pProfile->csrPersona;
11092 // When starting an IBSS, start on the channel from the Profile.
11093 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011094 return (status);
11095}
11096
Jeff Johnson295189b2012-06-20 16:38:30 -070011097static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011098 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011099{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011100 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011101 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011102 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011103
11104 if(!pSession)
11105 {
11106 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11107 return;
11108 }
11109
Jeff Johnson295189b2012-06-20 16:38:30 -070011110 if( pBssDesc )
11111 {
11112 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11113 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11114 //The following code has to be do after that.
11115 //For WDS station, use selfMac as the self BSSID
11116 if( CSR_IS_WDS_STA( pProfile ) )
11117 {
11118 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11119 }
11120 }
11121 else
11122 {
11123 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011124 //Use the first SSID
11125 if(pProfile->SSIDs.numOfSSIDs)
11126 {
11127 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11128 }
11129 //For WDS station, use selfMac as the self BSSID
11130 if( CSR_IS_WDS_STA( pProfile ) )
11131 {
11132 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11133 }
11134 //Use the first BSSID
11135 else if( pProfile->BSSIDs.numOfBSSIDs )
11136 {
11137 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11138 }
11139 else
11140 {
11141 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11142 }
11143 }
11144 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011145 //Set operating channel in pProfile which will be used
11146 //in csrRoamSetBssConfigCfg() to determine channel bonding
11147 //mode and will be configured in CFG later
11148 pProfile->operationChannel = Channel;
11149
11150 if(Channel == 0)
11151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011152 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 }
11154 else
11155 {
11156
11157 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011158 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011159 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011160 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011161 {
11162 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11163 }
11164 else
11165 {
11166 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11167 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011168 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011169 pBssConfig->cbMode = cbMode;
11170 pSession->bssParams.cbMode = cbMode;
11171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 }
11173}
11174
Jeff Johnson295189b2012-06-20 16:38:30 -070011175static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11176 tANI_BOOLEAN *pfSameIbss )
11177{
11178 eHalStatus status = eHAL_STATUS_SUCCESS;
11179 tANI_BOOLEAN fSameIbss = FALSE;
11180
11181 if ( csrIsConnStateIbss( pMac, sessionId ) )
11182 {
11183 // Check if any profile parameter has changed ? If any profile parameter
11184 // has changed then stop old BSS and start a new one with new parameters
11185 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11186 {
11187 fSameIbss = TRUE;
11188 }
11189 else
11190 {
11191 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11192 }
11193 }
11194 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11195 {
11196 // Disassociate from the connected Infrastructure network...
11197 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11198 }
11199 else
11200 {
11201 tBssConfigParam *pBssConfig;
11202
11203 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11204 if(HAL_STATUS_SUCCESS(status))
11205 {
11206 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11207 // there is no Bss description before we start an IBSS so we need to adopt
11208 // all Bss configuration parameters from the Profile.
11209 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11210 if(HAL_STATUS_SUCCESS(status))
11211 {
11212 //save dotMode
11213 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11214 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011215 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011216 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11217 NULL, pBssConfig,
11218 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011220 palFreeMemory(pMac->hHdd, pBssConfig);
11221 }//Allocate memory
11222 }
11223
11224 if(pfSameIbss)
11225 {
11226 *pfSameIbss = fSameIbss;
11227 }
11228 return( status );
11229}
11230
Jeff Johnson295189b2012-06-20 16:38:30 -070011231static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11232 tSirSmeNewBssInfo *pNewBss )
11233{
11234 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011235
11236 if(!pSession)
11237 {
11238 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11239 return;
11240 }
11241
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 if( pNewBss )
11243 {
11244 // Set the operating channel.
11245 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11246 // move the BSSId from the BSS description into the connected state information.
11247 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11248 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011250 return;
11251}
11252
Jeff Johnson295189b2012-06-20 16:38:30 -070011253#ifdef FEATURE_WLAN_WAPI
11254eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11255 tANI_U32 numItems )
11256{
11257 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11258 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011259 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011261 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 return status;
11263 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011264 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 pSession = CSR_GET_SESSION( pMac, sessionId );
11266 if(numItems <= CSR_MAX_BKID_ALLOWED)
11267 {
11268 status = eHAL_STATUS_SUCCESS;
11269 //numItems may be 0 to clear the cache
11270 pSession->NumBkidCache = (tANI_U16)numItems;
11271 if(numItems && pBKIDCache)
11272 {
11273 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11274 sizeof(tBkidCacheInfo) * numItems );
11275 }
11276 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 return (status);
11278}
Jeff Johnson295189b2012-06-20 16:38:30 -070011279eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11280 tBkidCacheInfo *pBkidCache)
11281{
11282 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11283 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011284 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011286 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 return status;
11288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 pSession = CSR_GET_SESSION( pMac, sessionId );
11290 if(pNum && pBkidCache)
11291 {
11292 if(pSession->NumBkidCache == 0)
11293 {
11294 *pNum = 0;
11295 status = eHAL_STATUS_SUCCESS;
11296 }
11297 else if(*pNum >= pSession->NumBkidCache)
11298 {
11299 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011301 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 -070011302 pSession->NumBkidCache);
11303 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11304 }
11305 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11306 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11307 *pNum = pSession->NumBkidCache;
11308 status = eHAL_STATUS_SUCCESS;
11309 }
11310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011312}
Jeff Johnson295189b2012-06-20 16:38:30 -070011313tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11314{
11315 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011316}
11317#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011318eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11319 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11320{
11321 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11322 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011323
11324 if(!pSession)
11325 {
11326 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11327 return eHAL_STATUS_FAILURE;
11328 }
11329
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011330 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11332 {
11333#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11334 {
11335 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11336 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11337 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11338 secEvent.encryptionModeMulticast =
11339 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11340 secEvent.encryptionModeUnicast =
11341 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11342 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11343 secEvent.authMode =
11344 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11345 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11346 }
11347#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 status = eHAL_STATUS_SUCCESS;
11349 //numItems may be 0 to clear the cache
11350 pSession->NumPmkidCache = (tANI_U16)numItems;
11351 if(numItems && pPMKIDCache)
11352 {
11353 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11354 sizeof(tPmkidCacheInfo) * numItems );
11355 }
11356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011357 return (status);
11358}
11359
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011360eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11361 tANI_U8 *pBSSId )
11362{
11363 eHalStatus status = eHAL_STATUS_FAILURE;
11364 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11365 tANI_BOOLEAN fMatchFound = FALSE;
11366 tANI_U32 Index;
11367 if(!pSession)
11368 {
11369 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11370 return eHAL_STATUS_FAILURE;
11371 }
11372 do
11373 {
11374 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11375 {
11376 smsLog(pMac, LOGW, "Delete PMKID for %02X-%02X-%02X-%02X-%02X-%02X ",
11377 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
11378 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
11379 {
11380 fMatchFound = TRUE;
11381 break;
11382 }
11383 }
11384 if( !fMatchFound ) break;
11385 palZeroMemory( pMac->hHdd, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo));
11386 status = eHAL_STATUS_SUCCESS;
11387 }
11388 while( 0 );
11389 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11390 fMatchFound, status);
11391 return status;
11392}
Jeff Johnson295189b2012-06-20 16:38:30 -070011393tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11394{
11395 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11396}
11397
Jeff Johnson295189b2012-06-20 16:38:30 -070011398eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11399{
11400 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11401 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011402
11403 if(!pSession)
11404 {
11405 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11406 return eHAL_STATUS_FAILURE;
11407 }
11408
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 if(pNum && pPmkidCache)
11410 {
11411 if(pSession->NumPmkidCache == 0)
11412 {
11413 *pNum = 0;
11414 status = eHAL_STATUS_SUCCESS;
11415 }
11416 else if(*pNum >= pSession->NumPmkidCache)
11417 {
11418 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011420 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 -070011421 pSession->NumPmkidCache);
11422 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11423 }
11424 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11425 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11426 *pNum = pSession->NumPmkidCache;
11427 status = eHAL_STATUS_SUCCESS;
11428 }
11429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 return (status);
11431}
11432
Jeff Johnson295189b2012-06-20 16:38:30 -070011433eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11434{
11435 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11436 tANI_U32 len;
11437 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011438
11439 if(!pSession)
11440 {
11441 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11442 return eHAL_STATUS_FAILURE;
11443 }
11444
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 if(pLen)
11446 {
11447 len = *pLen;
11448 *pLen = pSession->nWpaRsnReqIeLength;
11449 if(pBuf)
11450 {
11451 if(len >= pSession->nWpaRsnReqIeLength)
11452 {
11453 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11454 }
11455 }
11456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 return (status);
11458}
11459
Jeff Johnson295189b2012-06-20 16:38:30 -070011460eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11461{
11462 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11463 tANI_U32 len;
11464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011465
11466 if(!pSession)
11467 {
11468 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11469 return eHAL_STATUS_FAILURE;
11470 }
11471
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 if(pLen)
11473 {
11474 len = *pLen;
11475 *pLen = pSession->nWpaRsnRspIeLength;
11476 if(pBuf)
11477 {
11478 if(len >= pSession->nWpaRsnRspIeLength)
11479 {
11480 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11481 }
11482 }
11483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 return (status);
11485}
Jeff Johnson295189b2012-06-20 16:38:30 -070011486#ifdef FEATURE_WLAN_WAPI
11487eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11488{
11489 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11490 tANI_U32 len;
11491 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011492
11493 if(!pSession)
11494 {
11495 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11496 return eHAL_STATUS_FAILURE;
11497 }
11498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 if(pLen)
11500 {
11501 len = *pLen;
11502 *pLen = pSession->nWapiReqIeLength;
11503 if(pBuf)
11504 {
11505 if(len >= pSession->nWapiReqIeLength)
11506 {
11507 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11508 }
11509 }
11510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 return (status);
11512}
Jeff Johnson295189b2012-06-20 16:38:30 -070011513eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11514{
11515 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11516 tANI_U32 len;
11517 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011518
11519 if(!pSession)
11520 {
11521 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11522 return eHAL_STATUS_FAILURE;
11523 }
11524
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 if(pLen)
11526 {
11527 len = *pLen;
11528 *pLen = pSession->nWapiRspIeLength;
11529 if(pBuf)
11530 {
11531 if(len >= pSession->nWapiRspIeLength)
11532 {
11533 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11534 }
11535 }
11536 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 return (status);
11538}
11539#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011540eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11541{
11542 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11543 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011544
11545 if(!pSession)
11546 {
11547 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11548 return (retStatus);
11549 }
11550
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 if(CSR_IS_ROAMING(pSession))
11552 {
11553 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11554 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 return (retStatus);
11557}
11558
Jeff Johnson295189b2012-06-20 16:38:30 -070011559//This function remove the connected BSS from te cached scan result
11560eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11561 tCsrRoamConnectedProfile *pConnProfile)
11562{
11563 eHalStatus status = eHAL_STATUS_FAILURE;
11564 tCsrScanResultFilter *pScanFilter = NULL;
11565 tListElem *pEntry;
11566 tCsrScanResult *pResult;
11567 tDot11fBeaconIEs *pIes;
11568 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11570 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11571 {
11572 do
11573 {
11574 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11575 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11576 if(!HAL_STATUS_SUCCESS(status)) break;
11577 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11578 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11579 if(!HAL_STATUS_SUCCESS(status)) break;
11580 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11581 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11582 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11583 {
11584 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11585 if(!HAL_STATUS_SUCCESS(status)) break;
11586 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11587 }
11588 pScanFilter->authType.numEntries = 1;
11589 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11590 pScanFilter->BSSType = pConnProfile->BSSType;
11591 pScanFilter->EncryptionType.numEntries = 1;
11592 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11593 pScanFilter->mcEncryptionType.numEntries = 1;
11594 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11595 //We ignore the channel for now, BSSID should be enough
11596 pScanFilter->ChannelInfo.numOfChannels = 0;
11597 //Also ignore the following fields
11598 pScanFilter->uapsd_mask = 0;
11599 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11600 pScanFilter->countryCode[0] = 0;
11601 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 csrLLLock(&pMac->scan.scanResultList);
11603 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11604 while( pEntry )
11605 {
11606 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11607 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11608 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11609 pScanFilter, NULL, NULL, NULL, &pIes);
11610 //Release the IEs allocated by csrMatchBSS is needed
11611 if( !pResult->Result.pvIes )
11612 {
11613 //need to free the IEs since it is allocated by csrMatchBSS
11614 palFreeMemory(pMac->hHdd, pIes);
11615 }
11616 if(fMatch)
11617 {
11618 //We found the one
11619 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11620 {
11621 //Free the memory
11622 csrFreeScanResultEntry( pMac, pResult );
11623 }
11624 break;
11625 }
11626 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11627 }//while
11628 csrLLUnlock(&pMac->scan.scanResultList);
11629 }while(0);
11630 if(pScanFilter)
11631 {
11632 csrFreeScanFilter(pMac, pScanFilter);
11633 palFreeMemory(pMac->hHdd, pScanFilter);
11634 }
11635 }
11636 return (status);
11637}
11638
Jeff Johnson295189b2012-06-20 16:38:30 -070011639//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011640eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11641{
11642 eHalStatus status = eHAL_STATUS_SUCCESS;
11643 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11645 {
11646 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11647 {
11648 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11649 {
11650 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011651 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 status = eHAL_STATUS_CSR_WRONG_STATE;
11653 break;
11654 }
11655 if( csrIsConnStateInfra( pMac, sessionId ) )
11656 {
11657 if( chnId &&
11658 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011660 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11662 status = eHAL_STATUS_CSR_WRONG_STATE;
11663 break;
11664 }
11665 }
11666 }
11667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 return ( status );
11669}
11670
Jeff Johnson295189b2012-06-20 16:38:30 -070011671static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11672{
11673 eHalStatus status = eHAL_STATUS_SUCCESS;
11674 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11675 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011676
11677 if(!pSession)
11678 {
11679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11680 return eHAL_STATUS_FAILURE;
11681 }
11682
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 if ( csrIsConnStateIbss( pMac, sessionId ) )
11684 {
11685 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11686 }
11687 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11688 {
11689 // Disassociate from the connected Infrastructure network...
11690 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11691 }
11692 else
11693 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11695 //Otherwise we need to add code to handle the
11696 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11697 //send stop_bss to PE, before we can continue.
11698 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11700 /* Assume HDD provide bssid in profile */
11701 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11702 // there is no Bss description before we start an WDS so we need
11703 // to adopt all Bss configuration parameters from the Profile.
11704 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11705 if(HAL_STATUS_SUCCESS(status))
11706 {
11707 //Save profile for late use
11708 csrFreeRoamProfile( pMac, sessionId );
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011709 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 (void **)&pSession->pCurRoamProfile,
11711 sizeof(tCsrRoamProfile))))
11712 {
11713 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11714 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011717 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011718 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11719 NULL, &bssConfig,
11720 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 }
11722 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011723
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 return( status );
11725}
11726
Jeff Johnson295189b2012-06-20 16:38:30 -070011727////////////////////Mail box
11728
Jeff Johnson295189b2012-06-20 16:38:30 -070011729//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11730//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011731static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11732 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11734{
11735 tCsrChannelSet channelGroup;
11736 tSirMacCapabilityInfo *pAP_capabilityInfo;
11737 tAniBool fTmp;
11738 tANI_BOOLEAN found = FALSE;
11739 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011740 tANI_S8 pwrLimit = 0;
11741 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11743 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11744 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11745 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 // 802.11h
11747 //We can do this because it is in HOST CPU order for now.
11748 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011749 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11750 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11751 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 fTmp = (tAniBool)pal_cpu_to_be32(1);
11753 }
11754 else
11755 fTmp = (tAniBool)0;
11756
11757 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11758 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11759 pBuf += sizeof(tAniBool);
11760 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011761 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 // This is required for 11k test VoWiFi Ent: Test 2.
11763 // We need the power capabilities for Assoc Req.
11764 // This macro is provided by the halPhyCfg.h. We pick our
11765 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011766 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11767 if (0 != pwrLimit)
11768 {
11769 *pBuf++ = pwrLimit;
11770 }
11771 else
11772 {
11773 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 size = sizeof(pMac->roam.validChannelList);
11776 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11777 {
11778 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11779 for ( i = 0; i < size; i++)
11780 {
11781 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11782
11783 }
11784 }
11785 else
11786 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011787 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 *pBuf++ = 0; //tSirSupChnl->numChnl
11789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 //Check whether it is ok to enter UAPSD
11791#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11792 if( btcIsReadyForUapsd(pMac) )
11793#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11794 {
11795 *pBuf++ = uapsdMask;
11796 }
11797#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11798 else
11799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011800 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 *pBuf++ = 0;
11802 }
11803#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11804
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 // move the entire BssDescription into the join request.
11806 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11807 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011808 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11809}
11810
Jeff Johnson295189b2012-06-20 16:38:30 -070011811/*
11812 * The communication between HDD and LIM is thru mailbox (MB).
11813 * Both sides will access the data structure "tSirSmeJoinReq".
11814 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11815 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11816 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11817 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11818 */
11819eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011820 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011821{
11822 eHalStatus status = eHAL_STATUS_SUCCESS;
11823 tSirSmeJoinReq *pMsg;
11824 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011825 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 tANI_U16 msgLen, wTmp, ieLen;
11827 tSirMacRateSet OpRateSet;
11828 tSirMacRateSet ExRateSet;
11829 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11830 tANI_U32 dwTmp;
11831 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011832 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011833
11834 if(!pSession)
11835 {
11836 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11837 return eHAL_STATUS_FAILURE;
11838 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011839 /* To satisfy klockworks */
11840 if (NULL == pBssDescription)
11841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011842 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011843 return eHAL_STATUS_FAILURE;
11844 }
11845
Jeff Johnson295189b2012-06-20 16:38:30 -070011846 do {
11847 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11848 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011849 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11851 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11852 // IE fields, but the length field in the bssDescription needs to be interpreted to
11853 // determine length of the IE fields.
11854 //
11855 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11856 // add in the length from the bssDescription (then add the size of the 'length' field
11857 // itself because that is NOT included in the length field).
11858 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11859 pBssDescription->length + sizeof( pBssDescription->length ) +
11860 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11862 if ( !HAL_STATUS_SUCCESS(status) ) break;
11863 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011864 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 pMsg->length = pal_cpu_to_be16(msgLen);
11866 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 // sessionId
11868 *pBuf = (tANI_U8)sessionId;
11869 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 // transactionId
11871 *pBuf = 0;
11872 *( pBuf + 1 ) = 0;
11873 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011874 // ssId
11875 if( pIes->SSID.present && pIes->SSID.num_ssid )
11876 {
11877 // ssId len
11878 *pBuf = pIes->SSID.num_ssid;
11879 pBuf++;
11880 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11881 pBuf += pIes->SSID.num_ssid;
11882 }
11883 else
11884 {
11885 *pBuf = 0;
11886 pBuf++;
11887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 // selfMacAddr
11889 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11890 pBuf += sizeof(tSirMacAddr);
11891 // bsstype
11892 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11893 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11894 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11895 pBuf += sizeof(tSirBssType);
11896 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011897 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11898 if (pBssDescription->channelId <= 14 &&
11899 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11900 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11901 {
11902 //Need to disable VHT operation in 2.4 GHz band
11903 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11904 }
11905 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 //Persona
11908 *pBuf = (tANI_U8)pProfile->csrPersona;
11909 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011910 //CBMode
11911 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11912 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011913
11914 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011915 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11916
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 // uapsdPerAcBitmask
11918 *pBuf = pProfile->uapsd_mask;
11919 pBuf++;
11920
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011921
11922
Jeff Johnson295189b2012-06-20 16:38:30 -070011923 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011924 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 {
11926 // OperationalRateSet
11927 if (OpRateSet.numRates) {
11928 *pBuf++ = OpRateSet.numRates;
11929 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11930 pBuf += OpRateSet.numRates;
11931 } else *pBuf++ = 0;
11932 // ExtendedRateSet
11933 if (ExRateSet.numRates) {
11934 *pBuf++ = ExRateSet.numRates;
11935 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11936 pBuf += ExRateSet.numRates;
11937 } else *pBuf++ = 0;
11938 }
11939 else
11940 {
11941 *pBuf++ = 0;
11942 *pBuf++ = 0;
11943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 // rsnIE
11945 if ( csrIsProfileWpa( pProfile ) )
11946 {
11947 // Insert the Wpa IE into the join request
11948 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11949 (tCsrWpaIe *)( wpaRsnIE ) );
11950 }
11951 else if( csrIsProfileRSN( pProfile ) )
11952 {
11953 // Insert the RSN IE into the join request
11954 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11955 (tCsrRSNIe *)( wpaRsnIE ) );
11956 }
11957#ifdef FEATURE_WLAN_WAPI
11958 else if( csrIsProfileWapi( pProfile ) )
11959 {
11960 // Insert the WAPI IE into the join request
11961 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11962 (tCsrWapiIe *)( wpaRsnIE ) );
11963 }
11964#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 else
11966 {
11967 ieLen = 0;
11968 }
11969 //remember the IE for future use
11970 if( ieLen )
11971 {
11972 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011974 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 -070011975 ieLen = DOT11F_IE_RSN_MAX_LEN;
11976 }
11977#ifdef FEATURE_WLAN_WAPI
11978 if( csrIsProfileWapi( pProfile ) )
11979 {
11980 //Check whether we need to allocate more memory
11981 if(ieLen > pSession->nWapiReqIeLength)
11982 {
11983 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11984 {
11985 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11986 }
11987 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11988 if(!HAL_STATUS_SUCCESS(status)) break;
11989 }
11990 pSession->nWapiReqIeLength = ieLen;
11991 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11992 wTmp = pal_cpu_to_be16( ieLen );
11993 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11994 pBuf += sizeof(tANI_U16);
11995 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11996 pBuf += ieLen;
11997 }
11998 else//should be WPA/WPA2 otherwise
11999#endif /* FEATURE_WLAN_WAPI */
12000 {
12001 //Check whether we need to allocate more memory
12002 if(ieLen > pSession->nWpaRsnReqIeLength)
12003 {
12004 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12005 {
12006 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12007 }
12008 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
12009 if(!HAL_STATUS_SUCCESS(status)) break;
12010 }
12011 pSession->nWpaRsnReqIeLength = ieLen;
12012 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
12013 wTmp = pal_cpu_to_be16( ieLen );
12014 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12015 pBuf += sizeof(tANI_U16);
12016 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12017 pBuf += ieLen;
12018 }
12019 }
12020 else
12021 {
12022 //free whatever old info
12023 pSession->nWpaRsnReqIeLength = 0;
12024 if(pSession->pWpaRsnReqIE)
12025 {
12026 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12027 pSession->pWpaRsnReqIE = NULL;
12028 }
12029#ifdef FEATURE_WLAN_WAPI
12030 pSession->nWapiReqIeLength = 0;
12031 if(pSession->pWapiReqIE)
12032 {
12033 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12034 pSession->pWapiReqIE = NULL;
12035 }
12036#endif /* FEATURE_WLAN_WAPI */
12037 //length is two bytes
12038 *pBuf = 0;
12039 *(pBuf + 1) = 0;
12040 pBuf += 2;
12041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012042#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012043 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012045 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 //length is two bytes
12047 *pBuf = 0;
12048 *(pBuf + 1) = 0;
12049 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012050 }
12051 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012053 // cckmIE
12054 if( csrIsProfileCCX( pProfile ) )
12055 {
12056 // Insert the CCKM IE into the join request
12057 ieLen = csrConstructCcxCckmIe( pMac,
12058 pSession,
12059 pProfile,
12060 pBssDescription,
12061 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 pSession->nWpaRsnReqIeLength,
12063 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012064 }
12065 else
12066 {
12067 ieLen = 0;
12068 }
12069 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12070 if( ieLen )
12071 {
12072 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12073 wTmp = pal_cpu_to_be16( ieLen );
12074 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12075 pBuf += sizeof(tANI_U16);
12076 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12077 pBuf += ieLen;
12078 }
12079 else
12080 {
12081 //Indicate you have no CCKM IE
12082 //length is two bytes
12083 *pBuf = 0;
12084 *(pBuf + 1) = 0;
12085 pBuf += 2;
12086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 }
12088#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 // addIEScan
12090 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12091 {
12092 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 if(ieLen > pSession->nAddIEScanLength)
12094 {
12095 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12096 {
12097 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12098 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012099 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 (void **)&pSession->pAddIEScan, ieLen);
12101 if(!HAL_STATUS_SUCCESS(status)) break;
12102 }
12103 pSession->nAddIEScanLength = ieLen;
12104 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12105 pProfile->pAddIEScan, ieLen);
12106 wTmp = pal_cpu_to_be16( ieLen );
12107 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12108 pBuf += sizeof(tANI_U16);
12109 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12110 pBuf += ieLen;
12111 }
12112 else
12113 {
12114 pSession->nAddIEScanLength = 0;
12115 if(pSession->pAddIEScan)
12116 {
12117 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12118 pSession->pAddIEScan = NULL;
12119 }
12120 *pBuf = 0;
12121 *(pBuf + 1) = 0;
12122 pBuf += 2;
12123 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012124 // addIEAssoc
12125 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12126 {
12127 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 if(ieLen > pSession->nAddIEAssocLength)
12129 {
12130 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12131 {
12132 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12133 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012134 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 (void **)&pSession->pAddIEAssoc, ieLen);
12136 if(!HAL_STATUS_SUCCESS(status)) break;
12137 }
12138 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012139 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 pProfile->pAddIEAssoc, ieLen);
12141 wTmp = pal_cpu_to_be16( ieLen );
12142 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12143 pBuf += sizeof(tANI_U16);
12144 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12145 pBuf += ieLen;
12146 }
12147 else
12148 {
12149 pSession->nAddIEAssocLength = 0;
12150 if(pSession->pAddIEAssoc)
12151 {
12152 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12153 pSession->pAddIEAssoc = NULL;
12154 }
12155 *pBuf = 0;
12156 *(pBuf + 1) = 0;
12157 pBuf += 2;
12158 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012159
12160 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012162 //Unmask any AC in reassoc that is ACM-set
12163 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12164 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012166 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12167 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012168#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012169 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012170#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012171 uapsd_mask &= ~(acm_mask);
12172 }
12173 else
12174 {
12175 uapsd_mask = 0;
12176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 }
12178 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012179
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12181 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012182 pBuf += sizeof(tANI_U32);
12183
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12185 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012186 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012187#ifdef WLAN_FEATURE_11W
12188 //MgmtEncryption
12189 if (pProfile->MFPEnabled)
12190 {
12191 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12192 }
12193 else
12194 {
12195 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12196 }
12197 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12198 pBuf += sizeof(tANI_U32);
12199#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012200#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012201 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012202 if (csrIsProfile11r( pProfile )
12203#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012204 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12205 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012206#endif
12207 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012208 {
12209 // is11Rconnection;
12210 dwTmp = pal_cpu_to_be32(TRUE);
12211 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12212 pBuf += sizeof(tAniBool);
12213 }
12214 else
12215 {
12216 // is11Rconnection;
12217 dwTmp = pal_cpu_to_be32(FALSE);
12218 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12219 pBuf += sizeof(tAniBool);
12220 }
12221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012222#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012223
12224 // isCCXFeatureIniEnabled
12225 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12226 {
12227 dwTmp = pal_cpu_to_be32(TRUE);
12228 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12229 pBuf += sizeof(tAniBool);
12230 }
12231 else
12232 {
12233 dwTmp = pal_cpu_to_be32(FALSE);
12234 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12235 pBuf += sizeof(tAniBool);
12236 }
12237
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012238 /* A profile can not be both CCX and 11R. But an 802.11R AP
12239 * may be advertising support for CCX as well. So if we are
12240 * associating Open or explicitly CCX then we will get CCX.
12241 * If we are associating explictly 11R only then we will get
12242 * 11R.
12243 */
12244 if ((csrIsProfileCCX(pProfile) ||
12245 ((pIes->CCXVersion.present)
12246 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012247 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12248 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12249 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012250#ifdef WLAN_FEATURE_11W
12251 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12252#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012253 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012254 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12255 {
12256 // isCCXconnection;
12257 dwTmp = pal_cpu_to_be32(TRUE);
12258 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12259 pBuf += sizeof(tAniBool);
12260 }
12261 else
12262 {
12263 //isCCXconnection;
12264 dwTmp = pal_cpu_to_be32(FALSE);
12265 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12266 pBuf += sizeof(tAniBool);
12267 }
12268
12269 if (eWNI_SME_JOIN_REQ == messageType)
12270 {
12271 tCCXTspecInfo ccxTspec;
12272 // CCX-Tspec IEs in the ASSOC request is presently not supported
12273 // so nullify the TSPEC parameters
12274 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12275 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12276 pBuf += sizeof(tCCXTspecInfo);
12277 }
12278 else if (eWNI_SME_REASSOC_REQ == messageType)
12279 {
12280 if ((csrIsProfileCCX(pProfile) ||
12281 ((pIes->CCXVersion.present)
12282 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012283 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12284 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12285 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012286#ifdef WLAN_FEATURE_11W
12287 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12288#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012289 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012290 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 {
12292 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012293 // CCX Tspec information
12294 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12295 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12296 *pBuf = ccxTspec.numTspecs;
12297 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012298 // Copy the TSPEC information only if present
12299 if (ccxTspec.numTspecs) {
12300 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12301 }
12302 pBuf += sizeof(ccxTspec.tspec);
12303 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012304 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 tCCXTspecInfo ccxTspec;
12307 // CCX-Tspec IEs in the ASSOC request is presently not supported
12308 // so nullify the TSPEC parameters
12309 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12310 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12311 pBuf += sizeof(tCCXTspecInfo);
12312 }
12313 }
12314#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012315#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012317 if (pMac->roam.configParam.isFastTransitionEnabled
12318#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012319 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012320#endif
12321 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012323 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012325 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 }
12327 else
12328 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012329 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012331 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 }
12333#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012334#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012335 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012336 {
12337 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012338 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012339 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012340 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012341 }
12342 else
12343 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012344 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012345 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012346 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012347 }
12348#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012349
12350 // txLdpcIniFeatureEnabled
12351 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12352 pBuf++;
12353
Kiran4a17ebe2013-01-31 10:43:43 -080012354 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12355 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12356 {
12357 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12358 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12359 csrApplyPower2Current(pMac);
12360 }
12361
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012362#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012363 // txBFIniFeatureEnabled
12364 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12365 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012366
12367 // txBFCsnValue
12368 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12369 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012370#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012371 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12372 pBuf++;
12373
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012374 //BssDesc
12375 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12376 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012377
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012378 status = palSendMBMessage(pMac->hHdd, pMsg );
12379 if(!HAL_STATUS_SUCCESS(status))
12380 {
12381 break;
12382 }
12383 else
12384 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012385#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012386 if (eWNI_SME_JOIN_REQ == messageType)
12387 {
12388 //Tush-QoS: notify QoS module that join happening
12389 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12390 }
12391 else if (eWNI_SME_REASSOC_REQ == messageType)
12392 {
12393 //Tush-QoS: notify QoS module that reassoc happening
12394 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012396#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012400}
12401
Jeff Johnson295189b2012-06-20 16:38:30 -070012402//
12403eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12404{
12405 eHalStatus status = eHAL_STATUS_SUCCESS;
12406 tSirSmeDisassocReq *pMsg;
12407 tANI_U8 *pBuf;
12408 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12410 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12411 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 do {
12413 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12414 if ( !HAL_STATUS_SUCCESS(status) ) break;
12415 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12416 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12417 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 pBuf = &pMsg->sessionId;
12419 // sessionId
12420 *pBuf++ = (tANI_U8)sessionId;
12421 // transactionId
12422 *pBuf = 0;
12423 *( pBuf + 1 ) = 0;
12424 pBuf += sizeof(tANI_U16);
12425
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012426 if ( (pSession->pCurRoamProfile != NULL) &&
12427 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12428 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 {
12430 // Set the bssid address before sending the message to LIM
12431 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12432 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 // Set the peer MAC address before sending the message to LIM
12434 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12435 pBuf = pBuf + sizeof ( tSirMacAddr );
12436 }
12437 else
12438 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 // Set the peer MAC address before sending the message to LIM
12440 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12441 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012442 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12443 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 if(!HAL_STATUS_SUCCESS(status))
12446 {
12447 palFreeMemory(pMac->hHdd, pMsg);
12448 break;
12449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 // reasonCode
12451 wTmp = pal_cpu_to_be16(reasonCode);
12452 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12453 if(!HAL_STATUS_SUCCESS(status))
12454 {
12455 palFreeMemory(pMac->hHdd, pMsg);
12456 break;
12457 }
12458 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12460 Here we should not send the disassoc over the air to the AP */
12461 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12462#ifdef WLAN_FEATURE_VOWIFI_11R
12463 && csrRoamIs11rAssoc(pMac)
12464#endif
12465 )
12466 {
12467 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12468 }
12469 pBuf += sizeof(tANI_U8);
12470 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 return( status );
12473}
Jeff Johnson295189b2012-06-20 16:38:30 -070012474eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12475{
12476 eHalStatus status = eHAL_STATUS_SUCCESS;
12477 tSirSmeTkipCntrMeasReq *pMsg;
12478 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 do
12480 {
12481 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12482 if ( !HAL_STATUS_SUCCESS(status) ) break;
12483 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12484 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12485 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 pBuf = &pMsg->sessionId;
12487 // sessionId
12488 *pBuf++ = (tANI_U8)sessionId;
12489 // transactionId
12490 *pBuf = 0;
12491 *( pBuf + 1 ) = 0;
12492 pBuf += sizeof(tANI_U16);
12493 // bssid
12494 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12495 pBuf = pBuf + sizeof ( tSirMacAddr );
12496 // bEnable
12497 *pBuf = (tANI_BOOLEAN)bEnable;
12498 if(!HAL_STATUS_SUCCESS(status))
12499 {
12500 palFreeMemory(pMac->hHdd, pMsg);
12501 break;
12502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 return( status );
12506}
Jeff Johnson295189b2012-06-20 16:38:30 -070012507eHalStatus
12508csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12509 VOS_MODULE_ID modId, tSirMacAddr bssId,
12510 void *pUsrContext, void *pfnSapEventCallback,
12511 tANI_U8 *pAssocStasBuf )
12512{
12513 eHalStatus status = eHAL_STATUS_SUCCESS;
12514 tSirSmeGetAssocSTAsReq *pMsg;
12515 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12516 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 do
12518 {
12519 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12520 if (!HAL_STATUS_SUCCESS(status)) break;
12521 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12522 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 pBuf = (tANI_U8 *)&pMsg->bssId;
12524 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012525 // bssId
12526 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12527 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 // modId
12529 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12530 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12531 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 // pUsrContext
12533 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12534 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12535 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 // pfnSapEventCallback
12537 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12538 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12539 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 // pAssocStasBuf
12541 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12542 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12543 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 status = palSendMBMessage( pMac->hHdd, pMsg );
12546 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 return( status );
12548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012549eHalStatus
12550csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12551 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12552 {
12553 eHalStatus status = eHAL_STATUS_SUCCESS;
12554 tSirSmeGetWPSPBCSessionsReq *pMsg;
12555 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12556 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 do
12558 {
12559 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12560 if (!HAL_STATUS_SUCCESS(status)) break;
12561 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12562 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070012564 VOS_ASSERT(pBuf);
12565
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 // pUsrContext
12568 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12569 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12570 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 // pSapEventCallback
12572 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12573 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12574 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 // bssId
12576 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12577 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 // MAC Address of STA in WPS session
12579 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12580 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 return( status );
12585}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012586
12587eHalStatus
12588csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12589{
12590 tpSirChangeBIParams pMsg;
12591 tANI_U16 len = 0;
12592 eHalStatus status = eHAL_STATUS_SUCCESS;
12593 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12594
12595 if(!pSession)
12596 {
12597 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12598 return eHAL_STATUS_FAILURE;
12599 }
12600
12601 //NO need to update the Beacon Params if update beacon parameter flag is not set
12602 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12603 return eHAL_STATUS_SUCCESS;
12604
12605 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12606
12607 /* Create the message and send to lim */
12608 len = sizeof(tSirChangeBIParams);
12609 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12610 if(HAL_STATUS_SUCCESS(status))
12611 {
12612 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12613 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12614 pMsg->length = len;
12615
12616 // bssId
12617 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012618 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012619 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12620 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12621 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012622 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012623 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12624 status = palSendMBMessage(pMac->hHdd, pMsg);
12625 }
12626 return status;
12627}
12628
Jeff Johnson295189b2012-06-20 16:38:30 -070012629eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12630{
12631 eHalStatus status = eHAL_STATUS_SUCCESS;
12632 tSirSmeDeauthReq *pMsg;
12633 tANI_U8 *pBuf;
12634 tANI_U16 wTmp;
12635 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12636 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12637 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 do {
12639 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12640 if ( !HAL_STATUS_SUCCESS(status) ) break;
12641 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12642 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12643 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12644 //sessionId
12645 pBuf = &pMsg->sessionId;
12646 *pBuf++ = (tANI_U8)sessionId;
12647
12648 //tansactionId
12649 *pBuf = 0;
12650 *(pBuf + 1 ) = 0;
12651 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12655 // Set the BSSID before sending the message to LIM
12656 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12657 pBuf = pBuf + sizeof(tSirMacAddr);
12658 }
12659 else
12660 {
12661 // Set the BSSID before sending the message to LIM
12662 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12663 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 }
12665 if(!HAL_STATUS_SUCCESS(status))
12666 {
12667 palFreeMemory(pMac->hHdd, pMsg);
12668 break;
12669 }
12670 // Set the peer MAC address before sending the message to LIM
12671 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12672 pBuf = pBuf + sizeof(tSirMacAddr);
12673 if(!HAL_STATUS_SUCCESS(status))
12674 {
12675 palFreeMemory(pMac->hHdd, pMsg);
12676 break;
12677 }
12678 wTmp = pal_cpu_to_be16(reasonCode);
12679 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12680 if(!HAL_STATUS_SUCCESS(status))
12681 {
12682 palFreeMemory(pMac->hHdd, pMsg);
12683 break;
12684 }
12685 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012686 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012687 return( status );
12688}
12689
Jeff Johnson295189b2012-06-20 16:38:30 -070012690eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12691{
12692 eHalStatus status = eHAL_STATUS_SUCCESS;
12693 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 do {
12695 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12696 if ( !HAL_STATUS_SUCCESS(status) ) break;
12697 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12698 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12699 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12700 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12701 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12702 if(!HAL_STATUS_SUCCESS(status))
12703 {
12704 palFreeMemory(pMac->hHdd, pMsg);
12705 break;
12706 }
12707//To test reconn
12708 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12709 if(!HAL_STATUS_SUCCESS(status))
12710 {
12711 palFreeMemory(pMac->hHdd, pMsg);
12712 break;
12713 }
12714//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 return( status );
12718}
12719
Jeff Johnson295189b2012-06-20 16:38:30 -070012720eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12721{
12722 eHalStatus status = eHAL_STATUS_SUCCESS;
12723 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 do {
12725 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12726 if ( !HAL_STATUS_SUCCESS(status) ) break;
12727 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12728 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12729 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12730 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12731 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12732 if(!HAL_STATUS_SUCCESS(status))
12733 {
12734 palFreeMemory(pMac->hHdd, pMsg);
12735 break;
12736 }
12737 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12738 if(!HAL_STATUS_SUCCESS(status))
12739 {
12740 palFreeMemory(pMac->hHdd, pMsg);
12741 break;
12742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 return( status );
12746}
Jeff Johnson295189b2012-06-20 16:38:30 -070012747eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12748{
12749 eHalStatus status = eHAL_STATUS_SUCCESS;
12750 tSirSmeAssocCnf *pMsg;
12751 tANI_U8 *pBuf;
12752 tSirResultCodes statusCode;
12753 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 do {
12755 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12756 if ( !HAL_STATUS_SUCCESS(status) ) break;
12757 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12758 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12759 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 pBuf = (tANI_U8 *)&pMsg->statusCode;
12761 if(HAL_STATUS_SUCCESS(Halstatus))
12762 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12763 else
12764 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12765 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12766 pBuf += sizeof(tSirResultCodes);
12767 // bssId
12768 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12769 pBuf += sizeof (tSirMacAddr);
12770 // peerMacAddr
12771 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12772 pBuf += sizeof (tSirMacAddr);
12773 // aid
12774 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12775 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12776 pBuf += sizeof (tANI_U16);
12777 // alternateBssId
12778 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12779 pBuf += sizeof (tSirMacAddr);
12780 // alternateChannelId
12781 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 status = palSendMBMessage( pMac->hHdd, pMsg );
12783 if(!HAL_STATUS_SUCCESS(status))
12784 {
12785 //pMsg is freed by palSendMBMessage
12786 break;
12787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 return( status );
12790}
Jeff Johnson295189b2012-06-20 16:38:30 -070012791eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12792 tpSirSmeAssocInd pAssocInd,
12793 eHalStatus Halstatus,
12794 tANI_U8 sessionId)
12795{
12796 tSirMsgQ msgQ;
12797 eHalStatus status = eHAL_STATUS_SUCCESS;
12798 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12799 tANI_U8 *pBuf;
12800 tSirResultCodes statusCode;
12801 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 do {
12803 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12804 if ( !HAL_STATUS_SUCCESS(status) ) break;
12805 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012806
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12808 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12809
12810 pMsg->sessionId = sessionId;
12811
12812 pBuf = (tANI_U8 *)&pMsg->statusCode;
12813 if(HAL_STATUS_SUCCESS(Halstatus))
12814 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12815 else
12816 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12817 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12818 pBuf += sizeof(tSirResultCodes);
12819 // bssId
12820 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12821 pBuf += sizeof (tSirMacAddr);
12822 // peerMacAddr
12823 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12824 pBuf += sizeof (tSirMacAddr);
12825 // StaId
12826 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12827 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12828 pBuf += sizeof (tANI_U16);
12829 // alternateBssId
12830 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12831 pBuf += sizeof (tSirMacAddr);
12832 // alternateChannelId
12833 *pBuf = 11;
12834 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012835 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 //Wmm
12837 *pBuf = pAssocInd->wmmEnabledSta;
12838 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 //RSN IE
12840 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12841 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 //Additional IE
12843 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12844 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 //reassocReq
12846 *pBuf = pAssocInd->reassocReq;
12847 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12849 msgQ.bodyptr = pMsg;
12850 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 return( status );
12854}
Jeff Johnson295189b2012-06-20 16:38:30 -070012855
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012856eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12858 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12859 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12860 tANI_U8 *pKeyRsc )
12861{
12862 tSirSmeSetContextReq *pMsg;
12863 tANI_U16 msgLen;
12864 eHalStatus status = eHAL_STATUS_FAILURE;
12865 tAniEdType tmpEdType;
12866 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012867 tANI_U8 *pBuf = NULL;
12868 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12873 // key set. Since we only support upto one key, we always allocate memory for 1 key
12874 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12875 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12876 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12877 ( sizeof( pMsg->keyMaterial.key ) );
12878
12879 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12880 if ( !HAL_STATUS_SUCCESS(status) ) break;
12881 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12882 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12883 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 //sessionId
12885 pBuf = &pMsg->sessionId;
12886 *pBuf = (tANI_U8)sessionId;
12887 pBuf++;
12888 // transactionId
12889 *pBuf = 0;
12890 *(pBuf + 1) = 0;
12891 pBuf += sizeof(tANI_U16);
12892 // peerMacAddr
12893 palCopyMemory( pMac->hHdd, pBuf,
12894 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12895
12896 pBuf += sizeof(tSirMacAddr);
12897
12898 // bssId
12899 palCopyMemory( pMac->hHdd, pBuf,
12900 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12901
12902 pBuf += sizeof(tSirMacAddr);
12903
12904 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12906 // in the tSirKeyMaterial keyMaterial; field).
12907 //
12908 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12909 // shorter than this max size. Is LIM interpreting this ok ?
12910 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 -070012911 // set pMsg->keyMaterial.edType
12912 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12913 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12914 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012915 // set the pMsg->keyMaterial.numKeys field
12916 *p = numKeys;
12917 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 // set pSirKey->keyId = keyId;
12919 *p = keyId;
12920 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 // set pSirKey->unicast = (tANI_U8)fUnicast;
12922 *p = (tANI_U8)fUnicast;
12923 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 // set pSirKey->keyDirection = aniKeyDirection;
12925 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12926 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12927 p += sizeof(tAniKeyDirection);
12928 // pSirKey->keyRsc = ;;
12929 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12930 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 // set pSirKey->paeRole
12932 *p = paeRole; // 0 is Supplicant
12933 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 // set pSirKey->keyLength = keyLength;
12935 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 if ( keyLength && pKey )
12937 {
12938 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12939 if(keyLength == 16)
12940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012941 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 -070012942 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12943 pKey[5], pKey[6], pKey[7], pKey[8],
12944 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12945 }
12946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 return( status );
12950}
12951
Jeff Johnson295189b2012-06-20 16:38:30 -070012952eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12953 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12954{
12955 eHalStatus status;
12956 tSirSmeStartBssReq *pMsg;
12957 tANI_U8 *pBuf = NULL;
12958 tANI_U8 *wTmpBuf = NULL;
12959 tANI_U16 msgLen, wTmp;
12960 tANI_U32 dwTmp;
12961 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012962 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012965
12966 if(!pSession)
12967 {
12968 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12969 return eHAL_STATUS_FAILURE;
12970 }
12971
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 do {
12973 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12974 pSession->joinFailStatusCode.reasonCode = 0;
12975 msgLen = sizeof(tSirSmeStartBssReq);
12976 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12977 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12979 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 //sessionId
12983 *pBuf = (tANI_U8)sessionId;
12984 pBuf++;
12985 // transactionId
12986 *pBuf = 0;
12987 *(pBuf + 1) = 0;
12988 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 // bssid
12990 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12991 pBuf += sizeof(tSirMacAddr);
12992 // selfMacAddr
12993 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12994 pBuf += sizeof(tSirMacAddr);
12995 // beaconInterval
12996 if( pBssDesc && pBssDesc->beaconInterval )
12997 {
12998 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 else if(pParam->beaconInterval)
13001 {
13002 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 else
13005 {
13006 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13007 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013008 if(csrIsconcurrentsessionValid (pMac, sessionId,
13009 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013010 == eHAL_STATUS_SUCCESS )
13011 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013012 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013013 pParam->bssPersona);
13014 //Update the beacon Interval
13015 pParam->beaconInterval = wTmp;
13016 }
13017 else
13018 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013019 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013020 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070013021 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070013022 return status;
13023 }
13024
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13026 pBuf += sizeof(tANI_U16);
13027 // dot11mode
13028 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13029 pBuf += 1;
13030 // bssType
13031 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
13032 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
13033 pBuf += sizeof(tSirBssType);
13034 // ssId
13035 if( pParam->ssId.length )
13036 {
13037 // ssId len
13038 *pBuf = pParam->ssId.length;
13039 pBuf++;
13040 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
13041 pBuf += pParam->ssId.length;
13042 }
13043 else
13044 {
13045 *pBuf = 0;
13046 pBuf++;
13047 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 // set the channel Id
13049 *pBuf = pParam->operationChn;
13050 pBuf++;
13051 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013052 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
13053 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
13054 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013055
Jeff Johnson295189b2012-06-20 16:38:30 -070013056 // Set privacy
13057 *pBuf = pParam->privacy;
13058 pBuf++;
13059
13060 //Set Uapsd
13061 *pBuf = pParam->ApUapsdEnable;
13062 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 //Set SSID hidden
13064 *pBuf = pParam->ssidHidden;
13065 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13067 pBuf++;
13068
13069 //Ht protection Enable/Disable
13070 *pBuf = (tANI_U8)pParam->protEnabled;
13071 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 //Enable Beacons to Receive for OBSS protection Enable/Disable
13073 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13074 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 //set cfg related to protection
13076 wTmp = pal_cpu_to_be16( pParam->ht_protection );
13077 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13078 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 // Set Auth type
13080 authType = pal_cpu_to_be32(pParam->authType);
13081 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
13082 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 // Set DTIM
13084 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
13085 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
13086 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 // Set wps_state
13088 *pBuf = pParam->wps_state;
13089 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 //Persona
13091 *pBuf = (tANI_U8)pParam->bssPersona;
13092 pBuf++;
13093
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013094 //txLdpcIniFeatureEnabled
13095 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13096 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013097
krunal soni4f087d22013-07-29 16:32:26 -070013098 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13100 {
13101 status = eHAL_STATUS_INVALID_PARAMETER;
13102 palFreeMemory( pMac->hHdd, pMsg );
13103 break;
13104 }
13105 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
13106 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
13107 pBuf += sizeof(tANI_U16);
13108 if( wTmp )
13109 {
13110 wTmp = pParam->nRSNIELength;
13111 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13112 pBuf += wTmp;
13113 }
13114 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13115 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13116 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13118 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13120 pBuf += pParam->operationalRateSet.numRates ;
13121 *pBuf++ = pParam->extendedRateSet.numRates;
13122 if(0 != pParam->extendedRateSet.numRates)
13123 {
13124 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13125 pBuf += pParam->extendedRateSet.numRates;
13126 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13128 pMsg->length = pal_cpu_to_be16(msgLen);
13129
13130 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 return( status );
13133}
13134
Jeff Johnson295189b2012-06-20 16:38:30 -070013135eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13136{
13137 eHalStatus status = eHAL_STATUS_FAILURE;
13138 tSirSmeStopBssReq *pMsg;
13139 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13140 tANI_U8 *pBuf;
13141 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013142
13143 if(!pSession)
13144 {
13145 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13146 return eHAL_STATUS_FAILURE;
13147 }
13148
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 do {
13150 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13151 if ( !HAL_STATUS_SUCCESS(status) ) break;
13152 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13153 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13154 pBuf = &pMsg->sessionId;
13155 //sessionId
13156 *pBuf = (tANI_U8)sessionId;
13157 pBuf++;
13158 // transactionId
13159 *pBuf = 0;
13160 pBuf += sizeof(tANI_U16);
13161 //reason code
13162 *pBuf = 0;
13163 pBuf += sizeof(tSirResultCodes);
13164 // bssid
13165 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13166 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13167 {
13168 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13169 }
13170 else
13171 {
13172 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13173 }
13174 pBuf += sizeof(tSirMacAddr);
13175 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13176 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 status = palSendMBMessage( pMac->hHdd, pMsg );
13178#if 0
13179 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13180 if ( !HAL_STATUS_SUCCESS(status) ) break;
13181 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13182 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13183 pMsg->reasonCode = 0;
13184 // bssid
13185 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13186 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13187 {
13188 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13189 }
13190 else
13191 {
13192 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13193 }
13194 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13195 pMsg->transactionId = 0;
13196 pMsg->sessionId = (tANI_U8)sessionId;
13197 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13198 status = palSendMBMessage( pMac->hHdd, pMsg );
13199#endif
13200 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 return( status );
13202}
13203
Jeff Johnson295189b2012-06-20 16:38:30 -070013204eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13205 tCsrRoamModifyProfileFields *pModProfileFields,
13206 tANI_U32 *pRoamId, v_BOOL_t fForce)
13207{
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 eHalStatus status = eHAL_STATUS_FAILURE;
13209 tANI_U32 roamId = 0;
13210 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 if((csrIsConnStateConnected(pMac, sessionId)) &&
13212 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13213 &pSession->connectedProfile.modifyProfileFields,
13214 sizeof(tCsrRoamModifyProfileFields)))) )
13215 {
13216 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13217 if(pRoamId)
13218 {
13219 *pRoamId = roamId;
13220 }
13221
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13223 eCsrSmeIssuedReassocToSameAP, roamId,
13224 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 return status;
13227}
Jeff Johnson295189b2012-06-20 16:38:30 -070013228static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13229{
13230 eHalStatus status = eHAL_STATUS_SUCCESS;
13231 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13233 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13234 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13235 return (status);
13236}
Jeff Johnson295189b2012-06-20 16:38:30 -070013237eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13238{
13239 eHalStatus status = eHAL_STATUS_SUCCESS;
13240 tListElem *pEntry = NULL;
13241 tSmeCmd *pCommand = NULL;
13242 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 do
13244 {
13245 if(pMsg == NULL)
13246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013247 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 status = eHAL_STATUS_FAILURE;
13249 break;
13250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13252 if(pEntry)
13253 {
13254 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13255 if(eSmeCommandAddStaSession == pCommand->command)
13256 {
13257 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013258 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013261 //Remove this command out of the active list
13262 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13263 {
13264 //Now put this command back on the avilable command list
13265 csrReleaseCommand(pMac, pCommand);
13266 }
13267 smeProcessPendingQueue( pMac );
13268 }
13269 else
13270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013271 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 -070013272 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 status = eHAL_STATUS_FAILURE;
13274 break;
13275 }
13276 }
13277 else
13278 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013279 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 -070013280 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 status = eHAL_STATUS_FAILURE;
13282 break;
13283 }
13284 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013286}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013287eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13288 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013289{
13290 tSirSmeAddStaSelfReq *pMsg;
13291 tANI_U16 msgLen;
13292 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013294 msgLen = sizeof(tSirSmeAddStaSelfReq);
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13296 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13299 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 // self station address
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013301 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr,
13302 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13303
13304 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13305
13306 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 pMsg->selfMacAddr[0],
13308 pMsg->selfMacAddr[1],
13309 pMsg->selfMacAddr[2],
13310 pMsg->selfMacAddr[3],
13311 pMsg->selfMacAddr[4],
13312 pMsg->selfMacAddr[5]);
13313 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 return( status );
13316}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013317eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13318 tANI_U32 sessionId,
13319 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013320{
13321 eHalStatus status = eHAL_STATUS_SUCCESS;
13322 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 pCommand = csrGetCommandBuffer(pMac);
13324 if(NULL == pCommand)
13325 {
13326 status = eHAL_STATUS_RESOURCES;
13327 }
13328 else
13329 {
13330 pCommand->command = eSmeCommandAddStaSession;
13331 pCommand->sessionId = (tANI_U8)sessionId;
13332 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013333 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13335 if( !HAL_STATUS_SUCCESS( status ) )
13336 {
13337 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013338 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 }
13340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 return (status);
13342}
Jeff Johnson295189b2012-06-20 16:38:30 -070013343eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13344{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013345 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013346}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013347eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13348 csrRoamCompleteCallback callback,
13349 void *pContext, tANI_U8 *pSelfMacAddr,
13350 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013351{
13352 eHalStatus status = eHAL_STATUS_SUCCESS;
13353 tANI_U32 i;
13354 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 *pbSessionId = CSR_SESSION_ID_INVALID;
13356 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13357 {
13358 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13359 {
13360 pSession = CSR_GET_SESSION( pMac, i );
13361 status = eHAL_STATUS_SUCCESS;
13362 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13363 pSession->sessionId = (tANI_U8)i;
13364 pSession->callback = callback;
13365 pSession->pContext = pContext;
13366 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13367 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013368 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13369 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013371 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013373 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 break;
13375 }
13376#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013377 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13378 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013380 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013382 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 break;
13384 }
13385#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013386 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 break;
13388 }
13389 }
13390 if( CSR_ROAM_SESSION_MAX == i )
13391 {
13392 //No session is available
13393 status = eHAL_STATUS_RESOURCES;
13394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 return ( status );
13396}
Jeff Johnson295189b2012-06-20 16:38:30 -070013397eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13398{
13399 eHalStatus status = eHAL_STATUS_SUCCESS;
13400 tListElem *pEntry = NULL;
13401 tSmeCmd *pCommand = NULL;
13402 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 do
13404 {
13405 if(pMsg == NULL)
13406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013407 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 status = eHAL_STATUS_FAILURE;
13409 break;
13410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013411 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13412 if(pEntry)
13413 {
13414 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13415 if(eSmeCommandDelStaSession == pCommand->command)
13416 {
13417 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013419 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 //This session is done.
13421 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 if(pCommand->u.delStaSessionCmd.callback)
13423 {
13424
13425 status = sme_ReleaseGlobalLock( &pMac->sme );
13426 if ( HAL_STATUS_SUCCESS( status ) )
13427 {
13428 pCommand->u.delStaSessionCmd.callback(
13429 pCommand->u.delStaSessionCmd.pContext);
13430 status = sme_AcquireGlobalLock( &pMac->sme );
13431 if (! HAL_STATUS_SUCCESS( status ) )
13432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013433 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013434 return status;
13435 }
13436 }
13437 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013438 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013439 }
13440 }
13441
13442 //Remove this command out of the active list
13443 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13444 {
13445 //Now put this command back on the avilable command list
13446 csrReleaseCommand(pMac, pCommand);
13447 }
13448 smeProcessPendingQueue( pMac );
13449 }
13450 else
13451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013452 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 -070013453 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 status = eHAL_STATUS_FAILURE;
13455 break;
13456 }
13457 }
13458 else
13459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013460 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 -070013461 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 status = eHAL_STATUS_FAILURE;
13463 break;
13464 }
13465 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013467}
Jeff Johnson295189b2012-06-20 16:38:30 -070013468eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13469{
13470 tSirSmeDelStaSelfReq *pMsg;
13471 tANI_U16 msgLen;
13472 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13475 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13477 if ( !HAL_STATUS_SUCCESS(status) ) break;
13478
13479 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13481 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 // self station address
13483 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 return( status );
13487}
Jeff Johnson295189b2012-06-20 16:38:30 -070013488eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13489 tSirMacAddr sessionMacAddr,
13490 csrRoamSessionCloseCallback callback,
13491 void *pContext)
13492{
13493 eHalStatus status = eHAL_STATUS_SUCCESS;
13494 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 pCommand = csrGetCommandBuffer(pMac);
13496 if(NULL == pCommand)
13497 {
13498 status = eHAL_STATUS_RESOURCES;
13499 }
13500 else
13501 {
13502 pCommand->command = eSmeCommandDelStaSession;
13503 pCommand->sessionId = (tANI_U8)sessionId;
13504 pCommand->u.delStaSessionCmd.callback = callback;
13505 pCommand->u.delStaSessionCmd.pContext = pContext;
13506 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013507 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13508 if( !HAL_STATUS_SUCCESS( status ) )
13509 {
13510 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013511 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 }
13513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 return (status);
13515}
Jeff Johnson295189b2012-06-20 16:38:30 -070013516eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13517{
13518 return csrSendMBDelSelfStaReqMsg( pMac,
13519 pCommand->u.delStaSessionCmd.selfMacAddr );
13520}
Jeff Johnson295189b2012-06-20 16:38:30 -070013521static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13522{
13523 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13524 tListElem *pEntry, *pNext;
13525 tSmeCmd *pCommand;
13526 tDblLinkList localList;
13527
13528 vos_mem_zero(&localList, sizeof(tDblLinkList));
13529 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13530 {
13531 smsLog(pMac, LOGE, FL(" failed to open list"));
13532 return;
13533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 csrLLLock(pList);
13535 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13536 while(pEntry != NULL)
13537 {
13538 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13539 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13540 if(pCommand->sessionId == sessionId)
13541 {
13542 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13543 {
13544 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13545 }
13546 }
13547 pEntry = pNext;
13548 }
13549 csrLLUnlock(pList);
13550
13551 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13552 {
13553 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13554 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13555 }
13556 csrLLClose(&localList);
13557}
13558
Jeff Johnson295189b2012-06-20 16:38:30 -070013559void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13560{
13561 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13562 {
13563 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 csrRoamStop(pMac, sessionId);
13565 csrFreeConnectBssDesc(pMac, sessionId);
13566 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13567 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013568 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070013569#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013570 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013571#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053013572 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
13573 if (pMac->fScanOffload)
13574 {
13575 purgeSmeSessionCmdList(pMac, sessionId,
13576 &pMac->sme.smeScanCmdPendingList);
13577 }
13578
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 purgeCsrSessionCmdList(pMac, sessionId);
13580 csrInitSession(pMac, sessionId);
13581 }
13582}
13583
Jeff Johnson295189b2012-06-20 16:38:30 -070013584eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13585 tANI_BOOLEAN fSync,
13586 csrRoamSessionCloseCallback callback,
13587 void *pContext )
13588{
13589 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13591 {
13592 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13593 if(fSync)
13594 {
13595 csrCleanupSession(pMac, sessionId);
13596 }
13597 else
13598 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053013599 purgeSmeSessionCmdList(pMac, sessionId,
13600 &pMac->sme.smeCmdPendingList);
13601 if (pMac->fScanOffload)
13602 {
13603 purgeSmeSessionCmdList(pMac, sessionId,
13604 &pMac->sme.smeScanCmdPendingList);
13605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 purgeCsrSessionCmdList(pMac, sessionId);
13607 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13608 pSession->selfMacAddr, callback, pContext);
13609 }
13610 }
13611 else
13612 {
13613 status = eHAL_STATUS_INVALID_PARAMETER;
13614 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 return ( status );
13616}
13617
Jeff Johnson295189b2012-06-20 16:38:30 -070013618static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13619{
13620 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013621
13622 if(!pSession)
13623 {
13624 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13625 return;
13626 }
13627
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13629 pSession->sessionId = CSR_SESSION_ID_INVALID;
13630 pSession->callback = NULL;
13631 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13633 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13634 csrFreeRoamProfile( pMac, sessionId );
13635 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13636 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13637 csrFreeConnectBssDesc(pMac, sessionId);
13638 csrScanEnable(pMac);
13639 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13640 if(pSession->pWpaRsnReqIE)
13641 {
13642 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13643 pSession->pWpaRsnReqIE = NULL;
13644 }
13645 pSession->nWpaRsnReqIeLength = 0;
13646 if(pSession->pWpaRsnRspIE)
13647 {
13648 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13649 pSession->pWpaRsnRspIE = NULL;
13650 }
13651 pSession->nWpaRsnRspIeLength = 0;
13652#ifdef FEATURE_WLAN_WAPI
13653 if(pSession->pWapiReqIE)
13654 {
13655 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13656 pSession->pWapiReqIE = NULL;
13657 }
13658 pSession->nWapiReqIeLength = 0;
13659 if(pSession->pWapiRspIE)
13660 {
13661 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13662 pSession->pWapiRspIE = NULL;
13663 }
13664 pSession->nWapiRspIeLength = 0;
13665#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 if(pSession->pAddIEScan)
13667 {
13668 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13669 pSession->pAddIEScan = NULL;
13670 }
13671 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 if(pSession->pAddIEAssoc)
13673 {
13674 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13675 pSession->pAddIEAssoc = NULL;
13676}
13677 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013678}
13679
Jeff Johnson295189b2012-06-20 16:38:30 -070013680eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13681{
13682 eHalStatus status = eHAL_STATUS_FAILURE;
13683 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13685 {
13686 if( CSR_IS_SESSION_VALID( pMac, i ) )
13687 {
13688 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13689 {
13690 //Found it
13691 status = eHAL_STATUS_SUCCESS;
13692 *pSessionId = i;
13693 break;
13694 }
13695 }
13696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 return( status );
13698}
13699
Jeff Johnson295189b2012-06-20 16:38:30 -070013700//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13701//session because for IBSS, the bssid changes.
13702static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13703{
13704 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13705 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13707 {
13708 if( CSR_IS_SESSION_VALID( pMac, i ) )
13709 {
13710 pSession = CSR_GET_SESSION( pMac, i );
13711 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13712 {
13713 //Found it
13714 nRet = i;
13715 break;
13716 }
13717 }
13718 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 return (nRet);
13720}
Jeff Johnson295189b2012-06-20 16:38:30 -070013721static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13722{
13723 /* Update the current BSS info in ho control block based on connected
13724 profile info from pmac global structure */
13725
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013726 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13728 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 /* Check for user misconfig of RSSI trigger threshold */
13730 pMac->roam.configParam.vccRssiThreshold =
13731 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13732 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13733 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 /* Check for user misconfig of UL MAC Loss trigger threshold */
13735 pMac->roam.configParam.vccUlMacLossThreshold =
13736 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13737 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013738#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13739 {
13740 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 /* Indicate the neighbor roal algorithm about the connect indication */
13742 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13743 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13744 }
13745#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013746}
13747
Jeff Johnson295189b2012-06-20 16:38:30 -070013748static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13749{
13750 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013751
13752 if(!pSession)
13753 {
13754 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13755 return;
13756 }
13757
Jeff Johnson295189b2012-06-20 16:38:30 -070013758 //Only to handle the case for Handover on infra link
13759 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13760 {
13761 return;
13762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13764 csrRoamDeregStatisticsReq(pMac);
13765 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13766#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13767 /* Indicate the neighbor roal algorithm about the disconnect indication */
13768 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13769#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013770
13771 //Remove this code once SLM_Sessionization is supported
13772 //BMPS_WORKAROUND_NOT_NEEDED
13773 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013774 csrIsInfraApStarted( pMac ) &&
13775 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013776 {
13777 pMac->roam.configParam.doBMPSWorkaround = 0;
13778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013779}
13780
Jeff Johnson295189b2012-06-20 16:38:30 -070013781void csrRoamTlStatsTimerHandler(void *pv)
13782{
13783 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13784 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13786
Jeff Johnsone7245742012-09-05 17:12:55 -070013787 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13788
Jeff Johnson295189b2012-06-20 16:38:30 -070013789#if 0
13790 // TODO Persession .???
13791 //req TL for stats
13792 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013794 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 }
13796 else
13797 {
13798 //save in SME
13799 csrRoamSaveStatsFromTl(pMac, tlStats);
13800 }
13801#endif
13802 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13803 {
13804 if(pMac->roam.tlStatsReqInfo.periodicity)
13805 {
13806 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013807 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13808 pMac->roam.tlStatsReqInfo.periodicity);
13809 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013811 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 return;
13813 }
13814 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13815 }
13816 }
13817}
Jeff Johnson295189b2012-06-20 16:38:30 -070013818void csrRoamPeStatsTimerHandler(void *pv)
13819{
13820 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13821 eHalStatus status;
13822 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13823 VOS_STATUS vosStatus;
13824 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 pPeStatsReqListEntry->timerRunning = FALSE;
13826 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13827 {
13828 // If we entered here, meaning the timer could not be successfully
13829 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13830
13831 /* Destroy the timer */
13832 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13833 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013835 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 }
13837
13838 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013839 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 pPeStatsReqListEntry = NULL;
13841 }
13842 else
13843 {
13844 if(!pPeStatsReqListEntry->rspPending)
13845 {
13846 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13847 pPeStatsReqListEntry->staId);
13848 if(!HAL_STATUS_SUCCESS(status))
13849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013850 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 }
13852 else
13853 {
13854 pPeStatsReqListEntry->rspPending = TRUE;
13855 }
13856 }
13857
13858 //send down a req
13859 if(pPeStatsReqListEntry->periodicity &&
13860 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13861 {
13862 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13863 if(ePMC_FULL_POWER == powerState)
13864 {
13865 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13866 {
13867 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13868 }
13869 }
13870 else
13871 {
13872 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13873 {
13874 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13875 }
13876 }
13877 //start timer
13878 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13879 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013881 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 return;
13883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 pPeStatsReqListEntry->timerRunning = TRUE;
13885
13886 }
13887
13888 }
13889}
Jeff Johnson295189b2012-06-20 16:38:30 -070013890void csrRoamStatsClientTimerHandler(void *pv)
13891{
13892 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13894 {
13895#if 0
13896 // TODO Stats fix for multisession
13897 //start the timer
13898 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13899
13900 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013902 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 }
13904#endif
13905 }
13906#if 0
13907 //send up the stats report
13908 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13909 pStaEntry->staId, pStaEntry->pContext);
13910#endif
13911}
13912
13913
13914
Jeff Johnson295189b2012-06-20 16:38:30 -070013915eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13916{
13917 tAniGetPEStatsReq *pMsg;
13918 eHalStatus status = eHAL_STATUS_SUCCESS;
13919 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13920 if ( !HAL_STATUS_SUCCESS(status) )
13921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013922 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 return status;
13924 }
13925 // need to initiate a stats request to PE
13926 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13927 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13928 pMsg->staId = staId;
13929 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 if(!HAL_STATUS_SUCCESS(status))
13932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013933 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 return status;
13936}
Jeff Johnson295189b2012-06-20 16:38:30 -070013937void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13938{
13939 tAniGetPEStatsRsp *pSmeStatsRsp;
13940 eHalStatus status = eHAL_STATUS_FAILURE;
13941 tListElem *pEntry = NULL;
13942 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13943 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13944 tANI_U32 tempMask = 0;
13945 tANI_U8 counter = 0;
13946 tANI_U8 *pStats = NULL;
13947 tANI_U32 length = 0;
13948 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013949 v_S7_t rssi = 0, snr = 0;
13950 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013951 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13953 if(pSmeStatsRsp->rc)
13954 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013955 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 goto post_update;
13957 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 tempMask = pSmeStatsRsp->statsMask;
13959 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 /* subtract all statistics from this length, and after processing the entire
13961 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13962 * in this 'stats' message.
13963 */
13964 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 //new stats info from PE, fill up the stats strucutres in PMAC
13966 while(tempMask)
13967 {
13968 if(tempMask & 1)
13969 {
13970 switch(counter)
13971 {
13972 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013973 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13975 pStats, sizeof(tCsrSummaryStatsInfo));
13976 if(!HAL_STATUS_SUCCESS(status))
13977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013978 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 }
13980 pStats += sizeof(tCsrSummaryStatsInfo);
13981 length -= sizeof(tCsrSummaryStatsInfo);
13982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013984 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13986 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13987 if(!HAL_STATUS_SUCCESS(status))
13988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013989 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 }
13991 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13992 length -= sizeof(tCsrGlobalClassAStatsInfo);
13993 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013995 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13997 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13998 if(!HAL_STATUS_SUCCESS(status))
13999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014000 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 }
14002 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14003 length -= sizeof(tCsrGlobalClassBStatsInfo);
14004 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014006 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14008 pStats, sizeof(tCsrGlobalClassCStatsInfo));
14009 if(!HAL_STATUS_SUCCESS(status))
14010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014011 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 }
14013 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14014 length -= sizeof(tCsrGlobalClassCStatsInfo);
14015 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014017 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14019 {
14020 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14021 pStats, sizeof(tCsrPerStaStatsInfo));
14022 }
14023 else
14024 {
14025 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014026 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 VOS_ASSERT( 0 );
14028 }
14029 if(!HAL_STATUS_SUCCESS(status))
14030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014031 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 }
14033 pStats += sizeof(tCsrPerStaStatsInfo);
14034 length -= sizeof(tCsrPerStaStatsInfo);
14035 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014037 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 }
14040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 tempMask >>=1;
14042 counter++;
14043 }
14044 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14045 if (length != 0)
14046 {
14047 pRssi = (tANI_U32*)pStats;
14048 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014049 pStats += sizeof(tANI_U32);
14050 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 }
14052 else
14053 {
14054 /* If riva is not sending rssi, continue to use the hack */
14055 rssi = RSSI_HACK_BMPS;
14056 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014057
Jeff Johnson295189b2012-06-20 16:38:30 -070014058 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014059
14060 if (length != 0)
14061 {
14062 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014063 pStats += sizeof(tANI_U32);
14064 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014065 }
14066 else
14067 {
14068 linkCapacity = 0;
14069 }
14070
14071 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014072
14073 if (length != 0)
14074 {
14075 pSnr = (tANI_U32*)pStats;
14076 snr = (v_S7_t)*pSnr;
14077 }
14078 else
14079 {
14080 snr = SNR_HACK_BMPS;
14081 }
14082
14083 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014084post_update:
14085 //make sure to update the pe stats req list
14086 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14087 if(pEntry)
14088 {
14089 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14090 pPeStaEntry->rspPending = FALSE;
14091
14092 }
14093 //check the one timer cases
14094 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14095 if(pEntry)
14096 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014098 if(pTempStaEntry->timerExpired)
14099 {
14100 //send up the stats report
14101 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14102 pTempStaEntry->staId, pTempStaEntry->pContext);
14103 //also remove from the client list
14104 csrRoamRemoveStatListEntry(pMac, pEntry);
14105 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014106 }
14107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014108}
Jeff Johnson295189b2012-06-20 16:38:30 -070014109tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14110{
14111 tListElem *pEntry = NULL;
14112 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 if(!pEntry)
14115 {
14116 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014117 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 return NULL;
14119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 while( pEntry )
14121 {
14122 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 if(pTempStaEntry->statsMask == statsMask)
14124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014125 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 break;
14127 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 return pEntry;
14131}
14132
Jeff Johnson295189b2012-06-20 16:38:30 -070014133tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14134 tANI_BOOLEAN update)
14135{
14136 tListElem *pEntry;
14137 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014139 if(!pEntry)
14140 {
14141 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014142 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014143 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 return NULL;
14145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 while( pEntry )
14147 {
14148 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014149 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14150 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014152 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 if(update)
14154 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014155 pTempStaEntry->periodicity = pStaEntry->periodicity;
14156 pTempStaEntry->callback = pStaEntry->callback;
14157 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 }
14159 break;
14160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 return pEntry;
14164}
Jeff Johnson295189b2012-06-20 16:38:30 -070014165tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14166{
14167 tListElem *pEntry;
14168 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 if(!pEntry)
14171 {
14172 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014173 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014174 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 return NULL;
14176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 while( pEntry )
14178 {
14179 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014182 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 break;
14184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014187 return pEntry;
14188}
Jeff Johnson295189b2012-06-20 16:38:30 -070014189eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14190 csrRoamLinkQualityIndCallback callback,
14191 void *pContext)
14192{
14193 pMac->roam.linkQualityIndInfo.callback = callback;
14194 pMac->roam.linkQualityIndInfo.context = pContext;
14195 if( NULL == callback )
14196 {
14197 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14198 }
14199 else
14200 {
14201 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 /* do we need to invoke the callback to notify client of initial value ?? */
14203 }
14204 return eHAL_STATUS_SUCCESS;
14205}
Jeff Johnson295189b2012-06-20 16:38:30 -070014206void csrRoamVccTrigger(tpAniSirGlobal pMac)
14207{
14208 eCsrRoamLinkQualityInd newVccLinkQuality;
14209 tANI_U32 ul_mac_loss = 0;
14210 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14212 /*-------------------------------------------------------------------------
14213 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 Check for a change in link quality and notify client if necessary
14215 -------------------------------------------------------------------------*/
14216 ul_mac_loss_trigger_threshold =
14217 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014219 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14222 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014223 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14225 }
14226 else
14227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014228 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14232 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014235 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014238 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 newVccLinkQuality );
14240
14241 /* we now invoke the callback once to notify client of initial value */
14242 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14243 pMac->roam.linkQualityIndInfo.context );
14244 //event: EVENT_WLAN_VCC
14245 }
14246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 pMac->roam.vccLinkQuality = newVccLinkQuality;
14248
Jeff Johnson295189b2012-06-20 16:38:30 -070014249}
Jeff Johnson295189b2012-06-20 16:38:30 -070014250VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14251 v_U8_t rssiNotification,
14252 void * context)
14253{
14254 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14255 eCsrRoamLinkQualityInd newVccLinkQuality;
14256 // TODO : Session info unavailable
14257 tANI_U32 sessionId = 0;
14258 VOS_STATUS status = VOS_STATUS_SUCCESS;
14259 /*-------------------------------------------------------------------------
14260 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 Check for a change in link quality and notify client if necessary
14262 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014263 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 pMac->roam.configParam.vccRssiThreshold);
14265 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014267 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 return VOS_STATUS_SUCCESS;
14269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014272 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14274 }
14275 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014277 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14279 }
14280 else
14281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014282 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 //Set to this so the code below won't do anything
14284 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 VOS_ASSERT(0);
14286 }
14287
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014290 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014293 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 /* we now invoke the callback once to notify client of initial value */
14296 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14297 pMac->roam.linkQualityIndInfo.context );
14298 //event: EVENT_WLAN_VCC
14299 }
14300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 return status;
14303}
Jeff Johnson295189b2012-06-20 16:38:30 -070014304tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14305 tDblLinkList *pStaList,
14306 tCsrStatsClientReqInfo *pStaEntry)
14307{
14308 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 //if same entity requested for same set of stats with different periodicity &
14311 // callback update it
14312 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14313 {
14314
14315 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14316 if (!HAL_STATUS_SUCCESS(status))
14317 {
14318 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014319 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 return NULL;
14321 }
14322
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 pNewStaEntry->callback = pStaEntry->callback;
14324 pNewStaEntry->pContext = pStaEntry->pContext;
14325 pNewStaEntry->periodicity = pStaEntry->periodicity;
14326 pNewStaEntry->requesterId = pStaEntry->requesterId;
14327 pNewStaEntry->statsMask = pStaEntry->statsMask;
14328 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14329 pNewStaEntry->pMac = pStaEntry->pMac;
14330 pNewStaEntry->staId = pStaEntry->staId;
14331 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14332
14333 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14334 }
14335 return pNewStaEntry;
14336}
14337
Jeff Johnson295189b2012-06-20 16:38:30 -070014338tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14339 tDblLinkList *pStaList,
14340 tCsrPeStatsReqInfo *pStaEntry)
14341{
14342 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014344 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14345 if (!HAL_STATUS_SUCCESS(status))
14346 {
14347 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014348 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 return NULL;
14350 }
14351
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14353 pNewStaEntry->numClient = pStaEntry->numClient;
14354 pNewStaEntry->periodicity = pStaEntry->periodicity;
14355 pNewStaEntry->statsMask = pStaEntry->statsMask;
14356 pNewStaEntry->pMac = pStaEntry->pMac;
14357 pNewStaEntry->staId = pStaEntry->staId;
14358 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14359 pNewStaEntry->rspPending = pStaEntry->rspPending;
14360
14361 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 return pNewStaEntry;
14363}
Jeff Johnson295189b2012-06-20 16:38:30 -070014364eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14365 tCsrRssiCallback callback,
14366 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14367{
14368 eHalStatus status = eHAL_STATUS_SUCCESS;
14369 vos_msg_t msg;
14370 tANI_U32 sessionId;
14371
14372 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014373 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014374 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14375 if ( !HAL_STATUS_SUCCESS(status) )
14376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014377 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014378 return status;
14379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014380 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14381
14382 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14383 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14384 pMsg->sessionId = sessionId;
14385 pMsg->staId = staId;
14386 pMsg->rssiCallback = callback;
14387 pMsg->pDevContext = pContext;
14388 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014389 msg.type = eWNI_SME_GET_RSSI_REQ;
14390 msg.bodyptr = pMsg;
14391 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014392 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014394 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014395 palFreeMemory(pMac->hHdd, (void *)pMsg);
14396 status = eHAL_STATUS_FAILURE;
14397 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014398 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 return status;
14400}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014401
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014402eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14403 tCsrSnrCallback callback,
14404 tANI_U8 staId, tCsrBssid bssId,
14405 void *pContext)
14406{
14407 eHalStatus status = eHAL_STATUS_SUCCESS;
14408 vos_msg_t msg;
14409 tANI_U32 sessionId;
14410
14411 tAniGetSnrReq *pMsg;
14412
14413 smsLog(pMac, LOG2, FL("called"));
14414
14415 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14416 if (NULL == pMsg )
14417 {
14418 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14419 return status;
14420 }
14421
14422 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14423
14424 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14425 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14426 pMsg->sessionId = sessionId;
14427 pMsg->staId = staId;
14428 pMsg->snrCallback = callback;
14429 pMsg->pDevContext = pContext;
14430 msg.type = eWNI_SME_GET_SNR_REQ;
14431 msg.bodyptr = pMsg;
14432 msg.reserved = 0;
14433
14434 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14435 {
14436 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14437 vos_mem_free((v_VOID_t *)pMsg);
14438 status = eHAL_STATUS_FAILURE;
14439 }
14440
14441 smsLog(pMac, LOG2, FL("returned"));
14442 return status;
14443}
14444
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014445#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14446eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14447 tCsrRssiCallback callback,
14448 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14449{
14450 eHalStatus status = eHAL_STATUS_SUCCESS;
14451 tAniGetRssiReq *pMsg;
14452
14453 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14454 if ( !HAL_STATUS_SUCCESS(status) )
14455 {
14456 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14457 return status;
14458 }
14459 // need to initiate a stats request to PE
14460 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14461 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14462 pMsg->staId = staId;
14463 pMsg->rssiCallback = callback;
14464 pMsg->pDevContext = pContext;
14465 pMsg->pVosContext = pVosContext;
14466 status = palSendMBMessage(pMac->hHdd, pMsg );
14467 if(!HAL_STATUS_SUCCESS(status))
14468 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014469 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14470 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014471 status = eHAL_STATUS_FAILURE;
14472 }
14473 return status;
14474}
14475#endif
14476
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053014477/* ---------------------------------------------------------------------------
14478 \fn csrGetTLSTAState
14479 \helper function to get teh TL STA State whenever the function is called.
14480
14481 \param staId - The staID to be passed to the TL
14482 to get the relevant TL STA State
14483 \return the state as tANI_U16
14484 ---------------------------------------------------------------------------*/
14485tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
14486{
14487 WLANTL_STAStateType tlSTAState;
14488 tlSTAState = WLANTL_STA_INIT;
14489
14490 //request TL for STA State
14491 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
14492 {
14493 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
14494 }
14495
14496 return tlSTAState;
14497}
14498
Jeff Johnson295189b2012-06-20 16:38:30 -070014499eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14500 tANI_U32 statsMask,
14501 tCsrStatsCallback callback,
14502 tANI_U32 periodicity, tANI_BOOLEAN cache,
14503 tANI_U8 staId, void *pContext)
14504{
14505 tCsrStatsClientReqInfo staEntry;
14506 tCsrStatsClientReqInfo *pStaEntry = NULL;
14507 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14508 tListElem *pEntry = NULL;
14509 tANI_BOOLEAN found = FALSE;
14510 eHalStatus status = eHAL_STATUS_SUCCESS;
14511 tANI_BOOLEAN insertInClientList = FALSE;
14512 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014513 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014514
14515 if( csrIsAllSessionDisconnected(pMac) )
14516 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014517 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 return eHAL_STATUS_FAILURE;
14519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 if((!statsMask) && (!callback))
14521 {
14522 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014523 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014524 return eHAL_STATUS_FAILURE;
14525 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 //for the search list method for deregister
14527 staEntry.requesterId = requesterId;
14528 staEntry.statsMask = statsMask;
14529 //requester wants to deregister or just an error
14530 if((statsMask) && (!callback))
14531 {
14532 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14533 if(!pEntry)
14534 {
14535 //msg
14536 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014537 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 return eHAL_STATUS_FAILURE;
14539 }
14540 else
14541 {
14542 //clean up & return
14543 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014544 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014546 pStaEntry->pPeStaEntry->numClient--;
14547 //check if we need to delete the entry from peStatsReqList too
14548 if(!pStaEntry->pPeStaEntry->numClient)
14549 {
14550 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14551 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014553
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 //check if we need to stop the tl stats timer too
14555 pMac->roam.tlStatsReqInfo.numClient--;
14556 if(!pMac->roam.tlStatsReqInfo.numClient)
14557 {
14558 if(pMac->roam.tlStatsReqInfo.timerRunning)
14559 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014560 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14561 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014563 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 return eHAL_STATUS_FAILURE;
14565 }
14566 }
14567 pMac->roam.tlStatsReqInfo.periodicity = 0;
14568 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14569 }
14570 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 // Destroy the vos timer...
14572 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14573 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014575 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 csrRoamRemoveStatListEntry(pMac, pEntry);
14578 pStaEntry = NULL;
14579 return eHAL_STATUS_SUCCESS;
14580 }
14581 }
14582
14583 if(cache && !periodicity)
14584 {
14585 //return the cached stats
14586 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14587 }
14588 else
14589 {
14590 //add the request in the client req list
14591 staEntry.callback = callback;
14592 staEntry.pContext = pContext;
14593 staEntry.periodicity = periodicity;
14594 staEntry.pPeStaEntry = NULL;
14595 staEntry.staId = staId;
14596 staEntry.pMac = pMac;
14597 staEntry.timerExpired = FALSE;
14598
14599
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 //if periodic report requested with non cached result from PE/TL
14601 if(periodicity)
14602 {
14603
14604 //if looking for stats from PE
14605 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14606 {
14607
14608 //check if same request made already & waiting for rsp
14609 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14610 periodicity, &found, staId);
14611 if(!pPeStaEntry)
14612 {
14613 //bail out, maxed out on number of req for PE
14614 return eHAL_STATUS_FAILURE;
14615 }
14616 else
14617 {
14618 staEntry.pPeStaEntry = pPeStaEntry;
14619 }
14620
14621 }
14622 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14623 if(statsMask & (1 << eCsrGlobalClassDStats))
14624 {
14625 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014627 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014628 }
14629 else
14630 {
14631
14632 //update periodicity
14633 if(pMac->roam.tlStatsReqInfo.periodicity)
14634 {
14635 pMac->roam.tlStatsReqInfo.periodicity =
14636 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14637 }
14638 else
14639 {
14640 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14641 }
14642 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14643 {
14644 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14645 }
14646
14647 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14648 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014649 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14650 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014652 //req TL for class D stats
14653 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014655 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014656 }
14657 else
14658 {
14659 //save in SME
14660 csrRoamSaveStatsFromTl(pMac, pTlStats);
14661 }
14662 vos_mem_free(pTlStats);
14663 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014664 }
14665 else
14666 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014667 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014669
Jeff Johnson295189b2012-06-20 16:38:30 -070014670 if(pMac->roam.tlStatsReqInfo.periodicity)
14671 {
14672 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014673 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14674 pMac->roam.tlStatsReqInfo.periodicity);
14675 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014677 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014678 return eHAL_STATUS_FAILURE;
14679 }
14680 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14681 }
14682 }
14683 }
14684 pMac->roam.tlStatsReqInfo.numClient++;
14685 }
14686
14687 insertInClientList = TRUE;
14688 }
14689 //if one time report requested with non cached result from PE/TL
14690 else if(!cache && !periodicity)
14691 {
14692 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14693 {
14694 //send down a req
14695 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14696 if(!HAL_STATUS_SUCCESS(status))
14697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014698 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 }
14700 //so that when the stats rsp comes back from PE we respond to upper layer
14701 //right away
14702 staEntry.timerExpired = TRUE;
14703 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014704 }
14705 if(statsMask & (1 << eCsrGlobalClassDStats))
14706 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014707 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14708 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014710 //req TL for class D stats
14711 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014713 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014714 }
14715 else
14716 {
14717 //save in SME
14718 csrRoamSaveStatsFromTl(pMac, pTlStats);
14719 }
14720 vos_mem_free(pTlStats);
14721 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 }
14723 else
14724 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014725 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014727
14728 }
14729 //if looking for stats from TL only
14730 if(!insertInClientList)
14731 {
14732 //return the stats
14733 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 if(insertInClientList)
14737 {
14738 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14739 if(!pStaEntry)
14740 {
14741 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014742 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 return eHAL_STATUS_FAILURE;
14744 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014745 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 //Init & start timer if needed
14747 if(periodicity)
14748 {
14749 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14750 csrRoamStatsClientTimerHandler, pStaEntry );
14751 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014753 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 return eHAL_STATUS_FAILURE;
14755 }
14756 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14757 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014759 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 return eHAL_STATUS_FAILURE;
14761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014763 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014764 }
14765 return eHAL_STATUS_SUCCESS;
14766}
14767
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014768#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14769
14770static tSirRetStatus
14771csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14772 tANI_U8* pBD,
14773 tANI_U8 type,
14774 tANI_U8 subType,
14775 tSirMacAddr peerAddr,
14776 tSirMacAddr selfMacAddr)
14777{
14778 tSirRetStatus statusCode = eSIR_SUCCESS;
14779 tpSirMacMgmtHdr pMacHdr;
14780
14781 /* Prepare MAC management header */
14782 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14783
14784 /* Prepare FC */
14785 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14786 pMacHdr->fc.type = type;
14787 pMacHdr->fc.subType = subType;
14788
14789 /* Prepare Address 1 */
14790 palCopyMemory( pMac->hHdd,
14791 (tANI_U8 *) pMacHdr->da,
14792 (tANI_U8 *) peerAddr,
14793 sizeof( tSirMacAddr ));
14794
14795 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14796
14797 /* Prepare Address 3 */
14798 palCopyMemory( pMac->hHdd,
14799 (tANI_U8 *) pMacHdr->bssId,
14800 (tANI_U8 *) peerAddr,
14801 sizeof( tSirMacAddr ));
14802 return statusCode;
14803} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14804
14805static tSirRetStatus
14806csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14807 tANI_U8 nChannelNum,
14808 tANI_U32 dot11mode,
14809 tSirMacAddr selfMacAddr,
14810 tANI_U8 *pFrame,
14811 tANI_U16 *pusLen)
14812{
14813 tDot11fProbeRequest pr;
14814 tANI_U32 nStatus, nBytes, nPayload;
14815 tSirRetStatus nSirStatus;
14816 /*Bcast tx*/
14817 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14818 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14819
14820
14821 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14822
14823 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14824
14825 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14826 {
14827 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14828 }
14829
14830
14831 if (IS_DOT11_MODE_HT(dot11mode))
14832 {
14833 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14834 }
14835
14836
14837 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14838 if ( DOT11F_FAILED( nStatus ) )
14839 {
14840 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14841 "Failed to calculate the packed size f"
14842 "or a Probe Request (0x%08x).\n", nStatus );
14843
14844
14845 nPayload = sizeof( tDot11fProbeRequest );
14846 }
14847 else if ( DOT11F_WARNED( nStatus ) )
14848 {
14849 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14850 "There were warnings while calculating"
14851 "the packed size for a Probe Request ("
14852 "0x%08x).\n", nStatus );
14853 }
14854
14855 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14856
14857 /* Prepare outgoing frame*/
14858 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14859
14860
14861 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014862 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014863
14864 if ( eSIR_SUCCESS != nSirStatus )
14865 {
14866 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14867 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14868 nSirStatus );
14869 return nSirStatus;
14870 }
14871
14872
14873 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14874 sizeof( tSirMacMgmtHdr ),
14875 nPayload, &nPayload );
14876 if ( DOT11F_FAILED( nStatus ) )
14877 {
14878 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14879 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14880 return eSIR_FAILURE;
14881 }
14882 else if ( DOT11F_WARNED( nStatus ) )
14883 {
14884 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14885 "There were warnings while packing a Probe Request (0x%08x).\n" );
14886 }
14887
14888 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14889 return eSIR_SUCCESS;
14890}
14891
14892eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14893{
14894 vos_msg_t msg;
14895 tSirRoamOffloadScanReq *pRequestBuf;
14896 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14897 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070014898 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014899 tANI_U8 *ChannelList = NULL;
14900 tANI_U32 sessionId;
14901 eHalStatus status = eHAL_STATUS_SUCCESS;
14902 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070014903 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070014904 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014905 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14906
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070014907 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014908 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014909 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014910 return eHAL_STATUS_FAILURE;
14911 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014912
14913 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
14914 {
14915 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
14916 return eHAL_STATUS_FAILURE;
14917 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014918 status = csrRoamGetSessionIdFromBSSID(pMac,
14919 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14920 &sessionId);
14921 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14922 * It is important to ensure that the command is passed down to the FW only
14923 * if the Infra Station is in a connected state.A connected station could also be
14924 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14925 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14926 * irrespective of whichever state we are in.*/
14927 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14928 (command != ROAM_SCAN_OFFLOAD_STOP))
14929 {
14930 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14931 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14932 return eHAL_STATUS_FAILURE;
14933 }
14934
14935 if ( !HAL_STATUS_SUCCESS( status ) )
14936 {
14937 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14938 return eHAL_STATUS_FAILURE;
14939 }
14940 pSession = CSR_GET_SESSION( pMac, sessionId );
14941 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14942 if (NULL == pRequestBuf)
14943 {
14944 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14945 return eHAL_STATUS_FAILED_ALLOC;
14946 }
14947
14948 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14949 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14950 * host driver reloads, but Riva still up and running*/
14951 if(command == ROAM_SCAN_OFFLOAD_STOP)
14952 pRequestBuf->RoamScanOffloadEnabled = 0;
14953 else
14954 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14955 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14956 sizeof(tCsrBssid));
14957 pRequestBuf->ConnectedNetwork.ssId.length =
14958 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14959 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14960 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14961 pRequestBuf->ConnectedNetwork.ssId.length);
14962 pRequestBuf->ConnectedNetwork.authentication =
14963 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14964 pRequestBuf->ConnectedNetwork.encryption =
14965 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14966 pRequestBuf->ConnectedNetwork.mcencryption =
14967 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14968 pRequestBuf->LookupThreshold =
14969 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14970 pRequestBuf->RoamRssiDiff =
14971 pMac->roam.configParam.RoamRssiDiff;
14972 pRequestBuf->Command = command;
14973 pRequestBuf->StartScanReason = reason;
14974 pRequestBuf->NeighborScanTimerPeriod =
14975 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14976 pRequestBuf->NeighborRoamScanRefreshPeriod =
14977 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14978 pRequestBuf->NeighborScanChannelMinTime =
14979 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14980 pRequestBuf->NeighborScanChannelMaxTime =
14981 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14982 pRequestBuf->EmptyRefreshScanPeriod =
14983 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14984#ifdef FEATURE_WLAN_CCX
14985 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14986#endif
14987 if (
14988#ifdef FEATURE_WLAN_CCX
14989 ((pNeighborRoamInfo->isCCXAssoc) &&
14990 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14991 eANI_BOOLEAN_FALSE)) ||
14992 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14993#endif // CCX
14994 currChannelListInfo->numOfChannels == 0)
14995 {
14996
14997 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14998 * Give Preference to INI Channels.*/
14999 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15000 {
15001 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15002 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
15003 {
15004 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15005 {
15006 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15007 }
15008 ChannelList++;
15009 }
15010 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15011 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15012 }
15013 else{
15014 ChannelList = pMac->scan.occupiedChannels.channelList;
15015 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15016 {
15017 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15018 {
15019 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15020 }
15021 ChannelList++;
15022 }
15023 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15024 /* If the profile changes as to what it was earlier, inform the FW through
15025 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15026 * for the earlier profile and try to learn them afresh.*/
15027 if (reason == REASON_FLUSH_CHANNEL_LIST)
15028 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15029 else {
15030 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15031 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15032 else
15033 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15034 }
15035 }
15036 }
15037#ifdef FEATURE_WLAN_CCX
15038 else
15039 {
15040 /* If CCX is enabled, and a neighbor Report is received,then
15041 * Ignore the INI Channels or the Occupied Channel List. Consider
15042 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015043 if (currChannelListInfo->numOfChannels != 0)
15044 {
15045 ChannelList = currChannelListInfo->ChannelList;
15046 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015047 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015048 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15049 {
15050 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15051 }
15052 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015053 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015054 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15055 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15056 }
15057 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015058#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015059 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15060 {
15061 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15062 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15063 }
15064 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15065 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15066 pRequestBuf->ChannelCacheType,
15067 pRequestBuf->ConnectedNetwork.ChannelCount,
15068 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015069 num_channels = 0;
15070 ChannelList = NULL;
15071
15072 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015073 host_channels = sizeof(pMac->roam.validChannelList);
15074 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015075 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015076 ChannelList = pMac->roam.validChannelList;
15077 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015078 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015079 else
15080 {
15081 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15082 "%s:Failed to get the valid channel list", __func__);
15083 return eHAL_STATUS_FAILURE;
15084 }
15085 for(i=0; i<pMac->roam.numValidChannels; i++)
15086 {
15087 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15088 {
15089 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15090 }
15091 ChannelList++;
15092 }
15093 pRequestBuf->ValidChannelCount = num_channels;
15094
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015095 pRequestBuf->MDID.mdiePresent =
15096 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15097 pRequestBuf->MDID.mobilityDomain =
15098 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015099 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15100
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015101 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015102
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015103 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15104 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15105 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15106 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15107 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15108
15109 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15110 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015111 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015112 msg.reserved = 0;
15113 msg.bodyptr = pRequestBuf;
15114 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15115 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015116 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15117 vos_mem_free(pRequestBuf);
15118 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015119 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015120 else
15121 {
15122 if (ROAM_SCAN_OFFLOAD_START == command)
15123 bRoamScanOffloadStarted = VOS_TRUE;
15124 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15125 bRoamScanOffloadStarted = VOS_FALSE;
15126 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015127
15128 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15129 return status;
15130}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015131
15132eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15133{
15134 switch(reason)
15135 {
15136 case 0:
15137 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15138 break;
15139 case REASON_OS_REQUESTED_ROAMING_NOW:
15140 csrNeighborRoamProceedWithHandoffReq(pMac);
15141 break;
15142 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015143 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 -070015144 }
15145 return eHAL_STATUS_SUCCESS;
15146}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015147#endif
15148
Jeff Johnson295189b2012-06-20 16:38:30 -070015149tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15150 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15151{
15152 tANI_BOOLEAN found = FALSE;
15153 eHalStatus status = eHAL_STATUS_SUCCESS;
15154 tCsrPeStatsReqInfo staEntry;
15155 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15156 tListElem *pStaEntry = NULL;
15157 VOS_STATUS vosStatus;
15158 tPmcPowerState powerState;
15159 *pFound = FALSE;
15160
15161 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15162 if(pStaEntry)
15163 {
15164 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15165 if(pTempStaEntry->periodicity)
15166 {
15167 pTempStaEntry->periodicity =
15168 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15169 }
15170 else
15171 {
15172 pTempStaEntry->periodicity = periodicity;
15173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 pTempStaEntry->numClient++;
15175 found = TRUE;
15176 }
15177 else
15178 {
15179 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
15180 staEntry.numClient = 1;
15181 staEntry.periodicity = periodicity;
15182 staEntry.pMac = pMac;
15183 staEntry.rspPending = FALSE;
15184 staEntry.staId = staId;
15185 staEntry.statsMask = statsMask;
15186 staEntry.timerRunning = FALSE;
15187 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15188 if(!pTempStaEntry)
15189 {
15190 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015191 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 return NULL;
15193 }
15194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15196 if(ePMC_FULL_POWER == powerState)
15197 {
15198 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15199 {
15200 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15201 }
15202 }
15203 else
15204 {
15205 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15206 {
15207 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15208 }
15209 }
15210 if(!pTempStaEntry->timerRunning)
15211 {
15212 //send down a req in case of one time req, for periodic ones wait for timer to expire
15213 if(!pTempStaEntry->rspPending &&
15214 !pTempStaEntry->periodicity)
15215 {
15216 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15217 if(!HAL_STATUS_SUCCESS(status))
15218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015219 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 }
15221 else
15222 {
15223 pTempStaEntry->rspPending = TRUE;
15224 }
15225 }
15226 if(pTempStaEntry->periodicity)
15227 {
15228 if(!found)
15229 {
15230
15231 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15232 csrRoamPeStatsTimerHandler, pTempStaEntry );
15233 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15234 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015235 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 return NULL;
15237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 }
15239 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015240 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15242 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015244 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015245 return NULL;
15246 }
15247 pTempStaEntry->timerRunning = TRUE;
15248 }
15249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 *pFound = found;
15251 return pTempStaEntry;
15252}
15253
Jeff Johnson295189b2012-06-20 16:38:30 -070015254/*
15255 pStaEntry is no longer invalid upon the return of this function.
15256*/
15257static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15258{
15259 if(pEntry)
15260 {
15261 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15262 {
15263 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 }
15266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015267
15268void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15269{
15270 tListElem *pEntry;
15271 tCsrPeStatsReqInfo *pTempStaEntry;
15272 VOS_STATUS vosStatus;
15273 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 if(!pEntry)
15275 {
15276 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015277 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 return;
15279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015280 while( pEntry )
15281 {
15282 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015285 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 if(pTempStaEntry->timerRunning)
15287 {
15288 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15289 /* If we are not able to stop the timer here, just remove
15290 * the entry from the linked list. Destroy the timer object
15291 * and free the memory in the timer CB
15292 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015293 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 {
15295 /* the timer is successfully stopped */
15296 pTempStaEntry->timerRunning = FALSE;
15297
15298 /* Destroy the timer */
15299 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15300 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015302 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 }
15304 }
15305 else
15306 {
15307 // the timer could not be stopped. Hence destroy and free the
15308 // memory for the PE stat entry in the timer CB.
15309 pTempStaEntry->timerStopFailed = TRUE;
15310 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015312
15313 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15314 {
15315 // Only free the memory if we could stop the timer successfully
15316 if(!pTempStaEntry->timerStopFailed)
15317 {
15318 palFreeMemory(pMac->hHdd, pTempStaEntry);
15319 pTempStaEntry = NULL;
15320 }
15321 break;
15322 }
15323
15324 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15325 }
15326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015327 return;
15328}
15329
15330
Jeff Johnsone7245742012-09-05 17:12:55 -070015331void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015332{
15333
Jeff Johnsone7245742012-09-05 17:12:55 -070015334 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15335 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15336 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15337 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15338 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15339 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15340 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015342 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15343 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15344 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15345 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15346 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15347 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015349 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15350 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015351
15352}
15353
Jeff Johnson295189b2012-06-20 16:38:30 -070015354void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15355 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15356{
15357 tANI_U8 stats[500];
15358 tANI_U8 *pStats = NULL;
15359 tANI_U32 tempMask = 0;
15360 tANI_U8 counter = 0;
15361 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 if(!callback)
15363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015364 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015365 return;
15366 }
15367 if(!statsMask)
15368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015369 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 return;
15371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015374 while(tempMask)
15375 {
15376 if(tempMask & 1)
15377 {
15378 //new stats info from PE, fill up the stats strucutres in PMAC
15379 switch(counter)
15380 {
15381 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015382 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15384 sizeof(tCsrSummaryStatsInfo));
15385 if(!HAL_STATUS_SUCCESS(status))
15386 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015387 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 }
15389 pStats += sizeof(tCsrSummaryStatsInfo);
15390 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015392 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15394 sizeof(tCsrGlobalClassAStatsInfo));
15395 if(!HAL_STATUS_SUCCESS(status))
15396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015397 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 }
15399 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015402 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015403 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15404 sizeof(tCsrGlobalClassBStatsInfo));
15405 if(!HAL_STATUS_SUCCESS(status))
15406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015407 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 }
15409 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015412 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15414 sizeof(tCsrGlobalClassCStatsInfo));
15415 if(!HAL_STATUS_SUCCESS(status))
15416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015417 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 }
15419 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015422 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15424 sizeof(tCsrGlobalClassDStatsInfo));
15425 if(!HAL_STATUS_SUCCESS(status))
15426 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015427 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 }
15429 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015432 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15434 sizeof(tCsrPerStaStatsInfo));
15435 if(!HAL_STATUS_SUCCESS(status))
15436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015437 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 }
15439 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015442 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 }
15445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 tempMask >>=1;
15447 counter++;
15448 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015450}
15451
Jeff Johnson295189b2012-06-20 16:38:30 -070015452eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15453{
15454 tListElem *pEntry = NULL;
15455 tListElem *pPrevEntry = NULL;
15456 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15457 eHalStatus status = eHAL_STATUS_SUCCESS;
15458 VOS_STATUS vosStatus;
15459 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015460 if(!pEntry)
15461 {
15462 //list empty
15463 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015464 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015465 return status;
15466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 while( pEntry )
15468 {
15469 if(pPrevEntry)
15470 {
15471 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15472 //send up the stats report
15473 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15474 pTempStaEntry->staId, pTempStaEntry->pContext);
15475 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015477 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15479 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015480 pTempStaEntry->pPeStaEntry->numClient--;
15481 //check if we need to delete the entry from peStatsReqList too
15482 if(!pTempStaEntry->pPeStaEntry->numClient)
15483 {
15484 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 //check if we need to stop the tl stats timer too
15488 pMac->roam.tlStatsReqInfo.numClient--;
15489 if(!pMac->roam.tlStatsReqInfo.numClient)
15490 {
15491 if(pMac->roam.tlStatsReqInfo.timerRunning)
15492 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015493 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15494 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015496 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 //we will continue
15498 }
15499 }
15500 pMac->roam.tlStatsReqInfo.periodicity = 0;
15501 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 if (pTempStaEntry->periodicity)
15504 {
15505 //While creating StaEntry in csrGetStatistics,
15506 //Initializing and starting timer only when periodicity is set.
15507 //So Stop and Destroy timer only when periodicity is set.
15508
Jeff Johnsone7245742012-09-05 17:12:55 -070015509 vos_timer_stop( &pTempStaEntry->timer );
15510 // Destroy the vos timer...
15511 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15512 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015514 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015516 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015517
Jeff Johnson295189b2012-06-20 16:38:30 -070015518
15519 pPrevEntry = pEntry;
15520 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15521 }
15522 //the last one
15523 if(pPrevEntry)
15524 {
15525 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15526 //send up the stats report
15527 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15528 pTempStaEntry->staId, pTempStaEntry->pContext);
15529 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15530 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015531 return status;
15532
15533}
15534
Jeff Johnson295189b2012-06-20 16:38:30 -070015535eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15536 tRequestFullPowerReason *pReason,
15537 tANI_BOOLEAN *pfNeedPower )
15538{
15539 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15540 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15541 tPmcState pmcState;
15542 eHalStatus status = eHAL_STATUS_SUCCESS;
15543 // TODO : Session info unavailable
15544 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 if( pfNeedPower )
15546 {
15547 *pfNeedPower = eANI_BOOLEAN_FALSE;
15548 }
15549 //We only handle CSR commands
15550 if( !(eSmeCsrCommandMask & pCommand->command) )
15551 {
15552 return eHAL_STATUS_SUCCESS;
15553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 //Check PMC state first
15555 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015556 switch( pmcState )
15557 {
15558 case REQUEST_IMPS:
15559 case IMPS:
15560 if( eSmeCommandScan == pCommand->command )
15561 {
15562 switch( pCommand->u.scanCmd.reason )
15563 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015564#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15565 case eCsrScanGetLfrResult:
15566#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 case eCsrScanGetResult:
15568 case eCsrScanBGScanAbort:
15569 case eCsrScanBGScanEnable:
15570 case eCsrScanGetScanChnInfo:
15571 //Internal process, no need for full power
15572 fNeedFullPower = eANI_BOOLEAN_FALSE;
15573 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015574 default:
15575 //Other scans are real scan, ask for power
15576 fNeedFullPower = eANI_BOOLEAN_TRUE;
15577 break;
15578 } //switch
15579 }
15580 else
15581 {
15582 //ask for power for roam and status change
15583 fNeedFullPower = eANI_BOOLEAN_TRUE;
15584 }
15585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015586 case REQUEST_BMPS:
15587 case BMPS:
15588 case REQUEST_START_UAPSD:
15589 case UAPSD:
15590 //We treat WOWL same as BMPS
15591 case REQUEST_ENTER_WOWL:
15592 case WOWL:
15593 if( eSmeCommandRoam == pCommand->command )
15594 {
15595 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15596 tCsrScanResult *pScanResult;
15597 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 switch ( pCommand->u.roamCmd.roamReason )
15599 {
15600 case eCsrForcedDisassoc:
15601 case eCsrForcedDisassocMICFailure:
15602 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15603 fNeedFullPower = eANI_BOOLEAN_TRUE;
15604 break;
15605 case eCsrSmeIssuedDisassocForHandoff:
15606 case eCsrForcedDeauth:
15607 case eCsrHddIssuedReassocToSameAP:
15608 case eCsrSmeIssuedReassocToSameAP:
15609 fNeedFullPower = eANI_BOOLEAN_TRUE;
15610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 case eCsrCapsChange:
15612 fNeedFullPower = eANI_BOOLEAN_TRUE;
15613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 default:
15615 //Check whether the profile is already connected. If so, no need for full power
15616 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15617 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15618 {
15619 //Only need to check the first one
15620 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15621 if( pEntry )
15622 {
15623 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15624#if 0
15625 // TODO : Session Specific info pConnectBssDesc
15626 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15627 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15628 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15629 {
15630 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15631 // with Authenticating first. To force this, stop the current association (Disassociate) and
15632 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15633 // a new Association.
15634 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15635 {
15636 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15637 {
15638 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15639 //No need for full power
15640 //Set the flag so the code later can avoid to do the above
15641 //check again.
15642 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15643 break;
15644 }
15645 }
15646 }
15647#endif
15648 }
15649 }
15650 //If we are here, full power is needed
15651 fNeedFullPower = eANI_BOOLEAN_TRUE;
15652 break;
15653 }
15654 }
15655 else if( eSmeCommandWmStatusChange == pCommand->command )
15656 {
15657 //need full power for all
15658 fNeedFullPower = eANI_BOOLEAN_TRUE;
15659 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15660 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015661#ifdef FEATURE_WLAN_TDLS
15662 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15663 {
15664 //TDLS link is getting established. need full power
15665 fNeedFullPower = eANI_BOOLEAN_TRUE;
15666 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15667 }
15668#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 case REQUEST_STOP_UAPSD:
15671 case REQUEST_EXIT_WOWL:
15672 if( eSmeCommandRoam == pCommand->command )
15673 {
15674 fNeedFullPower = eANI_BOOLEAN_TRUE;
15675 switch ( pCommand->u.roamCmd.roamReason )
15676 {
15677 case eCsrForcedDisassoc:
15678 case eCsrForcedDisassocMICFailure:
15679 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15680 break;
15681 default:
15682 break;
15683 }
15684 }
15685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 case STOPPED:
15687 case REQUEST_STANDBY:
15688 case STANDBY:
15689 case LOW_POWER:
15690 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015691 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015692 status = eHAL_STATUS_FAILURE;
15693 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015694 case FULL_POWER:
15695 case REQUEST_FULL_POWER:
15696 default:
15697 //No need to ask for full power. This has to be FULL_POWER state
15698 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 if( pReason )
15701 {
15702 *pReason = reason;
15703 }
15704 if( pfNeedPower )
15705 {
15706 *pfNeedPower = fNeedFullPower;
15707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 return ( status );
15709}
15710
Jeff Johnson295189b2012-06-20 16:38:30 -070015711static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15712{
15713 eHalStatus status = eHAL_STATUS_SUCCESS;
15714 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15715 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015716 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015717 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15718 {
15719 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015721 return ( status );
15722}
15723
Jeff Johnson295189b2012-06-20 16:38:30 -070015724tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15725{
15726 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015727 if( pCmd )
15728 {
15729 pMac->roam.sPendingCommands++;
15730 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 return ( pCmd );
15732}
15733
Jeff Johnson295189b2012-06-20 16:38:30 -070015734void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15735{
15736 if (pMac->roam.sPendingCommands > 0)
15737 {
15738 //All command allocated through csrGetCommandBuffer need to
15739 //decrement the pending count when releasing.
15740 pMac->roam.sPendingCommands--;
15741 smeReleaseCommand( pMac, pCommand );
15742 }
15743 else
15744 {
15745 smsLog(pMac, LOGE, FL( "no pending commands"));
15746 VOS_ASSERT(0);
15747 }
15748}
15749
Jeff Johnson295189b2012-06-20 16:38:30 -070015750//Return SUCCESS is the command is queued, failed
15751eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15752{
15753 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015754 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15755 {
15756 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15757 pCommand->u.scanCmd.reason);
15758 return eHAL_STATUS_CSR_WRONG_STATE;
15759 }
15760
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015761 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
15762 {
15763 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
15764 &pCommand->Link, LL_ACCESS_LOCK);
15765 // process the command queue...
15766 smeProcessPendingQueue(pMac);
15767 status = eHAL_STATUS_SUCCESS;
15768 goto end;
15769 }
15770
Jeff Johnson295189b2012-06-20 16:38:30 -070015771 //We can call request full power first before putting the command into pending Q
15772 //because we are holding SME lock at this point.
15773 status = csrRequestFullPower( pMac, pCommand );
15774 if( HAL_STATUS_SUCCESS( status ) )
15775 {
15776 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 //make sure roamCmdPendingList is not empty first
15778 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15779 if( fNoCmdPending )
15780 {
15781 smePushCommand( pMac, pCommand, fHighPriority );
15782 }
15783 else
15784 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015785 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070015786 //no list lock is needed since SME lock is held
15787 if( !fHighPriority )
15788 {
15789 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15790 }
15791 else {
15792 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15793 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015795 }
15796 else if( eHAL_STATUS_PMC_PENDING == status )
15797 {
15798 //no list lock is needed since SME lock is held
15799 if( !fHighPriority )
15800 {
15801 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15802 }
15803 else {
15804 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15805 }
15806 //Let caller know the command is queue
15807 status = eHAL_STATUS_SUCCESS;
15808 }
15809 else
15810 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015811 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070015812 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015813 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015814 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015815end:
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015817}
Jeff Johnson295189b2012-06-20 16:38:30 -070015818eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15819{
15820 eHalStatus status = eHAL_STATUS_SUCCESS;
15821 tSirUpdateAPWPSIEsReq *pMsg;
15822 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15823
15824 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15825 if (NULL == pSession)
15826 {
15827 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15828 return eHAL_STATUS_FAILURE;
15829 }
15830
Jeff Johnson295189b2012-06-20 16:38:30 -070015831 do
15832 {
15833 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15834 if (!HAL_STATUS_SUCCESS(status)) break;
15835 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15836 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15837
15838 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070015839 VOS_ASSERT(pBuf);
15840
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 // transactionId
15843 *pBuf = 0;
15844 *( pBuf + 1 ) = 0;
15845 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015846 // bssId
15847 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15848 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 //sessionId
15850 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 // APWPSIEs
15852 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15853 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015854 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015855 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 return ( status );
15858}
Jeff Johnson295189b2012-06-20 16:38:30 -070015859eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15860{
15861 eHalStatus status = eHAL_STATUS_SUCCESS;
15862 tSirUpdateAPWPARSNIEsReq *pMsg;
15863 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15865 if (NULL == pSession)
15866 {
15867 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15868 return eHAL_STATUS_FAILURE;
15869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015870 do
15871 {
15872 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15873 if (!HAL_STATUS_SUCCESS(status)) break;
15874 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15875 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015876 pBuf = (tANI_U8 *)&pMsg->transactionId;
15877 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 // transactionId
15879 *pBuf = 0;
15880 *( pBuf + 1 ) = 0;
15881 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070015882 VOS_ASSERT(pBuf);
15883
Jeff Johnson295189b2012-06-20 16:38:30 -070015884 // bssId
15885 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15886 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015887 // sessionId
15888 *pBuf++ = (tANI_U8)sessionId;
15889
15890 // APWPARSNIEs
15891 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15892 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015893 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 return ( status );
15897}
Jeff Johnson295189b2012-06-20 16:38:30 -070015898
15899#ifdef WLAN_FEATURE_VOWIFI_11R
15900//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15901eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15902{
15903 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15904 tpSirFTPreAuthReq pftPreAuthReq;
15905 tANI_U16 auth_req_len = 0;
15906 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015907 auth_req_len = sizeof(tSirFTPreAuthReq);
15908 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15909 if (pftPreAuthReq == NULL)
15910 {
15911 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15912 return eHAL_STATUS_RESOURCES;
15913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015914 // Save the SME Session ID here. We need it while processing the preauth response
15915 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015916 vos_mem_zero(pftPreAuthReq, auth_req_len);
15917
15918 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15919 sizeof(pBssDescription->length) + pBssDescription->length);
15920
15921 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15922
15923 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15924
Jeff Johnson295189b2012-06-20 16:38:30 -070015925 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015926 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15927
Jeff Johnson295189b2012-06-20 16:38:30 -070015928#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015929 if (csrRoamIs11rAssoc(pMac) &&
15930 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 {
15932 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15933 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15934 pMac->ft.ftSmeContext.auth_ft_ies_length);
15935 }
15936 else
15937#endif
15938 {
15939 pftPreAuthReq->ft_ies_length = 0;
15940 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015941 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15942 sizeof(pBssDescription->length) + pBssDescription->length);
15943 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015944 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15945}
Jeff Johnson295189b2012-06-20 16:38:30 -070015946/*--------------------------------------------------------------------------
15947 * This will receive and process the FT Pre Auth Rsp from the current
15948 * associated ap.
15949 *
15950 * This will invoke the hdd call back. This is so that hdd can now
15951 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15952 ------------------------------------------------------------------------*/
15953void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15954{
15955 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15956 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015957#ifdef FEATURE_WLAN_LFR
15958 tCsrRoamInfo roamInfo;
15959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015960
15961#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015962 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015963#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015964#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015965 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015966 if (status != eHAL_STATUS_SUCCESS) {
15967 /*
15968 * Bail out if pre-auth was not even processed.
15969 */
15970 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15971 return;
15972 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15975 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15976 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 // Implies a success
15978 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015979 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15980 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070015981 /* No need to notify qos module if this is a non 11r roam*/
15982 if (csrRoamIs11rAssoc(pMac))
15983 {
15984 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15985 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015986 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15987 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015988 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15989 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070015990 if (eHAL_STATUS_SUCCESS != status)
15991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015992 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 return;
15994 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 // Save the received response
15996 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15997 if (csrRoamIs11rAssoc(pMac))
15998 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15999 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16000
16001 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016002#ifdef FEATURE_WLAN_LFR
16003 // If Legacy Fast Roaming is enabled, signal the supplicant
16004 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016005 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016006 {
16007 // Save the bssid from the received response
16008 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16009 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16010 }
16011
16012#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016013
16014 // Done with it, init it.
16015 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16016}
16017#endif
16018#ifdef FEATURE_WLAN_BTAMP_UT_RF
16019void csrRoamJoinRetryTimerHandler(void *pv)
16020{
16021 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16022 tpAniSirGlobal pMac = pInfo->pMac;
16023 tANI_U32 sessionId = pInfo->sessionId;
16024 tCsrRoamSession *pSession;
16025
16026 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016028 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 pSession = CSR_GET_SESSION( pMac, sessionId );
16030 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16031 {
16032 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016034 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 }
16036 }
16037 }
16038}
Jeff Johnson295189b2012-06-20 16:38:30 -070016039eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16040{
16041 eHalStatus status = eHAL_STATUS_FAILURE;
16042 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16043
16044 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016046 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016047 pSession->maxRetryCount--;
16048 pSession->joinRetryTimerInfo.pMac = pMac;
16049 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016050 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16051 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016052 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016053 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 }
16055 }
16056 else
16057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016058 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016059 pSession->maxRetryCount);
16060 }
16061
16062 return (status);
16063}
Jeff Johnson295189b2012-06-20 16:38:30 -070016064eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16065{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016066 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016067 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16068 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016069 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 }
16071
16072 return eHAL_STATUS_SUCCESS;
16073}
16074#endif
16075
16076
16077/*
16078 pBuf points to the beginning of the message
16079 LIM packs disassoc rsp as below,
16080 messageType - 2 bytes
16081 messageLength - 2 bytes
16082 sessionId - 1 byte
16083 transactionId - 2 bytes (tANI_U16)
16084 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16085 peerMacAddr - 6 bytes
16086 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16087*/
16088static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16089{
16090 if(pBuf && pRsp)
16091 {
16092 pBuf += 4; //skip type and length
16093 pRsp->sessionId = *pBuf++;
16094 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16095 pBuf += 2;
16096 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16097 pBuf += 4;
16098 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16099 }
16100}
16101
Jeff Johnsond13512a2012-07-17 11:42:19 -070016102eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16103{
16104 static uNvTables nvTables;
16105 eHalStatus status = eHAL_STATUS_SUCCESS;
16106 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16107
16108 /* read the country code from NV and use it */
16109 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16110 {
16111 palCopyMemory( pMac->hHdd, pCountry,
16112 nvTables.defaultCountryTable.countryCode,
16113 WNI_CFG_COUNTRY_CODE_LEN );
16114 return status;
16115 }
16116 else
16117 {
16118 palCopyMemory( pMac->hHdd, pCountry,
16119 "XXX",
16120 WNI_CFG_COUNTRY_CODE_LEN );
16121 status = eHAL_STATUS_FAILURE;
16122 return status;
16123 }
16124}
16125
16126eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16127{
16128 palCopyMemory( pMac->hHdd, pCountry,
16129 pMac->scan.countryCode11d,
16130 WNI_CFG_COUNTRY_CODE_LEN );
16131 return eHAL_STATUS_SUCCESS;
16132}
schang86c22c42013-03-13 18:41:24 -070016133
16134eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16135{
16136 tSirSetTxPowerReq *pMsg = NULL;
16137 eHalStatus status = eHAL_STATUS_SUCCESS;
16138 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16139
16140 if (!pSession)
16141 {
16142 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16143 return eHAL_STATUS_FAILURE;
16144 }
16145
16146 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
16147 if (HAL_STATUS_SUCCESS(status))
16148 {
16149 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
16150 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16151 pMsg->length = sizeof(tSirSetTxPowerReq);
16152 pMsg->mwPower = mW;
16153 palCopyMemory( pMac->hHdd,
16154 (tSirMacAddr *)pMsg->bssId,
16155 &pSession->selfMacAddr,
16156 sizeof(tSirMacAddr) );
16157 status = palSendMBMessage(pMac->hHdd, pMsg);
16158 if (!HAL_STATUS_SUCCESS(status))
16159 {
16160 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016161 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016162 }
16163 }
16164 return status;
16165}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016166
16167/* Returns whether a session is in VOS_STA_MODE...or not */
16168tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16169{
16170 tCsrRoamSession *pSession = NULL;
16171 pSession = CSR_GET_SESSION ( pMac, sessionId );
16172 if(!pSession)
16173 {
16174 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16175 return eANI_BOOLEAN_FALSE;
16176 }
16177 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16178 {
16179 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16180 return eANI_BOOLEAN_FALSE;
16181 }
16182 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16183 {
16184 return eANI_BOOLEAN_FALSE;
16185 }
16186 /* There is a possibility that the above check may fail,because
16187 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16188 * when it is connected.So,we may sneak through the above check even
16189 * if we are not a STA mode INFRA station. So, if we sneak through
16190 * the above condition, we can use the following check if we are
16191 * really in STA Mode.*/
16192
16193 if ( NULL != pSession->pCurRoamProfile )
16194 {
16195 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16196 {
16197 return eANI_BOOLEAN_TRUE;
16198 } else {
16199 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16200 return eANI_BOOLEAN_FALSE;
16201 }
16202 }
16203
16204 return eANI_BOOLEAN_FALSE;
16205}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016206
16207#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16208eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16209 tCsrHandoffRequest *pHandoffInfo)
16210{
16211 eHalStatus status = eHAL_STATUS_SUCCESS;
16212 vos_msg_t msg;
16213
16214 tAniHandoffReq *pMsg;
16215 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
16216 if ( !HAL_STATUS_SUCCESS(status) )
16217 {
16218 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
16219 return status;
16220 }
16221 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16222 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16223 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16224 pMsg->channel = pHandoffInfo->channel;
16225 palCopyMemory(pMac->hHdd, pMsg->bssid,
16226 pHandoffInfo->bssid,
16227 6);
16228 msg.type = eWNI_SME_HANDOFF_REQ;
16229 msg.bodyptr = pMsg;
16230 msg.reserved = 0;
16231 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16232 {
16233 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
16234 palFreeMemory(pMac->hHdd, (void *)pMsg);
16235 status = eHAL_STATUS_FAILURE;
16236 }
16237 return status;
16238}
16239#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */