blob: 2894bb221c209f7482c578e9ccbaf896ae6c1cc8 [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
91#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080092#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 -070093#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
94/*---------------------------------------------------------------------------
95 OBIWAN recommends [8 10]% : pick 9%
96---------------------------------------------------------------------------*/
97#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070098/*---------------------------------------------------------------------------
99 OBIWAN recommends -85dBm
100---------------------------------------------------------------------------*/
101#define CSR_VCC_RSSI_THRESHOLD 80
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
103#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
104#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
105#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//We use constatnt 4 here
107//This macro returns true when higher AC parameter is bigger than lower AC for a difference
108//The bigger the number, the less chance of TX
109//It must put lower AC as the first parameter.
110#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111//Flag to send/do not send disassoc frame over the air
112#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#define MAX_CB_VALUE_IN_INI (2)
115
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700116#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
117static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
118#endif
119
Jeff Johnson295189b2012-06-20 16:38:30 -0700120/*--------------------------------------------------------------------------
121 Static Type declarations
122 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800123static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800124
Jeff Johnson295189b2012-06-20 16:38:30 -0700125/*--------------------------------------------------------------------------
126 Type declarations
127 ------------------------------------------------------------------------*/
128#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700129int diagAuthTypeFromCSRType(eCsrAuthType authType)
130{
131 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 switch(authType)
133 {
134 case eCSR_AUTH_TYPE_SHARED_KEY:
135 n = AUTH_SHARED;
136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 case eCSR_AUTH_TYPE_WPA:
138 n = AUTH_WPA_EAP;
139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 case eCSR_AUTH_TYPE_WPA_PSK:
141 n = AUTH_WPA_PSK;
142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 case eCSR_AUTH_TYPE_RSN:
144 n = AUTH_WPA2_EAP;
145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700147#ifdef WLAN_FEATURE_11W
148 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
149#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 n = AUTH_WPA2_PSK;
151 break;
152#ifdef FEATURE_WLAN_WAPI
153 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
154 n = AUTH_WAPI_CERT;
155 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
157 n = AUTH_WAPI_PSK;
158 break;
159#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 default:
161 break;
162 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 return (n);
164}
Jeff Johnson295189b2012-06-20 16:38:30 -0700165int diagEncTypeFromCSRType(eCsrEncryptionType encType)
166{
167 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 switch(encType)
169 {
170 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
171 case eCSR_ENCRYPT_TYPE_WEP40:
172 n = ENC_MODE_WEP40;
173 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
175 case eCSR_ENCRYPT_TYPE_WEP104:
176 n = ENC_MODE_WEP104;
177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 case eCSR_ENCRYPT_TYPE_TKIP:
179 n = ENC_MODE_TKIP;
180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 case eCSR_ENCRYPT_TYPE_AES:
182 n = ENC_MODE_AES;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184#ifdef FEATURE_WLAN_WAPI
185 case eCSR_ENCRYPT_TYPE_WPI:
186 n = ENC_MODE_SMS4;
187 break;
188#endif /* FEATURE_WLAN_WAPI */
189 default:
190 break;
191 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 return (n);
193}
Jeff Johnson295189b2012-06-20 16:38:30 -0700194#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700195static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
196static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700197static void initConfigParam(tpAniSirGlobal pMac);
198static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
199 eCsrRoamCompleteResult Result, void *Context );
200static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
201 tCsrRoamProfile *pProfile,
202 tANI_BOOLEAN *pfSameIbss );
203static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
204static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700205 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
206static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700207eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
208static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
209eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
210eHalStatus csrRoamClose(tpAniSirGlobal pMac);
211void csrRoamMICErrorTimerHandler(void *pv);
212void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
213tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
214
215static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
216static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
217static void csrRoamRoamingTimerHandler(void *pv);
218eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
219eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
220static void csrRoamIbssJoinTimerHandler(void *pv);
221eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
222eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
223static void csrRoamWaitForKeyTimeOutHandler(void *pv);
224
225static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700226static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700227static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
228eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
229 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
230 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
231 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
232 tANI_U8 *pKeyRsc );
233static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
234 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
235 tCsrRoamProfile *pProfile );
236void csrRoamStatisticsTimerHandler(void *pv);
237void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700238static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
239VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
240 v_U8_t rssiNotification,
241 void * context);
242static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
243void csrRoamVccTrigger(tpAniSirGlobal pMac);
244eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
245/*
246 pStaEntry is no longer invalid upon the return of this function.
247*/
248static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700249static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700250static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
252 tDblLinkList *pStaList,
253 tCsrStatsClientReqInfo *pStaEntry);
254void csrRoamStatsClientTimerHandler(void *pv);
255tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
256 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
257void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
258 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700259void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700260void csrRoamTlStatsTimerHandler(void *pv);
261void csrRoamPeStatsTimerHandler(void *pv);
262tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
263void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
264tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
265eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
266static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
267static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
268static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
269static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
270 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
271//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
272static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
273void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
274#ifdef FEATURE_WLAN_BTAMP_UT_RF
275void csrRoamJoinRetryTimerHandler(void *pv);
276#endif
277extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700278extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700279static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700280void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
282//Initialize global variables
283static void csrRoamInitGlobals(tpAniSirGlobal pMac)
284{
285 if(pMac)
286 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800287 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
288 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 }
290 return;
291}
292
Jeff Johnson295189b2012-06-20 16:38:30 -0700293static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
294{
295 if(pMac)
296 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800297 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 }
299 return;
300}
Jeff Johnson295189b2012-06-20 16:38:30 -0700301eHalStatus csrOpen(tpAniSirGlobal pMac)
302{
303 eHalStatus status = eHAL_STATUS_SUCCESS;
304 static uNvTables nvTables;
305 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700306 v_REGDOMAIN_t regId;
307 tANI_U32 i;
308
309 do
310 {
311 /* Initialize CSR Roam Globals */
312 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
314 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
315
316 initConfigParam(pMac);
317 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
318 break;
319 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
320 break;
321 pMac->roam.nextRoamId = 1; //Must not be 0
322 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
323 break;
324 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
325 break;
326 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
327 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
329 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
330 {
331 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
332 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
333 status = eHAL_STATUS_SUCCESS;
334 }
335 else
336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800337 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 //hardcoded for now
339 pMac->scan.countryCodeDefault[0] = 'U';
340 pMac->scan.countryCodeDefault[1] = 'S';
341 pMac->scan.countryCodeDefault[2] = 'I';
342 //status = eHAL_STATUS_SUCCESS;
343 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700344 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 WDA_SetRegDomain(pMac, regId);
347 pMac->scan.domainIdDefault = regId;
348 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
350 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
351 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 }while(0);
353
354 return (status);
355}
356
Jeff Johnson295189b2012-06-20 16:38:30 -0700357eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
358{
359 eHalStatus status = eHAL_STATUS_SUCCESS;
360 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
361 v_REGDOMAIN_t regId;
362 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 if(NULL == apCntryCode)
364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800365 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 return eHAL_STATUS_FAILURE;
367 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700368 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 /* To get correct Regulatory domain from NV table
370 * 2 character Country code should be used
371 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700372 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
373/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700375
376 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800378 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700379 return eHAL_STATUS_FAILURE;
380 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700381*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
383 if (status != eHAL_STATUS_SUCCESS)
384 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700385 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 return status;
387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 status = WDA_SetRegDomain(hHal, regId);
389 if (status != eHAL_STATUS_SUCCESS)
390 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700391 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 return status;
393 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 pMac->scan.domainIdDefault = regId;
395 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700396 /* Clear CC field */
397 palFillMemory( pMac->hHdd,
398 pMac->scan.countryCodeDefault,
399 WNI_CFG_COUNTRY_CODE_LEN,
400 0 );
401 /* Copy 2 or 3 bytes country code */
402 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
403 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 /* If 2 bytes country code, 3rd byte must be filled with space */
405 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
406 {
407 palFillMemory( pMac->hHdd,
408 pMac->scan.countryCodeDefault + 2,
409 1,
410 0x20 );
411 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
413 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
414 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 return status;
416}
Jeff Johnson295189b2012-06-20 16:38:30 -0700417eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
418{
419 eHalStatus status = eHAL_STATUS_SUCCESS;
420 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
421 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
423 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
425 {
426 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
427 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
428 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
429 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
430 }
431 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
432
433 return status;
434}
Jeff Johnson295189b2012-06-20 16:38:30 -0700435eHalStatus csrClose(tpAniSirGlobal pMac)
436{
437 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800438
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 csrRoamClose(pMac);
440 csrScanClose(pMac);
441 csrLLClose(&pMac->roam.statsClientReqList);
442 csrLLClose(&pMac->roam.peStatsReqList);
443 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 /* DeInit Globals */
445 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 return (status);
447}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530448
449eHalStatus csrUpdateChannelList(tCsrScanStruct *pScan)
450{
451 tSirUpdateChanList *pChanList;
452 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
453 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
454 (sizeof(tSirUpdateChanParam) * (numChan - 1));
455 vos_msg_t msg;
456 tANI_U8 i;
457
458 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
459 if (!pChanList)
460 {
461 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
462 "Failed to allocate memory for tSirUpdateChanList");
463 return eHAL_STATUS_FAILED_ALLOC;
464 }
465
466 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
467 msg.reserved = 0;
468 msg.bodyptr = pChanList;
469 pChanList->numChan = numChan;
470 for (i = 0; i < pChanList->numChan; i++)
471 {
472 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
473 pChanList->chanParam[i].pwr = pScan->defaultPowerTable[i].pwr;
474 }
475
476 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
477 {
478 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
479 "%s: Failed to post msg to WDA", __func__);
480 vos_mem_free(pChanList);
481 return eHAL_STATUS_FAILURE;
482 }
483
484 return eHAL_STATUS_SUCCESS;
485}
486
Jeff Johnson295189b2012-06-20 16:38:30 -0700487eHalStatus csrStart(tpAniSirGlobal pMac)
488{
489 eHalStatus status = eHAL_STATUS_SUCCESS;
490 tANI_U32 i;
491
492 do
493 {
494 //save the global vos context
495 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
496 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
497 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
498
499 status = csrRoamStart(pMac);
500 if(!HAL_STATUS_SUCCESS(status)) break;
501 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
502 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
503 if(!HAL_STATUS_SUCCESS(status)) break;
504 pMac->roam.sPendingCommands = 0;
505 csrScanEnable(pMac);
506#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
507 status = csrNeighborRoamInit(pMac);
508#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
509 pMac->roam.tlStatsReqInfo.numClient = 0;
510 pMac->roam.tlStatsReqInfo.periodicity = 0;
511 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
512 //init the link quality indication also
513 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
514 if(!HAL_STATUS_SUCCESS(status))
515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800516 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 break;
518 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530519
520 if (pMac->fScanOffload)
521 {
522 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
523 "Scan offload is enabled, update default chan list");
524 status = csrUpdateChannelList(&pMac->scan);
525 }
526
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700528#if defined(ANI_LOGDUMP)
529 csrDumpInit(pMac);
530#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 return (status);
532}
533
Jeff Johnson295189b2012-06-20 16:38:30 -0700534eHalStatus csrStop(tpAniSirGlobal pMac)
535{
536 tANI_U32 sessionId;
537 tANI_U32 i;
538
539 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
540 {
541 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 csrScanDisable(pMac);
544 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
545 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
547
548#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
549 csrNeighborRoamClose(pMac);
550#endif
551 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 // deregister from PMC since we register during csrStart()
553 // (ignore status since there is nothing we can do if it fails)
554 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 //Reset the domain back to the deault
556 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800557 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700558
559 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
560 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530561 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
563 }
564
565 return (eHAL_STATUS_SUCCESS);
566}
567
Jeff Johnson295189b2012-06-20 16:38:30 -0700568eHalStatus csrReady(tpAniSirGlobal pMac)
569{
570 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 csrScanGetSupportedChannels( pMac );
572 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
573 //use it to init the background scan list
574 csrInitBGScanChannelList(pMac);
575 /* HDD issues the init scan */
576 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800577 /* If the gScanAgingTime is set to '0' then scan results aging timeout
578 based on timer feature is not enabled*/
579 if(0 != pMac->scan.scanResultCfgAgingTime )
580 {
581 csrScanStartResultCfgAgingTimer(pMac);
582 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 //Store the AC weights in TL for later use
584 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 status = csrInitChannelList( pMac );
586 if ( ! HAL_STATUS_SUCCESS( status ) )
587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800588 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 status );
590 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 return (status);
592}
Jeff Johnson295189b2012-06-20 16:38:30 -0700593void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
594{
595 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
597 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
598}
Jeff Johnson295189b2012-06-20 16:38:30 -0700599void csrSetGlobalCfgs( tpAniSirGlobal pMac )
600{
Jeff Johnsone7245742012-09-05 17:12:55 -0700601
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
603 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
604 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
605 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
606 NULL, eANI_BOOLEAN_FALSE);
607 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700608 /* 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
609 * Once session is established we will use the session related params stored in PE session for CB mode
610 */
611 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
613
614 //Update the operating mode to configured value during initialization,
615 //So that client can advertise full capabilities in Probe request frame.
616 csrSetDefaultDot11Mode( pMac );
617}
618
Jeff Johnson295189b2012-06-20 16:38:30 -0700619eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
620{
621 eHalStatus status = eHAL_STATUS_SUCCESS;
622 tANI_U32 i;
623 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 do
625 {
626 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
627 {
628 pSession = CSR_GET_SESSION( pMac, i );
629 pSession->roamingTimerInfo.pMac = pMac;
630 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
631 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
633 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530634 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
635 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530637 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800639 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 break;
641 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530642 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
643 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
644 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800646 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 return eHAL_STATUS_FAILURE;
648 }
649 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 return (status);
651}
652
Jeff Johnson295189b2012-06-20 16:38:30 -0700653eHalStatus csrRoamClose(tpAniSirGlobal pMac)
654{
655 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
657 {
658 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
659 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530660 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
661 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
662 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
663 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 return (eHAL_STATUS_SUCCESS);
665}
666
Jeff Johnson295189b2012-06-20 16:38:30 -0700667eHalStatus csrRoamStart(tpAniSirGlobal pMac)
668{
669 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 return (eHAL_STATUS_SUCCESS);
671}
672
Jeff Johnson295189b2012-06-20 16:38:30 -0700673void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
674{
675 csrRoamStopRoamingTimer(pMac, sessionId);
676 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
677 csrRoamDeregStatisticsReq(pMac);
678}
Jeff Johnson295189b2012-06-20 16:38:30 -0700679eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
680{
681 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800682 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 {
684 status = eHAL_STATUS_SUCCESS;
685 *pState = pMac->roam.roamSession[sessionId].connectState;
686 }
687 return (status);
688}
689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
691{
692 eHalStatus status = eHAL_STATUS_FAILURE;
693 tANI_U32 size = 0;
694 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700695
696 if(!pSession)
697 {
698 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
699 return eHAL_STATUS_FAILURE;
700 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700701
702 if(pProfile)
703 {
704 if(pSession->pConnectBssDesc)
705 {
706 do
707 {
708 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
709 if(size)
710 {
711 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
712 if(HAL_STATUS_SUCCESS(status))
713 {
714 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
715 }
716 else
717 break;
718 }
719 else
720 {
721 pProfile->pBssDesc = NULL;
722 }
723 pProfile->AuthType = pSession->connectedProfile.AuthType;
724 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
725 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
726 pProfile->BSSType = pSession->connectedProfile.BSSType;
727 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
728 pProfile->CBMode = pSession->connectedProfile.CBMode;
729 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
730 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
731#ifdef WLAN_FEATURE_VOWIFI_11R
732 if (pSession->connectedProfile.MDID.mdiePresent)
733 {
734 pProfile->MDID.mdiePresent = 1;
735 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
736 }
737 else
738 {
739 pProfile->MDID.mdiePresent = 0;
740 pProfile->MDID.mobilityDomain = 0;
741 }
742#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700743#ifdef FEATURE_WLAN_CCX
744 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
746 {
747 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
748 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
749 pProfile->ccxCckmInfo.reassoc_req_num=
750 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
751 pProfile->ccxCckmInfo.krk_plumbed =
752 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
753 }
754#endif
755 }while(0);
756 }
757 }
758
759 return (status);
760}
761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
763{
764 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700765
766 if((csrIsConnStateConnected(pMac, sessionId)) ||
767 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700768 {
769 if(pProfile)
770 {
771 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
772 }
773 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 return (status);
775}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700776
Jeff Johnson295189b2012-06-20 16:38:30 -0700777eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
778{
779 eHalStatus status = eHAL_STATUS_SUCCESS;
780
781 if(pProfile->pBssDesc)
782 {
783 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
784 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700785 if(pProfile->pAddIEAssoc)
786 {
787 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
788 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
790 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
791 return (status);
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
795{
796 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if( pConnectedInfo->pbFrames )
798 {
799 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
800 pConnectedInfo->pbFrames = NULL;
801 }
802 pConnectedInfo->nBeaconLength = 0;
803 pConnectedInfo->nAssocReqLength = 0;
804 pConnectedInfo->nAssocRspLength = 0;
805 pConnectedInfo->staId = 0;
806#ifdef WLAN_FEATURE_VOWIFI_11R
807 pConnectedInfo->nRICRspLength = 0;
808#endif
809#ifdef FEATURE_WLAN_CCX
810 pConnectedInfo->nTspecIeLength = 0;
811#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 return ( status );
813}
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815
816
Jeff Johnsone7245742012-09-05 17:12:55 -0700817
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700818void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
819{
820 csrReinitPreauthCmd(pMac, pCommand);
821 csrReleaseCommand( pMac, pCommand );
822}
823
Jeff Johnson295189b2012-06-20 16:38:30 -0700824void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
825{
826 csrReinitRoamCmd(pMac, pCommand);
827 csrReleaseCommand( pMac, pCommand );
828}
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
831{
832 csrReinitScanCmd(pMac, pCommand);
833 csrReleaseCommand( pMac, pCommand );
834}
835
Jeff Johnson295189b2012-06-20 16:38:30 -0700836void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
837{
838 csrReinitWmStatusChangeCmd(pMac, pCommand);
839 csrReleaseCommand( pMac, pCommand );
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
843{
844 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
845}
846
Jeff Johnson295189b2012-06-20 16:38:30 -0700847void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
848{
849 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
850}
851
Jeff Johnson295189b2012-06-20 16:38:30 -0700852void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
853{
854 csrReinitSetKeyCmd(pMac, pCommand);
855 csrReleaseCommand( pMac, pCommand );
856}
Jeff Johnson295189b2012-06-20 16:38:30 -0700857void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
858{
859 csrReinitRemoveKeyCmd(pMac, pCommand);
860 csrReleaseCommand( pMac, pCommand );
861}
Jeff Johnson295189b2012-06-20 16:38:30 -0700862void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
863{
864
865 if( eSmeCsrCommandMask & pCommand->command )
866 {
867 switch (pCommand->command)
868 {
869 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800870 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800871 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700872 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 if (NULL != pCommand->u.scanCmd.callback)
874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800875 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
877 }
878 csrReleaseCommandScan( pMac, pCommand );
879 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 case eSmeCommandRoam:
881 csrReleaseCommandRoam( pMac, pCommand );
882 break;
883
884 case eSmeCommandWmStatusChange:
885 csrReleaseCommandWmStatusChange( pMac, pCommand );
886 break;
887
888 case eSmeCommandSetKey:
889 csrReleaseCommandSetKey( pMac, pCommand );
890 break;
891
892 case eSmeCommandRemoveKey:
893 csrReleaseCommandRemoveKey( pMac, pCommand );
894 break;
895
896 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800897 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 csrReleaseCommand( pMac, pCommand );
899 break;
900 }
901 }
902}
903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
905{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800906 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 if(pMac->roam.curSubState[sessionId] == NewSubstate)
909 {
910 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 pMac->roam.curSubState[sessionId] = NewSubstate;
913}
914
Jeff Johnson295189b2012-06-20 16:38:30 -0700915eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
916{
917 eCsrRoamState PreviousState;
918
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800919 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700920
921 PreviousState = pMac->roam.curState[sessionId];
922
923 if ( NewRoamState != pMac->roam.curState[sessionId] )
924 {
925 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
926 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
927 {
928 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
929 }
930
931 pMac->roam.curState[sessionId] = NewRoamState;
932 }
933 return( PreviousState );
934}
935
Jeff Johnson295189b2012-06-20 16:38:30 -0700936void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
937{
938 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 if(catOffset)
940 {
941 pMac->roam.configParam.bCatRssiOffset = catOffset;
942 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
943 {
944 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
945 }
946 }
947}
948
Jeff Johnson295189b2012-06-20 16:38:30 -0700949static void initConfigParam(tpAniSirGlobal pMac)
950{
951 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
953 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
954 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700955
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
957 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
958 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
959 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
960 pMac->roam.configParam.HeartbeatThresh24 = 40;
961 pMac->roam.configParam.HeartbeatThresh50 = 40;
962 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
963 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
964 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700965 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 pMac->roam.configParam.RTSThreshold = 2346;
967 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
968 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
969 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
970 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
971 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
972 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
973 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
974 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
975 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
976 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
977 {
978 pMac->roam.configParam.BssPreferValue[i] = i;
979 }
980 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
981 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
982 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
983 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
985 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
986 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
987 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
988 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
989 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800990 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
991 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700992 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700993#ifdef WLAN_AP_STA_CONCURRENCY
994 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
995 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
996 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
997 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
998 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700999 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1000 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001001#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1003 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1004 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1005 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001006#ifdef WLAN_FEATURE_VOWIFI_11R
1007 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1008#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001009#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1010 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1011 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1012 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1013 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1014 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1015 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1016 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1017 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1018 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1019 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1020 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001021 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001022#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001023#ifdef WLAN_FEATURE_11AC
1024 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1025#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001026
1027 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1028 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001029
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001030 //Remove this code once SLM_Sessionization is supported
1031 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001032 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001033
Jeff Johnsone7245742012-09-05 17:12:55 -07001034}
Jeff Johnson295189b2012-06-20 16:38:30 -07001035eCsrBand csrGetCurrentBand(tHalHandle hHal)
1036{
1037 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1038 return pMac->roam.configParam.bandCapability;
1039}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001040
1041#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001042/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001043 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001044*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001045eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001046{
1047 eHalStatus status = eHAL_STATUS_SUCCESS;
1048 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1049
1050 /* Free up the memory first (if required) */
1051 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1052 {
1053 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1054 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001055 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001056 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001057 return status;
1058}
1059
1060
1061
1062/*
1063 This function flushes the roam scan cache and creates fresh cache
1064 based on the input channel list
1065*/
1066eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1067 const tANI_U8 *pChannelList,
1068 const tANI_U8 numChannels)
1069{
1070 eHalStatus status = eHAL_STATUS_SUCCESS;
1071 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1072
Srinivas Girigowdade697412013-02-14 16:31:48 -08001073 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1074
1075 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1076 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1077
1078 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1079 {
1080 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1081 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1082 return eHAL_STATUS_RESOURCES;
1083 }
1084
1085 /* Update the roam global structure */
1086 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1087 pChannelList,
1088 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1089 return status;
1090}
1091
1092/* This function modifies the bgscan channel list set via config ini or
1093 runtime, whenever the band changes.
1094 if the band is auto, then no operation is performed on the channel list
1095 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1096 if the band is 5G, then make sure channel list contains only 5G valid channels
1097*/
1098eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1099 eCsrBand eBand)
1100{
1101 eHalStatus status = eHAL_STATUS_SUCCESS;
1102 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1103 tANI_U8 outNumChannels = 0;
1104 tANI_U8 inNumChannels = 0;
1105 tANI_U8 *inPtr = NULL;
1106 tANI_U8 i = 0;
1107 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1108
1109 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1110
1111 {
1112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1113 "No update required for channel list "
1114 "either cfg.ini channel list is not set up or "
1115 "auto band (Band %d)", eBand);
1116 return status;
1117 }
1118
1119 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1120 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1121 if (eCSR_BAND_24 == eBand)
1122 {
1123 for (i = 0; i < inNumChannels; i++)
1124 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001125 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001126 {
1127 ChannelList[outNumChannels++] = inPtr[i];
1128 }
1129 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001130 csrFlushBgScanRoamChannelList(pMac);
1131 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001132 }
1133 else if (eCSR_BAND_5G == eBand)
1134 {
1135 for (i = 0; i < inNumChannels; i++)
1136 {
1137 /* Add 5G Non-DFS channel */
1138 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001139 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001140 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1141 {
1142 ChannelList[outNumChannels++] = inPtr[i];
1143 }
1144 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001145 csrFlushBgScanRoamChannelList(pMac);
1146 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001147 }
1148 else if (eCSR_BAND_ALL == eBand)
1149 {
1150 for (i = 0; i < inNumChannels; i++)
1151 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001152 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001153 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1154 {
1155 ChannelList[outNumChannels++] = inPtr[i];
1156 }
1157 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001158 csrFlushBgScanRoamChannelList(pMac);
1159 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001160 }
1161 else
1162 {
1163 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1164 "Invalid band, No operation carried out (Band %d)", eBand);
1165 status = eHAL_STATUS_INVALID_PARAMETER;
1166 }
1167
1168 return status;
1169}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001170#endif
1171
Jeff Johnson295189b2012-06-20 16:38:30 -07001172eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1173{
1174 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1175 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1177 (eBand == eCSR_BAND_24))
1178 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001181 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001182 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 pMac->roam.configParam.uCfgDot11Mode, eBand);
1184 return eHAL_STATUS_INVALID_PARAMETER;
1185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1187 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1188 (eBand == eCSR_BAND_5G))
1189 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001190 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001192 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001193 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 pMac->roam.configParam.uCfgDot11Mode, eBand);
1195 return eHAL_STATUS_INVALID_PARAMETER;
1196 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001197 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001198 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001199 pMac->roam.configParam.eBand = eBand;
1200 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001202#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1203 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1204#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 status = csrInitGetChannels( pMac );
1206 if (eHAL_STATUS_SUCCESS == status)
1207 csrInitChannelList( hHal );
1208 return status;
1209}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001210
1211
Jeff Johnsone7245742012-09-05 17:12:55 -07001212/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1213 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1214 * Ideally we should have kept the ini value and enum value same and representing the same
1215 * cb values as in 11n standard i.e.
1216 * Set to 1 (SCA) if the secondary channel is above the primary channel
1217 * Set to 3 (SCB) if the secondary channel is below the primary channel
1218 * Set to 0 (SCN) if no secondary channel is present
1219 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1220 * 0 - secondary none
1221 * 1 - secondary LOW
1222 * 2 - secondary HIGH
1223 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1224 * The enum values are as follows:
1225 * PHY_SINGLE_CHANNEL_CENTERED = 0
1226 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1227 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1228 */
1229ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1230{
1231
1232 ePhyChanBondState phyCbState;
1233 switch (cbIniValue) {
1234 // secondary none
1235 case 0:
1236 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1237 break;
1238 // secondary LOW
1239 case 1:
1240 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1241 break;
1242 // secondary HIGH
1243 case 2:
1244 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1245 break;
1246#ifdef WLAN_FEATURE_11AC
1247 case 3:
1248 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1249 break;
1250 case 4:
1251 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1252 break;
1253 case 5:
1254 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1255 break;
1256 case 6:
1257 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1258 break;
1259 case 7:
1260 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1261 break;
1262 case 8:
1263 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1264 break;
1265 case 9:
1266 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1267 break;
1268#endif
1269 default:
1270 // If an invalid value is passed, disable CHANNEL BONDING
1271 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1272 break;
1273 }
1274 return phyCbState;
1275}
1276
1277v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1278{
1279
1280 v_U32_t cbIniValue;
1281 switch (phyCbState) {
1282 // secondary none
1283 case PHY_SINGLE_CHANNEL_CENTERED:
1284 cbIniValue = 0;
1285 break;
1286 // secondary LOW
1287 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1288 cbIniValue = 1;
1289 break;
1290 // secondary HIGH
1291 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1292 cbIniValue = 2;
1293 break;
1294#ifdef WLAN_FEATURE_11AC
1295 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1296 cbIniValue = 3;
1297 break;
1298 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1299 cbIniValue = 4;
1300 break;
1301 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1302 cbIniValue = 5;
1303 break;
1304 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1305 cbIniValue = 6;
1306 break;
1307 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1308 cbIniValue = 7;
1309 break;
1310 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1311 cbIniValue = 8;
1312 break;
1313 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1314 cbIniValue = 9;
1315 break;
1316#endif
1317 default:
1318 // return some invalid value
1319 cbIniValue = 10;
1320 break;
1321 }
1322 return cbIniValue;
1323}
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
1325eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1326{
1327 eHalStatus status = eHAL_STATUS_SUCCESS;
1328
1329 if(pParam)
1330 {
1331 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1332 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1333 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1334 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1335 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1336 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1337
1338 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001339 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1340
Jeff Johnsone7245742012-09-05 17:12:55 -07001341 /* channelBondingMode5GHz plays a dual role right now
1342 * 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
1343 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1344 */
1345 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001347 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001348 }
1349 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1350 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1351 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001352 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001353 }
1354 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1356 pMac->roam.configParam.phyMode = pParam->phyMode;
1357 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1358 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1359 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1360 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1361 pMac->roam.configParam.TxRate = pParam->TxRate;
1362 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1363 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1364 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1365 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1366 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001367 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 //if HDD passed down non zero values then only update,
1369 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001370 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 {
1372 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1373 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001374 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 {
1376 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1377 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001378 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 {
1380 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1381 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001382 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 {
1384 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1385 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001386 if (pParam->nActiveMaxChnTimeBtc)
1387 {
1388 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1389 }
1390 if (pParam->nActiveMinChnTimeBtc)
1391 {
1392 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1393 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001394#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001395 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001396 {
1397 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1398 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001399 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001400 {
1401 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1402 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001403 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001404 {
1405 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1406 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001407 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001408 {
1409 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1410 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001411 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001412 {
1413 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1414 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001415 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001416 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001417 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1418 }
1419 if (pParam->nNumP2PChanCombinedConc)
1420 {
1421 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001422 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001423#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001425 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 {
1427 //Change the unit from second to microsecond
1428 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1430 {
1431 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1432 }
1433 else
1434 {
1435 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1436 }
1437 }
1438 else
1439 {
1440 pMac->roam.configParam.impsSleepTime = 0;
1441 }
1442 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1444 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001445 //if HDD passed down non zero values for age params, then only update,
1446 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001447 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 {
1449 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 if(pParam->scanAgeTimeNCNPS)
1452 {
1453 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 if(pParam->scanAgeTimeNCPS)
1456 {
1457 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 if(pParam->scanAgeTimeCNPS)
1460 {
1461 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1462 }
1463 if(pParam->scanAgeTimeCPS)
1464 {
1465 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1466 }
1467
1468 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1469 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1470 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1471 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1472 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1473 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1475 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1477 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1478 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1479 //Assign this before calling CsrInit11dInfo
1480 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 if( csrIs11dSupported( pMac ) )
1482 {
1483 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1484 }
1485 else
1486 {
1487 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1488 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001489
1490 /* Initialize the power + channel information if 11h is enabled.
1491 If 11d is enabled this information has already been initialized */
1492 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1493 {
1494 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1495 }
1496
1497
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301498#ifdef WLAN_FEATURE_VOWIFI_11R
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001500 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001501#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001502#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001504 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001505 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001506 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001507 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001508 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001509 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001510 pMac->roam.configParam.nProbes = pParam->nProbes;
1511 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001512#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001513#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1514 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001515 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001516#endif
1517#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001518 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1519#endif
1520
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301521#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1523#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001524#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1525 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001526 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1527 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1528 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1529 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1530 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1531 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1532 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1533 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 {
1535 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001536 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 -07001537 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1538 {
1539 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1540 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001541 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 }
1543#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1545 pMac->scan.fValidateList = pParam->fValidateList;
1546 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1547 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001548 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001550 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1551 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1552 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1553 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1554 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1555 * single session
1556 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001557 //Remove this code once SLM_Sessionization is supported
1558 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001559 pMac->roam.configParam.doBMPSWorkaround = 0;
1560
Jeff Johnsone7245742012-09-05 17:12:55 -07001561#ifdef WLAN_FEATURE_11AC
1562 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001563 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001564 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001565 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001566#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001567 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni4f087d22013-07-29 16:32:26 -07001568 pMac->roam.configParam.enableOxygenNwk = pParam->enableOxygenNwk;
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 }
1570
1571 return status;
1572}
1573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1575{
1576 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 if(pParam)
1578 {
1579 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1580 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1581 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1582 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1583 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1584 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001585 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1586 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1588 pParam->phyMode = pMac->roam.configParam.phyMode;
1589 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1590 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1591 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1592 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1593 pParam->TxRate = pMac->roam.configParam.TxRate;
1594 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1595 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1596 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1597 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1598 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1600 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1601 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1602 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001603 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1604 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1605 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001606#ifdef WLAN_AP_STA_CONCURRENCY
1607 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1608 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1609 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1610 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1611 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001612 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1613 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001614#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 //Change the unit from microsecond to second
1616 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1617 pParam->eBand = pMac->roam.configParam.eBand;
1618 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1619 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1620 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1621 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1622 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1623 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1624 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1625 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1626 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1627 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1628 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1629 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1630 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1632 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1633 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1634 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1636 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1637 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1638 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1639 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001640 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001641 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001642 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001643 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001644
1645#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1646 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1647#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001648#ifdef WLAN_FEATURE_11AC
1649 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001650 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001651 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001652#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001653#ifdef WLAN_FEATURE_VOWIFI_11R
1654 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1655#endif
1656#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1657 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1658 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1659 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1660 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1661 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001662 pParam->nProbes = pMac->roam.configParam.nProbes;
1663 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001664#endif
1665#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1666 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1667 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1668#endif
1669#ifdef FEATURE_WLAN_LFR
1670 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1671#endif
1672
1673#ifdef FEATURE_WLAN_CCX
1674 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1675#endif
1676#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1677 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1678 {
1679 int i;
1680 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1681 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1682 {
1683 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1684 }
1685 smsLog( pMac, LOG1, "");
1686 }
1687#endif
1688
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001689 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001690 pParam->enableOxygenNwk = pMac->roam.configParam.enableOxygenNwk;
1691
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 csrSetChannels(pMac, pParam);
1693
1694 status = eHAL_STATUS_SUCCESS;
1695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 return (status);
1697}
1698
Jeff Johnson295189b2012-06-20 16:38:30 -07001699eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1700{
1701 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1702 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1703 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1704 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 do
1706 {
1707 if(eCSR_BAND_24 == eBand)
1708 {
1709 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1710 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1711 }
1712 if(eCSR_BAND_5G == eBand)
1713 {
1714 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1715 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1716 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1717 )
1718 {
1719 break;
1720 }
1721 }
1722 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1723 {
1724 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1725 }
1726 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1727 {
1728 newPhyMode = eCSR_DOT11_MODE_AUTO;
1729 }
1730 else
1731 {
1732 //Check for dual band and higher capability first
1733 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1734 {
1735 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1736 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1737 }
1738 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1739 {
1740 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1741 if(eCSR_BAND_24 == eBand) break;
1742 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1743 eBand = eCSR_BAND_5G;
1744 }
1745 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1746 {
1747 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1748 if(eCSR_BAND_5G == eBand) break;
1749 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1750 eBand = eCSR_BAND_24;
1751 }
1752 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1753 {
1754 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1755 if(eCSR_BAND_5G == eBand) break;
1756 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1757 eBand = eCSR_BAND_24;
1758 }
1759 else if(eCSR_DOT11_MODE_11n & phyMode)
1760 {
1761 newPhyMode = eCSR_DOT11_MODE_11n;
1762 }
1763 else if(eCSR_DOT11_MODE_abg & phyMode)
1764 {
1765 newPhyMode = eCSR_DOT11_MODE_abg;
1766 }
1767 else if(eCSR_DOT11_MODE_11a & phyMode)
1768 {
1769 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1770 {
1771 if(eCSR_BAND_ALL == eBand)
1772 {
1773 newPhyMode = eCSR_DOT11_MODE_abg;
1774 }
1775 else
1776 {
1777 //bad setting
1778 break;
1779 }
1780 }
1781 else
1782 {
1783 newPhyMode = eCSR_DOT11_MODE_11a;
1784 eBand = eCSR_BAND_5G;
1785 }
1786 }
1787 else if(eCSR_DOT11_MODE_11g & phyMode)
1788 {
1789 newPhyMode = eCSR_DOT11_MODE_11g;
1790 eBand = eCSR_BAND_24;
1791 }
1792 else if(eCSR_DOT11_MODE_11b & phyMode)
1793 {
1794 newPhyMode = eCSR_DOT11_MODE_11b;
1795 eBand = eCSR_BAND_24;
1796 }
1797 else
1798 {
1799 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001800 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 newPhyMode = eCSR_DOT11_MODE_AUTO;
1802 }
1803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 //Done validating
1805 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 //Now we need to check whether a restart is needed.
1807 if(eBand != pMac->roam.configParam.eBand)
1808 {
1809 fRestartNeeded = eANI_BOOLEAN_TRUE;
1810 break;
1811 }
1812 if(newPhyMode != pMac->roam.configParam.phyMode)
1813 {
1814 fRestartNeeded = eANI_BOOLEAN_TRUE;
1815 break;
1816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 if(HAL_STATUS_SUCCESS(status))
1819 {
1820 pMac->roam.configParam.eBand = eBand;
1821 pMac->roam.configParam.phyMode = newPhyMode;
1822 if(pfRestartNeeded)
1823 {
1824 *pfRestartNeeded = fRestartNeeded;
1825 }
1826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 return (status);
1828}
1829
Jeff Johnson295189b2012-06-20 16:38:30 -07001830void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1831{
1832 tANI_U8 Index;
1833 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 // for dual band NICs, don't need to trim the channel list....
1835 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1836 {
1837 // 2.4 GHz band operation requires the channel list to be trimmed to
1838 // the 2.4 GHz channels only...
1839 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1840 {
1841 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1842 Index++ )
1843 {
1844 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1845 {
1846 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1847 cChannels++;
1848 }
1849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1851 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1852 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1853 // only if we need to.
1854 //
1855 // The amount of memory to clear is the number of channesl that we trimmed
1856 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1857
1858 if ( pChannelList->numChannels > cChannels )
1859 {
1860 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1861 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1862
1863 }
1864
1865 pChannelList->numChannels = cChannels;
1866 }
1867 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1868 {
1869 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1870 {
1871 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1872 {
1873 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1874 cChannels++;
1875 }
1876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1878 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1879 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1880 // only if we need to.
1881 //
1882 // The amount of memory to clear is the number of channesl that we trimmed
1883 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1884 if ( pChannelList->numChannels > cChannels )
1885 {
1886 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1887 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1888 }
1889
1890 pChannelList->numChannels = cChannels;
1891 }
1892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001893}
Jeff Johnson295189b2012-06-20 16:38:30 -07001894#define INFRA_AP_DEFAULT_CHANNEL 6
1895eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1896{
1897 tANI_U8 index= 0;
1898 eHalStatus status = eHAL_STATUS_FAILURE;
1899 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1900 {
1901 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1902 status = eHAL_STATUS_SUCCESS;
1903 break;
1904 }
1905 }
1906 return status;
1907}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001908
1909eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1910{
1911 eHalStatus status = eHAL_STATUS_SUCCESS;
1912 tANI_U8 num20MHzChannelsFound = 0;
1913 VOS_STATUS vosStatus;
1914 tANI_U8 num40MHzChannelsFound = 0;
1915 tANI_U8 Index = 0;
1916 tANI_U8 channelList = 0;
1917
1918 // Updating the defaultpower Table for changed Domain Id
1919 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1920 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1921
1922 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1923 {
1924 smsLog( pMac, LOGE, FL("failed to get channels"));
1925 status = eHAL_STATUS_FAILURE;
1926 }
1927 else
1928 {
1929 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1930 {
1931 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1932 }
1933
1934 // Move the only 5GHZ channel list to the global data,
1935 // As 2.4GHZ list coming from the AP for the changed domain
1936 // structure -- this will be used as the scan list
1937 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1938 {
1939 // If Channel is 5GHz just break the for loop
1940 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1941 break;
1942 }
1943 // Update the 5G channels from nv.bin
1944 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1945 {
1946 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1947 {
Krunal Sonia75019a2013-05-01 01:08:22 -07001948 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1949 {
1950 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1951 channelList++;
1952 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001953 }
1954 }
1955
1956 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1957 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1958 // Filling the remaining index as Zero Just for causion
1959 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1960 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1961 }
1962 return status;
1963}
1964
1965eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1966{
1967 eHalStatus status = eHAL_STATUS_SUCCESS;
1968 tANI_U8 num20MHzChannelsFound = 0;
1969 VOS_STATUS vosStatus;
1970 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05301971 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001972 tANI_U8 num40MHzChannelsFound = 0;
1973 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1974 tANI_U8 channelList = 0;
1975
1976 // Read the scan channel list (including the power limit) from EEPROM
1977 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1978 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1979
1980 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1981 {
1982 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1983 status = eHAL_STATUS_FAILURE;
1984 }
1985 else
1986 {
1987 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1988 {
1989 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1990 }
1991
1992 // Move the 2.4GHZ channel list only to the global data,
1993 // As 5GHz list been provided by AP as part of 11d IE
1994 // structure -- this will be used as the scan list
1995 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1996 {
1997 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1998 {
1999 // First taking the 5GHz channel list backup
2000 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2001 nuum5GchannelListBackup++;
2002 }
2003 }
2004 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302005 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002006 {
2007 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302008 {
2009 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2010 numChan++;
2011 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002012 }
2013 // Restoring the Backed up 5 GHZ channels
2014 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2015 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302016 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002017 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302018 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2019 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002020 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002021 }
2022
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302023 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2024 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002025 }
2026 return (status);
2027}
2028
Jeff Johnson295189b2012-06-20 16:38:30 -07002029eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2030{
2031 eHalStatus status = eHAL_STATUS_SUCCESS;
2032 tANI_U8 num20MHzChannelsFound = 0;
2033 VOS_STATUS vosStatus;
2034 tANI_U8 Index = 0;
2035 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002036
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 //TODO: this interface changed to include the 40MHz channel list
2039 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2040 // Read the scan channel list (including the power limit) from EEPROM
2041 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2042 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2043 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2044 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002045 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 status = eHAL_STATUS_FAILURE;
2047 }
2048 else
2049 {
2050 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2051 {
2052 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2053 }
2054 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2055 // Move the channel list to the global data
2056 // structure -- this will be used as the scan list
2057 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2058 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 }
2061 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2062 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2063 {
2064 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2065 }
2066 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2067 {
2068 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2069 }
2070 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 return (status);
2073}
2074
Jeff Johnson295189b2012-06-20 16:38:30 -07002075eHalStatus csrInitChannelList( tHalHandle hHal )
2076{
2077 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2078 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2080 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002081 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2082 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002084 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002085
2086 return (status);
2087}
Jeff Johnson295189b2012-06-20 16:38:30 -07002088eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2089 tCsrUpdateConfigParam *pUpdateConfigParam)
2090{
2091 eHalStatus status = eHAL_STATUS_FAILURE;
2092 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2094 status = CsrInit11dInfo(pMac, ps11dinfo);
2095 return status;
2096}
2097
Jeff Johnson295189b2012-06-20 16:38:30 -07002098static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2099{
2100 eHalStatus status = eHAL_STATUS_FAILURE;
2101 tANI_U8 index;
2102 tANI_U32 count=0;
2103 tSirMacChanInfo *pChanInfo;
2104 tSirMacChanInfo *pChanInfoStart;
2105 tANI_BOOLEAN applyConfig = TRUE;
2106
2107 if(!ps11dinfo)
2108 {
2109 return (status);
2110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2112 {
2113 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2114 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2115 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2116 if(!HAL_STATUS_SUCCESS(status)) return (status);
2117 }
2118 else
2119 {
2120 //No change
2121 return (eHAL_STATUS_SUCCESS);
2122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 //legacy maintenance
2124 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2125 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2126 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 //Tush: at csropen get this initialized with default, during csr reset if this
2128 // already set with some value no need initilaize with default again
2129 if(0 == pMac->scan.countryCodeCurrent[0])
2130 {
2131 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2132 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2133 if(!HAL_STATUS_SUCCESS(status)) return (status);
2134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 // need to add the max power channel list
2136 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2137 {
2138 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2139 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002140 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2141 {
2142 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2143 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2144 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2145 pChanInfo++;
2146 count++;
2147 }
2148 if(count)
2149 {
2150 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2151 }
2152 palFreeMemory(pMac->hHdd, pChanInfoStart);
2153 }
2154 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2155 if( HAL_STATUS_SUCCESS(status) )
2156 {
2157 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2158 {
2159 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2160 {
2161 applyConfig = FALSE;
2162 }
2163 }
2164
2165 if(TRUE == applyConfig)
2166 {
2167 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002168 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002169 }
2170
2171 }
2172 return (status);
2173}
2174/* Initialize the Channel + Power List in the local cache and in the CFG */
2175eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2176{
2177 tANI_U8 index;
2178 tANI_U32 count=0;
2179 tSirMacChanInfo *pChanInfo;
2180 tSirMacChanInfo *pChanInfoStart;
2181
2182 if(!ps11dinfo || !pMac)
2183 {
2184 return eHAL_STATUS_FAILURE;
2185 }
2186
2187 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2188 {
2189 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2190 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002191
2192 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2193 {
2194 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2195 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2196 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2197 pChanInfo++;
2198 count++;
2199 }
2200 if(count)
2201 {
2202 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2203 }
2204 palFreeMemory(pMac->hHdd, pChanInfoStart);
2205 }
2206
Jeff Johnsone7245742012-09-05 17:12:55 -07002207 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002208}
2209
2210//pCommand may be NULL
2211//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2212void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2213{
2214 tListElem *pEntry, *pNextEntry;
2215 tSmeCmd *pDupCommand;
2216 tDblLinkList localList;
2217
2218 vos_mem_zero(&localList, sizeof(tDblLinkList));
2219 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2220 {
2221 smsLog(pMac, LOGE, FL(" failed to open list"));
2222 return;
2223 }
2224 csrLLLock( &pMac->sme.smeCmdPendingList );
2225 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2226 while( pEntry )
2227 {
2228 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2229 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 // Remove the previous command if..
2231 // - the new roam command is for the same RoamReason...
2232 // - the new roam command is a NewProfileList.
2233 // - the new roam command is a Forced Dissoc
2234 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2235 if (
2236 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2237 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002238 /* This peermac check is requried for Softap/GO scenarios
2239 * For STA scenario below OR check will suffice as pCommand will
2240 * always be NULL for STA scenarios
2241 */
2242 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2244 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2245 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2246 ||
2247 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002248 ( (sessionId == pDupCommand->sessionId) &&
2249 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 ((eCsrForcedDisassoc == eRoamReason) ||
2251 (eCsrHddIssued == eRoamReason))
2252 )
2253 )
2254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002255 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 // Remove the 'stale' roam command from the pending list...
2257 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2258 {
2259 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2260 }
2261 }
2262 pEntry = pNextEntry;
2263 }
2264 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2265
2266 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2267 {
2268 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2269 //Tell caller that the command is cancelled
2270 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2271 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2272 csrReleaseCommandRoam(pMac, pDupCommand);
2273 }
2274 csrLLClose(&localList);
2275}
Jeff Johnson295189b2012-06-20 16:38:30 -07002276eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2277 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2278{
2279 eHalStatus status = eHAL_STATUS_SUCCESS;
2280#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2281 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2282#endif
2283 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2285 {
2286 pSession = CSR_GET_SESSION( pMac, sessionId );
2287 }
2288 else
2289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002290 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 VOS_ASSERT(0);
2292 return eHAL_STATUS_FAILURE;
2293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002296 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002298 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2299 /*
2300 * Decrement bRefAssocStartCnt for FT reassoc failure.
2301 * Reason: For FT reassoc failures, we first call
2302 * csrRoamCallCallback before notifying a failed roam
2303 * completion through csrRoamComplete. The latter in
2304 * turn calls csrRoamProcessResults which tries to
2305 * once again call csrRoamCallCallback if bRefAssocStartCnt
2306 * is non-zero. Since this is redundant for FT reassoc
2307 * failure, decrement bRefAssocStartCnt.
2308 */
2309 pSession->bRefAssocStartCnt--;
2310 }
2311
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 if ( (pSession == NULL) ||
2313 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002315 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 return eHAL_STATUS_FAILURE;
2317 }
2318
2319 if(NULL != pSession->callback)
2320 {
2321 if( pRoamInfo )
2322 {
2323 pRoamInfo->sessionId = (tANI_U8)sessionId;
2324 }
2325
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302326 /* avoid holding the global lock when making the roaming callback, original change came
2327 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2328 is possible on other OS ports where the callback may need to take locks to protect
2329 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2331 that may actually depend on the lock being held */
2332 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2333 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2334 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2335 }
2336 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2337 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2338#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2339 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2340 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2341 {
2342 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2343 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2344 if(NULL != pRoamInfo->pBssDesc)
2345 {
2346 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2347 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2350 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2351 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2352 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2353 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2354 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2357 {
2358 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2359 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2360 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 if(eCSR_ROAM_RESULT_FORCED == u2)
2363 {
2364 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2365 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2366 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2369 {
2370 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2371 connectionStatus.reason = eCSR_REASON_DISASSOC;
2372 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2375 {
2376 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2377 connectionStatus.reason = eCSR_REASON_DEAUTH;
2378 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002380#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2381
2382 return (status);
2383}
Jeff Johnson295189b2012-06-20 16:38:30 -07002384// Returns whether handoff is currently in progress or not
2385tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2386{
2387#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2388 return csrNeighborRoamIsHandoffInProgress(pMac);
2389#else
2390 return eANI_BOOLEAN_FALSE;
2391#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002392}
Jeff Johnson295189b2012-06-20 16:38:30 -07002393eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2394 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2395{
2396 eHalStatus status = eHAL_STATUS_SUCCESS;
2397 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2398 tANI_U16 reasonCode;
2399 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002400
2401 if(!pSession)
2402 {
2403 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2404 return eHAL_STATUS_FAILURE;
2405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002406
2407 //Restore AC weight in case we change it
2408 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2409 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002410 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 -07002411 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2412 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2413 }
2414
2415 if ( fMICFailure )
2416 {
2417 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2418 }
2419 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2420 {
2421 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002422 }
2423 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 {
2425 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427#ifdef WLAN_FEATURE_VOWIFI_11R
2428 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2429 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2430 {
2431 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2432 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002433 }
2434 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002435#endif
2436 if(pSession->pConnectBssDesc)
2437 {
2438 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2439 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002440
Jeff Johnson295189b2012-06-20 16:38:30 -07002441
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002442 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2443 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2444 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2445
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2447
2448 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2449
2450 if(HAL_STATUS_SUCCESS(status))
2451 {
2452 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002453#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2454 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2455 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2456 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002457 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2459 }
2460#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002461 }
2462 else
2463 {
2464 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2465 }
2466
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 return (status);
2468}
Jeff Johnson295189b2012-06-20 16:38:30 -07002469
Jeff Johnson295189b2012-06-20 16:38:30 -07002470/* ---------------------------------------------------------------------------
2471 \fn csrRoamIssueDisassociateStaCmd
2472 \brief csr function that HDD calls to disassociate a associated station
2473 \param sessionId - session Id for Soft AP
2474 \param pPeerMacAddr - MAC of associated station to delete
2475 \param reason - reason code, be one of the tSirMacReasonCodes
2476 \return eHalStatus
2477 ---------------------------------------------------------------------------*/
2478eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2479 tANI_U32 sessionId,
2480 tANI_U8 *pPeerMacAddr,
2481 tANI_U32 reason)
2482{
2483 eHalStatus status = eHAL_STATUS_SUCCESS;
2484 tSmeCmd *pCommand;
2485
2486 do
2487 {
2488 pCommand = csrGetCommandBuffer( pMac );
2489 if ( !pCommand )
2490 {
2491 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2492 status = eHAL_STATUS_RESOURCES;
2493 break;
2494 }
2495 pCommand->command = eSmeCommandRoam;
2496 pCommand->sessionId = (tANI_U8)sessionId;
2497 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2498 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2499 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2500 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2501 if( !HAL_STATUS_SUCCESS( status ) )
2502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002503 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 csrReleaseCommandRoam( pMac, pCommand );
2505 }
2506 }while(0);
2507
2508 return status;
2509}
2510
2511
Jeff Johnson295189b2012-06-20 16:38:30 -07002512/* ---------------------------------------------------------------------------
2513 \fn csrRoamIssueDeauthSta
2514 \brief csr function that HDD calls to delete a associated station
2515 \param sessionId - session Id for Soft AP
2516 \param pPeerMacAddr - MAC of associated station to delete
2517 \param reason - reason code, be one of the tSirMacReasonCodes
2518 \return eHalStatus
2519 ---------------------------------------------------------------------------*/
2520eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2521 tANI_U32 sessionId,
2522 tANI_U8 *pPeerMacAddr,
2523 tANI_U32 reason)
2524{
2525 eHalStatus status = eHAL_STATUS_SUCCESS;
2526 tSmeCmd *pCommand;
2527
2528 do
2529 {
2530 pCommand = csrGetCommandBuffer( pMac );
2531 if ( !pCommand )
2532 {
2533 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2534 status = eHAL_STATUS_RESOURCES;
2535 break;
2536 }
2537 pCommand->command = eSmeCommandRoam;
2538 pCommand->sessionId = (tANI_U8)sessionId;
2539 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2540 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2541 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2542 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2543 if( !HAL_STATUS_SUCCESS( status ) )
2544 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002545 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 csrReleaseCommandRoam( pMac, pCommand );
2547 }
2548 }while(0);
2549
2550 return status;
2551}
Jeff Johnson295189b2012-06-20 16:38:30 -07002552eHalStatus
2553csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2554 tANI_BOOLEAN bEnable )
2555{
2556 eHalStatus status = eHAL_STATUS_FAILURE;
2557 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2558 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 if (!pSession)
2560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002561 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 return (status);
2563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 if (pSession->pConnectBssDesc)
2565 {
2566 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2567 }
2568 else
2569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002570 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 return (status);
2572 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002573 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 -07002574 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302575 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2577 return (status);
2578}
Jeff Johnson295189b2012-06-20 16:38:30 -07002579eHalStatus
2580csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2581 VOS_MODULE_ID modId, void *pUsrContext,
2582 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2583{
2584 eHalStatus status = eHAL_STATUS_SUCCESS;
2585 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2586 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 if (!pSession)
2588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002589 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 return (status);
2591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 if(pSession->pConnectBssDesc)
2593 {
2594 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2595 }
2596 else
2597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002598 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 return (status);
2600 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002601 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2603 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2605 return (status);
2606}
Jeff Johnson295189b2012-06-20 16:38:30 -07002607eHalStatus
2608csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2609 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2610{
2611 eHalStatus status = eHAL_STATUS_SUCCESS;
2612 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2613 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2614
2615 if (!pSession)
2616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002617 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 return (status);
2619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 if(pSession->pConnectBssDesc)
2621 {
2622 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2623 }
2624 else
2625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002626 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 return (status);
2628 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002629 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2631 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2632
2633 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2634
2635 return (status);
2636}
Jeff Johnson295189b2012-06-20 16:38:30 -07002637eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2638{
2639 eHalStatus status = eHAL_STATUS_SUCCESS;
2640 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2641 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002642
2643 if (!pSession)
2644 {
2645 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2646 return eHAL_STATUS_FAILURE;
2647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002648
2649 if(pSession->pConnectBssDesc)
2650 {
2651 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2652 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002653 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2655 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2657
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302658 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002659 if(!HAL_STATUS_SUCCESS(status))
2660 {
2661 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2662 }
2663
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 return (status);
2665}
2666
Jeff Johnson295189b2012-06-20 16:38:30 -07002667eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2668{
2669 eHalStatus status = eHAL_STATUS_SUCCESS;
2670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2671 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002672
2673 if(!pSession)
2674 {
2675 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2676 return eHAL_STATUS_FAILURE;
2677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002678
2679 // If no BSS description was found in this connection (happens with start IBSS), then
2680 // nix the BSS description that we keep around for the connected BSS) and get out...
2681 if(NULL == pBssDesc)
2682 {
2683 csrFreeConnectBssDesc(pMac, sessionId);
2684 }
2685 else
2686 {
2687 size = pBssDesc->length + sizeof( pBssDesc->length );
2688 if(NULL != pSession->pConnectBssDesc)
2689 {
2690 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2691 {
2692 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2693 csrFreeConnectBssDesc(pMac, sessionId);
2694 }
2695 }
2696 if(NULL == pSession->pConnectBssDesc)
2697 {
2698 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2699 }
2700 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2701 {
2702 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2703 }
2704 }
2705
2706 return (status);
2707}
2708
Jeff Johnson295189b2012-06-20 16:38:30 -07002709eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2710 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2711 tDot11fBeaconIEs *pIes)
2712{
2713 eHalStatus status = eHAL_STATUS_SUCCESS;
2714 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302716 if (pIes == NULL)
2717 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002718
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 do
2720 {
2721 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2722 //get qos
2723 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2724 //get SSID
2725 if(pIes->SSID.present)
2726 {
2727 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2728 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2729 }
2730 else
2731 pBssConfig->SSID.length = 0;
2732 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002734 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 //Return failed if profile doesn't have an SSID either.
2736 if(pProfile->SSIDs.numOfSSIDs == 0)
2737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002738 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 status = eHAL_STATUS_FAILURE;
2740 break;
2741 }
2742 }
2743 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2744 {
2745 pBssConfig->eBand = eCSR_BAND_5G;
2746 }
2747 else
2748 {
2749 pBssConfig->eBand = eCSR_BAND_24;
2750 }
2751 //phymode
2752 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2753 {
2754 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2755 }
2756 else
2757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002758 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 //force it
2760 if(eCSR_BAND_24 == pBssConfig->eBand)
2761 {
2762 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2763 }
2764 else
2765 {
2766 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2767 }
2768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 //Qos
2770 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2771 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2772 {
2773 //Joining BSS is not 11n capable and WMM is disabled on client.
2774 //Disable QoS and WMM
2775 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2776 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302777
2778 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302779 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302780 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2781 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2782 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2783 {
2784 //Joining BSS is 11n capable and WMM is disabled on AP.
2785 //Assume all HT AP's are QOS AP's and enable WMM
2786 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2787 }
2788
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 //auth type
2790 switch( pProfile->negotiatedAuthType )
2791 {
2792 default:
2793 case eCSR_AUTH_TYPE_WPA:
2794 case eCSR_AUTH_TYPE_WPA_PSK:
2795 case eCSR_AUTH_TYPE_WPA_NONE:
2796 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2797 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2798 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 case eCSR_AUTH_TYPE_SHARED_KEY:
2800 pBssConfig->authType = eSIR_SHARED_KEY;
2801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 case eCSR_AUTH_TYPE_AUTOSWITCH:
2803 pBssConfig->authType = eSIR_AUTO_SWITCH;
2804 break;
2805 }
2806 //short slot time
2807 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2808 {
2809 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2810 }
2811 else
2812 {
2813 pBssConfig->uShortSlotTime = 0;
2814 }
2815 if(pBssConfig->BssCap.ibss)
2816 {
2817 //We don't support 11h on IBSS
2818 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2819 }
2820 else
2821 {
2822 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2823 }
2824 //power constraint
2825 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2826 //heartbeat
2827 if ( CSR_IS_11A_BSS( pBssDesc ) )
2828 {
2829 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2830 }
2831 else
2832 {
2833 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2834 }
2835 //Join timeout
2836 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002837 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 if ( pBssDesc->beaconInterval )
2839 {
2840 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002841 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 }
2843 else
2844 {
2845 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2846 }
2847 //validate CB
2848 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2849 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 return (status);
2851}
2852
Jeff Johnson295189b2012-06-20 16:38:30 -07002853static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2854 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2855{
2856 eHalStatus status = eHAL_STATUS_SUCCESS;
2857 tANI_U8 operationChannel = 0;
2858 tANI_U8 qAPisEnabled = FALSE;
2859 //SSID
2860 pBssConfig->SSID.length = 0;
2861 if(pProfile->SSIDs.numOfSSIDs)
2862 {
2863 //only use the first one
2864 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2865 }
2866 else
2867 {
2868 //SSID must present
2869 return eHAL_STATUS_FAILURE;
2870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 //Settomg up the capabilities
2872 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2873 {
2874 pBssConfig->BssCap.ibss = 1;
2875 }
2876 else
2877 {
2878 pBssConfig->BssCap.ess = 1;
2879 }
2880 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2881 {
2882 pBssConfig->BssCap.privacy = 1;
2883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 pBssConfig->eBand = pMac->roam.configParam.eBand;
2885 //phymode
2886 if(pProfile->ChannelInfo.ChannelList)
2887 {
2888 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2891 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 //QOS
2893 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 if ( pBssConfig->BssCap.ess == 1 )
2895 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 /*For Softap case enable WMM*/
2897 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2898 qAPisEnabled = TRUE;
2899 }
2900 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2902 qAPisEnabled = TRUE;
2903 } else {
2904 qAPisEnabled = FALSE;
2905 }
2906 } else {
2907 qAPisEnabled = TRUE;
2908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2910 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2911 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2912 )
2913 {
2914 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2915 } else {
2916 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2917 }
2918
2919 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002920 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 {
2922 default:
2923 case eCSR_AUTH_TYPE_WPA:
2924 case eCSR_AUTH_TYPE_WPA_PSK:
2925 case eCSR_AUTH_TYPE_WPA_NONE:
2926 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2927 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2928 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 case eCSR_AUTH_TYPE_SHARED_KEY:
2930 pBssConfig->authType = eSIR_SHARED_KEY;
2931 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 case eCSR_AUTH_TYPE_AUTOSWITCH:
2933 pBssConfig->authType = eSIR_AUTO_SWITCH;
2934 break;
2935 }
2936 //short slot time
2937 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2938 {
2939 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2940 }
2941 else
2942 {
2943 pBssConfig->uShortSlotTime = 0;
2944 }
2945 //power constraint. We don't support 11h on IBSS
2946 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2947 pBssConfig->uPowerLimit = 0;
2948 //heartbeat
2949 if ( eCSR_BAND_5G == pBssConfig->eBand )
2950 {
2951 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2952 }
2953 else
2954 {
2955 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2956 }
2957 //Join timeout
2958 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002959
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 return (status);
2961}
Jeff Johnson295189b2012-06-20 16:38:30 -07002962static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2963{
2964 eHalStatus status = eHAL_STATUS_FAILURE;
2965 tDot11fBeaconIEs *pIes = NULL;
2966
2967 do
2968 {
2969 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2970 {
2971 //err msg
2972 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002973 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 break;
2975 }
2976 //check if the AP is QAP & it supports APSD
2977 if( CSR_IS_QOS_BSS(pIes) )
2978 {
2979 return eHAL_STATUS_SUCCESS;
2980 }
2981 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 return status;
2983}
2984
Jeff Johnson295189b2012-06-20 16:38:30 -07002985void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2986{
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2988 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2989 // See !!Note: below in this function...
2990 tANI_U32 PrivacyEnabled = 0;
2991 tANI_U32 RsnEnabled = 0;
2992 tANI_U32 WepDefaultKeyId = 0;
2993 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2994 tANI_U32 Key0Length = 0;
2995 tANI_U32 Key1Length = 0;
2996 tANI_U32 Key2Length = 0;
2997 tANI_U32 Key3Length = 0;
2998
2999 // Reserve for the biggest key
3000 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3001 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3002 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3003 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3004
3005 switch ( pProfile->negotiatedUCEncryptionType )
3006 {
3007 case eCSR_ENCRYPT_TYPE_NONE:
3008
3009 // for NO encryption, turn off Privacy and Rsn.
3010 PrivacyEnabled = 0;
3011 RsnEnabled = 0;
3012
3013 // WEP key length and Wep Default Key ID don't matter in this case....
3014
3015 // clear out the WEP keys that may be hanging around.
3016 Key0Length = 0;
3017 Key1Length = 0;
3018 Key2Length = 0;
3019 Key3Length = 0;
3020
3021 break;
3022
3023 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303024 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003025
3026 // Privacy is ON. NO RSN for Wep40 static key.
3027 PrivacyEnabled = 1;
3028 RsnEnabled = 0;
3029
3030 // Set the Wep default key ID.
3031 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 // Wep key size if 5 bytes (40 bits).
3033 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3034
3035 // set encryption keys in the CFG database or clear those that are not present in this profile.
3036 if ( pProfile->Keys.KeyLength[0] )
3037 {
3038 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3039 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3040 }
3041 else
3042 {
3043 Key0Length = 0;
3044 }
3045
3046 if ( pProfile->Keys.KeyLength[1] )
3047 {
3048 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3049 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3050 }
3051 else
3052 {
3053 Key1Length = 0;
3054 }
3055
3056 if ( pProfile->Keys.KeyLength[2] )
3057 {
3058 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3059 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3060 }
3061 else
3062 {
3063 Key2Length = 0;
3064 }
3065
3066 if ( pProfile->Keys.KeyLength[3] )
3067 {
3068 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3069 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3070 }
3071 else
3072 {
3073 Key3Length = 0;
3074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 break;
3076
3077 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303078 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003079
3080 // Privacy is ON. NO RSN for Wep40 static key.
3081 PrivacyEnabled = 1;
3082 RsnEnabled = 0;
3083
3084 // Set the Wep default key ID.
3085 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3086
3087 // Wep key size if 13 bytes (104 bits).
3088 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3089
3090 // set encryption keys in the CFG database or clear those that are not present in this profile.
3091 if ( pProfile->Keys.KeyLength[0] )
3092 {
3093 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3094 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3095 }
3096 else
3097 {
3098 Key0Length = 0;
3099 }
3100
3101 if ( pProfile->Keys.KeyLength[1] )
3102 {
3103 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3104 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3105 }
3106 else
3107 {
3108 Key1Length = 0;
3109 }
3110
3111 if ( pProfile->Keys.KeyLength[2] )
3112 {
3113 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3114 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3115 }
3116 else
3117 {
3118 Key2Length = 0;
3119 }
3120
3121 if ( pProfile->Keys.KeyLength[3] )
3122 {
3123 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3124 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3125 }
3126 else
3127 {
3128 Key3Length = 0;
3129 }
3130
3131 break;
3132
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 case eCSR_ENCRYPT_TYPE_TKIP:
3134 case eCSR_ENCRYPT_TYPE_AES:
3135#ifdef FEATURE_WLAN_WAPI
3136 case eCSR_ENCRYPT_TYPE_WPI:
3137#endif /* FEATURE_WLAN_WAPI */
3138 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3139 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3140 PrivacyEnabled = (0 != fPrivacy);
3141
3142 // turn on RSN enabled for WPA associations
3143 RsnEnabled = 1;
3144
3145 // WEP key length and Wep Default Key ID don't matter in this case....
3146
3147 // clear out the static WEP keys that may be hanging around.
3148 Key0Length = 0;
3149 Key1Length = 0;
3150 Key2Length = 0;
3151 Key3Length = 0;
3152
3153 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 default:
3155 PrivacyEnabled = 0;
3156 RsnEnabled = 0;
3157 break;
3158 }
3159
3160 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3161 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3162 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3163 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3164 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3165 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3166 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3167 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3168}
3169
Jeff Johnson295189b2012-06-20 16:38:30 -07003170static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3171{
3172 tANI_U32 len = 0;
3173 if(pSSID->length <= WNI_CFG_SSID_LEN)
3174 {
3175 len = pSSID->length;
3176 }
3177 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3178}
3179
Jeff Johnson295189b2012-06-20 16:38:30 -07003180eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3181{
3182 eHalStatus status = eHAL_STATUS_SUCCESS;
3183 tANI_U32 QoSEnabled;
3184 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 // set the CFG enable/disable variables based on the qosType being configured...
3186 switch( qosType )
3187 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3189 QoSEnabled = FALSE;
3190 WmeEnabled = TRUE;
3191 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3193 QoSEnabled = FALSE;
3194 WmeEnabled = TRUE;
3195 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3197 QoSEnabled = FALSE;
3198 WmeEnabled = TRUE;
3199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3201 QoSEnabled = TRUE;
3202 WmeEnabled = FALSE;
3203 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 case eCSR_MEDIUM_ACCESS_11e_HCF:
3205 QoSEnabled = TRUE;
3206 WmeEnabled = FALSE;
3207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 default:
3209 case eCSR_MEDIUM_ACCESS_DCF:
3210 QoSEnabled = FALSE;
3211 WmeEnabled = FALSE;
3212 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 }
3214 //save the WMM setting for later use
3215 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3217 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 return (status);
3219}
Jeff Johnson295189b2012-06-20 16:38:30 -07003220static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3221 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3222{
3223 eHalStatus status = eHAL_STATUS_FAILURE;
3224 int i;
3225 eCsrCfgDot11Mode cfgDot11Mode;
3226 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3228 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003230
3231 if( NULL != pIes )
3232 {
3233 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 // Originally, we thought that for 11a networks, the 11a rates are always
3235 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3236 // appear in the Operational Rate set. Consequently, in either case, we
3237 // would blindly put the rates we support into our Operational Rate set
3238 // (including the basic rates, which we have already verified are
3239 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 // However, it turns out that this is not always the case. Some AP's
3241 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3242 // too. Now, we're a little more careful:
3243 pDstRate = pOpRateSet->rate;
3244 if(pIes->SuppRates.present)
3245 {
3246 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3247 {
3248 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3249 {
3250 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003251 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 }
3253 }
3254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3256 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3257 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3258 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3259 {
3260 // If there are Extended Rates in the beacon, we will reflect those
3261 // extended rates that we support in out Extended Operational Rate
3262 // set:
3263 pDstRate = pExRateSet->rate;
3264 if(pIes->ExtSuppRates.present)
3265 {
3266 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3267 {
3268 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3269 {
3270 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3271 pExRateSet->numRates++;
3272 }
3273 }
3274 }
3275 }
3276 }//Parsing BSSDesc
3277 else
3278 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003279 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 }
3281 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3282 return status;
3283}
3284
3285static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3286 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3287{
3288 int i;
3289 tANI_U8 *pDstRate;
3290 eCsrCfgDot11Mode cfgDot11Mode;
3291 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3292 tANI_U32 OperationalRatesLength = 0;
3293 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3294 tANI_U32 ExtendedOperationalRatesLength = 0;
3295 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3296 tANI_U32 ProprietaryOperationalRatesLength = 0;
3297 tANI_U32 PropRatesEnable = 0;
3298 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3299 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 if( NULL != pIes )
3302 {
3303 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 // Originally, we thought that for 11a networks, the 11a rates are always
3305 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3306 // appear in the Operational Rate set. Consequently, in either case, we
3307 // would blindly put the rates we support into our Operational Rate set
3308 // (including the basic rates, which we have already verified are
3309 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 // However, it turns out that this is not always the case. Some AP's
3311 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3312 // too. Now, we're a little more careful:
3313 pDstRate = OperationalRates;
3314 if(pIes->SuppRates.present)
3315 {
3316 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3317 {
3318 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3319 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3320 {
3321 *pDstRate++ = pIes->SuppRates.rates[ i ];
3322 OperationalRatesLength++;
3323 }
3324 }
3325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3327 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3328 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3329 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3330 {
3331 // If there are Extended Rates in the beacon, we will reflect those
3332 // extended rates that we support in out Extended Operational Rate
3333 // set:
3334 pDstRate = ExtendedOperationalRates;
3335 if(pIes->ExtSuppRates.present)
3336 {
3337 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3338 {
3339 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3340 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3341 {
3342 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3343 ExtendedOperationalRatesLength++;
3344 }
3345 }
3346 }
3347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 // Enable proprietary MAC features if peer node is Airgo node and STA
3349 // user wants to use them
3350 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3351 {
3352 PropRatesEnable = 1;
3353 }
3354 else
3355 {
3356 PropRatesEnable = 0;
3357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 // For ANI network companions, we need to populate the proprietary rate
3359 // set with any proprietary rates we found in the beacon, only if user
3360 // allows them...
3361 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3362 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3363 {
3364 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3365 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3366 {
3367 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3368 }
3369 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3370 }
3371 else {
3372 // No proprietary modes...
3373 ProprietaryOperationalRatesLength = 0;
3374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 /* Get MCS Rate */
3376 pDstRate = MCSRateIdxSet;
3377 if ( pIes->HTCaps.present )
3378 {
3379 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3380 {
3381 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3382 {
3383 MCSRateLength++;
3384 *pDstRate++ = i;
3385 }
3386 }
3387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 // Set the operational rate set CFG variables...
3389 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3390 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3391 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3392 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3393 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3394 ProprietaryOperationalRates,
3395 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3396 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3397 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3398 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3399 }//Parsing BSSDesc
3400 else
3401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003402 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 }
3404}
3405
Jeff Johnson295189b2012-06-20 16:38:30 -07003406static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3407 tCsrRoamProfile *pProfile )
3408{
3409 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3410 { 8,
3411 { SIR_MAC_RATE_6,
3412 SIR_MAC_RATE_9,
3413 SIR_MAC_RATE_12,
3414 SIR_MAC_RATE_18,
3415 SIR_MAC_RATE_24,
3416 SIR_MAC_RATE_36,
3417 SIR_MAC_RATE_48,
3418 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3420 { 4,
3421 { SIR_MAC_RATE_1,
3422 SIR_MAC_RATE_2,
3423 SIR_MAC_RATE_5_5,
3424 SIR_MAC_RATE_11 } } };
3425
3426
3427 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3428 { SIR_MAC_RATE_72,
3429 SIR_MAC_RATE_96,
3430 SIR_MAC_RATE_108 } };
3431 eCsrCfgDot11Mode cfgDot11Mode;
3432 eCsrBand eBand;
3433 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3434 tANI_U32 OperationalRatesLength = 0;
3435 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3436 tANI_U32 ExtendedOperationalRatesLength = 0;
3437 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3438 tANI_U32 ProprietaryOperationalRatesLength = 0;
3439 tANI_U32 PropRatesEnable = 0;
3440 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 if(pProfile->ChannelInfo.ChannelList)
3442 {
3443 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3447 // networks, the 11b rates appear in the Operational Rate set. In either case,
3448 // we can blindly put the rates we support into our Operational Rate set
3449 // (including the basic rates, which we have already verified are supported
3450 // earlier in the roaming decision).
3451 if ( eCSR_BAND_5G == eBand )
3452 {
3453 // 11a rates into the Operational Rate Set.
3454 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3455 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3456 palCopyMemory( pMac->hHdd, OperationalRates,
3457 DefaultSupportedRates11a.supportedRateSet.rate,
3458 OperationalRatesLength );
3459
3460 // Nothing in the Extended rate set.
3461 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 // populate proprietary rates if user allows them
3463 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3464 {
3465 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3466 sizeof(*DefaultSupportedPropRates.propRate);
3467 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3468 DefaultSupportedPropRates.propRate,
3469 ProprietaryOperationalRatesLength );
3470 }
3471 else
3472 {
3473 // No proprietary modes
3474 ProprietaryOperationalRatesLength = 0;
3475 }
3476 }
3477 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3478 {
3479 // 11b rates into the Operational Rate Set.
3480 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3481 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3482 palCopyMemory( pMac->hHdd, OperationalRates,
3483 DefaultSupportedRates11b.supportedRateSet.rate,
3484 OperationalRatesLength );
3485 // Nothing in the Extended rate set.
3486 ExtendedOperationalRatesLength = 0;
3487 // No proprietary modes
3488 ProprietaryOperationalRatesLength = 0;
3489 }
3490 else
3491 {
3492 // 11G
3493
3494 // 11b rates into the Operational Rate Set.
3495 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3496 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3497 palCopyMemory( pMac->hHdd, OperationalRates,
3498 DefaultSupportedRates11b.supportedRateSet.rate,
3499 OperationalRatesLength );
3500
3501 // 11a rates go in the Extended rate set.
3502 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3503 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3504 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3505 DefaultSupportedRates11a.supportedRateSet.rate,
3506 ExtendedOperationalRatesLength );
3507
3508 // populate proprietary rates if user allows them
3509 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3510 {
3511 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3512 sizeof(*DefaultSupportedPropRates.propRate);
3513 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3514 DefaultSupportedPropRates.propRate,
3515 ProprietaryOperationalRatesLength );
3516 }
3517 else
3518 {
3519 // No proprietary modes
3520 ProprietaryOperationalRatesLength = 0;
3521 }
3522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3524 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3525 {
3526 PropRatesEnable = 1;
3527 }
3528 else
3529 {
3530 PropRatesEnable = 0;
3531 }
3532
3533 // Set the operational rate set CFG variables...
3534 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3535 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3536 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3537 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3538 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3539 ProprietaryOperationalRates,
3540 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3541 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003542}
Jeff Johnson295189b2012-06-20 16:38:30 -07003543void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3544{
3545 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003546
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3548 tANI_U32 sessionId;
3549 tSmeCmd *pCommand = NULL;
3550
3551 if(NULL == pEntry)
3552 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003553 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 return;
3555 }
3556 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3557 sessionId = pCommand->sessionId;
3558
3559 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3560 {
3561 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3562 }
3563}
3564
Jeff Johnson295189b2012-06-20 16:38:30 -07003565//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3566tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3567{
3568 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3569 {
3570 return (WNI_CFG_PHY_MODE_11B);
3571 }
3572 else
3573 {
3574 if(eCSR_BAND_24 == band)
3575 return (WNI_CFG_PHY_MODE_11G);
3576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 return (WNI_CFG_PHY_MODE_11A);
3578}
Jeff Johnson295189b2012-06-20 16:38:30 -07003579
Jeff Johnsone7245742012-09-05 17:12:55 -07003580
3581#ifdef WLAN_FEATURE_11AC
3582ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3583{
3584 switch ( aniCBMode )
3585 {
3586 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3587 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3588 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3589 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3590 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3591 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3592 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3593 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3594 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003595 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003596 return PHY_SINGLE_CHANNEL_CENTERED;
3597 }
3598}
3599#endif
3600
Jeff Johnson295189b2012-06-20 16:38:30 -07003601//pIes may be NULL
3602eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3603 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303604 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003605{
3606 eHalStatus status = eHAL_STATUS_SUCCESS;
3607 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3608 tANI_U8 channel = 0;
3609 //Make sure we have the domain info for the BSS we try to connect to.
3610 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303611 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303613 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 {
3615 //Make sure the 11d info from this BSSDesc can be applied
3616 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303617 if (VOS_TRUE == resetCountry)
3618 {
3619 csrApplyCountryInformation(pMac, FALSE);
3620 }
3621 else
3622 {
3623 csrApplyCountryInformation(pMac, TRUE);
3624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 }
Kiran4a17ebe2013-01-31 10:43:43 -08003626 if ((csrIs11dSupported (pMac)) && pIes)
3627 {
3628 if (!pIes->Country.present)
3629 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 //Qos
3633 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3634 //SSID
3635 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3636 //fragment threshold
3637 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3638 //RTS threshold
3639 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3640
3641 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3642
3643 //Auth type
3644 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3645 //encryption type
3646 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3647 //short slot time
3648 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 //11d
3650 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3651 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3652 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 /*//11h
3654 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3655 */
3656 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3657 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003658
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003659 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 {
3661 channel = pProfile->operationChannel;
3662 }
3663 else
3664 {
3665 if(pBssDesc)
3666 {
3667 channel = pBssDesc->channelId;
3668 }
3669 }
3670 if(0 != channel)
3671 {
3672 if(CSR_IS_CHANNEL_24GHZ(channel))
3673 {//for now if we are on 2.4 Ghz, CB will be always disabled
3674 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3675 }
3676 else
3677 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003678 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 }
3680 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003681#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003682 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3683 // in function csrConvertCBIniValueToPhyCBState()
3684 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3685 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003686 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003687 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003688 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003689 }
3690 else
3691 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003692 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003693 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003694 }
3695 else
3696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3698 //Rate
3699 //Fixed Rate
3700 if(pBssDesc)
3701 {
3702 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3703 }
3704 else
3705 {
3706 csrSetCfgRateSetFromProfile(pMac, pProfile);
3707 }
3708 //Make this the last CFG to set. The callback will trigger a join_req
3709 //Join time out
3710 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3711
3712 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 return (status);
3714}
3715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3717 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3718{
3719 eHalStatus status;
3720 tBssConfigParam *pBssConfig;
3721 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003722
3723 if(!pSession)
3724 {
3725 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3726 return eHAL_STATUS_FAILURE;
3727 }
3728
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3730 if(HAL_STATUS_SUCCESS(status))
3731 {
3732 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3733 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3734 if(HAL_STATUS_SUCCESS(status))
3735 {
3736 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003737 /* This will allow to pass cbMode during join req */
3738 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 //For IBSS, we need to prepare some more information
3740 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 )
3743 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003744 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 }
3746 // If we are in an IBSS, then stop the IBSS...
3747 ////Not worry about WDS connection for now
3748 if ( csrIsConnStateIbss( pMac, sessionId ) )
3749 {
3750 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3751 }
3752 else
3753 {
3754 // if we are in an Infrastructure association....
3755 if ( csrIsConnStateInfra( pMac, sessionId ) )
3756 {
3757 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3758 // across SSIDs (roaming to a new SSID)... //
3759 //Not worry about WDS connection for now
3760 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303761 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 {
3763 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303764 status = csrRoamIssueDisassociate( pMac, sessionId,
3765 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303767 else
3768 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3770 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303771 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303773 // Set parameters for this Bss.
3774 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3775 pBssDesc, pBssConfig,
3776 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303780 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 {
3782 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3783 // Nothing to stop.
3784 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303786 )
3787 {
3788 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3789 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3790 // Set parameters for this Bss.
3791 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3792 pBssDesc, pBssConfig,
3793 pIes, is11rRoamingFlag);
3794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 }
3796 }
3797 }//Success getting BSS config info
3798 palFreeMemory(pMac->hHdd, pBssConfig);
3799 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 return (status);
3801}
3802
Jeff Johnson295189b2012-06-20 16:38:30 -07003803eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3804 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3805{
3806 eCsrJoinState eRoamState = eCsrContinueRoaming;
3807 eHalStatus status;
3808 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3809 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003811
3812 if(!pSession)
3813 {
3814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3815 return (eCsrStopRoaming);
3816 }
3817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 if( CSR_IS_WDS_STA( pProfile ) )
3819 {
3820 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3821 if( !HAL_STATUS_SUCCESS( status ) )
3822 {
3823 eRoamState = eCsrStopRoaming;
3824 }
3825 }
3826 else
3827 {
3828 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3829 {
3830 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3831 return (eCsrStopRoaming);
3832 }
3833 if ( csrIsInfraBssDesc( pBssDesc ) )
3834 {
3835 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3836 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3837 // have changed and handle the changes (without disturbing the current association).
3838
3839 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3840 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3841 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3842 )
3843 {
3844 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3845 // with Authenticating first. To force this, stop the current association (Disassociate) and
3846 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3847 // a new Association.
3848 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003850 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3852 {
3853 eRoamState = eCsrReassocToSelfNoCapChange;
3854 }
3855 else
3856 {
3857 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 //The key changes
3859 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3860 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3861 if(HAL_STATUS_SUCCESS(status))
3862 {
3863 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003864 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303866 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3867 pBssDesc, &bssConfig,
3868 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 if(!HAL_STATUS_SUCCESS(status))
3870 {
3871 eRoamState = eCsrStopRoaming;
3872 }
3873 }
3874 else
3875 {
3876 eRoamState = eCsrStopRoaming;
3877 }
3878 }//same profile
3879 }
3880 else
3881 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303882 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003885 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303889 }
3890 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 {
3892 // 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 +05303893 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 // work much better.
3895 //
3896 //
3897 // stop the existing network before attempting to join the new network...
3898 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3899 {
3900 eRoamState = eCsrStopRoaming;
3901 }
3902 }
3903 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303904 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 {
3906 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3907 {
3908 eRoamState = eCsrStopRoaming;
3909 }
3910 }
3911 if( pIesLocal && !pScanResult->pvIes )
3912 {
3913 palFreeMemory(pMac->hHdd, pIesLocal);
3914 }
3915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 return( eRoamState );
3917}
3918
Jeff Johnson295189b2012-06-20 16:38:30 -07003919eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3920 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3921{
3922 eHalStatus status = eHAL_STATUS_SUCCESS;
3923 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3925 roamInfo.pBssDesc = pBssDesc;
3926 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3927 return (status);
3928}
Jeff Johnson295189b2012-06-20 16:38:30 -07003929//In case no matching BSS is found, use whatever default we can find
3930static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3931{
3932 //Need to get all negotiated types in place first
3933 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003934 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 {
3936 default:
3937 case eCSR_AUTH_TYPE_WPA:
3938 case eCSR_AUTH_TYPE_WPA_PSK:
3939 case eCSR_AUTH_TYPE_WPA_NONE:
3940 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3941 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3942 break;
3943
3944 case eCSR_AUTH_TYPE_SHARED_KEY:
3945 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3946 break;
3947
3948 case eCSR_AUTH_TYPE_AUTOSWITCH:
3949 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3950 break;
3951 }
3952 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3953 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3954 //In this case, the multicast encryption needs to follow the uncast ones.
3955 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3956 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3957}
3958
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003959
3960static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3961{
3962 switch(pCommand->u.roamCmd.roamReason)
3963 {
3964 case eCsrLostLink1:
3965 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3966 break;
3967 case eCsrLostLink2:
3968 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3969 break;
3970 case eCsrLostLink3:
3971 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3972 break;
3973 default:
3974 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3975 pCommand->u.roamCmd.roamReason);
3976 break;
3977 }
3978}
3979
Jeff Johnson295189b2012-06-20 16:38:30 -07003980static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3981{
3982 eHalStatus status;
3983 tCsrScanResult *pScanResult = NULL;
3984 eCsrJoinState eRoamState = eCsrStopRoaming;
3985 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3986 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3987 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3988#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3989 v_U8_t acm_mask = 0;
3990#endif
3991 tANI_U32 sessionId = pCommand->sessionId;
3992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3993 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3994 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003995
3996 if(!pSession)
3997 {
3998 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3999 return (eCsrStopRoaming);
4000 }
4001
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 do
4003 {
4004 // Check for Cardbus eject condition, before trying to Roam to any BSS
4005 //***if( !balIsCardPresent(pAdapter) ) break;
4006
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004007 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4008 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 if(NULL != pBSSList)
4010 {
4011 // When handling AP's capability change, continue to associate to
4012 // same BSS and make sure pRoamBssEntry is not Null.
4013 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4014 {
4015 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4016 {
4017 //Try the first BSS
4018 pCommand->u.roamCmd.pLastRoamBss = NULL;
4019 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4020 }
4021 else
4022 {
4023 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4024 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4025 {
4026 //Done with all the BSSs
4027 //In this case, will tell HDD the completion
4028 break;
4029 }
4030 else
4031 {
4032 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004033 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4035 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4036 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4037 pRoamInfo = &roamInfo;
4038 }
4039 }
4040 while(pCommand->u.roamCmd.pRoamBssEntry)
4041 {
4042 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 /*If concurrency enabled take the concurrent connected channel first. */
4044 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004045 if (vos_concurrent_sessions_running() &&
4046 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 {
4048 concurrentChannel =
4049 csrGetConcurrentOperationChannel(pMac);
4050 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004051 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 if ((concurrentChannel) &&
4053 (concurrentChannel ==
4054 pScanResult->Result.BssDescriptor.channelId))
4055 {
4056 //make this 0 because we do not want the
4057 //below check to pass as we don't want to
4058 //connect on other channel
4059 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4060 FL("Concurrent channel match =%d"),
4061 concurrentChannel);
4062 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 }
4064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004065
4066 if (!concurrentChannel)
4067 {
4068
4069 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4070 sessionId, &pScanResult->Result.BssDescriptor,
4071 pCommand->u.roamCmd.roamId)))
4072 {
4073 //Ok to roam this
4074 break;
4075 }
4076 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004077 else
4078 {
4079 eRoamState = eCsrStopRoamingDueToConcurrency;
4080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4082 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4083 {
4084 //Done with all the BSSs
4085 fDone = eANI_BOOLEAN_TRUE;
4086 break;
4087 }
4088 }
4089 if(fDone)
4090 {
4091 break;
4092 }
4093 }
4094 }
4095 //We have something to roam, tell HDD when it is infra.
4096 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4097 //For WDS, the indication is eCSR_ROAM_WDS_IND
4098 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4099 {
4100 if(pRoamInfo)
4101 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004102 if(pSession->bRefAssocStartCnt)
4103 {
4104 pSession->bRefAssocStartCnt--;
4105 //Complete the last association attemp because a new one is about to be tried
4106 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4107 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004109 }
4110 }
4111 /* If the roaming has stopped, not to continue the roaming command*/
4112 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4113 {
4114 //No need to complete roaming here as it already completes
4115 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4116 pCommand->u.roamCmd.roamReason);
4117 eRoamState = eCsrStopRoaming;
4118 csrSetAbortRoamingCommand(pMac, pCommand);
4119 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4122 if(pScanResult)
4123 {
4124 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004127 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 fDone = eANI_BOOLEAN_TRUE;
4129 eRoamState = eCsrStopRoaming;
4130 break;
4131 }
4132 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4133 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4134 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4135 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4136 CSR_IS_QOS_BSS(pIesLocal) &&
4137 CSR_IS_UAPSD_BSS(pIesLocal) )
4138 {
4139#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4141 pIesLocal);
4142 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4143#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 }
4145 else
4146 {
4147 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4148 }
4149 if( pIesLocal && !pScanResult->Result.pvIes)
4150 {
4151 palFreeMemory(pMac->hHdd, pIesLocal);
4152 }
4153 }
4154 else
4155 {
4156 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4157 }
4158 roamInfo.pProfile = pProfile;
4159 pSession->bRefAssocStartCnt++;
4160 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4161 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4164 {
4165 // If this is a start IBSS profile, then we need to start the IBSS.
4166 if ( CSR_IS_START_IBSS(pProfile) )
4167 {
4168 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 // Attempt to start this IBSS...
4170 csrRoamAssignDefaultParam( pMac, pCommand );
4171 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4172 if(HAL_STATUS_SUCCESS(status))
4173 {
4174 if ( fSameIbss )
4175 {
4176 eRoamState = eCsrStartIbssSameIbss;
4177 }
4178 else
4179 {
4180 eRoamState = eCsrContinueRoaming;
4181 }
4182 }
4183 else
4184 {
4185 //it somehow fail need to stop
4186 eRoamState = eCsrStopRoaming;
4187 }
4188 break;
4189 }
4190 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 )
4193 {
4194 // Attempt to start this WDS...
4195 csrRoamAssignDefaultParam( pMac, pCommand );
4196 /* For AP WDS, we dont have any BSSDescription */
4197 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4198 if(HAL_STATUS_SUCCESS(status))
4199 {
4200 eRoamState = eCsrContinueRoaming;
4201 }
4202 else
4203 {
4204 //it somehow fail need to stop
4205 eRoamState = eCsrStopRoaming;
4206 }
4207 }
4208 else
4209 {
4210 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004211 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 eRoamState = eCsrStopRoaming;
4213 break;
4214 }
4215 }
4216 else //We have BSS
4217 {
4218 //Need to assign these value because they are used in csrIsSameProfile
4219 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4220 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4221 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4222 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4223 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4224 {
4225 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4226 {
4227 eRoamState = eCsrStartIbssSameIbss;
4228 break;
4229 }
4230 }
4231 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4232 {
4233 //trying to connect to the one already connected
4234 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4235 eRoamState = eCsrReassocToSelfNoCapChange;
4236 break;
4237 }
4238 // Attempt to Join this Bss...
4239 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4240 break;
4241 }
4242
4243 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4245 {
4246 //Need to indicate association_completion if association_start has been done
4247 if(pSession->bRefAssocStartCnt > 0)
4248 {
4249 pSession->bRefAssocStartCnt--;
4250 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004251 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4253 eCSR_ROAM_ASSOCIATION_COMPLETION,
4254 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4255 }
4256 }
4257
4258 return( eRoamState );
4259}
4260
Jeff Johnson295189b2012-06-20 16:38:30 -07004261static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4262{
4263 eHalStatus status = eHAL_STATUS_SUCCESS;
4264 eCsrJoinState RoamState;
4265 tANI_U32 sessionId = pCommand->sessionId;
4266
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 //***if( hddIsRadioStateOn( pAdapter ) )
4268 {
4269 // Attept to join a Bss...
4270 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004271
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004273 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 {
4275 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 // and if connected in Infrastructure mode...
4277 if ( csrIsConnStateInfra(pMac, sessionId) )
4278 {
4279 //... then we need to issue a disassociation
4280 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4281 if(!HAL_STATUS_SUCCESS(status))
4282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004283 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 //roam command is completed by caller in the failed case
4285 fComplete = eANI_BOOLEAN_TRUE;
4286 }
4287 }
4288 else if( csrIsConnStateIbss(pMac, sessionId) )
4289 {
4290 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4291 if(!HAL_STATUS_SUCCESS(status))
4292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004293 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 //roam command is completed by caller in the failed case
4295 fComplete = eANI_BOOLEAN_TRUE;
4296 }
4297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4299 {
4300 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4301 if(!HAL_STATUS_SUCCESS(status))
4302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004303 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 //roam command is completed by caller in the failed case
4305 fComplete = eANI_BOOLEAN_TRUE;
4306 }
4307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 else
4309 {
4310 fComplete = eANI_BOOLEAN_TRUE;
4311 }
4312 if(fComplete)
4313 {
4314 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004315 if(eCsrStopRoamingDueToConcurrency == RoamState)
4316 {
4317 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4318 }
4319 else
4320 {
4321 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 }
4324 }
4325 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4326 {
4327 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4328 }
4329 else if ( eCsrStartIbssSameIbss == RoamState )
4330 {
4331 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4332 }
4333 }//hddIsRadioStateOn
4334
4335 return status;
4336}
Jeff Johnson295189b2012-06-20 16:38:30 -07004337eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4338{
4339 tANI_U32 sessionId;
4340 tCsrRoamSession *pSession;
4341 tCsrScanResult *pScanResult = NULL;
4342 tSirBssDescription *pBssDesc = NULL;
4343 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 sessionId = pCommand->sessionId;
4345 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004346
4347 if(!pSession)
4348 {
4349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4350 return eHAL_STATUS_FAILURE;
4351 }
4352
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4354 {
4355 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004356 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4358 return eHAL_STATUS_FAILURE;
4359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 if (pCommand->u.roamCmd.pRoamBssEntry)
4361 {
4362 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4363 pBssDesc = &pScanResult->Result.BssDescriptor;
4364 }
4365 else
4366 {
4367 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004368 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4370 return eHAL_STATUS_FAILURE;
4371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4373 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4374 return status;
4375}
4376
Jeff Johnson295189b2012-06-20 16:38:30 -07004377eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4378{
4379 eHalStatus status = eHAL_STATUS_SUCCESS;
4380 tCsrRoamInfo roamInfo;
4381 tANI_U32 sessionId = pCommand->sessionId;
4382 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004383
4384 if(!pSession)
4385 {
4386 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4387 return eHAL_STATUS_FAILURE;
4388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004389
4390 switch ( pCommand->u.roamCmd.roamReason )
4391 {
4392 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004394 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 case eCsrSmeIssuedDisassocForHandoff:
4397 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4398#if 0 // TODO : Confirm this change
4399 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4400#else
4401 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4402#endif
4403
4404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004407 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004411 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 case eCsrHddIssuedReassocToSameAP:
4414 case eCsrSmeIssuedReassocToSameAP:
4415 {
4416 tDot11fBeaconIEs *pIes = NULL;
4417
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 if( pSession->pConnectBssDesc )
4419 {
4420 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4421 if(!HAL_STATUS_SUCCESS(status) )
4422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004423 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 }
4425 else
4426 {
4427 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4428 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4429 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4431 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4432 pSession->bRefAssocStartCnt++;
4433 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4434 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4435
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004436 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004437 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4438 &pCommand->u.roamCmd.roamProfile );
4439 if(!HAL_STATUS_SUCCESS(status))
4440 {
4441 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004442 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004443 }
4444
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 palFreeMemory(pMac->hHdd, pIes);
4446 pIes = NULL;
4447 }
4448 }
4449 break;
4450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004452 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4454 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4455 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004457 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4459 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004460
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 case eCsrStopBss:
4462 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4463 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4464 break;
4465
4466 case eCsrForcedDisassocSta:
4467 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4468 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4469 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4470 pCommand->u.roamCmd.reason);
4471 break;
4472
4473 case eCsrForcedDeauthSta:
4474 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4475 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4476 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4477 pCommand->u.roamCmd.reason);
4478 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004479
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004480 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004481 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004482 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4483 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004485
4486 default:
4487 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4488
4489 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4490 {
4491 //Remember the roaming profile
4492 csrFreeRoamProfile(pMac, sessionId);
4493 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4494 {
4495 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4496 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4497 }
4498 }
4499
4500 //At this point, original uapsd_mask is saved in pCurRoamProfile
4501 //uapsd_mask in the pCommand may change from this point on.
4502
4503 // Attempt to roam with the new scan results (if we need to..)
4504 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004505 if(!HAL_STATUS_SUCCESS(status))
4506 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004507 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 break;
4510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 return (status);
4512}
4513
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004514void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4515{
4516 pCommand->u.roamCmd.pLastRoamBss = NULL;
4517 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4518 //Because u.roamCmd is union and share with scanCmd and StatusChange
4519 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4520}
4521
Jeff Johnson295189b2012-06-20 16:38:30 -07004522void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4523{
4524 if(pCommand->u.roamCmd.fReleaseBssList)
4525 {
4526 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4527 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4528 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4529 }
4530 if(pCommand->u.roamCmd.fReleaseProfile)
4531 {
4532 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4533 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4534 }
4535 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4536 //Because u.roamCmd is union and share with scanCmd and StatusChange
4537 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4538}
4539
Jeff Johnson295189b2012-06-20 16:38:30 -07004540void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4541{
4542 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4543}
Jeff Johnson295189b2012-06-20 16:38:30 -07004544void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4545{
4546 tListElem *pEntry;
4547 tSmeCmd *pCommand;
4548 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004549 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4551 if ( pEntry )
4552 {
4553 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 // If the head of the queue is Active and it is a ROAM command, remove
4555 // and put this on the Free queue.
4556 if ( eSmeCommandRoam == pCommand->command )
4557 {
4558 //we need to process the result first before removing it from active list because state changes
4559 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4560 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4561 if( fReleaseCommand )
4562 {
4563 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4564 {
4565 csrReleaseCommandRoam( pMac, pCommand );
4566 }
4567 else
4568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004569 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004570 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 }
4572 }
4573 else
4574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004575 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004576 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 }
4578 }
4579 else
4580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004581 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 }
4583 }
4584 else
4585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004586 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 if( fReleaseCommand )
4589 {
4590 smeProcessPendingQueue( pMac );
4591 }
4592}
4593
Jeff Johnson295189b2012-06-20 16:38:30 -07004594void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4595{
4596 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004597 if(!pSession)
4598 {
4599 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4600 return;
4601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4603 pSession->NumPmkidCandidate = 0;
4604}
Jeff Johnson295189b2012-06-20 16:38:30 -07004605#ifdef FEATURE_WLAN_WAPI
4606void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4607{
4608 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004609 if(!pSession)
4610 {
4611 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4612 return;
4613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4615 pSession->NumBkidCandidate = 0;
4616}
4617#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004618extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4621 tSirBssDescription *pSirBssDesc,
4622 tDot11fBeaconIEs *pIes)
4623{
4624 eHalStatus status = eHAL_STATUS_SUCCESS;
4625 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4626 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004627
4628 if(!pSession)
4629 {
4630 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4631 return eHAL_STATUS_FAILURE;
4632 }
4633
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 if((eCSR_AUTH_TYPE_WPA == authType) ||
4635 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4636 (eCSR_AUTH_TYPE_RSN == authType) ||
4637 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4638#if defined WLAN_FEATURE_VOWIFI_11R
4639 ||
4640 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4641 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4642#endif /* FEATURE_WLAN_WAPI */
4643#ifdef FEATURE_WLAN_WAPI
4644 ||
4645 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4646 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4647#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004648#ifdef WLAN_FEATURE_11W
4649 ||
4650 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4651#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 )
4653 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004656 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 }
4658 if( pIesLocal )
4659 {
4660 tANI_U32 nIeLen;
4661 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 if((eCSR_AUTH_TYPE_RSN == authType) ||
4663#if defined WLAN_FEATURE_VOWIFI_11R
4664 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4665 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4666#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004667#if defined WLAN_FEATURE_11W
4668 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4669#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4671 {
4672 if(pIesLocal->RSN.present)
4673 {
4674 //Calculate the actual length
4675 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4676 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4677 + 2 //akm_suite_count
4678 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4679 + 2; //reserved
4680 if( pIesLocal->RSN.pmkid_count )
4681 {
4682 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4683 }
4684 //nIeLen doesn't count EID and length fields
4685 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4686 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004687 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4689 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4690 //copy upto akm_suites
4691 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004692 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4693 pIeBuf += sizeof(pIesLocal->RSN.version);
4694 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4695 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4696 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4697 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 if( pIesLocal->RSN.pwise_cipher_suite_count )
4699 {
4700 //copy pwise_cipher_suites
4701 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4702 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4703 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4704 }
4705 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4706 pIeBuf += 2;
4707 if( pIesLocal->RSN.akm_suite_count )
4708 {
4709 //copy akm_suites
4710 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4711 pIesLocal->RSN.akm_suite_count * 4);
4712 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4713 }
4714 //copy the rest
4715 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4716 pIesLocal->RSN.akm_suite_count * 4,
4717 2 + pIesLocal->RSN.pmkid_count * 4);
4718 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4719 }
4720 }
4721 }
4722 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4723 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4724 {
4725 if(pIesLocal->WPA.present)
4726 {
4727 //Calculate the actual length
4728 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4729 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4730 + 2 //auth_suite_count
4731 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4732 // The WPA capabilities follows the Auth Suite (two octects)--
4733 // this field is optional, and we always "send" zero, so just
4734 // remove it. This is consistent with our assumptions in the
4735 // frames compiler; c.f. bug 15234:
4736 //nIeLen doesn't count EID and length fields
4737 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4738 {
4739 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4740 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4741 pIeBuf = pSession->pWpaRsnRspIE + 2;
4742 //Copy WPA OUI
4743 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4744 pIeBuf += 4;
4745 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4746 pIesLocal->WPA.unicast_cipher_count * 4);
4747 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4748 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4749 pIesLocal->WPA.auth_suite_count * 4);
4750 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4751 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4752 }
4753 }
4754 }
4755#ifdef FEATURE_WLAN_WAPI
4756 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4757 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4758 {
4759 if(pIesLocal->WAPI.present)
4760 {
4761 //Calculate the actual length
4762 nIeLen = 4 //version + akm_suite_count
4763 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4764 + 2 //pwise_cipher_suite_count
4765 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4766 + 6; //gp_cipher_suite + preauth + reserved
4767 if( pIesLocal->WAPI.bkid_count )
4768 {
4769 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4770 }
4771
4772 //nIeLen doesn't count EID and length fields
4773 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4774 {
4775 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4776 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4777 pIeBuf = pSession->pWapiRspIE + 2;
4778 //copy upto akm_suite_count
lukez3c809222013-05-03 10:23:02 -07004779 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 pIeBuf += 4;
4781 if( pIesLocal->WAPI.akm_suite_count )
4782 {
4783 //copy akm_suites
4784 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4785 pIesLocal->WAPI.akm_suite_count * 4);
4786 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4787 }
4788 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4789 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4791 {
4792 //copy pwise_cipher_suites
4793 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4794 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4795 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4796 }
lukez3c809222013-05-03 10:23:02 -07004797 //gp_cipher_suite
4798 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite, 4);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304799 //preauth + reserved
4800 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite + 4, 2);
4801 //bkid_count
4802 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 pIeBuf += 8;
4804 if( pIesLocal->WAPI.bkid_count )
4805 {
4806 //copy akm_suites
4807 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4808 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4809 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304810 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 }
4813 }
4814#endif /* FEATURE_WLAN_WAPI */
4815 if( !pIes )
4816 {
4817 //locally allocated
4818 palFreeMemory(pMac->hHdd, pIesLocal);
4819 }
4820 }
4821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 return (status);
4823}
4824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4826{
4827 v_U8_t bACWeights[WLANTL_MAX_AC];
4828 v_U8_t paramBk, paramBe, paramVi, paramVo;
4829 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4831 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4832 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4833 //This doesn't address the case where the lower AC needs a real higher weight
4834 if( pIEs->WMMParams.present )
4835 {
4836 //no change to the lowest ones
4837 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4838 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4839 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4840 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4841 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4842 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4843 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4844 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4845 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4846 {
4847 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4848 fWeightChange = VOS_TRUE;
4849 }
4850 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4851 {
4852 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4853 fWeightChange = VOS_TRUE;
4854 }
4855 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4856 {
4857 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4858 fWeightChange = VOS_TRUE;
4859 }
4860 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4861 {
4862 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4863 fWeightChange = VOS_TRUE;
4864 }
4865 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4866 {
4867 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4868 fWeightChange = VOS_TRUE;
4869 }
4870 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4871 {
4872 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4873 fWeightChange = VOS_TRUE;
4874 }
4875 if(fWeightChange)
4876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004877 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 bACWeights[2], bACWeights[3]);
4879 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4880 }
4881 }
4882}
Jeff Johnson295189b2012-06-20 16:38:30 -07004883#ifdef WLAN_FEATURE_VOWIFI_11R
4884//Returns whether the current association is a 11r assoc or not
4885tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4886{
4887#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4888 return csrNeighborRoamIs11rAssoc(pMac);
4889#else
4890 return eANI_BOOLEAN_FALSE;
4891#endif
4892}
4893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004894#ifdef FEATURE_WLAN_CCX
4895//Returns whether the current association is a CCX assoc or not
4896tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4897{
4898#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4899 return csrNeighborRoamIsCCXAssoc(pMac);
4900#else
4901 return eANI_BOOLEAN_FALSE;
4902#endif
4903}
4904#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004905#ifdef FEATURE_WLAN_LFR
4906//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304907tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004908{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304909 tCsrRoamSession *pSession = NULL;
4910
4911 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4912 {
4913 pSession = CSR_GET_SESSION( pMac, sessionId );
4914 if (NULL != pSession->pCurRoamProfile)
4915 {
4916 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4917 {
4918 return eANI_BOOLEAN_FALSE;
4919 }
4920 }
4921 }
4922
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004923#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4924 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4925 {
4926 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
4927 }
4928 else
4929#endif
4930 {
4931 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004932 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004933 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004934}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004935
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004936#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4937//Returns whether "FW based BG scan" is currently enabled...or not
4938tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4939{
4940 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4941}
4942#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004943#endif
4944
Jeff Johnson295189b2012-06-20 16:38:30 -07004945//Return true means the command can be release, else not
4946static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4947 eCsrRoamCompleteResult Result, void *Context )
4948{
4949 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4950 tSirBssDescription *pSirBssDesc = NULL;
4951 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4952 tCsrScanResult *pScanResult = NULL;
4953 tCsrRoamInfo roamInfo;
4954 sme_QosAssocInfo assocInfo;
4955 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4956 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4957 tDot11fBeaconIEs *pIes = NULL;
4958 tANI_U32 sessionId = pCommand->sessionId;
4959 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4960 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4961 eRoamCmdStatus roamStatus;
4962 eCsrRoamResult roamResult;
4963 eHalStatus status;
4964 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004966
Jeff Johnson32d95a32012-09-10 13:15:23 -07004967 if(!pSession)
4968 {
4969 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4970 return eANI_BOOLEAN_FALSE;
4971 }
4972
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004973 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 switch( Result )
4975 {
4976 case eCsrJoinSuccess:
4977 // reset the IDLE timer
4978 // !!
4979 // !! fall through to the next CASE statement here is intentional !!
4980 // !!
4981 case eCsrReassocSuccess:
4982 if(eCsrReassocSuccess == Result)
4983 {
4984 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4985 }
4986 else
4987 {
4988 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4989 }
4990 // Success Join Response from LIM. Tell NDIS we are connected and save the
4991 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004992 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4994 //always free the memory here
4995 if(pSession->pWpaRsnRspIE)
4996 {
4997 pSession->nWpaRsnRspIeLength = 0;
4998 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4999 pSession->pWpaRsnRspIE = NULL;
5000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005001#ifdef FEATURE_WLAN_WAPI
5002 if(pSession->pWapiRspIE)
5003 {
5004 pSession->nWapiRspIeLength = 0;
5005 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
5006 pSession->pWapiRspIE = NULL;
5007 }
5008#endif /* FEATURE_WLAN_WAPI */
5009#ifdef FEATURE_WLAN_BTAMP_UT_RF
5010 //Reset counter so no join retry is needed.
5011 pSession->maxRetryCount = 0;
5012 csrRoamStopJoinRetryTimer(pMac, sessionId);
5013#endif
5014 /* This creates problem since we have not saved the connected profile.
5015 So moving this after saving the profile
5016 */
5017 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5018 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5019 {
5020 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5021 }
5022 else
5023 {
5024 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 //Use the last connected bssdesc for reassoc-ing to the same AP.
5027 //NOTE: What to do when reassoc to a different AP???
5028 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5029 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5030 {
5031 pSirBssDesc = pSession->pConnectBssDesc;
5032 if(pSirBssDesc)
5033 {
5034 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5035 }
5036 }
5037 else
5038 {
5039
5040 if(pCommand->u.roamCmd.pRoamBssEntry)
5041 {
5042 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5043 if(pScanResult != NULL)
5044 {
5045 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5046 //this can be NULL
5047 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5048 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5049 }
5050 }
5051 }
5052 if( pSirBssDesc )
5053 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5056 //Save WPA/RSN IE
5057 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5058#ifdef FEATURE_WLAN_CCX
5059 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5060#endif
5061
5062 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5063 // substate change.
5064 // Moving even save profile above so that below mentioned conditon is also met.
5065 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5066 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5068 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5069 // will be dropped for the security context may not be set properly.
5070 //
5071 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5072 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5073 //
5074 // this reordering was done on titan_prod_usb branch and is being replicated here.
5075 //
5076
5077 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5078 !pProfile->bWPSAssociation)
5079 {
5080 // Issue the set Context request to LIM to establish the Unicast STA context
5081 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5082 pProfile->negotiatedUCEncryptionType,
5083 pSirBssDesc, &(pSirBssDesc->bssId),
5084 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005086 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5088 }
5089 // Issue the set Context request to LIM to establish the Broadcast STA context
5090 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5091 pSirBssDesc, &BroadcastMac,
5092 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5093 }
5094 else
5095 {
5096 //Need to wait for supplicant authtication
5097 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 //Set the subestate to WaitForKey in case authentiation is needed
5099 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5100
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 if(pProfile->bWPSAssociation)
5102 {
5103 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5104 }
5105 else
5106 {
5107 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5108 }
5109
5110 //Save sessionId in case of timeout
5111 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5112 //This time should be long enough for the rest of the process plus setting key
5113 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5114 {
5115 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005116 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5118 }
5119 }
5120
5121 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5122 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 if(Context)
5124 {
5125 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5126 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5128 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5129#ifdef WLAN_FEATURE_VOWIFI_11R
5130 len += pJoinRsp->parsedRicRspLen;
5131#endif /* WLAN_FEATURE_VOWIFI_11R */
5132#ifdef FEATURE_WLAN_CCX
5133 len += pJoinRsp->tspecIeLen;
5134#endif
5135 if(len)
5136 {
5137 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5138 (void **)&pSession->connectedInfo.pbFrames, len)))
5139 {
5140 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5141 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5142 {
5143 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5144 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5145 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5146#ifdef WLAN_FEATURE_VOWIFI_11R
5147 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5148#endif /* WLAN_FEATURE_VOWIFI_11R */
5149#ifdef FEATURE_WLAN_CCX
5150 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5151#endif
5152 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5153 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5154 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5155 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5156 }
5157 else
5158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005159 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005160 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005161 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5162 pSession->connectedInfo.pbFrames = NULL;
5163 }
5164 }
5165 }
5166 if(pCommand->u.roamCmd.fReassoc)
5167 {
5168 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5169 }
5170 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5171 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5172 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5173 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5174 }
5175 else
5176 {
5177 if(pCommand->u.roamCmd.fReassoc)
5178 {
5179 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5180 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5181 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5182 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5183 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5184 }
5185 }
5186#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5187 // Indicate SME-QOS with reassoc success event, only after
5188 // copying the frames
5189 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 roamInfo.pBssDesc = pSirBssDesc;
5192 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5193 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5194#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5195 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5196#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5197 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5199 //It may be better to let QoS do this????
5200 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005202 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005203 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5204 pmcStartUapsd( pMac, NULL, NULL );
5205 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305206 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5208 if( pSession->bRefAssocStartCnt > 0 )
5209 {
5210 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005211 //Remove this code once SLM_Sessionization is supported
5212 //BMPS_WORKAROUND_NOT_NEEDED
5213 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005214 {
5215 pMac->roam.configParam.doBMPSWorkaround = 1;
5216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5218 }
5219
5220 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 // reset the PMKID candidate list
5222 csrResetPMKIDCandidateList( pMac, sessionId );
5223 //Update TL's AC weight base on the current EDCA parameters
5224 //These parameters may change in the course of the connection, that sictuation
5225 //is not taken care here. This change is mainly to address a WIFI WMM test where
5226 //BE has a equal or higher TX priority than VI.
5227 //We only do this for infra link
5228 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5229 {
5230 csrCheckAndUpdateACWeight(pMac, pIes);
5231 }
5232#ifdef FEATURE_WLAN_WAPI
5233 // reset the BKID candidate list
5234 csrResetBKIDCandidateList( pMac, sessionId );
5235#endif /* FEATURE_WLAN_WAPI */
5236 }
5237 else
5238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005239 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 csrScanCancelIdleScan(pMac);
5242 //Not to signal link up because keys are yet to be set.
5243 //The linkup function will overwrite the sub-state that we need to keep at this point.
5244 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5245 {
5246 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5249 //enough to let security and DHCP handshake succeed before entry into BMPS
5250 if (pmcShouldBmpsTimerRun(pMac))
5251 {
5252 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5253 != eHAL_STATUS_SUCCESS)
5254 {
5255 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5256 }
5257 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 break;
5260
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 case eCsrStartBssSuccess:
5262 // on the StartBss Response, LIM is returning the Bss Description that we
5263 // are beaconing. Add this Bss Description to our scan results and
5264 // chain the Profile to this Bss Description. On a Start BSS, there was no
5265 // detected Bss description (no partner) so we issued the Start Bss to
5266 // start the Ibss without any Bss description. Lim was kind enough to return
5267 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005268 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5272 if( CSR_IS_IBSS( pProfile ) )
5273 {
5274 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 else if (CSR_IS_INFRA_AP(pProfile))
5277 {
5278 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 else
5281 {
5282 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5283 }
5284 if( !CSR_IS_WDS_STA( pProfile ) )
5285 {
5286 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005290 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 roamInfo.pBssDesc = pSirBssDesc;
5292 //We need to associate_complete it first, becasue Associate_start already indicated.
5293 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5294 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5295 break;
5296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005299 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 }
5301 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5302 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5303 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5304 if(pSirBssDesc)
5305 {
5306 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5307 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5308 }
5309 //We are doen with the IEs so free it
5310 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005311#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5312 {
5313 vos_log_ibss_pkt_type *pIbssLog;
5314 tANI_U32 bi;
5315
5316 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5317 if(pIbssLog)
5318 {
5319 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5320 {
5321 //We start the IBSS (didn't find any matched IBSS out there)
5322 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5323 }
5324 else
5325 {
5326 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5327 }
5328 if(pSirBssDesc)
5329 {
5330 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5331 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5332 }
5333 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5334 {
5335 //***U8 is not enough for beacon interval
5336 pIbssLog->beaconInterval = (v_U8_t)bi;
5337 }
5338 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5339 }
5340 }
5341#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5342 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5343 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5345 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5347 csrRoamIssueSetContextReq( pMac, sessionId,
5348 pProfile->negotiatedMCEncryptionType,
5349 pSirBssDesc, &BroadcastMac,
5350 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5351 }
5352 }
5353 else
5354 {
5355 //Keep the state to eCSR_ROAMING_STATE_JOINING
5356 //Need to send join_req.
5357 if(pCommand->u.roamCmd.pRoamBssEntry)
5358 {
5359 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5360 {
5361 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5362 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5363 // Set the roaming substate to 'join attempt'...
5364 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005365 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 }
5367 }
5368 else
5369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005370 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 VOS_ASSERT( 0 );
5372 }
5373 }
5374 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5375 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5376 //trigger the connection start indication in Vista
5377 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5378 {
5379 roamStatus = eCSR_ROAM_IBSS_IND;
5380 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5381 if( CSR_IS_WDS( pProfile ) )
5382 {
5383 roamStatus = eCSR_ROAM_WDS_IND;
5384 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 if( CSR_IS_INFRA_AP( pProfile ) )
5387 {
5388 roamStatus = eCSR_ROAM_INFRA_IND;
5389 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005391
5392 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5393 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5394 //trigger the connection start indication in Vista
5395 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5396 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5397 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5398 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5399 {
5400 //We start the IBSS (didn't find any matched IBSS out there)
5401 roamInfo.pBssDesc = pSirBssDesc;
5402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005404 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005405 //Remove this code once SLM_Sessionization is supported
5406 //BMPS_WORKAROUND_NOT_NEEDED
5407 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005408 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005409 {
5410 pMac->roam.configParam.doBMPSWorkaround = 1;
5411 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005412
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5414 }
5415
5416 csrScanCancelIdleScan(pMac);
5417 //Only use this timer for ibss. BAP has its own timer for WDS
5418 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5419 {
5420 //start the join IBSS timer
5421 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5422 pSession->ibss_join_pending = TRUE;
5423 }
5424 if( HAL_STATUS_SUCCESS( status ) )
5425 {
5426 //Already sent join_req for the WDS station
5427 fReleaseCommand = eANI_BOOLEAN_FALSE;
5428 }
5429 else if( CSR_IS_WDS_STA( pProfile ) )
5430 {
5431 //need to send stop BSS because we fail to send join_req
5432 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5433 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5434 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 case eCsrStartBssFailure:
5438#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5439 {
5440 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5442 if(pIbssLog)
5443 {
5444 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5445 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5446 }
5447 }
5448#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 roamStatus = eCSR_ROAM_IBSS_IND;
5450 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5451 if( CSR_IS_WDS( pProfile ) )
5452 {
5453 roamStatus = eCSR_ROAM_WDS_IND;
5454 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 if( CSR_IS_INFRA_AP( pProfile ) )
5457 {
5458 roamStatus = eCSR_ROAM_INFRA_IND;
5459 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 if(Context)
5462 {
5463 pSirBssDesc = (tSirBssDescription *)Context;
5464 }
5465 else
5466 {
5467 pSirBssDesc = NULL;
5468 }
5469 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5470 roamInfo.pBssDesc = pSirBssDesc;
5471 //We need to associate_complete it first, becasue Associate_start already indicated.
5472 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5473 csrSetDefaultDot11Mode( pMac );
5474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 case eCsrSilentlyStopRoaming:
5476 // We are here because we try to start the same IBSS
5477 //No message to PE
5478 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005479 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5481 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5482 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5483 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5484 if( roamInfo.pBssDesc )
5485 {
5486 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5487 }
5488 //Since there is no change in the current state, simply pass back no result otherwise
5489 //HDD may be mistakenly mark to disconnected state.
5490 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5491 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 case eCsrSilentlyStopRoamingSaveState:
5494 //We are here because we try to connect to the same AP
5495 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005496 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5498
5499 //to aviod resetting the substate to NONE
5500 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5501 //No need to change substate to wai_for_key because there is no state change
5502 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5503 if( roamInfo.pBssDesc )
5504 {
5505 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5508 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5509 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5510 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5511 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5512 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5513 roamInfo.staId = pSession->connectedInfo.staId;
5514 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 pSession->bRefAssocStartCnt--;
5517 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5518 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5519 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5520 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 case eCsrReassocFailure:
5522#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5523 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5524#endif
5525 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005526 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 csrFreeConnectBssDesc(pMac, sessionId);
5528 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5529 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5530 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5531 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5532 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5533 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5534 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5535 eCSR_ROAM_WDS_IND,
5536 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5537 //Need to issue stop_bss
5538 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 case eCsrJoinFailure:
5540 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005541 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 default:
5543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005544 smsLog(pMac, LOGW, FL("receives no association indication"));
5545 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005546 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5548 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5549 {
5550 //do not free for the other profiles as we need to send down stop BSS later
5551 csrFreeConnectBssDesc(pMac, sessionId);
5552 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5553 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5554 csrSetDefaultDot11Mode( pMac );
5555 }
5556
5557 switch( pCommand->u.roamCmd.roamReason )
5558 {
5559 // If this transition is because of an 802.11 OID, then we transition
5560 // back to INIT state so we sit waiting for more OIDs to be issued and
5561 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005562 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 case eCsrSmeIssuedAssocToSimilarAP:
5564 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005565 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5567 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5568 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5569 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5570 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005571 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5572
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 /* Defeaturize this later if needed */
5574#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5575 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5576 if (csrRoamIsHandoffInProgress(pMac))
5577 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 /* Should indicate neighbor roam algorithm about the connect failure here */
5579 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005581#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 if(pSession->bRefAssocStartCnt > 0)
5583 {
5584 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005585 if(eCsrJoinFailureDueToConcurrency == Result)
5586 {
5587 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5588 eCSR_ROAM_ASSOCIATION_COMPLETION,
5589 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5590 }
5591 else
5592 {
5593 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 eCSR_ROAM_ASSOCIATION_COMPLETION,
5595 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005598 else
5599 {
5600 /* bRefAssocStartCnt is not incremented when
5601 * eRoamState == eCsrStopRoamingDueToConcurrency
5602 * in csrRoamJoinNextBss API. so handle this in
5603 * else case by sending assoc failure
5604 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005605 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005606 pCommand->u.scanCmd.roamId,
5607 eCSR_ROAM_ASSOCIATION_FAILURE,
5608 eCSR_ROAM_RESULT_FAILURE);
5609 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005610 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005611#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5612 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5613#endif
5614 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5615 csrScanStartIdleScan(pMac);
5616#ifdef FEATURE_WLAN_BTAMP_UT_RF
5617 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5618 //BT activity and not able to recevie WLAN traffic. Retry the join
5619 if( CSR_IS_WDS_STA(pProfile) )
5620 {
5621 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5622 }
5623#endif
5624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 case eCsrHddIssuedReassocToSameAP:
5626 case eCsrSmeIssuedReassocToSameAP:
5627 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5628
5629 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5630#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5631 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5632#endif
5633 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5634 csrScanStartIdleScan(pMac);
5635 break;
5636 case eCsrForcedDisassoc:
5637 case eCsrForcedDeauth:
5638 case eCsrSmeIssuedIbssJoinFailure:
5639 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5640
5641 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5642 {
5643 // Notify HDD that IBSS join failed
5644 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5645 }
5646 else
5647 {
5648 csrRoamCallCallback(pMac, sessionId, NULL,
5649 pCommand->u.roamCmd.roamId,
5650 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5651 }
5652#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5653 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5654#endif
5655 csrRoamLinkDown(pMac, sessionId);
5656 csrScanStartIdleScan(pMac);
5657 break;
5658 case eCsrForcedIbssLeave:
5659 csrRoamCallCallback(pMac, sessionId, NULL,
5660 pCommand->u.roamCmd.roamId,
5661 eCSR_ROAM_IBSS_LEAVE,
5662 eCSR_ROAM_RESULT_IBSS_STOP);
5663 break;
5664 case eCsrForcedDisassocMICFailure:
5665 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5666
5667 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5668#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5669 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5670#endif
5671 csrScanStartIdleScan(pMac);
5672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 case eCsrStopBss:
5674 csrRoamCallCallback(pMac, sessionId, NULL,
5675 pCommand->u.roamCmd.roamId,
5676 eCSR_ROAM_INFRA_IND,
5677 eCSR_ROAM_RESULT_INFRA_STOPPED);
5678 break;
5679 case eCsrForcedDisassocSta:
5680 case eCsrForcedDeauthSta:
5681 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5682 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5683 {
5684 pSession = CSR_GET_SESSION(pMac, sessionId);
5685 if (!pSession)
5686 break;
5687
5688 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5689 {
5690 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5691 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5692 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5693 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5694 roamInfo.statusCode = eSIR_SME_SUCCESS;
5695 status = csrRoamCallCallback(pMac, sessionId,
5696 &roamInfo, pCommand->u.roamCmd.roamId,
5697 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5698 }
5699 }
5700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 case eCsrLostLink1:
5702 // if lost link roam1 failed, then issue lost link Scan2 ...
5703 csrScanRequestLostLink2(pMac, sessionId);
5704 break;
5705 case eCsrLostLink2:
5706 // if lost link roam2 failed, then issue lost link scan3 ...
5707 csrScanRequestLostLink3(pMac, sessionId);
5708 break;
5709 case eCsrLostLink3:
5710 default:
5711 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5712
5713 //We are done with one round of lostlink roaming here
5714 csrScanHandleFailedLostlink3(pMac, sessionId);
5715 break;
5716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 break;
5718 }
5719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 return ( fReleaseCommand );
5721}
5722
Jeff Johnson295189b2012-06-20 16:38:30 -07005723eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5724{
5725 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 return (status);
5727}
5728
Jeff Johnson295189b2012-06-20 16:38:30 -07005729eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5730{
5731 eHalStatus status = eHAL_STATUS_SUCCESS;
5732 tANI_U32 size = 0;
5733
5734 do
5735 {
5736 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5737 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5738 {
5739 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5740 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5741 if(!HAL_STATUS_SUCCESS(status))
5742 {
5743 break;
5744 }
5745 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5746 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5747 }
5748 if(pSrcProfile->SSIDs.numOfSSIDs)
5749 {
5750 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5751 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5752 if(!HAL_STATUS_SUCCESS(status))
5753 {
5754 break;
5755 }
5756 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5757 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5758 }
5759 if(pSrcProfile->nWPAReqIELength)
5760 {
5761 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5762 if(!HAL_STATUS_SUCCESS(status))
5763 {
5764 break;
5765 }
5766 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5767 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5768 }
5769 if(pSrcProfile->nRSNReqIELength)
5770 {
5771 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5772 if(!HAL_STATUS_SUCCESS(status))
5773 {
5774 break;
5775 }
5776 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5777 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5778 }
5779#ifdef FEATURE_WLAN_WAPI
5780 if(pSrcProfile->nWAPIReqIELength)
5781 {
5782 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5783 if(!HAL_STATUS_SUCCESS(status))
5784 {
5785 break;
5786 }
5787 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5788 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5789 }
5790#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 if(pSrcProfile->nAddIEScanLength)
5792 {
5793 status = palAllocateMemory(pMac->hHdd,
5794 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5795 if(!HAL_STATUS_SUCCESS(status))
5796 {
5797 break;
5798 }
5799 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5800 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5801 pSrcProfile->nAddIEScanLength);
5802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 if(pSrcProfile->nAddIEAssocLength)
5804 {
5805 status = palAllocateMemory(pMac->hHdd,
5806 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5807 if(!HAL_STATUS_SUCCESS(status))
5808 {
5809 break;
5810 }
5811 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5812 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5813 pSrcProfile->nAddIEAssocLength);
5814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 if(pSrcProfile->ChannelInfo.ChannelList)
5816 {
5817 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5818 if(!HAL_STATUS_SUCCESS(status))
5819 {
5820 break;
5821 }
5822 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5823 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 pDstProfile->AuthType = pSrcProfile->AuthType;
5826 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5827 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5828 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5829 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5830 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005831#ifdef WLAN_FEATURE_11W
5832 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5833 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5834 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5835#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 pDstProfile->BSSType = pSrcProfile->BSSType;
5837 pDstProfile->phyMode = pSrcProfile->phyMode;
5838 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5839
5840#ifdef FEATURE_WLAN_WAPI
5841 if(csrIsProfileWapi(pSrcProfile))
5842 {
5843 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5844 {
5845 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5846 }
5847 }
5848#endif /* FEATURE_WLAN_WAPI */
5849 pDstProfile->CBMode = pSrcProfile->CBMode;
5850 /*Save the WPS info*/
5851 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5852 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 pDstProfile->privacy = pSrcProfile->privacy;
5855 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5856 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5857 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5858 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5859 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5860 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5861 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5862 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5863 pDstProfile->wps_state = pSrcProfile->wps_state;
5864 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005866#ifdef WLAN_FEATURE_VOWIFI_11R
5867 if (pSrcProfile->MDID.mdiePresent)
5868 {
5869 pDstProfile->MDID.mdiePresent = 1;
5870 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5871 }
5872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 }while(0);
5874
5875 if(!HAL_STATUS_SUCCESS(status))
5876 {
5877 csrReleaseProfile(pMac, pDstProfile);
5878 pDstProfile = NULL;
5879 }
5880
5881 return (status);
5882}
Jeff Johnson295189b2012-06-20 16:38:30 -07005883eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5884{
5885 eHalStatus status = eHAL_STATUS_SUCCESS;
5886 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5887 do
5888 {
5889 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5890 if(pSrcProfile->bssid)
5891 {
5892 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5893 if(!HAL_STATUS_SUCCESS(status))
5894 {
5895 break;
5896 }
5897 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5898 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5899 }
5900 if(pSrcProfile->SSID.ssId)
5901 {
5902 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5903 if(!HAL_STATUS_SUCCESS(status))
5904 {
5905 break;
5906 }
5907 pDstProfile->SSIDs.numOfSSIDs = 1;
5908 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5909 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5910 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5911 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005912 if(pSrcProfile->nAddIEAssocLength)
5913 {
5914 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5915 if(!HAL_STATUS_SUCCESS(status))
5916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005917 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005918 break;
5919 }
5920 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5921 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5922 pSrcProfile->nAddIEAssocLength);
5923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5925 if(!HAL_STATUS_SUCCESS(status))
5926 {
5927 break;
5928 }
5929 pDstProfile->ChannelInfo.numOfChannels = 1;
5930 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 pDstProfile->AuthType.numEntries = 1;
5932 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5933 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5934 pDstProfile->EncryptionType.numEntries = 1;
5935 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5936 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5937 pDstProfile->mcEncryptionType.numEntries = 1;
5938 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5939 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5940 pDstProfile->BSSType = pSrcProfile->BSSType;
5941 pDstProfile->CBMode = pSrcProfile->CBMode;
5942 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5943#ifdef WLAN_FEATURE_VOWIFI_11R
5944 if (pSrcProfile->MDID.mdiePresent)
5945 {
5946 pDstProfile->MDID.mdiePresent = 1;
5947 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5948 }
5949#endif
5950
5951 }while(0);
5952
5953 if(!HAL_STATUS_SUCCESS(status))
5954 {
5955 csrReleaseProfile(pMac, pDstProfile);
5956 pDstProfile = NULL;
5957 }
5958
5959 return (status);
5960}
5961
Jeff Johnson295189b2012-06-20 16:38:30 -07005962eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5963 tScanResultHandle hBSSList,
5964 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5965 tANI_BOOLEAN fClearScan)
5966{
5967 eHalStatus status = eHAL_STATUS_SUCCESS;
5968 tSmeCmd *pCommand;
5969
5970 pCommand = csrGetCommandBuffer(pMac);
5971 if(NULL == pCommand)
5972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005973 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 status = eHAL_STATUS_RESOURCES;
5975 }
5976 else
5977 {
5978 if( fClearScan )
5979 {
5980 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305981 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 }
5983 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5984 if(NULL == pProfile)
5985 {
5986 //We can roam now
5987 //Since pProfile is NULL, we need to build our own profile, set everything to default
5988 //We can only support open and no encryption
5989 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5990 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5991 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5992 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5993 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5994 }
5995 else
5996 {
5997 //make a copy of the profile
5998 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5999 if(HAL_STATUS_SUCCESS(status))
6000 {
6001 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6002 }
6003 }
6004 pCommand->command = eSmeCommandRoam;
6005 pCommand->sessionId = (tANI_U8)sessionId;
6006 pCommand->u.roamCmd.hBSSList = hBSSList;
6007 pCommand->u.roamCmd.roamId = roamId;
6008 pCommand->u.roamCmd.roamReason = reason;
6009 //We need to free the BssList when the command is done
6010 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6011 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6013 FL("CSR PERSONA=%d"),
6014 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6016 if( !HAL_STATUS_SUCCESS( status ) )
6017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006018 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 csrReleaseCommandRoam( pMac, pCommand );
6020 }
6021 }
6022
6023 return (status);
6024}
Jeff Johnson295189b2012-06-20 16:38:30 -07006025eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6026 tCsrRoamModifyProfileFields *pMmodProfileFields,
6027 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6028{
6029 eHalStatus status = eHAL_STATUS_SUCCESS;
6030 tSmeCmd *pCommand;
6031
6032 pCommand = csrGetCommandBuffer(pMac);
6033 if(NULL == pCommand)
6034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006035 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 status = eHAL_STATUS_RESOURCES;
6037 }
6038 else
6039 {
6040 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306041 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 if(pProfile)
6043 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 //This is likely trying to reassoc to different profile
6045 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6046 //make a copy of the profile
6047 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6048 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 }
6050 else
6051 {
6052 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6053 //how to update WPA/WPA2 info in roamProfile??
6054 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 if(HAL_STATUS_SUCCESS(status))
6057 {
6058 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6059 }
6060 pCommand->command = eSmeCommandRoam;
6061 pCommand->sessionId = (tANI_U8)sessionId;
6062 pCommand->u.roamCmd.roamId = roamId;
6063 pCommand->u.roamCmd.roamReason = reason;
6064 //We need to free the BssList when the command is done
6065 //For reassoc there is no BSS list, so the boolean set to false
6066 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6067 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6068 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6070 if( !HAL_STATUS_SUCCESS( status ) )
6071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006072 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6074 csrReleaseCommandRoam( pMac, pCommand );
6075 }
6076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 return (status);
6078}
6079
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006080eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6081 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306082// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006083{
6084 eHalStatus status = eHAL_STATUS_SUCCESS;
6085 tSmeCmd *pCommand;
6086
6087 pCommand = csrGetCommandBuffer(pMac);
6088 if(NULL == pCommand)
6089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006090 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006091 status = eHAL_STATUS_RESOURCES;
6092 }
6093 else
6094 {
6095 if(pBssDescription)
6096 {
6097 //copy over the parameters we need later
6098 pCommand->command = eSmeCommandRoam;
6099 pCommand->sessionId = (tANI_U8)sessionId;
6100 pCommand->u.roamCmd.roamReason = reason;
6101 //this is the important parameter
6102 //in this case we are using this field for the "next" BSS
6103 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6104 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6105 if( !HAL_STATUS_SUCCESS( status ) )
6106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006107 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006108 csrReleaseCommandPreauth( pMac, pCommand );
6109 }
6110 }
6111 else
6112 {
6113 //Return failure
6114 status = eHAL_STATUS_RESOURCES;
6115 }
6116 }
6117 return (status);
6118}
6119
6120eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6121{
6122 tListElem *pEntry;
6123 tSmeCmd *pCommand;
6124 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6125 if ( pEntry )
6126 {
6127 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6128 if ( (eSmeCommandRoam == pCommand->command) &&
6129 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6130 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006131 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006132 pCommand->command, pCommand->u.roamCmd.roamReason);
6133 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6134 csrReleaseCommandPreauth( pMac, pCommand );
6135 }
6136 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006137 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006138 pCommand->command, pCommand->u.roamCmd.roamReason);
6139 }
6140 }
6141 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006142 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006143 }
6144 smeProcessPendingQueue( pMac );
6145 return eHAL_STATUS_SUCCESS;
6146}
6147
Jeff Johnson295189b2012-06-20 16:38:30 -07006148eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6149 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6150{
6151 eHalStatus status = eHAL_STATUS_FAILURE;
6152 tScanResultHandle hBSSList;
6153 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6155 if(HAL_STATUS_SUCCESS(status))
6156 {
6157 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6158 if(pRoamId)
6159 {
6160 *pRoamId = roamId;
6161 }
6162 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6163 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6164 if(!HAL_STATUS_SUCCESS(status))
6165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006166 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 csrScanResultPurge(pMac, hBSSList);
6168 }
6169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 return (status);
6171}
6172
Jeff Johnson295189b2012-06-20 16:38:30 -07006173eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6174 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6175{
6176 eHalStatus status = eHAL_STATUS_SUCCESS;
6177 tScanResultHandle hBSSList;
6178 tCsrScanResultFilter *pScanFilter;
6179 tANI_U32 roamId = 0;
6180 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 if (NULL == pProfile)
6183 {
6184 smsLog(pMac, LOGP, FL("No profile specified"));
6185 return eHAL_STATUS_FAILURE;
6186 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006187 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 if( CSR_IS_WDS( pProfile ) &&
6190 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6191 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006192 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006193 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 return status;
6195 }
6196 csrRoamCancelRoaming(pMac, sessionId);
6197 csrScanRemoveFreshScanCommand(pMac, sessionId);
6198 csrScanCancelIdleScan(pMac);
6199 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306200 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6202 {
6203 csrScanDisable(pMac);
6204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6206 //Check whether ssid changes
6207 if(csrIsConnStateConnected(pMac, sessionId))
6208 {
6209 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6210 {
6211 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6212 }
6213 }
6214#ifdef FEATURE_WLAN_BTAMP_UT_RF
6215 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6216#endif
6217 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006219 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6221 if(pRoamId)
6222 {
6223 roamId = *pRoamId;
6224 }
6225 if(!HAL_STATUS_SUCCESS(status))
6226 {
6227 fCallCallback = eANI_BOOLEAN_TRUE;
6228 }
6229 }
6230 else
6231 {
6232 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6233 if(HAL_STATUS_SUCCESS(status))
6234 {
6235 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6236 //Try to connect to any BSS
6237 if(NULL == pProfile)
6238 {
6239 //No encryption
6240 pScanFilter->EncryptionType.numEntries = 1;
6241 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6242 }//we don't have a profile
6243 else
6244 {
6245 //Here is the profile we need to connect to
6246 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6247 }//We have a profile
6248 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6249 if(pRoamId)
6250 {
6251 *pRoamId = roamId;
6252 }
6253
6254 if(HAL_STATUS_SUCCESS(status))
6255 {
6256 /*Save the WPS info*/
6257 if(NULL != pProfile)
6258 {
6259 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6260 }
6261 else
6262 {
6263 pScanFilter->bWPSAssociation = 0;
6264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 do
6266 {
6267 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 )
6270 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006271 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6273 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6274 if(!HAL_STATUS_SUCCESS(status))
6275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006276 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 fCallCallback = eANI_BOOLEAN_TRUE;
6278 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006279 else
6280 {
6281 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 break;
6284 }
6285 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006286 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 if(HAL_STATUS_SUCCESS(status))
6288 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6290 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6291 if(!HAL_STATUS_SUCCESS(status))
6292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006293 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 csrScanResultPurge(pMac, hBSSList);
6295 fCallCallback = eANI_BOOLEAN_TRUE;
6296 }
6297 }//Have scan result
6298 else if(NULL != pProfile)
6299 {
6300 //Check whether it is for start ibss
6301 if(CSR_IS_START_IBSS(pProfile))
6302 {
6303 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6304 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6305 if(!HAL_STATUS_SUCCESS(status))
6306 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006307 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 fCallCallback = eANI_BOOLEAN_TRUE;
6309 }
6310 }
6311 else
6312 {
6313 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006314 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 if(!HAL_STATUS_SUCCESS(status))
6316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006317 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 fCallCallback = eANI_BOOLEAN_TRUE;
6319 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006320 else
6321 {
6322 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 }
6325 }
6326 else
6327 {
6328 fCallCallback = eANI_BOOLEAN_TRUE;
6329 }
6330 } while (0);
6331 if(NULL != pProfile)
6332 {
6333 //we need to free memory for filter if profile exists
6334 csrFreeScanFilter(pMac, pScanFilter);
6335 }
6336 }//Got the scan filter from profile
6337
6338 palFreeMemory(pMac->hHdd, pScanFilter);
6339 }//allocated memory for pScanFilter
6340 }//No Bsslist coming in
6341 //tell the caller if we fail to trigger a join request
6342 if( fCallCallback )
6343 {
6344 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6345 }
6346
6347 return (status);
6348}
Jeff Johnson295189b2012-06-20 16:38:30 -07006349eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6350 tCsrRoamModifyProfileFields modProfileFields,
6351 tANI_U32 *pRoamId)
6352{
6353 eHalStatus status = eHAL_STATUS_SUCCESS;
6354 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6355 tANI_U32 roamId = 0;
6356 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 if (NULL == pProfile)
6358 {
6359 smsLog(pMac, LOGP, FL("No profile specified"));
6360 return eHAL_STATUS_FAILURE;
6361 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006362 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 -07006363 csrRoamCancelRoaming(pMac, sessionId);
6364 csrScanRemoveFreshScanCommand(pMac, sessionId);
6365 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306366 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 if(csrIsConnStateConnected(pMac, sessionId))
6369 {
6370 if(pProfile)
6371 {
6372 if(pProfile->SSIDs.numOfSSIDs &&
6373 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6374 {
6375 fCallCallback = eANI_BOOLEAN_FALSE;
6376 }
6377 else
6378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006379 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006380 }
6381 }
6382 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6383 &pSession->connectedProfile.modifyProfileFields,
6384 sizeof(tCsrRoamModifyProfileFields)))
6385 {
6386 fCallCallback = eANI_BOOLEAN_FALSE;
6387 }
6388 else
6389 {
6390 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006391 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 }
6393 }
6394 else
6395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006396 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 if(!fCallCallback)
6399 {
6400 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6401 if(pRoamId)
6402 {
6403 *pRoamId = roamId;
6404 }
6405
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6407 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 }
6409 else
6410 {
6411 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6412 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 return status;
6415}
Jeff Johnson295189b2012-06-20 16:38:30 -07006416eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6417{
6418 eHalStatus status = eHAL_STATUS_FAILURE;
6419 tScanResultHandle hBSSList = NULL;
6420 tCsrScanResultFilter *pScanFilter = NULL;
6421 tANI_U32 roamId;
6422 tCsrRoamProfile *pProfile = NULL;
6423 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006424
6425 if(!pSession)
6426 {
6427 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6428 return eHAL_STATUS_FAILURE;
6429 }
6430
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 do
6432 {
6433 if(pSession->pCurRoamProfile)
6434 {
6435 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306436 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6438 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6439 if(!HAL_STATUS_SUCCESS(status))
6440 break;
6441 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6442 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6443 if(!HAL_STATUS_SUCCESS(status))
6444 break;
6445 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6446 if(!HAL_STATUS_SUCCESS(status))
6447 {
6448 break;
6449 }
6450 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6451 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6452 if(!HAL_STATUS_SUCCESS(status))
6453 {
6454 break;
6455 }
6456 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6457 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6458 if(HAL_STATUS_SUCCESS(status))
6459 {
6460 //we want to put the last connected BSS to the very beginning, if possible
6461 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6462 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6463 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6464 if(!HAL_STATUS_SUCCESS(status))
6465 {
6466 csrScanResultPurge(pMac, hBSSList);
6467 break;
6468 }
6469 }
6470 else
6471 {
6472 //Do a scan on this profile
6473 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006474 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 if(!HAL_STATUS_SUCCESS(status))
6476 {
6477 break;
6478 }
6479 }
6480 }//We have a profile
6481 else
6482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006483 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 break;
6485 }
6486 }while(0);
6487 if(pScanFilter)
6488 {
6489 csrFreeScanFilter(pMac, pScanFilter);
6490 palFreeMemory(pMac->hHdd, pScanFilter);
6491 }
6492 if(NULL != pProfile)
6493 {
6494 csrReleaseProfile(pMac, pProfile);
6495 palFreeMemory(pMac->hHdd, pProfile);
6496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 return (status);
6498}
Jeff Johnson295189b2012-06-20 16:38:30 -07006499eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6500{
6501 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 if(csrIsConnStateConnected(pMac, sessionId))
6503 {
6504 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6505 if(HAL_STATUS_SUCCESS(status))
6506 {
6507 status = csrRoamJoinLastProfile(pMac, sessionId);
6508 }
6509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 return (status);
6511}
6512
Jeff Johnson295189b2012-06-20 16:38:30 -07006513eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6514{
6515 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006516 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006517 csrRoamCancelRoaming(pMac, sessionId);
6518 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6519 if(csrIsConnStateDisconnected(pMac, sessionId))
6520 {
6521 status = csrRoamJoinLastProfile(pMac, sessionId);
6522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 return (status);
6524}
6525
Jeff Johnson295189b2012-06-20 16:38:30 -07006526eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6527{
6528 eHalStatus status = eHAL_STATUS_SUCCESS;
6529 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6530 eCsrRoamSubState NewSubstate;
6531 tANI_U32 sessionId = pCommand->sessionId;
6532
6533 // change state to 'Roaming'...
6534 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6535
6536 if ( csrIsConnStateIbss( pMac, sessionId ) )
6537 {
6538 // If we are in an IBSS, then stop the IBSS...
6539 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6540 fComplete = (!HAL_STATUS_SUCCESS(status));
6541 }
6542 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006544 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 -07006545 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6546 //Restore AC weight in case we change it
6547 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6548 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6549 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6550 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6551 {
6552 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6553 }
6554 if( fDisassoc )
6555 {
6556 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6557 }
6558 else
6559 {
6560 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6561 }
6562 fComplete = (!HAL_STATUS_SUCCESS(status));
6563 }
6564 else if ( csrIsConnStateWds( pMac, sessionId ) )
6565 {
6566 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6567 {
6568 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6569 fComplete = (!HAL_STATUS_SUCCESS(status));
6570 }
6571 //This has to be WDS station
6572 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6573 {
6574
6575 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6576 if( fDisassoc )
6577 {
6578 status = csrRoamIssueDisassociate( pMac, sessionId,
6579 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6580 fComplete = (!HAL_STATUS_SUCCESS(status));
6581 }
6582 }
6583 } else {
6584 // we got a dis-assoc request while not connected to any peer
6585 // just complete the command
6586 fComplete = eANI_BOOLEAN_TRUE;
6587 status = eHAL_STATUS_FAILURE;
6588 }
6589 if(fComplete)
6590 {
6591 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6592 }
6593
6594 if(HAL_STATUS_SUCCESS(status))
6595 {
6596 if ( csrIsConnStateInfra( pMac, sessionId ) )
6597 {
6598 //Set the state to disconnect here
6599 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6600 }
6601 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006602 else
6603 {
6604 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 return (status);
6607}
6608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609/* This is been removed from latest code base */
6610/*
6611static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6612{
6613 eHalStatus status;
6614 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6616 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 return ( status );
6618}
6619*/
6620
Jeff Johnson295189b2012-06-20 16:38:30 -07006621eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6622{
6623 eHalStatus status = eHAL_STATUS_SUCCESS;
6624 tSmeCmd *pCommand;
6625 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 do
6627 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006628 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 pCommand = csrGetCommandBuffer( pMac );
6630 if ( !pCommand )
6631 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006632 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 status = eHAL_STATUS_RESOURCES;
6634 break;
6635 }
6636 //Change the substate in case it is wait-for-key
6637 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6638 {
6639 csrRoamStopWaitForKeyTimer( pMac );
6640 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6641 }
6642 pCommand->command = eSmeCommandRoam;
6643 pCommand->sessionId = (tANI_U8)sessionId;
6644 switch ( reason )
6645 {
6646 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6647 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6648 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 case eCSR_DISCONNECT_REASON_DEAUTH:
6650 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 case eCSR_DISCONNECT_REASON_HANDOFF:
6653 fHighPriority = eANI_BOOLEAN_TRUE;
6654 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6655 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6657 case eCSR_DISCONNECT_REASON_DISASSOC:
6658 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6659 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6661 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6662 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6664 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6665 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 default:
6667 break;
6668 }
6669 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6670 if( !HAL_STATUS_SUCCESS( status ) )
6671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006672 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 csrReleaseCommandRoam( pMac, pCommand );
6674 }
6675 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 return( status );
6677}
6678
Jeff Johnson295189b2012-06-20 16:38:30 -07006679eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6680{
6681 eHalStatus status = eHAL_STATUS_SUCCESS;
6682 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 pCommand = csrGetCommandBuffer( pMac );
6684 if ( NULL != pCommand )
6685 {
6686 //Change the substate in case it is wait-for-key
6687 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6688 {
6689 csrRoamStopWaitForKeyTimer( pMac );
6690 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6691 }
6692 pCommand->command = eSmeCommandRoam;
6693 pCommand->sessionId = (tANI_U8)sessionId;
6694 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6695 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6696 if( !HAL_STATUS_SUCCESS( status ) )
6697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006698 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 csrReleaseCommandRoam( pMac, pCommand );
6700 }
6701 }
6702 else
6703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006704 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 status = eHAL_STATUS_RESOURCES;
6706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 return ( status );
6708}
6709
Jeff Johnson295189b2012-06-20 16:38:30 -07006710eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6711{
6712 eHalStatus status = eHAL_STATUS_SUCCESS;
6713 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006714
6715 if(!pSession)
6716 {
6717 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6718 return eHAL_STATUS_FAILURE;
6719 }
6720
Jeff Johnson295189b2012-06-20 16:38:30 -07006721#ifdef FEATURE_WLAN_BTAMP_UT_RF
6722 //Stop te retry
6723 pSession->maxRetryCount = 0;
6724 csrRoamStopJoinRetryTimer(pMac, sessionId);
6725#endif
6726 //Not to call cancel roaming here
6727 //Only issue disconnect when necessary
6728 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6729 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6730 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6731
6732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006733 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 return (status);
6737}
6738
Jeff Johnson295189b2012-06-20 16:38:30 -07006739eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6740{
6741 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006742
6743 if(!pSession)
6744 {
6745 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6746 return eHAL_STATUS_FAILURE;
6747 }
6748
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 csrRoamCancelRoaming(pMac, sessionId);
6750 pSession->ibss_join_pending = FALSE;
6751 csrRoamStopIbssJoinTimer(pMac, sessionId);
6752 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6753
6754 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6755}
6756
Jeff Johnson295189b2012-06-20 16:38:30 -07006757eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6758 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6759{
6760 eHalStatus status = eHAL_STATUS_SUCCESS;
6761 tDot11fBeaconIEs *pIesTemp = pIes;
6762 tANI_U8 index;
6763 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6764 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006765
6766 if(!pSession)
6767 {
6768 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6769 return eHAL_STATUS_FAILURE;
6770 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006771
6772 if(pConnectProfile->pAddIEAssoc)
6773 {
6774 palFreeMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc);
6775 pConnectProfile->pAddIEAssoc = NULL;
6776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6778 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6779 pConnectProfile->AuthInfo = pProfile->AuthType;
6780 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6781 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6782 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6783 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6784 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6785 pConnectProfile->BSSType = pProfile->BSSType;
6786 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6787 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006788 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6789
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006791
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006792 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6793 if(pProfile->nAddIEAssocLength)
6794 {
6795 status = palAllocateMemory(pMac->hHdd,
6796 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6797 if(!HAL_STATUS_SUCCESS(status))
6798 {
6799 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6800 return eHAL_STATUS_FAILURE;
6801 }
6802 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6803 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6804 pProfile->nAddIEAssocLength);
6805 }
6806
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 //Save bssid
6808 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6809#ifdef WLAN_FEATURE_VOWIFI_11R
6810 if (pSirBssDesc->mdiePresent)
6811 {
6812 pConnectProfile->MDID.mdiePresent = 1;
6813 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6814 }
6815#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006816 if( NULL == pIesTemp )
6817 {
6818 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006820#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006821 if ((csrIsProfileCCX(pProfile) ||
6822 ((pIesTemp->CCXVersion.present)
6823 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6824 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6825 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6826 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006827#ifdef WLAN_FEATURE_11W
6828 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6829#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306830 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006831 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 {
6833 pConnectProfile->isCCXAssoc = 1;
6834 }
6835#endif
6836 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 if(HAL_STATUS_SUCCESS(status))
6838 {
6839 if(pIesTemp->SSID.present)
6840 {
6841 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6842 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6843 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6844 }
6845
6846 //Save the bss desc
6847 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306848
6849 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306851 //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 -07006852 pConnectProfile->qap = TRUE;
6853 }
6854 else
6855 {
6856 pConnectProfile->qap = FALSE;
6857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 if ( NULL == pIes )
6859 {
6860 //Free memory if it allocated locally
6861 palFreeMemory(pMac->hHdd, pIesTemp);
6862 }
6863 }
6864 //Save Qos connection
6865 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6866
6867 if(!HAL_STATUS_SUCCESS(status))
6868 {
6869 csrFreeConnectBssDesc(pMac, sessionId);
6870 }
6871 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6872 {
6873 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6874 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6875 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6876 {
6877 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6878 break;
6879 }
6880 pConnectProfile->handoffPermitted = FALSE;
6881 }
6882
6883 return (status);
6884}
6885
Jeff Johnson295189b2012-06-20 16:38:30 -07006886static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6887{
6888 tListElem *pEntry = NULL;
6889 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 //The head of the active list is the request we sent
6891 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6892 if(pEntry)
6893 {
6894 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6897 {
6898 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6899 {
6900#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6901 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6902#endif
6903 }
6904 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6905 }
6906 else
6907 {
6908 tANI_U32 roamId = 0;
6909 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006910 if(!pSession)
6911 {
6912 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6913 return;
6914 }
6915
Jeff Johnson295189b2012-06-20 16:38:30 -07006916
6917 //The head of the active list is the request we sent
6918 //Try to get back the same profile and roam again
6919 if(pCommand)
6920 {
6921 roamId = pCommand->u.roamCmd.roamId;
6922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6924 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006925 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006926#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6927 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6928 if (csrRoamIsHandoffInProgress(pMac))
6929 {
6930 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6931 /* Should indicate neighbor roam algorithm about the connect failure here */
6932 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6933 }
6934#endif
6935 if (pCommand)
6936 {
6937 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6938 {
6939 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6940 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6941 csrRoamReissueRoamCommand(pMac);
6942 }
6943 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6944 {
6945 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6946 }
6947 else
6948 {
6949 csrRoam(pMac, pCommand);
6950 }
6951 }
6952 else
6953 {
6954 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6955 }
6956 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6957}
6958
Jeff Johnson295189b2012-06-20 16:38:30 -07006959eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6960 tDot11fBeaconIEs *pIes,
6961 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6962{
6963 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006964 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6966 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6967
6968 // Set the roaming substate to 'join attempt'...
6969 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006971 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 return (status);
6973}
6974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6976 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6977{
6978 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 // Set the roaming substate to 'join attempt'...
6980 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6981
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006982 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006983
6984 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006985 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006986}
6987
Jeff Johnson295189b2012-06-20 16:38:30 -07006988void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6989{
6990 tListElem *pEntry;
6991 tSmeCmd *pCommand;
6992 tCsrRoamInfo roamInfo;
6993 tANI_U32 sessionId;
6994 tCsrRoamSession *pSession;
6995
6996 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6997 if(pEntry)
6998 {
6999 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7000 if ( eSmeCommandRoam == pCommand->command )
7001 {
7002 sessionId = pCommand->sessionId;
7003 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007004
7005 if(!pSession)
7006 {
7007 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7008 return;
7009 }
7010
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 if( pCommand->u.roamCmd.fStopWds )
7012 {
7013 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7014 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7015 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7016 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7019 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7020 eCSR_ROAM_WDS_IND,
7021 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7023 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7024 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7025 eCSR_ROAM_INFRA_IND,
7026 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7027 }
7028
Jeff Johnson295189b2012-06-20 16:38:30 -07007029
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007032 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7034 }
7035 }
7036 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007038 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7040 }
7041 }
7042 else
7043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007044 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 }
7046 }
7047 else
7048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007049 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 }
7051}
7052
Jeff Johnson295189b2012-06-20 16:38:30 -07007053tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7054{
7055 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7056 tListElem *pEntry;
7057 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 //alwasy lock active list before locking pending list
7059 csrLLLock( &pMac->sme.smeCmdActiveList );
7060 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7061 if(pEntry)
7062 {
7063 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7064 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7065 {
7066 fRet = eANI_BOOLEAN_TRUE;
7067 }
7068 }
7069 if(eANI_BOOLEAN_FALSE == fRet)
7070 {
7071 csrLLLock(&pMac->sme.smeCmdPendingList);
7072 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7073 while(pEntry)
7074 {
7075 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7076 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7077 {
7078 fRet = eANI_BOOLEAN_TRUE;
7079 break;
7080 }
7081 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7082 }
7083 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7084 }
7085 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 return (fRet);
7087}
7088
Jeff Johnson295189b2012-06-20 16:38:30 -07007089tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7090{
7091 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7092 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7094 {
7095 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7096 {
7097 break;
7098 }
7099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 return ( fRet );
7101}
7102
Jeff Johnson295189b2012-06-20 16:38:30 -07007103tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7104{
7105 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 //alwasy lock active list before locking pending list
7107 csrLLLock( &pMac->sme.smeCmdActiveList );
7108 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7109 if(eANI_BOOLEAN_FALSE == fRet)
7110 {
7111 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7112 }
7113 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 return (fRet);
7115}
7116
Jeff Johnson295189b2012-06-20 16:38:30 -07007117tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7118{
7119 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7120 tListElem *pEntry;
7121 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 //alwasy lock active list before locking pending list
7123 csrLLLock( &pMac->sme.smeCmdActiveList );
7124 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7125 if( pEntry )
7126 {
7127 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7128 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7129 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7130 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7131 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7132 {
7133 fRet = eANI_BOOLEAN_TRUE;
7134 }
7135 }
7136 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 return (fRet);
7138}
Jeff Johnson295189b2012-06-20 16:38:30 -07007139eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7140{
7141 eHalStatus status = eHAL_STATUS_SUCCESS;
7142 tSmeCmd *pCommand = NULL;
7143 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7144 tANI_BOOLEAN fRemoveCmd = FALSE;
7145 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 // Delete the old assoc command. All is setup for reassoc to be serialized
7147 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7148 if ( pEntry )
7149 {
7150 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7151 if ( !pCommand )
7152 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007153 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 return eHAL_STATUS_RESOURCES;
7155 }
7156 if ( eSmeCommandRoam == pCommand->command )
7157 {
7158 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7159 {
7160 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7161 }
7162 else
7163 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007164 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 }
7166 if (fRemoveCmd == FALSE)
7167 {
7168 // Implies we did not get the serialized assoc command we
7169 // were expecting
7170 pCommand = NULL;
7171 }
7172 }
7173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 if(NULL == pCommand)
7175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007176 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 return eHAL_STATUS_RESOURCES;
7178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 do
7180 {
7181 //Change the substate in case it is wait-for-key
7182 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7183 {
7184 csrRoamStopWaitForKeyTimer( pMac );
7185 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7186 }
7187 pCommand->command = eSmeCommandRoam;
7188 pCommand->sessionId = (tANI_U8)sessionId;
7189 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7191 if( !HAL_STATUS_SUCCESS( status ) )
7192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007193 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 csrReleaseCommandRoam( pMac, pCommand );
7195 }
7196 } while( 0 );
7197
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 return( status );
7199}
7200static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7201{
7202 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7203 tCsrScanResult *pScanResult = NULL;
7204 tSirBssDescription *pBssDesc = NULL;
7205 tSmeCmd *pCommand = NULL;
7206 tANI_U32 sessionId;
7207 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 if(NULL == pEntry)
7209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007210 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 return;
7212 }
7213 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7214 sessionId = pCommand->sessionId;
7215 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007216
7217 if(!pSession)
7218 {
7219 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7220 return;
7221 }
7222
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7224 {
7225 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007226 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7228 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007229 /* If the roaming has stopped, not to continue the roaming command*/
7230 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7231 {
7232 //No need to complete roaming here as it already completes
7233 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7234 pCommand->u.roamCmd.roamReason);
7235 csrSetAbortRoamingCommand( pMac, pCommand );
7236 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 else
7239 {
7240 if ( CCM_IS_RESULT_SUCCESS(result) )
7241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007242 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 // Successfully set the configuration parameters for the new Bss. Attempt to
7244 // join the roaming Bss.
7245 if(pCommand->u.roamCmd.pRoamBssEntry)
7246 {
7247 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7248 pBssDesc = &pScanResult->Result.BssDescriptor;
7249 }
7250 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7251 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 )
7254 {
7255 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7256 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7257 pBssDesc, pCommand->u.roamCmd.roamId )))
7258 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007259 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 //We need to complete the command
7261 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7262 }
7263 }
7264 else
7265 {
7266 if (!pCommand->u.roamCmd.pRoamBssEntry)
7267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007268 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 //We need to complete the command
7270 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7271 return;
7272 }
7273 // If we are roaming TO an Infrastructure BSS...
7274 VOS_ASSERT(pScanResult != NULL);
7275 if ( csrIsInfraBssDesc( pBssDesc ) )
7276 {
7277 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7279 {
7280 // ..and currently in an Infrastructure connection....
7281 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7282 {
7283 // ...and the SSIDs are equal, then we Reassoc.
7284 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7285 pIesLocal ) )
7286 // ..and currently in an infrastructure connection
7287 {
7288 // then issue a Reassoc.
7289 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7290 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7291 &pCommand->u.roamCmd.roamProfile );
7292 }
7293 else
7294 {
7295
7296 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7297 // previously associated AP.
7298 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7299 pIesLocal,
7300 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7301 {
7302 //try something else
7303 csrRoam( pMac, pCommand );
7304 }
7305 }
7306 }
7307 else
7308 {
7309 eHalStatus status = eHAL_STATUS_SUCCESS;
7310
7311 /* We need to come with other way to figure out that this is because of HO in BMP
7312 The below API will be only available for Android as it uses a different HO algorithm */
7313 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7314 * use join request */
7315#ifdef WLAN_FEATURE_VOWIFI_11R
7316 if (csrRoamIsHandoffInProgress(pMac) &&
7317 csrRoamIs11rAssoc(pMac))
7318 {
7319 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7320 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7321 }
7322 else
7323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007324#ifdef FEATURE_WLAN_CCX
7325 if (csrRoamIsHandoffInProgress(pMac) &&
7326 csrRoamIsCCXAssoc(pMac))
7327 {
7328 // Now serialize the reassoc command.
7329 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7330 }
7331 else
7332#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007333#ifdef FEATURE_WLAN_LFR
7334 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307335 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007336 {
7337 // Now serialize the reassoc command.
7338 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7339 }
7340 else
7341#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 // else we are not connected and attempting to Join. Issue the
7343 // Join request.
7344 {
7345 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7346 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7347 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7348 }
7349 if(!HAL_STATUS_SUCCESS(status))
7350 {
7351 //try something else
7352 csrRoam( pMac, pCommand );
7353 }
7354 }
7355 if( !pScanResult->Result.pvIes )
7356 {
7357 //Locally allocated
7358 palFreeMemory(pMac->hHdd, pIesLocal);
7359 }
7360 }
7361 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7362 else
7363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007364 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 }
7366 }//else
7367 }//if ( WNI_CFG_SUCCESS == result )
7368 else
7369 {
7370 // In the event the configuration failed, for infra let the roam processor
7371 //attempt to join something else...
7372 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7373 {
7374 csrRoam(pMac, pCommand);
7375 }
7376 else
7377 {
7378 //We need to complete the command
7379 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7380 {
7381 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7382 }
7383 else
7384 {
7385 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7386 }
7387 }
7388 }
7389 }//we have active entry
7390}
7391
Jeff Johnson295189b2012-06-20 16:38:30 -07007392static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7393{
7394 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007395 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007398 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7400 // join the new one...
7401 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7403 }
7404 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007405 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 /***profHandleLostLinkAfterReset(pAdapter);
7407 // In the event the authenticate fails, let the roam processor attempt to join something else...
7408 roamRoam( pAdapter );***/
7409 }
7410}
7411
Jeff Johnson295189b2012-06-20 16:38:30 -07007412static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7413{
7414 eCsrRoamCompleteResult result;
7415 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7416 tCsrRoamInfo roamInfo;
7417 tANI_U32 roamId = 0;
7418
7419 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007421 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007422 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 /* Defeaturize this part later if needed */
7424#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7425 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7426 * we need the response contents while processing the result in csrRoamProcessResults() */
7427 if (csrRoamIsHandoffInProgress(pMac))
7428 {
7429 /* Need to dig more on indicating events to SME QoS module */
7430 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7431 csrRoamComplete( pMac, result, pSmeJoinRsp);
7432 }
7433 else
7434#endif
7435 {
7436 csrRoamComplete( pMac, result, NULL );
7437 }
7438 }
7439 /* Should we handle this similar to handling the join failure? Is it ok
7440 * to call csrRoamComplete() with state as CsrJoinFailure */
7441 else
7442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007443 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 result = eCsrReassocFailure;
7445#ifdef WLAN_FEATURE_VOWIFI_11R
7446 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7447 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7448 {
7449 // Inform HDD to turn off FT flag in HDD
7450 if (pNeighborRoamInfo)
7451 {
7452 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7453 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7454 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007455 /*
7456 * Since the above callback sends a disconnect
7457 * to HDD, we should clean-up our state
7458 * machine as well to be in sync with the upper
7459 * layers. There is no need to send a disassoc
7460 * since: 1) we will never reassoc to the current
7461 * AP in LFR, and 2) there is no need to issue a
7462 * disassoc to the AP with which we were trying
7463 * to reassoc.
7464 */
7465 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7466 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 }
7468 }
7469#endif
7470 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7471 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7472 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7473 //The disassoc rsp message will remove the command from active list
7474 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7475 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7476 {
7477 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7478 }
7479 }
7480}
7481
Jeff Johnson295189b2012-06-20 16:38:30 -07007482static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7483{
Jeff Johnson295189b2012-06-20 16:38:30 -07007484#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7485 {
7486 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7488 if(pIbssLog)
7489 {
7490 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7491 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7492 {
7493 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7494 }
7495 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7496 }
7497 }
7498#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007499 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7500 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7501 {
7502 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7503 }
7504 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7505 {
7506 csrRoamReissueRoamCommand(pMac);
7507 }
7508}
7509
Jeff Johnson295189b2012-06-20 16:38:30 -07007510void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7511{
7512 tSirResultCodes statusCode;
7513#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7514 tScanResultHandle hBSSList;
7515 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7516 eHalStatus status;
7517 tCsrRoamInfo roamInfo;
7518 tCsrScanResultFilter *pScanFilter = NULL;
7519 tANI_U32 roamId = 0;
7520 tCsrRoamProfile *pCurRoamProfile = NULL;
7521 tListElem *pEntry = NULL;
7522 tSmeCmd *pCommand = NULL;
7523#endif
7524 tANI_U32 sessionId;
7525 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007526
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 tSirSmeDisassocRsp SmeDisassocRsp;
7528
7529 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7530 sessionId = SmeDisassocRsp.sessionId;
7531 statusCode = SmeDisassocRsp.statusCode;
7532
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007533 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007534
7535 if ( csrIsConnStateInfra( pMac, sessionId ) )
7536 {
7537 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007540
7541 if(!pSession)
7542 {
7543 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7544 return;
7545 }
7546
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7548 {
7549 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7550 }
7551 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7552 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7553 {
7554 if ( eSIR_SME_SUCCESS == statusCode )
7555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007556 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7558 }
7559 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007563 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007564#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007565 /*
7566 * First ensure if the roam profile is in the scan cache.
7567 * If not, post a reassoc failure and disconnect.
7568 */
7569 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7570 if(HAL_STATUS_SUCCESS(status))
7571 {
7572 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7573 status = csrRoamPrepareFilterFromProfile(pMac,
7574 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7575 if(!HAL_STATUS_SUCCESS(status))
7576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007577 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007578 __func__, status);
7579 goto POST_ROAM_FAILURE;
7580 }
7581 else
7582 {
7583 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7584 if (!HAL_STATUS_SUCCESS(status))
7585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007586 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007587 __func__, status);
7588 goto POST_ROAM_FAILURE;
7589 }
7590 }
7591 }
7592 else
7593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007594 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007595 __func__, status);
7596 goto POST_ROAM_FAILURE;
7597 }
7598
7599 /*
7600 * After ensuring that the roam profile is in the scan result list,
7601 * dequeue the command from the active list.
7602 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7604 if ( pEntry )
7605 {
7606 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007607 /* If the head of the queue is Active and it is a ROAM command, remove
7608 * and put this on the Free queue.
7609 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 if ( eSmeCommandRoam == pCommand->command )
7611 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007612
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007613 /*
7614 * we need to process the result first before removing it from active list
7615 * because state changes still happening insides roamQProcessRoamResults so
7616 * no other roam command should be issued.
7617 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7619 if(pCommand->u.roamCmd.fReleaseProfile)
7620 {
7621 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7622 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007626 else
7627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007628 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007629 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 }
7631 }
7632 else
7633 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007634 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007635 }
7636 }
7637 else
7638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007639 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007641
7642 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7644
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007645 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7646 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7647 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007648
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007649 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7650 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007651
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007652 /* Copy the connected profile to apply the same for this connection as well */
7653 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7654 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007656 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7657 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7658 //make sure to put it at the head of the cmd queue
7659 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7660 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7661 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7662
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 if(!HAL_STATUS_SUCCESS(status))
7664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007665 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007666 __func__, status);
7667 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 }
7669
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007670 /* Notify sub-modules like QoS etc. that handoff happening */
7671 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007672 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007673 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 csrFreeScanFilter(pMac, pScanFilter);
7675 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007676 return;
7677 }
7678
7679POST_ROAM_FAILURE:
7680 if (pScanFilter)
7681 {
7682 csrFreeScanFilter(pMac, pScanFilter);
7683 palFreeMemory( pMac->hHdd, pScanFilter );
7684 }
7685 if (pCurRoamProfile)
7686 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7687
7688 /* Inform the upper layers that the reassoc failed */
7689 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7690 csrRoamCallCallback(pMac, sessionId,
7691 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7692
7693 /*
7694 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7695 * Upon success, we would re-enter this routine after receiving the disassoc
7696 * response and will fall into the reassoc fail sub-state. And, eventually
7697 * call csrRoamComplete which would remove the roam command from SME active
7698 * queue.
7699 */
7700 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7701 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007703 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007704 __func__, status);
7705 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007707#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007708
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7710 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7711 {
7712 // Disassoc due to Reassoc failure falls into this codepath....
7713 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7714 }
7715 else
7716 {
7717 if ( eSIR_SME_SUCCESS == statusCode )
7718 {
7719 // Successfully disassociated from the 'old' Bss...
7720 //
7721 // We get Disassociate response in three conditions.
7722 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7723 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7724 // Infrastructure network.
7725 // - Third is where we are doing an Infra to Infra roam between networks with different
7726 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7727
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007728 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007729 }
7730 else
7731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007732 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007733 }
7734 //We are not done yet. Get the data and continue roaming
7735 csrRoamReissueRoamCommand(pMac);
7736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007737}
7738
Jeff Johnson295189b2012-06-20 16:38:30 -07007739static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7740{
7741 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007743 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7745 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7746 {
7747 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7748 }
7749 else
7750 {
7751 if ( eSIR_SME_SUCCESS == statusCode )
7752 {
7753 // Successfully deauth from the 'old' Bss...
7754 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007755 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 }
7757 else
7758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007759 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 }
7761 //We are not done yet. Get the data and continue roaming
7762 csrRoamReissueRoamCommand(pMac);
7763 }
7764}
7765
Jeff Johnson295189b2012-06-20 16:38:30 -07007766static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7767{
7768 eCsrRoamCompleteResult result;
7769
7770 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007772 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007773 result = eCsrStartBssSuccess;
7774 }
7775 else
7776 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007777 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 //Let csrRoamComplete decide what to do
7779 result = eCsrStartBssFailure;
7780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007782}
7783
Jeff Johnson295189b2012-06-20 16:38:30 -07007784/*
7785 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7786 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7787 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7788 For the messages where sender allocates memory for specific structures, then it can be
7789 cast accordingly.
7790*/
7791void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7792{
7793 tSirSmeRsp *pSmeRsp;
7794 tSmeIbssPeerInd *pIbssPeerInd;
7795 tCsrRoamInfo roamInfo;
7796 // TODO Session Id need to be acquired in this function
7797 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007799 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 pSmeRsp->messageType, pSmeRsp->messageType,
7801 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007802 pSmeRsp->messageType = (pSmeRsp->messageType);
7803 pSmeRsp->length = (pSmeRsp->length);
7804 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 switch (pSmeRsp->messageType)
7806 {
7807
7808 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7809 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7810 {
7811 //We sent a JOIN_REQ
7812 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7813 }
7814 break;
7815
7816 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7817 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7818 {
7819 //We sent a AUTH_REQ
7820 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7821 }
7822 break;
7823
7824 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7825 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7826 {
7827 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7828 }
7829 break;
7830
7831 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7832 {
7833 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7834 }
7835 break;
7836
7837 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7838 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7839 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7840 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7841 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7842 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7843//HO
7844 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007846 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007847 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7848 }
7849 break;
7850
7851 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7852 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7853 {
7854 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7855 }
7856 break;
7857
7858 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7859 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7860 {
7861 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7862 }
7863 break;
7864
7865 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7866 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7867 {
7868 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7872 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7873 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007874 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7876 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7877 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7878 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7879 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7880 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7881 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7882 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7883 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007885 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 pSmeRsp->messageType, pSmeRsp->messageType,
7887 pMac->roam.curSubState[pSmeRsp->sessionId] );
7888
7889 //If we are connected, check the link status change
7890 if(!csrIsConnStateDisconnected(pMac, sessionId))
7891 {
7892 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7893 }
7894 break;
7895 }
7896}
7897
Jeff Johnson295189b2012-06-20 16:38:30 -07007898void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7899{
7900 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 switch (pSirMsg->messageType)
7902 {
7903 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007904 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007905 csrRoamStatsRspProcessor( pMac, pSirMsg );
7906 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7908 {
7909 tCsrRoamSession *pSession;
7910 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7911 tCsrRoamInfo roamInfo;
7912 tCsrRoamInfo *pRoamInfo = NULL;
7913 tANI_U32 sessionId;
7914 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007915 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7917 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7919 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7920 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007921
7922 if(!pSession)
7923 {
7924 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7925 return;
7926 }
7927
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7929 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007930 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7931 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7932 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7934 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7936 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7939 {
7940 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7941 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7942 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7943 }
7944 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7945 {
7946 vos_sleep( 100 );
7947 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7948 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7949 }
7950
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 }
7952 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 default:
7954 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7955 break;
7956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007957}
7958
Jeff Johnson295189b2012-06-20 16:38:30 -07007959eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7960 tSirBssDescription *pBssDescription,
7961 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7962 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7963 tANI_U8 keyId, tANI_U16 keyLength,
7964 tANI_U8 *pKey, tANI_U8 paeRole )
7965{
7966 eHalStatus status = eHAL_STATUS_SUCCESS;
7967 tAniEdType edType;
7968
7969 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7970 {
7971 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7972 }
7973
7974 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7975
7976 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7977 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7978 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7979 addKey )
7980 {
7981 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 setKey.encType = EncryptType;
7983 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7984 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7985 setKey.paeRole = paeRole; //0 for supplicant
7986 setKey.keyId = keyId; // Kye index
7987 setKey.keyLength = keyLength;
7988 if( keyLength )
7989 {
7990 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7991 }
7992 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 return (status);
7995}
7996
Jeff Johnson295189b2012-06-20 16:38:30 -07007997static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7998 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7999{
8000 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8001 tSmeCmd *pCommand = NULL;
8002#ifdef FEATURE_WLAN_CCX
8003 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8004#endif /* FEATURE_WLAN_CCX */
8005
8006 do
8007 {
8008 pCommand = csrGetCommandBuffer(pMac);
8009 if(NULL == pCommand)
8010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008011 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 status = eHAL_STATUS_RESOURCES;
8013 break;
8014 }
8015 pCommand->command = eSmeCommandSetKey;
8016 pCommand->sessionId = (tANI_U8)sessionId;
8017 // validate the key length, Adjust if too long...
8018 // for static WEP the keys are not set thru' SetContextReq
8019 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8020 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8021 {
8022 //KeyLength maybe 0 for static WEP
8023 if( pSetKey->keyLength )
8024 {
8025 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008027 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 break;
8029 }
8030
8031 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
8032 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
8033 }
8034 }
8035 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8036 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8037 {
8038 //KeyLength maybe 0 for static WEP
8039 if( pSetKey->keyLength )
8040 {
8041 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008043 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 break;
8045 }
8046
8047 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8048 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8049 }
8050 }
8051 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8052 {
8053 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8054 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008055 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 break;
8057 }
8058 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8059 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8060 }
8061 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8062 {
8063 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008065 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 break;
8067 }
8068 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8069 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8070 }
8071#ifdef FEATURE_WLAN_WAPI
8072 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8073 {
8074 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8075 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008076 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 break;
8078 }
8079 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8080 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8081 }
8082#endif /* FEATURE_WLAN_WAPI */
8083#ifdef FEATURE_WLAN_CCX
8084 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8085 {
8086 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008088 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 break;
8090 }
8091 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8092 pSession->ccxCckmInfo.reassoc_req_num=1;
8093 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8094 status = eHAL_STATUS_SUCCESS;
8095 break;
8096 }
8097#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008098
Jeff Johnson295189b2012-06-20 16:38:30 -07008099#ifdef WLAN_FEATURE_11W
8100 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008101 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008103 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008105 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 break;
8107 }
8108 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008109 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 }
8111#endif
8112 status = eHAL_STATUS_SUCCESS;
8113 pCommand->u.setKeyCmd.roamId = roamId;
8114 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8115 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8116 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8117 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8118 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8119 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8120 //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
8121
8122 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8123 if( !HAL_STATUS_SUCCESS( status ) )
8124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008125 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 }
8127 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008128 // Free the command if there has been a failure, or it is a
8129 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008130 if ( ( NULL != pCommand ) &&
8131 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008132#ifdef FEATURE_WLAN_CCX
8133 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8134#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008135 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 {
8137 csrReleaseCommandSetKey( pMac, pCommand );
8138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 return( status );
8140}
8141
Jeff Johnson295189b2012-06-20 16:38:30 -07008142eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8143 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8144{
8145 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8146 tSmeCmd *pCommand = NULL;
8147 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 do
8149 {
8150 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008152 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 status = eHAL_STATUS_CSR_WRONG_STATE;
8154 break;
8155 }
8156 pCommand = csrGetCommandBuffer(pMac);
8157 if(NULL == pCommand)
8158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008159 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 status = eHAL_STATUS_RESOURCES;
8161 break;
8162 }
8163 pCommand->command = eSmeCommandRemoveKey;
8164 pCommand->sessionId = (tANI_U8)sessionId;
8165 pCommand->u.removeKeyCmd.roamId = roamId;
8166 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8167 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8168 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8169 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8170 {
8171 //in this case, put it to the end of the Q incase there is a set key pending.
8172 fImediate = eANI_BOOLEAN_FALSE;
8173 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008174 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 pRemoveKey->encType, pRemoveKey->keyId,
8176 pCommand->u.removeKeyCmd.peerMac[0],
8177 pCommand->u.removeKeyCmd.peerMac[1],
8178 pCommand->u.removeKeyCmd.peerMac[2],
8179 pCommand->u.removeKeyCmd.peerMac[3],
8180 pCommand->u.removeKeyCmd.peerMac[4],
8181 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8183 if( !HAL_STATUS_SUCCESS( status ) )
8184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008185 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008186 break;
8187 }
8188 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8190 {
8191 csrReleaseCommandRemoveKey( pMac, pCommand );
8192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008193 return (status );
8194}
8195
Jeff Johnson295189b2012-06-20 16:38:30 -07008196eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8197{
8198 eHalStatus status;
8199 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8200 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8201 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8202 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008203#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8204 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8205 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008206 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 {
8208 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8209 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8210 {
8211 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8212 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8213 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8214 }
8215 else
8216 {
8217 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8218 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8219 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8220 }
8221 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
lukez3c809222013-05-03 10:23:02 -07008222 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 {
8224 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 //It has to be static WEP here
8226 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8227 {
8228 setKeyEvent.keyId = (v_U8_t)defKeyId;
8229 }
8230 }
8231 else
8232 {
8233 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8234 }
8235 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8236 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8237 }
8238#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 if( csrIsSetKeyAllowed(pMac, sessionId) )
8240 {
8241 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8242 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8243 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8244 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8245 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8246 pCommand->u.setKeyCmd.keyRsc);
8247 }
8248 else
8249 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008250 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 //Set this status so the error handling take care of the case.
8252 status = eHAL_STATUS_CSR_WRONG_STATE;
8253 }
8254 if( !HAL_STATUS_SUCCESS(status) )
8255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008256 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008258#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008259 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 {
8261 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8262 {
8263 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8264 }
8265 else
8266 {
8267 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8268 }
8269 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8270 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8271 }
8272#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 return ( status );
8275}
8276
Jeff Johnson295189b2012-06-20 16:38:30 -07008277eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8278{
8279 eHalStatus status;
8280 tpSirSmeRemoveKeyReq pMsg = NULL;
8281 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8282 tANI_U8 *p;
8283 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008284#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8285 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8286 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8288 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8289 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8290 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8291 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8292 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8293 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8294 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8295#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 if( csrIsSetKeyAllowed(pMac, sessionId) )
8297 {
8298 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8299 }
8300 else
8301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008302 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 //Set the error status so error handling kicks in below
8304 status = eHAL_STATUS_CSR_WRONG_STATE;
8305 }
8306 if( HAL_STATUS_SUCCESS( status ) )
8307 {
8308 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8309 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8310 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 pMsg->sessionId = (tANI_U8)sessionId;
8312 pMsg->transactionId = 0;
8313 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8314 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8315 // bssId - copy from session Info
8316 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8317 p += sizeof(tSirMacAddr);
8318 // peerMacAddr
8319 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8320 p += sizeof(tSirMacAddr);
8321 // edType
8322 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8323 p++;
8324 // weptype
8325 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8326 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8327 {
8328 *p = (tANI_U8)eSIR_WEP_STATIC;
8329 }
8330 else
8331 {
8332 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8333 }
8334 p++;
8335 //keyid
8336 *p = pCommand->u.removeKeyCmd.keyId;
8337 p++;
8338 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 status = palSendMBMessage(pMac->hHdd, pMsg);
8340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 if( !HAL_STATUS_SUCCESS( status ) )
8342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008343 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008344#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8345 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008346 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8348#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008351 return ( status );
8352}
8353
Jeff Johnson295189b2012-06-20 16:38:30 -07008354eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8355{
8356 eHalStatus status;
8357
8358 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8359 {
8360 status = eHAL_STATUS_CSR_WRONG_STATE;
8361 }
8362 else
8363 {
8364 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 return ( status );
8367}
8368
Jeff Johnson295189b2012-06-20 16:38:30 -07008369/*
8370 Prepare a filter base on a profile for parsing the scan results.
8371 Upon successful return, caller MUST call csrFreeScanFilter on
8372 pScanFilter when it is done with the filter.
8373*/
8374eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8375 tCsrScanResultFilter *pScanFilter)
8376{
8377 eHalStatus status = eHAL_STATUS_SUCCESS;
8378 tANI_U32 size = 0;
8379 tANI_U8 index = 0;
8380
8381 do
8382 {
8383 if(pProfile->BSSIDs.numOfBSSIDs)
8384 {
8385 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8386 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8387 if(!HAL_STATUS_SUCCESS(status))
8388 {
8389 break;
8390 }
8391 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8392 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8393 }
8394 if(pProfile->SSIDs.numOfSSIDs)
8395 {
8396 if( !CSR_IS_WDS_STA( pProfile ) )
8397 {
8398 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8399 }
8400 else
8401 {
8402 //For WDS station
8403 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8404 pScanFilter->SSIDs.numOfSSIDs = 1;
8405 }
8406 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8407 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8408 if(!HAL_STATUS_SUCCESS(status))
8409 {
8410 break;
8411 }
8412 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8413 }
8414 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8415 {
8416 pScanFilter->ChannelInfo.numOfChannels = 0;
8417 pScanFilter->ChannelInfo.ChannelList = NULL;
8418 }
8419 else if(pProfile->ChannelInfo.numOfChannels)
8420 {
8421 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8422 pScanFilter->ChannelInfo.numOfChannels = 0;
8423 if(HAL_STATUS_SUCCESS(status))
8424 {
8425 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8426 {
8427 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8428 {
8429 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8430 = pProfile->ChannelInfo.ChannelList[index];
8431 pScanFilter->ChannelInfo.numOfChannels++;
8432 }
8433 else
8434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008435 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 }
8438 }
8439 else
8440 {
8441 break;
8442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 }
8444 else
8445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008446 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 status = eHAL_STATUS_FAILURE;
8448 break;
8449 }
8450 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8451 pScanFilter->authType = pProfile->AuthType;
8452 pScanFilter->EncryptionType = pProfile->EncryptionType;
8453 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8454 pScanFilter->BSSType = pProfile->BSSType;
8455 pScanFilter->phyMode = pProfile->phyMode;
8456#ifdef FEATURE_WLAN_WAPI
8457 //check if user asked for WAPI with 11n or auto mode, in that case modify
8458 //the phymode to 11g
8459 if(csrIsProfileWapi(pProfile))
8460 {
8461 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8462 {
8463 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8464 }
8465 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8466 {
8467 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8468 }
8469 if(!pScanFilter->phyMode)
8470 {
8471 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8472 }
8473 }
8474#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 /*Save the WPS info*/
8476 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 if( pProfile->countryCode[0] )
8478 {
8479 //This causes the matching function to use countryCode as one of the criteria.
8480 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8481 WNI_CFG_COUNTRY_CODE_LEN );
8482 }
8483#ifdef WLAN_FEATURE_VOWIFI_11R
8484 if (pProfile->MDID.mdiePresent)
8485 {
8486 pScanFilter->MDID.mdiePresent = 1;
8487 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8488 }
8489#endif
8490
8491 }while(0);
8492
8493 if(!HAL_STATUS_SUCCESS(status))
8494 {
8495 csrFreeScanFilter(pMac, pScanFilter);
8496 }
8497
8498 return(status);
8499}
8500
Jeff Johnson295189b2012-06-20 16:38:30 -07008501tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8502 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8503{
8504 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8505 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 do
8507 {
8508 // Validate the type is ok...
8509 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8510 pCommand = csrGetCommandBuffer( pMac );
8511 if ( !pCommand )
8512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008513 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 break;
8515 }
8516 //Change the substate in case it is waiting for key
8517 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8518 {
8519 csrRoamStopWaitForKeyTimer( pMac );
8520 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8521 }
8522 pCommand->command = eSmeCommandWmStatusChange;
8523 pCommand->sessionId = (tANI_U8)sessionId;
8524 pCommand->u.wmStatusChangeCmd.Type = Type;
8525 if ( eCsrDisassociated == Type )
8526 {
8527 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8528 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8529 }
8530 else
8531 {
8532 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8533 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8534 }
8535 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8536 {
8537 fCommandQueued = eANI_BOOLEAN_TRUE;
8538 }
8539 else
8540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008541 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 csrReleaseCommandWmStatusChange( pMac, pCommand );
8543 }
8544
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8546 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 return( fCommandQueued );
8549}
8550
Jeff Johnson295189b2012-06-20 16:38:30 -07008551static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8552{
8553 v_S7_t rssi = 0;
8554 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8555 if(pGetRssiReq)
8556 {
8557 if(NULL != pGetRssiReq->pVosContext)
8558 {
8559 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8560 }
8561 else
8562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008563 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 return;
8565 }
8566
8567 if(NULL != pGetRssiReq->rssiCallback)
8568 {
8569 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8570 }
8571 else
8572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008573 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 return;
8575 }
8576 }
8577 else
8578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008579 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 }
8581 return;
8582}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308583
8584static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8585{
8586 tANI_S8 snr = 0;
8587 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8588
8589 if (pGetSnrReq)
8590 {
8591 if (VOS_STATUS_SUCCESS !=
8592 WDA_GetSnr(pGetSnrReq->staId, &snr))
8593 {
8594 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8595 return;
8596 }
8597
8598 if (pGetSnrReq->snrCallback)
8599 {
8600 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8601 pGetSnrReq->pDevContext);
8602 }
8603 else
8604 {
8605 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8606 return;
8607 }
8608 }
8609 else
8610 {
8611 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8612 }
8613 return;
8614}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008615#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8616void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8617{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008618 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8619
Jeff Johnson36d483b2013-04-08 11:08:53 -07008620 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008621 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008622 /* Get roam Rssi request is backed up and passed back to the response,
8623 Extract the request message to fetch callback */
8624 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8625 v_S7_t rssi = pRoamRssiRsp->rssi;
8626
8627 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008628 {
8629 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8630 reqBkp->rssiCallback = NULL;
8631 vos_mem_free(reqBkp);
8632 }
8633 else
8634 {
8635 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8636 if (NULL != reqBkp)
8637 {
8638 vos_mem_free(reqBkp);
8639 }
8640 }
8641 }
8642 else
8643 {
8644 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8645 }
8646 return;
8647}
8648#endif
8649
Jeff Johnsone7245742012-09-05 17:12:55 -07008650static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8651{
8652 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8653 if(pTlRssiInd)
8654 {
8655 if(NULL != pTlRssiInd->tlCallback)
8656 {
8657 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008658 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008659 }
8660 else
8661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008662 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008663 }
8664 }
8665 else
8666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008667 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008668 }
8669 return;
8670}
Jeff Johnson295189b2012-06-20 16:38:30 -07008671
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308672eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8673{
8674 tpSirResetAPCapsChange pMsg;
8675 tANI_U16 len;
8676 eHalStatus status = eHAL_STATUS_SUCCESS;
8677
8678 /* Create the message and send to lim */
8679 len = sizeof(tSirResetAPCapsChange);
8680 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8681 if (HAL_STATUS_SUCCESS(status))
8682 {
8683 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8684 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8685 pMsg->length = len;
8686 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8687 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8688 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8689 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8690 status = palSendMBMessage(pMac->hHdd, pMsg);
8691 }
8692 else
8693 {
8694 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8695 }
8696 return status;
8697}
8698
Jeff Johnson295189b2012-06-20 16:38:30 -07008699void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8700{
8701 tSirSmeAssocInd *pAssocInd;
8702 tSirSmeDisassocInd *pDisassocInd;
8703 tSirSmeDeauthInd *pDeauthInd;
8704 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8705 tSirSmeNewBssInfo *pNewBss;
8706 tSmeIbssPeerInd *pIbssPeerInd;
8707 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8708 tSirSmeApNewCaps *pApNewCaps;
8709 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8710 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8711 tCsrRoamInfo *pRoamInfo = NULL;
8712 tCsrRoamInfo roamInfo;
8713 eHalStatus status;
8714 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8715 tCsrRoamSession *pSession = NULL;
8716 tpSirSmeSwitchChannelInd pSwitchChnInd;
8717 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008718 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 pSirMsg->messageType = (pSirMsg->messageType);
8720 pSirMsg->length = (pSirMsg->length);
8721 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008723 switch( pSirMsg->messageType )
8724 {
8725 case eWNI_SME_ASSOC_IND:
8726 {
8727 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008728 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8730 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8731 if( HAL_STATUS_SUCCESS( status ) )
8732 {
8733 pSession = CSR_GET_SESSION(pMac, sessionId);
8734
Jeff Johnson32d95a32012-09-10 13:15:23 -07008735 if(!pSession)
8736 {
8737 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8738 return;
8739 }
8740
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 pRoamInfo = &roamInfo;
8742
8743 // Required for indicating the frames to upper layer
8744 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8745 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8746
8747 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8748 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8749 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8750 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8751
8752 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8753 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8754 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8755
8756 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8757 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8759 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8761 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008763 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8764 {
8765 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8766 {
8767 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8768 pSession->pConnectBssDesc,
8769 &(pRoamInfo->peerMac),
8770 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8771 pRoamInfo->fAuthRequired = FALSE;
8772 }
8773 else
8774 {
8775 pRoamInfo->fAuthRequired = TRUE;
8776 }
8777 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8778 if (!HAL_STATUS_SUCCESS(status))
8779 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 /* Send Association completion message to PE */
8782 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8783
8784 /* send a message to CSR itself just to avoid the EAPOL frames going
8785 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8787 {
8788 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8791 {
8792 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8793 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8794 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008796 }
8797 }
8798 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008800 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 // Check if AP dis-associated us because of MIC failure. If so,
8802 // then we need to take action immediately and not wait till the
8803 // the WmStatusChange requests is pushed and processed
8804 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8805 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8806 if( HAL_STATUS_SUCCESS( status ) )
8807 {
8808 // If we are in neighbor preauth done state then on receiving
8809 // disassoc or deauth we dont roam instead we just disassoc
8810 // from current ap and then go to disconnected state
8811 // This happens for CCX and 11r FT connections ONLY.
8812#ifdef WLAN_FEATURE_VOWIFI_11R
8813 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8814 {
8815 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8816 }
8817#endif
8818#ifdef FEATURE_WLAN_CCX
8819 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8820 {
8821 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8822 }
8823#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008824#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308825 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008826 {
8827 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8828 }
8829#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 pSession = CSR_GET_SESSION( pMac, sessionId );
8831
Jeff Johnson32d95a32012-09-10 13:15:23 -07008832 if(!pSession)
8833 {
8834 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8835 return;
8836 }
8837
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 if ( csrIsConnStateInfra( pMac, sessionId ) )
8839 {
8840 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008842#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8843 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8844#endif
8845 csrRoamLinkDown(pMac, sessionId);
8846 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8848 {
8849
8850 pRoamInfo = &roamInfo;
8851
8852 pRoamInfo->statusCode = pDisassocInd->statusCode;
8853 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8854
8855 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8856
8857 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8858 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8859
8860 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008861
8862 /*
8863 * STA/P2P client got disassociated so remove any pending deauth
8864 * commands in sme pending list
8865 */
8866 pCommand.command = eSmeCommandRoam;
8867 pCommand.sessionId = (tANI_U8)sessionId;
8868 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8869 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8870 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 }
8873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008875 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008876 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8877 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8878 if( HAL_STATUS_SUCCESS( status ) )
8879 {
8880 // If we are in neighbor preauth done state then on receiving
8881 // disassoc or deauth we dont roam instead we just disassoc
8882 // from current ap and then go to disconnected state
8883 // This happens for CCX and 11r FT connections ONLY.
8884#ifdef WLAN_FEATURE_VOWIFI_11R
8885 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8886 {
8887 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8888 }
8889#endif
8890#ifdef FEATURE_WLAN_CCX
8891 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8892 {
8893 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8894 }
8895#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008896#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308897 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008898 {
8899 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8900 }
8901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 pSession = CSR_GET_SESSION( pMac, sessionId );
8903
Jeff Johnson32d95a32012-09-10 13:15:23 -07008904 if(!pSession)
8905 {
8906 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8907 return;
8908 }
8909
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 if ( csrIsConnStateInfra( pMac, sessionId ) )
8911 {
8912 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008914#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8915 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8916#endif
8917 csrRoamLinkDown(pMac, sessionId);
8918 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8920 {
8921
8922 pRoamInfo = &roamInfo;
8923
8924 pRoamInfo->statusCode = pDeauthInd->statusCode;
8925 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8926
8927 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8928
8929 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8930 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8931
8932 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 }
8935 break;
8936
8937 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 -08008938 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008939 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8940 //Update with the new channel id.
8941 //The channel id is hidden in the statusCode.
8942 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8943 if( HAL_STATUS_SUCCESS( status ) )
8944 {
8945 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008946 if(!pSession)
8947 {
8948 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8949 return;
8950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008951 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8952 if(pSession->pConnectBssDesc)
8953 {
8954 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8955 }
8956 }
8957 break;
8958
8959 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008960 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008961 {
8962 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8963 sessionId = pDeauthRsp->sessionId;
8964 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8965 {
8966 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008967 if(!pSession)
8968 {
8969 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8970 return;
8971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8973 {
8974 pRoamInfo = &roamInfo;
8975 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8976 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8977 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8978 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8979 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8980 }
8981 }
8982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008983 break;
8984
8985 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008986 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008987 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 {
8989 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8990 sessionId = pDisassocRsp->sessionId;
8991 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8992 {
8993 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008994 if(!pSession)
8995 {
8996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8997 return;
8998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9000 {
9001 pRoamInfo = &roamInfo;
9002 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9003 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
9004 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9005 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9006 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9007 }
9008 }
9009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 case eWNI_SME_MIC_FAILURE_IND:
9012 {
9013 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9014 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9015 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07009016#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9017 {
lukez3c809222013-05-03 10:23:02 -07009018 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009020 if(!pSession)
9021 {
9022 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9023 return;
9024 }
lukez3c809222013-05-03 10:23:02 -07009025
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
9027 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9028 secEvent.encryptionModeMulticast =
9029 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9030 secEvent.encryptionModeUnicast =
9031 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9032 secEvent.authMode =
9033 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9034 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
9035 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9036 }
9037#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009038 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9039 if( HAL_STATUS_SUCCESS( status ) )
9040 {
9041 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9042 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9043 pRoamInfo = &roamInfo;
9044 if(pMicInd->info.multicast)
9045 {
9046 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9047 }
9048 else
9049 {
9050 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9051 }
9052 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9053 }
9054 }
9055 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9057 {
9058 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9059 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009060 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009061
9062 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9063 if( HAL_STATUS_SUCCESS( status ) )
9064 {
9065 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9066 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9067 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9068 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9069 }
9070 }
9071 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009072
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9074 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9075 switch( pStatusChangeMsg->statusChangeCode )
9076 {
9077 case eSIR_SME_IBSS_ACTIVE:
9078 sessionId = csrFindIbssSession( pMac );
9079 if( CSR_SESSION_ID_INVALID != sessionId )
9080 {
9081 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009082 if(!pSession)
9083 {
9084 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9085 return;
9086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9088 if(pSession->pConnectBssDesc)
9089 {
9090 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9091 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9092 pRoamInfo = &roamInfo;
9093 }
9094 else
9095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009096 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 }
9098 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9099 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9100 }
9101 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 case eSIR_SME_IBSS_INACTIVE:
9103 sessionId = csrFindIbssSession( pMac );
9104 if( CSR_SESSION_ID_INVALID != sessionId )
9105 {
9106 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009107 if(!pSession)
9108 {
9109 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9110 return;
9111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9113 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9114 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9115 }
9116 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009117 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9118 sessionId = csrFindIbssSession( pMac );
9119 if( CSR_SESSION_ID_INVALID != sessionId )
9120 {
9121 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009122 if(!pSession)
9123 {
9124 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9125 return;
9126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 // update the connection state information
9128 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009129#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9130 {
9131 vos_log_ibss_pkt_type *pIbssLog;
9132 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9134 if(pIbssLog)
9135 {
9136 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9137 if(pNewBss)
9138 {
9139 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9140 if(pNewBss->ssId.length)
9141 {
9142 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9143 }
9144 pIbssLog->operatingChannel = pNewBss->channelNumber;
9145 }
9146 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9147 {
9148 //***U8 is not enough for beacon interval
9149 pIbssLog->beaconInterval = (v_U8_t)bi;
9150 }
9151 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9152 }
9153 }
9154#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009156
9157 if ((eCSR_ENCRYPT_TYPE_NONE ==
9158 pSession->connectedProfile.EncryptionType ))
9159 {
9160 csrRoamIssueSetContextReq( pMac, sessionId,
9161 pSession->connectedProfile.EncryptionType,
9162 pSession->pConnectBssDesc,
9163 &Broadcastaddr,
9164 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9167 roamStatus = eCSR_ROAM_IBSS_IND;
9168 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9169 pRoamInfo = &roamInfo;
9170 //This BSSID is th ereal BSSID, let's save it
9171 if(pSession->pConnectBssDesc)
9172 {
9173 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9174 }
9175 // Stop the join IBSS timer in case of join, for
9176 // genuine merge do nothing
9177 if(pSession->ibss_join_pending)
9178 {
9179 pSession->ibss_join_pending = FALSE;
9180 csrRoamStopIbssJoinTimer(pMac, sessionId);
9181 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9182 }
9183 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009184 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 // detection by LIM that the capabilities of the associated AP have changed.
9187 case eSIR_SME_AP_CAPS_CHANGED:
9188 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009189 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009190 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9191 if( HAL_STATUS_SUCCESS( status ) )
9192 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009193 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9194 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309195 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009196 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9197 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9198 )
9199 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309200 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9201 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009202 }
9203 else
9204 {
9205 smsLog(pMac, LOGW,
9206 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009207 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009208 pMac->roam.curState[sessionId],
9209 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309210 /* We ignore the caps change event if CSR is not in full connected state.
9211 * Send one event to PE to reset limSentCapsChangeNtf
9212 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9213 * otherwise lim cannot send any CAPS change events to SME */
9214 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009216 }
9217 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309218
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 default:
9220 roamStatus = eCSR_ROAM_FAILED;
9221 result = eCSR_ROAM_RESULT_NONE;
9222 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 } // end switch on statusChangeCode
9224 if(eCSR_ROAM_RESULT_NONE != result)
9225 {
9226 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9227 }
9228 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 case eWNI_SME_IBSS_NEW_PEER_IND:
9230 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009231#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9232 {
9233 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9235 if(pIbssLog)
9236 {
9237 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9238 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9239 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9240 }
9241 }
9242#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009243 sessionId = csrFindIbssSession( pMac );
9244 if( CSR_SESSION_ID_INVALID != sessionId )
9245 {
9246 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009247
9248 if(!pSession)
9249 {
9250 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9251 return;
9252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009253 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9254 if(pSession->pConnectBssDesc)
9255 {
9256 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9257 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9258 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9259 {
9260 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9261 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9262 if(HAL_STATUS_SUCCESS(status))
9263 {
9264 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9265 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9266 roamInfo.nBeaconLength);
9267 }
9268 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9269 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9270 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9271 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9272 pSession->pConnectBssDesc->length);
9273 if(HAL_STATUS_SUCCESS(status))
9274 {
9275 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9276 pSession->pConnectBssDesc->length);
9277 }
9278 if(HAL_STATUS_SUCCESS(status))
9279 {
9280 pRoamInfo = &roamInfo;
9281 }
9282 else
9283 {
9284 if(roamInfo.pbFrames)
9285 {
9286 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9287 }
9288 if(roamInfo.pBssDesc)
9289 {
9290 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9291 }
9292 }
9293 }
9294 else
9295 {
9296 pRoamInfo = &roamInfo;
9297 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009298 if ((eCSR_ENCRYPT_TYPE_NONE ==
9299 pSession->connectedProfile.EncryptionType ))
9300 {
9301 csrRoamIssueSetContextReq( pMac, sessionId,
9302 pSession->connectedProfile.EncryptionType,
9303 pSession->pConnectBssDesc,
9304 &(pIbssPeerInd->peerAddr),
9305 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009307 }
9308 else
9309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009310 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 }
9312 //send up the sec type for the new peer
9313 if (pRoamInfo)
9314 {
9315 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9316 }
9317 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9318 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9319 if(pRoamInfo)
9320 {
9321 if(roamInfo.pbFrames)
9322 {
9323 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9324 }
9325 if(roamInfo.pBssDesc)
9326 {
9327 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9328 }
9329 }
9330 }
9331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9333 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9334 sessionId = csrFindIbssSession( pMac );
9335 if( CSR_SESSION_ID_INVALID != sessionId )
9336 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009337#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9338 {
9339 vos_log_ibss_pkt_type *pIbssLog;
9340
9341 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9342 if(pIbssLog)
9343 {
9344 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9345 if(pIbssPeerInd)
9346 {
9347 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9348 }
9349 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9350 }
9351 }
9352#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009353 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9355 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9356 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9357 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9358 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9359 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9360 }
9361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 case eWNI_SME_SETCONTEXT_RSP:
9363 {
9364 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9365 tListElem *pEntry;
9366 tSmeCmd *pCommand;
9367
9368 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9369 if ( pEntry )
9370 {
9371 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9372 if ( eSmeCommandSetKey == pCommand->command )
9373 {
9374 sessionId = pCommand->sessionId;
9375 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009376
9377 if(!pSession)
9378 {
9379 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9380 return;
9381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009382
9383#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9384 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9385 {
9386 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9387 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9388 if( pRsp->peerMacAddr[0] & 0x01 )
9389 {
9390 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9391 }
9392 else
9393 {
9394 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9395 }
9396 setKeyEvent.encryptionModeMulticast =
9397 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9398 setKeyEvent.encryptionModeUnicast =
9399 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9400 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9401 setKeyEvent.authMode =
9402 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009403 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 {
9405 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9406 }
9407 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9408 }
9409#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9410 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9411 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009412 csrRoamStopWaitForKeyTimer( pMac );
9413
Jeff Johnson295189b2012-06-20 16:38:30 -07009414 //We are done with authentication, whethere succeed or not
9415 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 //We do it here because this linkup function is not called after association
9417 //when a key needs to be set.
9418 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9419 {
9420 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9421 }
9422 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009423 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 {
9425 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009426 //Make sure we install the GTK before indicating to HDD as authenticated
9427 //This is to prevent broadcast packets go out after PTK and before GTK.
9428 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9429 sizeof(tSirMacAddr) ) )
9430 {
Yathish9f22e662012-12-10 14:21:35 -08009431#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9432 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9433 {
9434 tpSirSetActiveModeSetBncFilterReq pMsg;
9435 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9436 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9437 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9438 pMsg->seesionId = sessionId;
9439 status = palSendMBMessage(pMac->hHdd, pMsg );
9440 }
9441#endif
9442 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009443 }
9444 else
9445 {
9446 result = eCSR_ROAM_RESULT_NONE;
9447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 pRoamInfo = &roamInfo;
9449 }
9450 else
9451 {
9452 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009453 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9455 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9456 }
9457 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9458 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9460 // can go ahead and initiate the TSPEC if any are pending
9461 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009462#ifdef FEATURE_WLAN_CCX
9463 //Send Adjacent AP repot to new AP.
9464 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9465 pSession->isPrevApInfoValid &&
9466 pSession->connectedProfile.isCCXAssoc)
9467 {
9468#ifdef WLAN_FEATURE_VOWIFI
9469 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9470#endif
9471 pSession->isPrevApInfoValid = FALSE;
9472 }
9473#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9475 {
9476 csrReleaseCommandSetKey( pMac, pCommand );
9477 }
9478 }
9479 else
9480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009481 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 }
9483 }
9484 else
9485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009486 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 smeProcessPendingQueue( pMac );
9489 }
9490 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 case eWNI_SME_REMOVEKEY_RSP:
9492 {
9493 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9494 tListElem *pEntry;
9495 tSmeCmd *pCommand;
9496
9497 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9498 if ( pEntry )
9499 {
9500 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9501 if ( eSmeCommandRemoveKey == pCommand->command )
9502 {
9503 sessionId = pCommand->sessionId;
9504 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009505
9506 if(!pSession)
9507 {
9508 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9509 return;
9510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009511#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9512 {
9513 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9514 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9515 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9516 removeKeyEvent.encryptionModeMulticast =
9517 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9518 removeKeyEvent.encryptionModeUnicast =
9519 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9520 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9521 removeKeyEvent.authMode =
9522 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009523 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 {
9525 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9526 }
9527 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9528 }
9529#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009530 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 {
9532 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9533 result = eCSR_ROAM_RESULT_NONE;
9534 pRoamInfo = &roamInfo;
9535 }
9536 else
9537 {
9538 result = eCSR_ROAM_RESULT_FAILURE;
9539 }
9540 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9541 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9542 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9543 {
9544 csrReleaseCommandRemoveKey( pMac, pCommand );
9545 }
9546 }
9547 else
9548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009549 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009550 }
9551 }
9552 else
9553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009554 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 smeProcessPendingQueue( pMac );
9557 }
9558 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009560 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 csrRoamStatsRspProcessor( pMac, pSirMsg );
9562 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009563#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9564 case eWNI_SME_GET_ROAM_RSSI_RSP:
9565 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9566 csrRoamRssiRspProcessor( pMac, pSirMsg );
9567 break;
9568#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009570 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 csrUpdateRssi( pMac, pSirMsg );
9572 break;
9573
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309574 case eWNI_SME_GET_SNR_REQ:
9575 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9576 csrUpdateSnr(pMac, pSirMsg);
9577 break;
9578
Jeff Johnson295189b2012-06-20 16:38:30 -07009579#ifdef WLAN_FEATURE_VOWIFI_11R
9580 case eWNI_SME_FT_PRE_AUTH_RSP:
9581 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9582 break;
9583#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9585 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009586 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 -07009587 sessionId = pSmeMaxAssocInd->sessionId;
9588 roamInfo.sessionId = sessionId;
9589 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9590 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9591 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9592 break;
9593
9594 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009595 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 btampEstablishLogLinkHdlr( pSirMsg );
9597 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009598 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009599 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009600 csrRoamRssiIndHdlr( pMac, pSirMsg );
9601 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009602#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9603 case eWNI_SME_CANDIDATE_FOUND_IND:
9604 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9605 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9606 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009607 case eWNI_SME_HANDOFF_REQ:
9608 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9609 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9610 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009611#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009612
9613 default:
9614 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009616}
9617
Jeff Johnson295189b2012-06-20 16:38:30 -07009618void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9619 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9620{
9621 if(pSession)
9622 {
9623 if(pSession->bRefAssocStartCnt)
9624 {
9625 pSession->bRefAssocStartCnt--;
9626 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9627 //Need to call association_completion because there is an assoc_start pending.
9628 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9629 eCSR_ROAM_ASSOCIATION_COMPLETION,
9630 eCSR_ROAM_RESULT_FAILURE);
9631 }
9632 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9633 }
9634 else
9635 {
9636 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9637 }
9638}
9639
9640
9641eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9642{
9643 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9645 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9646 {
9647 status = csrScanRequestLostLink1( pMac, sessionId );
9648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 return(status);
9650}
9651
Jeff Johnson295189b2012-06-20 16:38:30 -07009652//return a boolean to indicate whether roaming completed or continue.
9653tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9654 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9655{
9656 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9657 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9658 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9659 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009660 if(!pSession)
9661 {
9662 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9663 return eANI_BOOLEAN_FALSE;
9664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 //Check whether time is up
9666 if(pSession->fCancelRoaming || fForce ||
9667 ((curTime - pSession->roamingStartTime) > roamTime) ||
9668 eCsrReassocRoaming == pSession->roamingReason ||
9669 eCsrDynamicRoaming == pSession->roamingReason)
9670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009671 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9673 {
9674 //roaming is cancelled, tell HDD to indicate disconnect
9675 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9676 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9677 //to be eSIR_BEACON_MISSED
9678 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9679 {
9680 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9681 }
9682 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9683 {
9684 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9685 }
9686 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9687 {
9688 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9689 }
9690 else
9691 {
9692 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9693 }
9694 }
9695 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9696 pSession->roamingReason = eCsrNotRoaming;
9697 }
9698 else
9699 {
9700 pSession->roamResult = roamResult;
9701 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9702 {
9703 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9704 pSession->roamingReason = eCsrNotRoaming;
9705 }
9706 else
9707 {
9708 fCompleted = eANI_BOOLEAN_FALSE;
9709 }
9710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 return(fCompleted);
9712}
9713
Jeff Johnson295189b2012-06-20 16:38:30 -07009714void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9715{
9716 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009717
9718 if(!pSession)
9719 {
9720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9721 return;
9722 }
9723
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 if(CSR_IS_ROAMING(pSession))
9725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009726 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9728 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9729 {
9730 //No need to do anything in here because the handler takes care of it
9731 }
9732 else
9733 {
9734 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9735 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9736 //Roaming is stopped after here
9737 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9738 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05309739 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 csrRoamStopRoamingTimer(pMac, sessionId);
9741 }
9742 }
9743}
9744
Jeff Johnson295189b2012-06-20 16:38:30 -07009745void csrRoamRoamingTimerHandler(void *pv)
9746{
9747 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9748 tpAniSirGlobal pMac = pInfo->pMac;
9749 tANI_U32 sessionId = pInfo->sessionId;
9750 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009751
9752 if(!pSession)
9753 {
9754 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9755 return;
9756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009757
9758 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9759 {
9760 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9761 {
9762 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9763 pSession->roamingReason = eCsrNotRoaming;
9764 }
9765 }
9766}
9767
Jeff Johnson295189b2012-06-20 16:38:30 -07009768eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9769{
9770 eHalStatus status;
9771 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009772
9773 if(!pSession)
9774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009775 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009776 return eHAL_STATUS_FAILURE;
9777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009778
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009779 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309781 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782
9783 return (status);
9784}
9785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9787{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309788 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -07009789}
9790
Jeff Johnson295189b2012-06-20 16:38:30 -07009791void csrRoamWaitForKeyTimeOutHandler(void *pv)
9792{
9793 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9794 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009795 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9796
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009797 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009798 pMac->roam.neighborRoamInfo.neighborRoamState,
9799 pMac->roam.curSubState[pInfo->sessionId]);
9800
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9802 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009803#ifdef FEATURE_WLAN_LFR
9804 if (csrNeighborRoamIsHandoffInProgress(pMac))
9805 {
9806 /*
9807 * Enable heartbeat timer when hand-off is in progress
9808 * and Key Wait timer expired.
9809 */
9810 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009811 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009812 pMac->roam.configParam.HeartbeatThresh24);
9813 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9814 pMac->roam.configParam.HeartbeatThresh24,
9815 NULL, eANI_BOOLEAN_FALSE);
9816 }
9817#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009818 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 //Change the substate so command queue is unblocked.
9820 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009821 if (pSession)
9822 {
9823 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9824 {
9825 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9826 smeProcessPendingQueue(pMac);
9827 }
9828 else
9829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009830 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009831 __func__);
9832 }
9833 }
9834 else
9835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009836 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 }
9839
9840}
9841
Jeff Johnson295189b2012-06-20 16:38:30 -07009842eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9843{
9844 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009845#ifdef FEATURE_WLAN_LFR
9846 if (csrNeighborRoamIsHandoffInProgress(pMac))
9847 {
9848 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009849 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009850 __func__,
9851 pMac->roam.neighborRoamInfo.neighborRoamState,
9852 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9853 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9854 }
9855#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009856 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309857 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009858
9859 return (status);
9860}
9861
Jeff Johnson295189b2012-06-20 16:38:30 -07009862eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9863{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009864 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009865 pMac->roam.neighborRoamInfo.neighborRoamState,
9866 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9867#ifdef FEATURE_WLAN_LFR
9868 if (csrNeighborRoamIsHandoffInProgress(pMac))
9869 {
9870 /*
9871 * Enable heartbeat timer when hand-off is in progress
9872 * and Key Wait timer got stopped for some reason
9873 */
9874 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009875 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009876 pMac->roam.configParam.HeartbeatThresh24);
9877 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9878 pMac->roam.configParam.HeartbeatThresh24,
9879 NULL, eANI_BOOLEAN_FALSE);
9880 }
9881#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309882 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009883}
9884
Jeff Johnson295189b2012-06-20 16:38:30 -07009885void csrRoamIbssJoinTimerHandler(void *pv)
9886{
9887 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9888 tpAniSirGlobal pMac = pInfo->pMac;
9889 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9890 tANI_U32 sessionId = pInfo->sessionId;
9891 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009892
9893 if(!pSession)
9894 {
9895 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9896 return;
9897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009898
9899 pSession->ibss_join_pending = FALSE;
9900 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9901 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9902 // Send an IBSS stop request to PE
9903 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009904}
Jeff Johnson295189b2012-06-20 16:38:30 -07009905eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9906{
9907 eHalStatus status;
9908 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009909
9910 if(!pSession)
9911 {
9912 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9913 return eHAL_STATUS_FAILURE;
9914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009915
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009916 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009917 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309918 status = vos_timer_start(&pSession->hTimerIbssJoining, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009919
9920 return (status);
9921}
Jeff Johnson295189b2012-06-20 16:38:30 -07009922eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9923{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309924 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerIbssJoining));
Jeff Johnson295189b2012-06-20 16:38:30 -07009925}
Jeff Johnson295189b2012-06-20 16:38:30 -07009926void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9927 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9928{
9929 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9930 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009931 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9932 /* To silence the KW tool Null chaeck is added */
9933 if(!pSession)
9934 {
9935 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9936 return;
9937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009938
9939 if(pCommand)
9940 {
9941 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9945 {
9946 //if success, force roaming completion
9947 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9948 }
9949 else
9950 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009951 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009952 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9954 }
9955}
9956
Jeff Johnson295189b2012-06-20 16:38:30 -07009957eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9958{
9959 eHalStatus status = eHAL_STATUS_SUCCESS;
9960 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9961 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9962 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9963 tCsrRoamInfo *pRoamInfo = NULL;
9964 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009965 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009967 /* To silence the KW tool Null chaeck is added */
9968 if(!pSession)
9969 {
9970 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9971 return eHAL_STATUS_FAILURE;
9972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009974 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009975 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9976 if ( eWNI_SME_DISASSOC_IND == type )
9977 {
9978 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9979 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9980 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009981 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 }
9983 else if ( eWNI_SME_DEAUTH_IND == type )
9984 {
9985 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9986 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9987 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009988 /* Convert into proper reason code */
9989 pSession->joinFailStatusCode.reasonCode =
9990 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309991 0 : pDeauthIndMsg->reasonCode;
9992 /* cfg layer expects 0 as reason code if
9993 the driver dosent know the reason code
9994 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 }
9996 else
9997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009998 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010000 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 }
10002
10003 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 {
10006 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10007 }
10008
10009 if ( eWNI_SME_DISASSOC_IND == type )
10010 {
10011 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10012 }
10013 else if ( eWNI_SME_DEAUTH_IND == type )
10014 {
10015 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 if(!HAL_STATUS_SUCCESS(status))
10018 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010019 //If fail to send confirmation to PE, not to trigger roaming
10020 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 }
10022
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010023 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10025 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10026 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 if( eWNI_SME_DISASSOC_IND == type)
10028 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010029 //staMacAddr
10030 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10031 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 else if( eWNI_SME_DEAUTH_IND == type )
10034 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010035 //staMacAddr
10036 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10037 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10038 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010039 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010040
10041 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10042 that we are roaming. But if we cannot possibly roam, or if we are unable to
10043 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010044 if(fToRoam)
10045 {
10046 //Only remove the connected BSS in infrastructure mode
10047 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10048 //Not to do anying for lostlink with WDS
10049 if( pMac->roam.configParam.nRoamingTime )
10050 {
10051 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10052 ( eWNI_SME_DEAUTH_IND == type ) ?
10053 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10054 {
10055 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10056 //For IBSS, we need to give some more info to HDD
10057 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10058 {
10059 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10060 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10061 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10062 }
10063 else
10064 {
10065 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10066 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010067 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10069 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10070 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10071 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10072 }
10073 else
10074 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010075 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 fToRoam = eANI_BOOLEAN_FALSE;
10077 }
10078 }
10079 else
10080 {
10081 //We are told not to roam, indicate lostlink
10082 fToRoam = eANI_BOOLEAN_FALSE;
10083 }
10084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 if(!fToRoam)
10086 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010087 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010088 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010089 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010090 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10091 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10092 * csrRoamCheckForLinkStatusChange API.
10093 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010094 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10095 }
10096
10097 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 Still enable idle scan for polling in case concurrent sessions are running */
10099 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10100 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010101 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 }
10103 }
10104
10105 return (status);
10106}
10107
Jeff Johnson295189b2012-06-20 16:38:30 -070010108eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10109{
10110 eHalStatus status = eHAL_STATUS_SUCCESS;
10111 tListElem *pEntry = NULL;
10112 tSmeCmd *pCommand = NULL;
10113 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010114
10115 if(!pSession)
10116 {
10117 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10118 return eHAL_STATUS_FAILURE;
10119 }
10120
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 //Only remove the connected BSS in infrastructure mode
10123 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10124 if(pMac->roam.configParam.nRoamingTime)
10125 {
10126 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10127 {
10128 //before starting the lost link logic release the roam command for handoff
10129 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10130 if(pEntry)
10131 {
10132 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10133 }
10134 if(pCommand)
10135 {
10136 if (( eSmeCommandRoam == pCommand->command ) &&
10137 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10138 {
10139 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10140 {
10141 csrReleaseCommandRoam( pMac, pCommand );
10142 }
10143 }
10144 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010145 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010146 }
10147 }
10148 else
10149 {
10150 //We are told not to roam, indicate lostlink
10151 status = eHAL_STATUS_FAILURE;
10152 }
10153
10154 return (status);
10155}
Jeff Johnson295189b2012-06-20 16:38:30 -070010156void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10157{
10158 tListElem *pEntry;
10159 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10161 if ( pEntry )
10162 {
10163 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10164 if ( eSmeCommandWmStatusChange == pCommand->command )
10165 {
10166 // Nothing to process in a Lost Link completion.... It just kicks off a
10167 // roaming sequence.
10168 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10169 {
10170 csrReleaseCommandWmStatusChange( pMac, pCommand );
10171 }
10172 else
10173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010174 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 }
10176
10177 }
10178 else
10179 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010180 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 }
10182 }
10183 else
10184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010185 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010187 smeProcessPendingQueue( pMac );
10188}
10189
Jeff Johnson295189b2012-06-20 16:38:30 -070010190void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10191{
10192 eHalStatus status = eHAL_STATUS_FAILURE;
10193 tSirSmeRsp *pSirSmeMsg;
10194 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010195
10196 if(!pSession)
10197 {
10198 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10199 return;
10200 }
10201
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 switch ( pCommand->u.wmStatusChangeCmd.Type )
10203 {
10204 case eCsrDisassociated:
10205 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10206 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 case eCsrDeauthenticated:
10209 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10210 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10211 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010212 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010213 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 break;
10215 }
10216 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10217 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10218 {
10219 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10220 {
10221 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010222 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 }
10224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10226 // command here since there is nothing else to do.
10227 csrRoamWmStatusChangeComplete( pMac );
10228}
10229
Jeff Johnson295189b2012-06-20 16:38:30 -070010230//This function returns band and mode information.
10231//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10232//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010233static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10234 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010235{
Jeff Johnson295189b2012-06-20 16:38:30 -070010236 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10237 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10238 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010240
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 //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 -070010242 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10243 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10244 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10245 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 {
10247 switch( pMac->roam.configParam.uCfgDot11Mode )
10248 {
10249 case eCSR_CFG_DOT11_MODE_11A:
10250 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10251 eBand = eCSR_BAND_5G;
10252 break;
10253 case eCSR_CFG_DOT11_MODE_11B:
10254 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10255 eBand = eCSR_BAND_24;
10256 break;
10257 case eCSR_CFG_DOT11_MODE_11G:
10258 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10259 eBand = eCSR_BAND_24;
10260 break;
10261 case eCSR_CFG_DOT11_MODE_11N:
10262 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010263 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10264 break;
10265#ifdef WLAN_FEATURE_11AC
10266 case eCSR_CFG_DOT11_MODE_11AC:
10267 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10268 {
10269 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10270 eBand = eCSR_BAND_5G;
10271 }
10272 else
10273 {
10274 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10275 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10276 }
10277 break;
10278 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10279 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10280 {
10281 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10282 eBand = eCSR_BAND_5G;
10283 }
10284 else
10285 {
10286 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10287 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10288 }
10289 break;
10290#endif
10291 case eCSR_CFG_DOT11_MODE_AUTO:
10292 eBand = pMac->roam.configParam.eBand;
10293 if (eCSR_BAND_24 == eBand)
10294 {
10295 // WiFi tests require IBSS networks to start in 11b mode
10296 // without any change to the default parameter settings
10297 // on the adapter. We use ACU to start an IBSS through
10298 // creation of a startIBSS profile. This startIBSS profile
10299 // has Auto MACProtocol and the adapter property setting
10300 // for dot11Mode is also AUTO. So in this case, let's
10301 // start the IBSS network in 11b mode instead of 11g mode.
10302 // So this is for Auto=profile->MacProtocol && Auto=Global.
10303 // dot11Mode && profile->channel is < 14, then start the IBSS
10304 // in b mode.
10305 //
10306 // Note: we used to have this start as an 11g IBSS for best
10307 // performance... now to specify that the user will have to
10308 // set the do11Mode in the property page to 11g to force it.
10309 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10310 }
10311 else
10312 {
10313#ifdef WLAN_FEATURE_11AC
10314 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10315 {
10316 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10317 eBand = eCSR_BAND_5G;
10318 }
10319 else
10320 {
10321 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10322 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10323 }
10324#else
10325 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10326 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10327#endif
10328 }
10329 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 default:
10331 // Global dot11 Mode setting is 11a/b/g.
10332 // use the channel number to determine the Mode setting.
10333 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10334 {
10335 eBand = pMac->roam.configParam.eBand;
10336 if(eCSR_BAND_24 == eBand)
10337 {
10338 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10339 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10340 }
10341 else
10342 {
10343 //prefer 5GHz
10344 eBand = eCSR_BAND_5G;
10345 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10346 }
10347 }
10348 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10349 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010350 // WiFi tests require IBSS networks to start in 11b mode
10351 // without any change to the default parameter settings
10352 // on the adapter. We use ACU to start an IBSS through
10353 // creation of a startIBSS profile. This startIBSS profile
10354 // has Auto MACProtocol and the adapter property setting
10355 // for dot11Mode is also AUTO. So in this case, let's
10356 // start the IBSS network in 11b mode instead of 11g mode.
10357 // So this is for Auto=profile->MacProtocol && Auto=Global.
10358 // dot11Mode && profile->channel is < 14, then start the IBSS
10359 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010360 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010361 // Note: we used to have this start as an 11g IBSS for best
10362 // performance... now to specify that the user will have to
10363 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10365 eBand = eCSR_BAND_24;
10366 }
10367 else
10368 {
10369 // else, it's a 5.0GHz channel. Set mode to 11a.
10370 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10371 eBand = eCSR_BAND_5G;
10372 }
10373 break;
10374 }//switch
10375 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10376 else
10377 {
10378 //dot11 mode is set, lets pick the band
10379 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10380 {
10381 // channel is Auto also.
10382 eBand = pMac->roam.configParam.eBand;
10383 if(eCSR_BAND_ALL == eBand)
10384 {
10385 //prefer 5GHz
10386 eBand = eCSR_BAND_5G;
10387 }
10388 }
10389 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10390 {
10391 eBand = eCSR_BAND_24;
10392 }
10393 else
10394 {
10395 eBand = eCSR_BAND_5G;
10396 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 if(pBand)
10399 {
10400 *pBand = eBand;
10401 }
10402
10403 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010404 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10406 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010407
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010408 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10409 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 -070010410 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010411#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010412 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010413#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010414 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10415 {
10416 //We cannot do 11n here
10417 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10418 {
10419 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10420 }
10421 else
10422 {
10423 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10424 }
10425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010426 return( cfgDot11Mode );
10427}
10428
Jeff Johnson295189b2012-06-20 16:38:30 -070010429eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10430{
10431 eHalStatus status;
10432 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010433
10434 if(!pSession)
10435 {
10436 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10437 return eHAL_STATUS_FAILURE;
10438 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010439
10440#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10441 {
10442 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10444 if(pIbssLog)
10445 {
10446 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10447 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10448 }
10449 }
10450#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 pSession->ibss_join_pending = FALSE;
10452 csrRoamStopIbssJoinTimer(pMac, sessionId );
10453 // Set the roaming substate to 'stop Bss request'...
10454 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10455
10456 // attempt to stop the Bss (reason code is ignored...)
10457 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010458 if(!HAL_STATUS_SUCCESS(status))
10459 {
10460 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 return (status);
10463}
10464
Jeff Johnson295189b2012-06-20 16:38:30 -070010465//pNumChan is a caller allocated space with the sizeof pChannels
10466eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10467{
10468
10469 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10470 (tANI_U8 *)pChannels,
10471 pNumChan));
10472}
10473
Kiran4a17ebe2013-01-31 10:43:43 -080010474tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10475{
10476 tANI_U32 cfgLength = 0;
10477 tANI_U16 cfgId = 0;
10478 tPowerdBm maxTxPwr = 0;
10479 tANI_U8 *pCountryInfo = NULL;
10480 eHalStatus status;
10481 tANI_U8 count = 0;
10482 tANI_U8 firstChannel;
10483 tANI_U8 maxChannels;
10484
10485 if (CSR_IS_CHANNEL_5GHZ(channel))
10486 {
10487 cfgId = WNI_CFG_MAX_TX_POWER_5;
10488 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10489 }
10490 else if (CSR_IS_CHANNEL_24GHZ(channel))
10491 {
10492 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10493 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10494 }
10495 else
10496 return maxTxPwr;
10497
10498 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10499 if (status != eHAL_STATUS_SUCCESS)
10500 {
10501 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10502 FL("%s: palAllocateMemory() failed, status = %d"),
10503 __FUNCTION__, status);
10504 goto error;
10505 }
10506 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10507 if (status != eHAL_STATUS_SUCCESS)
10508 {
10509 goto error;
10510 }
10511 /* Identify the channel and maxtxpower */
10512 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10513 {
10514 firstChannel = pCountryInfo[count++];
10515 maxChannels = pCountryInfo[count++];
10516 maxTxPwr = pCountryInfo[count++];
10517
10518 if ((channel >= firstChannel) &&
10519 (channel < (firstChannel + maxChannels)))
10520 {
10521 break;
10522 }
10523 }
10524
10525error:
10526 if (NULL != pCountryInfo)
10527 palFreeMemory(pMac->hHdd, pCountryInfo);
10528
10529 return maxTxPwr;
10530}
10531
10532
Jeff Johnson295189b2012-06-20 16:38:30 -070010533tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10534{
10535 tANI_BOOLEAN fValid = FALSE;
10536 tANI_U32 idxValidChannels;
10537 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10538
10539 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10540 {
10541 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10542 {
10543 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10544 {
10545 fValid = TRUE;
10546 break;
10547 }
10548 }
10549 }
10550 pMac->roam.numValidChannels = len;
10551 return fValid;
10552}
10553
Jeff Johnson295189b2012-06-20 16:38:30 -070010554tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10555{
10556 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10557 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10559 {
10560 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10561 {
10562 fValid = eANI_BOOLEAN_TRUE;
10563 break;
10564 }
10565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 return (fValid);
10567}
10568
Jeff Johnson295189b2012-06-20 16:38:30 -070010569//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010570 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010571{
Jeff Johnsone7245742012-09-05 17:12:55 -070010572 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 tANI_U8 centerChn;
10574 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10576 {
10577 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10578 }
10579 else
10580 {
10581 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10582 }
10583 //Figure what the other side's CB mode
10584 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10585 {
10586 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10587 {
10588 if(pIes->HTInfo.present)
10589 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010590 /* This is called during INFRA STA/CLIENT and should use the merged value of
10591 * supported channel width and recommended tx width as per standard
10592 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010593 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010594 pIes->HTCaps.supportedChannelWidthSet,
10595 pIes->HTInfo.recommendedTxWidthSet,
10596 pIes->HTInfo.secondaryChannelOffset);
10597
10598 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10599 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010601 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10602 switch (eRet) {
10603 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10604 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10605 break;
10606 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10607 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10608 break;
10609 case PHY_SINGLE_CHANNEL_CENTERED:
10610 default:
10611 centerChn = primaryChn;
10612 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010614 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010616 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010617 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 }
10619 }
10620 }
10621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010622 return eRet;
10623}
Jeff Johnson295189b2012-06-20 16:38:30 -070010624tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10625{
10626 tANI_BOOLEAN fFound = FALSE;
10627 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10629 {
10630 if( pCipherList->encryptionType[idx] == encryptionType )
10631 {
10632 fFound = TRUE;
10633 break;
10634 }
10635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010636 return fFound;
10637}
Jeff Johnson295189b2012-06-20 16:38:30 -070010638tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10639{
10640 tANI_BOOLEAN fFound = FALSE;
10641 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010642 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10643 {
10644 if( pAuthList->authType[idx] == authType )
10645 {
10646 fFound = TRUE;
10647 break;
10648 }
10649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 return fFound;
10651}
Jeff Johnson295189b2012-06-20 16:38:30 -070010652tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10653{
10654 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10655 tCsrScanResultFilter *pScanFilter = NULL;
10656 eHalStatus status = eHAL_STATUS_SUCCESS;
10657
10658 if(pProfile1 && pProfile2)
10659 {
10660 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10661 if(HAL_STATUS_SUCCESS(status))
10662 {
10663 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10664 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10665 if(HAL_STATUS_SUCCESS(status))
10666 {
10667 fCheck = eANI_BOOLEAN_FALSE;
10668 do
10669 {
10670 tANI_U32 i;
10671 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10672 {
10673 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10674 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10675 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10676 if ( fCheck ) break;
10677 }
10678 if(!fCheck)
10679 {
10680 break;
10681 }
10682 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10683 || pProfile2->BSSType != pProfile1->BSSType
10684 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10685 )
10686 {
10687 fCheck = eANI_BOOLEAN_FALSE;
10688 break;
10689 }
10690#ifdef WLAN_FEATURE_VOWIFI_11R
10691 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10692 {
10693 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10694 {
10695 fCheck = eANI_BOOLEAN_FALSE;
10696 break;
10697 }
10698 }
10699#endif
10700 //Match found
10701 fCheck = eANI_BOOLEAN_TRUE;
10702 }while(0);
10703 csrFreeScanFilter(pMac, pScanFilter);
10704 }
10705 palFreeMemory(pMac->hHdd, pScanFilter);
10706 }
10707 }
10708
10709 return (fCheck);
10710}
10711
Jeff Johnson295189b2012-06-20 16:38:30 -070010712tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10713{
10714 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10715 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010716 do
10717 {
10718 //Only check for static WEP
10719 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10720 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10721 {
10722 fCheck = eANI_BOOLEAN_TRUE;
10723 break;
10724 }
10725 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10726 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10727 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10728 {
10729 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10730 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10731 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10732 {
10733 break;
10734 }
10735 }
10736 if( i == CSR_MAX_NUM_KEY)
10737 {
10738 fCheck = eANI_BOOLEAN_TRUE;
10739 }
10740 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010741 return (fCheck);
10742}
10743
Jeff Johnson295189b2012-06-20 16:38:30 -070010744//IBSS
10745
Jeff Johnson295189b2012-06-20 16:38:30 -070010746tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10747{
10748 tANI_U8 channel = 0;
10749 tANI_U32 idx;
10750 tANI_U32 idxValidChannels;
10751 tANI_BOOLEAN fFound = FALSE;
10752 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10753
10754 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10755 {
10756 channel = pMac->roam.configParam.AdHocChannel5G;
10757 if(!csrRoamIsChannelValid(pMac, channel))
10758 {
10759 channel = 0;
10760 }
10761 }
10762 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10763 {
10764 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10765 {
10766 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10767 {
10768 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10769 {
10770 fFound = TRUE;
10771 channel = csrStartIbssChannels50[ idx ];
10772 }
10773 }
10774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10776 if (!fFound)
10777 {
10778 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10779 {
10780 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10781 {
10782 channel = csrStartIbssChannels50[ idx ];
10783 break;
10784 }
10785 }
10786 }
10787 }//if
10788
10789 return( channel );
10790}
10791
Jeff Johnson295189b2012-06-20 16:38:30 -070010792tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10793{
10794 tANI_U8 channel = 1;
10795 tANI_U32 idx;
10796 tANI_U32 idxValidChannels;
10797 tANI_BOOLEAN fFound = FALSE;
10798 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10799
10800 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10801 {
10802 channel = pMac->roam.configParam.AdHocChannel24;
10803 if(!csrRoamIsChannelValid(pMac, channel))
10804 {
10805 channel = 0;
10806 }
10807 }
10808
10809 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10810 {
10811 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10812 {
10813 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10814 {
10815 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10816 {
10817 fFound = TRUE;
10818 channel = csrStartIbssChannels24[ idx ];
10819 }
10820 }
10821 }
10822 }
10823
10824 return( channel );
10825}
10826
Jeff Johnson295189b2012-06-20 16:38:30 -070010827static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10828 tCsrRoamStartBssParams *pParam )
10829{
10830 eCsrCfgDot11Mode cfgDot11Mode;
10831 eCsrBand eBand;
10832 tANI_U8 channel = 0;
10833 tSirNwType nwType;
10834 tANI_U8 operationChannel = 0;
10835
10836 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10837 {
10838 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10839 }
10840
Jeff Johnson295189b2012-06-20 16:38:30 -070010841 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010842
Jeff Johnson295189b2012-06-20 16:38:30 -070010843 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10844 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10845 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10846 )
10847 {
10848 /* This should never happen */
10849 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010850 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 pProfile->csrPersona);
10852 VOS_ASSERT(0);
10853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 switch( cfgDot11Mode )
10855 {
10856 case eCSR_CFG_DOT11_MODE_11G:
10857 nwType = eSIR_11G_NW_TYPE;
10858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 case eCSR_CFG_DOT11_MODE_11B:
10860 nwType = eSIR_11B_NW_TYPE;
10861 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 case eCSR_CFG_DOT11_MODE_11A:
10863 nwType = eSIR_11A_NW_TYPE;
10864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 default:
10866 case eCSR_CFG_DOT11_MODE_11N:
10867 case eCSR_CFG_DOT11_MODE_TAURUS:
10868 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10869 if(eCSR_BAND_24 == eBand)
10870 {
10871 nwType = eSIR_11G_NW_TYPE;
10872 }
10873 else
10874 {
10875 nwType = eSIR_11A_NW_TYPE;
10876 }
10877 break;
10878 }
10879
10880 pParam->extendedRateSet.numRates = 0;
10881
10882 switch ( nwType )
10883 {
10884 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010885 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010886 case eSIR_11A_NW_TYPE:
10887
10888 pParam->operationalRateSet.numRates = 8;
10889
10890 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10891 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10892 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10893 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10894 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10895 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10896 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10897 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10898
10899 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10900 {
10901 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10902 if( 0 == channel &&
10903 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10904 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10905 )
10906 {
10907 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10908 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10909 nwType = eSIR_11B_NW_TYPE;
10910 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10911 pParam->operationalRateSet.numRates = 4;
10912 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10913 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10914 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10915 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10916 }
10917 }
10918 else
10919 {
10920 channel = operationChannel;
10921 }
10922 break;
10923
10924 case eSIR_11B_NW_TYPE:
10925 pParam->operationalRateSet.numRates = 4;
10926 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10927 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10928 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10929 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10931 {
10932 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10933 }
10934 else
10935 {
10936 channel = operationChannel;
10937 }
10938
10939 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 /* For P2P Client and P2P GO, disable 11b rates */
10942 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10943 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10944 )
10945 {
10946 pParam->operationalRateSet.numRates = 8;
10947
10948 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10949 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10950 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10951 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10952 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10953 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10954 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10955 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10956 }
10957 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010958 {
10959 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10961 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10962 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10963 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10964
10965 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10967 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10968 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10969 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10970 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10971 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10972 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10973 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10974 }
10975
10976 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10977 {
10978 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10979 }
10980 else
10981 {
10982 channel = operationChannel;
10983 }
10984
10985 break;
10986 }
10987 pParam->operationChn = channel;
10988 pParam->sirNwType = nwType;
10989}
10990
Jeff Johnson295189b2012-06-20 16:38:30 -070010991static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10992 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10993{
10994
10995 if( pParam )
10996 {
10997 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010998 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010999 pParam->operationChn = pBssDesc->channelId;
11000 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
11001
11002 if( pIes )
11003 {
11004 if(pIes->SuppRates.present)
11005 {
11006 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11007 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011009 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 -070011010 pIes->SuppRates.num_rates);
11011 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11012 }
11013 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11014 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
11015 }
11016 if( pIes->SSID.present )
11017 {
11018 pParam->ssId.length = pIes->SSID.num_ssid;
11019 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
11020 }
11021 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011022 }
11023 else
11024 {
11025 pParam->ssId.length = 0;
11026 pParam->operationalRateSet.numRates = 0;
11027 }
11028 }
11029}
11030
Jeff Johnson295189b2012-06-20 16:38:30 -070011031static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11032{
11033 tANI_U8 MaxRate = 0;
11034 tANI_U32 i;
11035 tANI_U8 *pRate;
11036
11037 pRate = pSirRateSet->rate;
11038 for ( i = 0; i < pSirRateSet->numRates; i++ )
11039 {
11040 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11041 }
11042
11043 // Save the max rate in the connected state information...
11044
11045 // modify LastRates variable as well
11046
11047 return;
11048}
11049
Jeff Johnson295189b2012-06-20 16:38:30 -070011050eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11051 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11052{
11053 eHalStatus status = eHAL_STATUS_SUCCESS;
11054 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 // Set the roaming substate to 'Start BSS attempt'...
11056 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011057#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11058 //Need to figure out whether we need to log WDS???
11059 if( CSR_IS_IBSS( pProfile ) )
11060 {
11061 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11063 if(pIbssLog)
11064 {
11065 if(pBssDesc)
11066 {
11067 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
11068 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
11069 }
11070 else
11071 {
11072 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11073 }
11074 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11075 pParam->ssId.length);
11076 if(pProfile->ChannelInfo.numOfChannels == 0)
11077 {
11078 pIbssLog->channelSetting = AUTO_PICK;
11079 }
11080 else
11081 {
11082 pIbssLog->channelSetting = SPECIFIED;
11083 }
11084 pIbssLog->operatingChannel = pParam->operationChn;
11085 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11086 }
11087 }
11088#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11089 //Put RSN information in for Starting BSS
11090 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11091 pParam->pRSNIE = pProfile->pRSNReqIE;
11092
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 pParam->privacy = pProfile->privacy;
11094 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11095 pParam->authType = pProfile->csr80211AuthType;
11096 pParam->beaconInterval = pProfile->beaconInterval;
11097 pParam->dtimPeriod = pProfile->dtimPeriod;
11098 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11099 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11100 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11101 {
11102 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11103 {
11104 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11105 }
11106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 pParam->protEnabled = pProfile->protEnabled;
11108 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11109 pParam->ht_protection = pProfile->cfg_protection;
11110 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011111
Jeff Johnson295189b2012-06-20 16:38:30 -070011112 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11113 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011114 pParam->bssPersona = pProfile->csrPersona;
11115 // When starting an IBSS, start on the channel from the Profile.
11116 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 return (status);
11118}
11119
Jeff Johnson295189b2012-06-20 16:38:30 -070011120static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011121 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011122{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011123 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011124 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011126
11127 if(!pSession)
11128 {
11129 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11130 return;
11131 }
11132
Jeff Johnson295189b2012-06-20 16:38:30 -070011133 if( pBssDesc )
11134 {
11135 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11136 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11137 //The following code has to be do after that.
11138 //For WDS station, use selfMac as the self BSSID
11139 if( CSR_IS_WDS_STA( pProfile ) )
11140 {
11141 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11142 }
11143 }
11144 else
11145 {
11146 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011147 //Use the first SSID
11148 if(pProfile->SSIDs.numOfSSIDs)
11149 {
11150 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11151 }
11152 //For WDS station, use selfMac as the self BSSID
11153 if( CSR_IS_WDS_STA( pProfile ) )
11154 {
11155 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11156 }
11157 //Use the first BSSID
11158 else if( pProfile->BSSIDs.numOfBSSIDs )
11159 {
11160 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11161 }
11162 else
11163 {
11164 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11165 }
11166 }
11167 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 //Set operating channel in pProfile which will be used
11169 //in csrRoamSetBssConfigCfg() to determine channel bonding
11170 //mode and will be configured in CFG later
11171 pProfile->operationChannel = Channel;
11172
11173 if(Channel == 0)
11174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011175 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011176 }
11177 else
11178 {
11179
11180 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011181 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011182 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011183 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011184 {
11185 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11186 }
11187 else
11188 {
11189 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11190 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011191 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011192 pBssConfig->cbMode = cbMode;
11193 pSession->bssParams.cbMode = cbMode;
11194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 }
11196}
11197
Jeff Johnson295189b2012-06-20 16:38:30 -070011198static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11199 tANI_BOOLEAN *pfSameIbss )
11200{
11201 eHalStatus status = eHAL_STATUS_SUCCESS;
11202 tANI_BOOLEAN fSameIbss = FALSE;
11203
11204 if ( csrIsConnStateIbss( pMac, sessionId ) )
11205 {
11206 // Check if any profile parameter has changed ? If any profile parameter
11207 // has changed then stop old BSS and start a new one with new parameters
11208 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11209 {
11210 fSameIbss = TRUE;
11211 }
11212 else
11213 {
11214 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11215 }
11216 }
11217 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11218 {
11219 // Disassociate from the connected Infrastructure network...
11220 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11221 }
11222 else
11223 {
11224 tBssConfigParam *pBssConfig;
11225
11226 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11227 if(HAL_STATUS_SUCCESS(status))
11228 {
11229 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11230 // there is no Bss description before we start an IBSS so we need to adopt
11231 // all Bss configuration parameters from the Profile.
11232 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11233 if(HAL_STATUS_SUCCESS(status))
11234 {
11235 //save dotMode
11236 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11237 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011238 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011239 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11240 NULL, pBssConfig,
11241 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 palFreeMemory(pMac->hHdd, pBssConfig);
11244 }//Allocate memory
11245 }
11246
11247 if(pfSameIbss)
11248 {
11249 *pfSameIbss = fSameIbss;
11250 }
11251 return( status );
11252}
11253
Jeff Johnson295189b2012-06-20 16:38:30 -070011254static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11255 tSirSmeNewBssInfo *pNewBss )
11256{
11257 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011258
11259 if(!pSession)
11260 {
11261 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11262 return;
11263 }
11264
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 if( pNewBss )
11266 {
11267 // Set the operating channel.
11268 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11269 // move the BSSId from the BSS description into the connected state information.
11270 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11271 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11272 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011273 return;
11274}
11275
Jeff Johnson295189b2012-06-20 16:38:30 -070011276#ifdef FEATURE_WLAN_WAPI
11277eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11278 tANI_U32 numItems )
11279{
11280 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11281 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011282 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11283 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011284 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011285 return status;
11286 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011287 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011288 pSession = CSR_GET_SESSION( pMac, sessionId );
11289 if(numItems <= CSR_MAX_BKID_ALLOWED)
11290 {
11291 status = eHAL_STATUS_SUCCESS;
11292 //numItems may be 0 to clear the cache
11293 pSession->NumBkidCache = (tANI_U16)numItems;
11294 if(numItems && pBKIDCache)
11295 {
11296 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11297 sizeof(tBkidCacheInfo) * numItems );
11298 }
11299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 return (status);
11301}
Jeff Johnson295189b2012-06-20 16:38:30 -070011302eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11303 tBkidCacheInfo *pBkidCache)
11304{
11305 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11306 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011307 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011309 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 return status;
11311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011312 pSession = CSR_GET_SESSION( pMac, sessionId );
11313 if(pNum && pBkidCache)
11314 {
11315 if(pSession->NumBkidCache == 0)
11316 {
11317 *pNum = 0;
11318 status = eHAL_STATUS_SUCCESS;
11319 }
11320 else if(*pNum >= pSession->NumBkidCache)
11321 {
11322 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011324 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 -070011325 pSession->NumBkidCache);
11326 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11327 }
11328 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11329 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11330 *pNum = pSession->NumBkidCache;
11331 status = eHAL_STATUS_SUCCESS;
11332 }
11333 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011335}
Jeff Johnson295189b2012-06-20 16:38:30 -070011336tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11337{
11338 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011339}
11340#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011341eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11342 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11343{
11344 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11345 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011346
11347 if(!pSession)
11348 {
11349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11350 return eHAL_STATUS_FAILURE;
11351 }
11352
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011353 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011354 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11355 {
11356#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11357 {
11358 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11359 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11360 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11361 secEvent.encryptionModeMulticast =
11362 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11363 secEvent.encryptionModeUnicast =
11364 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11365 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11366 secEvent.authMode =
11367 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11368 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11369 }
11370#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 status = eHAL_STATUS_SUCCESS;
11372 //numItems may be 0 to clear the cache
11373 pSession->NumPmkidCache = (tANI_U16)numItems;
11374 if(numItems && pPMKIDCache)
11375 {
11376 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11377 sizeof(tPmkidCacheInfo) * numItems );
11378 }
11379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011380 return (status);
11381}
11382
Jeff Johnson295189b2012-06-20 16:38:30 -070011383tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11384{
11385 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11386}
11387
Jeff Johnson295189b2012-06-20 16:38:30 -070011388eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11389{
11390 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11391 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011392
11393 if(!pSession)
11394 {
11395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11396 return eHAL_STATUS_FAILURE;
11397 }
11398
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 if(pNum && pPmkidCache)
11400 {
11401 if(pSession->NumPmkidCache == 0)
11402 {
11403 *pNum = 0;
11404 status = eHAL_STATUS_SUCCESS;
11405 }
11406 else if(*pNum >= pSession->NumPmkidCache)
11407 {
11408 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011410 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 -070011411 pSession->NumPmkidCache);
11412 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11413 }
11414 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11415 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11416 *pNum = pSession->NumPmkidCache;
11417 status = eHAL_STATUS_SUCCESS;
11418 }
11419 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 return (status);
11421}
11422
Jeff Johnson295189b2012-06-20 16:38:30 -070011423eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11424{
11425 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11426 tANI_U32 len;
11427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011428
11429 if(!pSession)
11430 {
11431 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11432 return eHAL_STATUS_FAILURE;
11433 }
11434
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 if(pLen)
11436 {
11437 len = *pLen;
11438 *pLen = pSession->nWpaRsnReqIeLength;
11439 if(pBuf)
11440 {
11441 if(len >= pSession->nWpaRsnReqIeLength)
11442 {
11443 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11444 }
11445 }
11446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 return (status);
11448}
11449
Jeff Johnson295189b2012-06-20 16:38:30 -070011450eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11451{
11452 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11453 tANI_U32 len;
11454 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011455
11456 if(!pSession)
11457 {
11458 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11459 return eHAL_STATUS_FAILURE;
11460 }
11461
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 if(pLen)
11463 {
11464 len = *pLen;
11465 *pLen = pSession->nWpaRsnRspIeLength;
11466 if(pBuf)
11467 {
11468 if(len >= pSession->nWpaRsnRspIeLength)
11469 {
11470 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11471 }
11472 }
11473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 return (status);
11475}
Jeff Johnson295189b2012-06-20 16:38:30 -070011476#ifdef FEATURE_WLAN_WAPI
11477eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11478{
11479 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11480 tANI_U32 len;
11481 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011482
11483 if(!pSession)
11484 {
11485 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11486 return eHAL_STATUS_FAILURE;
11487 }
11488
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 if(pLen)
11490 {
11491 len = *pLen;
11492 *pLen = pSession->nWapiReqIeLength;
11493 if(pBuf)
11494 {
11495 if(len >= pSession->nWapiReqIeLength)
11496 {
11497 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11498 }
11499 }
11500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 return (status);
11502}
Jeff Johnson295189b2012-06-20 16:38:30 -070011503eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11504{
11505 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11506 tANI_U32 len;
11507 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011508
11509 if(!pSession)
11510 {
11511 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11512 return eHAL_STATUS_FAILURE;
11513 }
11514
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 if(pLen)
11516 {
11517 len = *pLen;
11518 *pLen = pSession->nWapiRspIeLength;
11519 if(pBuf)
11520 {
11521 if(len >= pSession->nWapiRspIeLength)
11522 {
11523 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11524 }
11525 }
11526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011527 return (status);
11528}
11529#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011530eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11531{
11532 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011534
11535 if(!pSession)
11536 {
11537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11538 return (retStatus);
11539 }
11540
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 if(CSR_IS_ROAMING(pSession))
11542 {
11543 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11544 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011546 return (retStatus);
11547}
11548
Jeff Johnson295189b2012-06-20 16:38:30 -070011549//This function remove the connected BSS from te cached scan result
11550eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11551 tCsrRoamConnectedProfile *pConnProfile)
11552{
11553 eHalStatus status = eHAL_STATUS_FAILURE;
11554 tCsrScanResultFilter *pScanFilter = NULL;
11555 tListElem *pEntry;
11556 tCsrScanResult *pResult;
11557 tDot11fBeaconIEs *pIes;
11558 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011559 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11560 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11561 {
11562 do
11563 {
11564 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11565 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11566 if(!HAL_STATUS_SUCCESS(status)) break;
11567 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11568 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11569 if(!HAL_STATUS_SUCCESS(status)) break;
11570 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11571 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11572 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11573 {
11574 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11575 if(!HAL_STATUS_SUCCESS(status)) break;
11576 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11577 }
11578 pScanFilter->authType.numEntries = 1;
11579 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11580 pScanFilter->BSSType = pConnProfile->BSSType;
11581 pScanFilter->EncryptionType.numEntries = 1;
11582 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11583 pScanFilter->mcEncryptionType.numEntries = 1;
11584 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11585 //We ignore the channel for now, BSSID should be enough
11586 pScanFilter->ChannelInfo.numOfChannels = 0;
11587 //Also ignore the following fields
11588 pScanFilter->uapsd_mask = 0;
11589 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11590 pScanFilter->countryCode[0] = 0;
11591 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 csrLLLock(&pMac->scan.scanResultList);
11593 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11594 while( pEntry )
11595 {
11596 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11597 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11598 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11599 pScanFilter, NULL, NULL, NULL, &pIes);
11600 //Release the IEs allocated by csrMatchBSS is needed
11601 if( !pResult->Result.pvIes )
11602 {
11603 //need to free the IEs since it is allocated by csrMatchBSS
11604 palFreeMemory(pMac->hHdd, pIes);
11605 }
11606 if(fMatch)
11607 {
11608 //We found the one
11609 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11610 {
11611 //Free the memory
11612 csrFreeScanResultEntry( pMac, pResult );
11613 }
11614 break;
11615 }
11616 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11617 }//while
11618 csrLLUnlock(&pMac->scan.scanResultList);
11619 }while(0);
11620 if(pScanFilter)
11621 {
11622 csrFreeScanFilter(pMac, pScanFilter);
11623 palFreeMemory(pMac->hHdd, pScanFilter);
11624 }
11625 }
11626 return (status);
11627}
11628
Jeff Johnson295189b2012-06-20 16:38:30 -070011629//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011630eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11631{
11632 eHalStatus status = eHAL_STATUS_SUCCESS;
11633 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11635 {
11636 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11637 {
11638 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11639 {
11640 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011641 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 status = eHAL_STATUS_CSR_WRONG_STATE;
11643 break;
11644 }
11645 if( csrIsConnStateInfra( pMac, sessionId ) )
11646 {
11647 if( chnId &&
11648 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011650 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11652 status = eHAL_STATUS_CSR_WRONG_STATE;
11653 break;
11654 }
11655 }
11656 }
11657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 return ( status );
11659}
11660
Jeff Johnson295189b2012-06-20 16:38:30 -070011661static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11662{
11663 eHalStatus status = eHAL_STATUS_SUCCESS;
11664 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11665 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011666
11667 if(!pSession)
11668 {
11669 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11670 return eHAL_STATUS_FAILURE;
11671 }
11672
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 if ( csrIsConnStateIbss( pMac, sessionId ) )
11674 {
11675 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11676 }
11677 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11678 {
11679 // Disassociate from the connected Infrastructure network...
11680 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11681 }
11682 else
11683 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11685 //Otherwise we need to add code to handle the
11686 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11687 //send stop_bss to PE, before we can continue.
11688 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11690 /* Assume HDD provide bssid in profile */
11691 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11692 // there is no Bss description before we start an WDS so we need
11693 // to adopt all Bss configuration parameters from the Profile.
11694 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11695 if(HAL_STATUS_SUCCESS(status))
11696 {
11697 //Save profile for late use
11698 csrFreeRoamProfile( pMac, sessionId );
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011699 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 (void **)&pSession->pCurRoamProfile,
11701 sizeof(tCsrRoamProfile))))
11702 {
11703 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11704 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011707 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011708 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11709 NULL, &bssConfig,
11710 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011711 }
11712 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011713
Jeff Johnson295189b2012-06-20 16:38:30 -070011714 return( status );
11715}
11716
Jeff Johnson295189b2012-06-20 16:38:30 -070011717////////////////////Mail box
11718
Jeff Johnson295189b2012-06-20 16:38:30 -070011719//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11720//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011721static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11722 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11724{
11725 tCsrChannelSet channelGroup;
11726 tSirMacCapabilityInfo *pAP_capabilityInfo;
11727 tAniBool fTmp;
11728 tANI_BOOLEAN found = FALSE;
11729 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011730 tANI_S8 pwrLimit = 0;
11731 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11733 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11734 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11735 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 // 802.11h
11737 //We can do this because it is in HOST CPU order for now.
11738 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011739 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11740 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11741 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 fTmp = (tAniBool)pal_cpu_to_be32(1);
11743 }
11744 else
11745 fTmp = (tAniBool)0;
11746
11747 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11748 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11749 pBuf += sizeof(tAniBool);
11750 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011751 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 // This is required for 11k test VoWiFi Ent: Test 2.
11753 // We need the power capabilities for Assoc Req.
11754 // This macro is provided by the halPhyCfg.h. We pick our
11755 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011756 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11757 if (0 != pwrLimit)
11758 {
11759 *pBuf++ = pwrLimit;
11760 }
11761 else
11762 {
11763 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 size = sizeof(pMac->roam.validChannelList);
11766 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11767 {
11768 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11769 for ( i = 0; i < size; i++)
11770 {
11771 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11772
11773 }
11774 }
11775 else
11776 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011777 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011778 *pBuf++ = 0; //tSirSupChnl->numChnl
11779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 //Check whether it is ok to enter UAPSD
11781#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11782 if( btcIsReadyForUapsd(pMac) )
11783#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11784 {
11785 *pBuf++ = uapsdMask;
11786 }
11787#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11788 else
11789 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011790 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 *pBuf++ = 0;
11792 }
11793#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11794
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 // move the entire BssDescription into the join request.
11796 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11797 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11799}
11800
Jeff Johnson295189b2012-06-20 16:38:30 -070011801/*
11802 * The communication between HDD and LIM is thru mailbox (MB).
11803 * Both sides will access the data structure "tSirSmeJoinReq".
11804 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11805 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11806 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11807 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11808 */
11809eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011810 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011811{
11812 eHalStatus status = eHAL_STATUS_SUCCESS;
11813 tSirSmeJoinReq *pMsg;
11814 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011815 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 tANI_U16 msgLen, wTmp, ieLen;
11817 tSirMacRateSet OpRateSet;
11818 tSirMacRateSet ExRateSet;
11819 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11820 tANI_U32 dwTmp;
11821 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011822 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011823
11824 if(!pSession)
11825 {
11826 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11827 return eHAL_STATUS_FAILURE;
11828 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011829 /* To satisfy klockworks */
11830 if (NULL == pBssDescription)
11831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011832 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011833 return eHAL_STATUS_FAILURE;
11834 }
11835
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 do {
11837 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11838 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011839 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011840 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11841 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11842 // IE fields, but the length field in the bssDescription needs to be interpreted to
11843 // determine length of the IE fields.
11844 //
11845 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11846 // add in the length from the bssDescription (then add the size of the 'length' field
11847 // itself because that is NOT included in the length field).
11848 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11849 pBssDescription->length + sizeof( pBssDescription->length ) +
11850 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 -070011851 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11852 if ( !HAL_STATUS_SUCCESS(status) ) break;
11853 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011854 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 pMsg->length = pal_cpu_to_be16(msgLen);
11856 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 // sessionId
11858 *pBuf = (tANI_U8)sessionId;
11859 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 // transactionId
11861 *pBuf = 0;
11862 *( pBuf + 1 ) = 0;
11863 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 // ssId
11865 if( pIes->SSID.present && pIes->SSID.num_ssid )
11866 {
11867 // ssId len
11868 *pBuf = pIes->SSID.num_ssid;
11869 pBuf++;
11870 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11871 pBuf += pIes->SSID.num_ssid;
11872 }
11873 else
11874 {
11875 *pBuf = 0;
11876 pBuf++;
11877 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 // selfMacAddr
11879 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11880 pBuf += sizeof(tSirMacAddr);
11881 // bsstype
11882 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11883 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11884 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11885 pBuf += sizeof(tSirBssType);
11886 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011887 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11888 if (pBssDescription->channelId <= 14 &&
11889 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11890 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11891 {
11892 //Need to disable VHT operation in 2.4 GHz band
11893 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11894 }
11895 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011896 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 //Persona
11898 *pBuf = (tANI_U8)pProfile->csrPersona;
11899 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011900 //CBMode
11901 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11902 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011903
11904 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011905 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11906
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 // uapsdPerAcBitmask
11908 *pBuf = pProfile->uapsd_mask;
11909 pBuf++;
11910
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011911
11912
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011914 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 {
11916 // OperationalRateSet
11917 if (OpRateSet.numRates) {
11918 *pBuf++ = OpRateSet.numRates;
11919 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11920 pBuf += OpRateSet.numRates;
11921 } else *pBuf++ = 0;
11922 // ExtendedRateSet
11923 if (ExRateSet.numRates) {
11924 *pBuf++ = ExRateSet.numRates;
11925 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11926 pBuf += ExRateSet.numRates;
11927 } else *pBuf++ = 0;
11928 }
11929 else
11930 {
11931 *pBuf++ = 0;
11932 *pBuf++ = 0;
11933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 // rsnIE
11935 if ( csrIsProfileWpa( pProfile ) )
11936 {
11937 // Insert the Wpa IE into the join request
11938 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11939 (tCsrWpaIe *)( wpaRsnIE ) );
11940 }
11941 else if( csrIsProfileRSN( pProfile ) )
11942 {
11943 // Insert the RSN IE into the join request
11944 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11945 (tCsrRSNIe *)( wpaRsnIE ) );
11946 }
11947#ifdef FEATURE_WLAN_WAPI
11948 else if( csrIsProfileWapi( pProfile ) )
11949 {
11950 // Insert the WAPI IE into the join request
11951 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11952 (tCsrWapiIe *)( wpaRsnIE ) );
11953 }
11954#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 else
11956 {
11957 ieLen = 0;
11958 }
11959 //remember the IE for future use
11960 if( ieLen )
11961 {
11962 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011964 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 -070011965 ieLen = DOT11F_IE_RSN_MAX_LEN;
11966 }
11967#ifdef FEATURE_WLAN_WAPI
11968 if( csrIsProfileWapi( pProfile ) )
11969 {
11970 //Check whether we need to allocate more memory
11971 if(ieLen > pSession->nWapiReqIeLength)
11972 {
11973 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11974 {
11975 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11976 }
11977 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11978 if(!HAL_STATUS_SUCCESS(status)) break;
11979 }
11980 pSession->nWapiReqIeLength = ieLen;
11981 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11982 wTmp = pal_cpu_to_be16( ieLen );
11983 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11984 pBuf += sizeof(tANI_U16);
11985 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11986 pBuf += ieLen;
11987 }
11988 else//should be WPA/WPA2 otherwise
11989#endif /* FEATURE_WLAN_WAPI */
11990 {
11991 //Check whether we need to allocate more memory
11992 if(ieLen > pSession->nWpaRsnReqIeLength)
11993 {
11994 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11995 {
11996 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11997 }
11998 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11999 if(!HAL_STATUS_SUCCESS(status)) break;
12000 }
12001 pSession->nWpaRsnReqIeLength = ieLen;
12002 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
12003 wTmp = pal_cpu_to_be16( ieLen );
12004 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12005 pBuf += sizeof(tANI_U16);
12006 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12007 pBuf += ieLen;
12008 }
12009 }
12010 else
12011 {
12012 //free whatever old info
12013 pSession->nWpaRsnReqIeLength = 0;
12014 if(pSession->pWpaRsnReqIE)
12015 {
12016 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12017 pSession->pWpaRsnReqIE = NULL;
12018 }
12019#ifdef FEATURE_WLAN_WAPI
12020 pSession->nWapiReqIeLength = 0;
12021 if(pSession->pWapiReqIE)
12022 {
12023 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12024 pSession->pWapiReqIE = NULL;
12025 }
12026#endif /* FEATURE_WLAN_WAPI */
12027 //length is two bytes
12028 *pBuf = 0;
12029 *(pBuf + 1) = 0;
12030 pBuf += 2;
12031 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012032#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012033 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012035 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 //length is two bytes
12037 *pBuf = 0;
12038 *(pBuf + 1) = 0;
12039 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012040 }
12041 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012043 // cckmIE
12044 if( csrIsProfileCCX( pProfile ) )
12045 {
12046 // Insert the CCKM IE into the join request
12047 ieLen = csrConstructCcxCckmIe( pMac,
12048 pSession,
12049 pProfile,
12050 pBssDescription,
12051 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 pSession->nWpaRsnReqIeLength,
12053 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012054 }
12055 else
12056 {
12057 ieLen = 0;
12058 }
12059 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12060 if( ieLen )
12061 {
12062 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12063 wTmp = pal_cpu_to_be16( ieLen );
12064 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12065 pBuf += sizeof(tANI_U16);
12066 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12067 pBuf += ieLen;
12068 }
12069 else
12070 {
12071 //Indicate you have no CCKM IE
12072 //length is two bytes
12073 *pBuf = 0;
12074 *(pBuf + 1) = 0;
12075 pBuf += 2;
12076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 }
12078#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 // addIEScan
12080 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12081 {
12082 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 if(ieLen > pSession->nAddIEScanLength)
12084 {
12085 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12086 {
12087 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12088 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012089 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 (void **)&pSession->pAddIEScan, ieLen);
12091 if(!HAL_STATUS_SUCCESS(status)) break;
12092 }
12093 pSession->nAddIEScanLength = ieLen;
12094 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12095 pProfile->pAddIEScan, ieLen);
12096 wTmp = pal_cpu_to_be16( ieLen );
12097 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12098 pBuf += sizeof(tANI_U16);
12099 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12100 pBuf += ieLen;
12101 }
12102 else
12103 {
12104 pSession->nAddIEScanLength = 0;
12105 if(pSession->pAddIEScan)
12106 {
12107 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12108 pSession->pAddIEScan = NULL;
12109 }
12110 *pBuf = 0;
12111 *(pBuf + 1) = 0;
12112 pBuf += 2;
12113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 // addIEAssoc
12115 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12116 {
12117 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 if(ieLen > pSession->nAddIEAssocLength)
12119 {
12120 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12121 {
12122 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12123 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012124 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012125 (void **)&pSession->pAddIEAssoc, ieLen);
12126 if(!HAL_STATUS_SUCCESS(status)) break;
12127 }
12128 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012129 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 pProfile->pAddIEAssoc, ieLen);
12131 wTmp = pal_cpu_to_be16( ieLen );
12132 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12133 pBuf += sizeof(tANI_U16);
12134 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12135 pBuf += ieLen;
12136 }
12137 else
12138 {
12139 pSession->nAddIEAssocLength = 0;
12140 if(pSession->pAddIEAssoc)
12141 {
12142 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12143 pSession->pAddIEAssoc = NULL;
12144 }
12145 *pBuf = 0;
12146 *(pBuf + 1) = 0;
12147 pBuf += 2;
12148 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012149
12150 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012152 //Unmask any AC in reassoc that is ACM-set
12153 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12154 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012156 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12157 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012158#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012159 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012160#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012161 uapsd_mask &= ~(acm_mask);
12162 }
12163 else
12164 {
12165 uapsd_mask = 0;
12166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 }
12168 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012169
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12171 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012172 pBuf += sizeof(tANI_U32);
12173
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12175 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012176 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012177#ifdef WLAN_FEATURE_11W
12178 //MgmtEncryption
12179 if (pProfile->MFPEnabled)
12180 {
12181 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12182 }
12183 else
12184 {
12185 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12186 }
12187 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12188 pBuf += sizeof(tANI_U32);
12189#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012190#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012191 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012192 if (csrIsProfile11r( pProfile )
12193#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012194 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12195 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012196#endif
12197 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012198 {
12199 // is11Rconnection;
12200 dwTmp = pal_cpu_to_be32(TRUE);
12201 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12202 pBuf += sizeof(tAniBool);
12203 }
12204 else
12205 {
12206 // is11Rconnection;
12207 dwTmp = pal_cpu_to_be32(FALSE);
12208 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12209 pBuf += sizeof(tAniBool);
12210 }
12211#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012212#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012213
12214 // isCCXFeatureIniEnabled
12215 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12216 {
12217 dwTmp = pal_cpu_to_be32(TRUE);
12218 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12219 pBuf += sizeof(tAniBool);
12220 }
12221 else
12222 {
12223 dwTmp = pal_cpu_to_be32(FALSE);
12224 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12225 pBuf += sizeof(tAniBool);
12226 }
12227
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012228 /* A profile can not be both CCX and 11R. But an 802.11R AP
12229 * may be advertising support for CCX as well. So if we are
12230 * associating Open or explicitly CCX then we will get CCX.
12231 * If we are associating explictly 11R only then we will get
12232 * 11R.
12233 */
12234 if ((csrIsProfileCCX(pProfile) ||
12235 ((pIes->CCXVersion.present)
12236 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012237 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12238 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12239 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012240#ifdef WLAN_FEATURE_11W
12241 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12242#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012243 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012244 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12245 {
12246 // isCCXconnection;
12247 dwTmp = pal_cpu_to_be32(TRUE);
12248 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12249 pBuf += sizeof(tAniBool);
12250 }
12251 else
12252 {
12253 //isCCXconnection;
12254 dwTmp = pal_cpu_to_be32(FALSE);
12255 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12256 pBuf += sizeof(tAniBool);
12257 }
12258
12259 if (eWNI_SME_JOIN_REQ == messageType)
12260 {
12261 tCCXTspecInfo ccxTspec;
12262 // CCX-Tspec IEs in the ASSOC request is presently not supported
12263 // so nullify the TSPEC parameters
12264 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12265 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12266 pBuf += sizeof(tCCXTspecInfo);
12267 }
12268 else if (eWNI_SME_REASSOC_REQ == messageType)
12269 {
12270 if ((csrIsProfileCCX(pProfile) ||
12271 ((pIes->CCXVersion.present)
12272 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012273 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12274 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12275 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012276#ifdef WLAN_FEATURE_11W
12277 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12278#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012279 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012280 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012281 {
12282 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012283 // CCX Tspec information
12284 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12285 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12286 *pBuf = ccxTspec.numTspecs;
12287 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012288 // Copy the TSPEC information only if present
12289 if (ccxTspec.numTspecs) {
12290 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12291 }
12292 pBuf += sizeof(ccxTspec.tspec);
12293 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012294 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 tCCXTspecInfo ccxTspec;
12297 // CCX-Tspec IEs in the ASSOC request is presently not supported
12298 // so nullify the TSPEC parameters
12299 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12300 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12301 pBuf += sizeof(tCCXTspecInfo);
12302 }
12303 }
12304#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012305#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012307 if (pMac->roam.configParam.isFastTransitionEnabled
12308#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012309 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012310#endif
12311 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012313 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012315 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 }
12317 else
12318 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012319 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012321 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 }
12323#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012324#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012325 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012326 {
12327 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012328 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012329 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012330 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012331 }
12332 else
12333 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012334 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012335 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012336 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012337 }
12338#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012339
12340 // txLdpcIniFeatureEnabled
12341 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12342 pBuf++;
12343
Kiran4a17ebe2013-01-31 10:43:43 -080012344 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12345 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12346 {
12347 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12348 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12349 csrApplyPower2Current(pMac);
12350 }
12351
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012352#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012353 // txBFIniFeatureEnabled
12354 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12355 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012356
12357 // txBFCsnValue
12358 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12359 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012360#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012361 //BssDesc
12362 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12363 (tANI_U8)pProfile->uapsd_mask);
12364 status = palSendMBMessage(pMac->hHdd, pMsg );
12365 if(!HAL_STATUS_SUCCESS(status))
12366 {
12367 break;
12368 }
12369 else
12370 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012371#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012372 if (eWNI_SME_JOIN_REQ == messageType)
12373 {
12374 //Tush-QoS: notify QoS module that join happening
12375 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12376 }
12377 else if (eWNI_SME_REASSOC_REQ == messageType)
12378 {
12379 //Tush-QoS: notify QoS module that reassoc happening
12380 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012382#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012386}
12387
Jeff Johnson295189b2012-06-20 16:38:30 -070012388//
12389eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12390{
12391 eHalStatus status = eHAL_STATUS_SUCCESS;
12392 tSirSmeDisassocReq *pMsg;
12393 tANI_U8 *pBuf;
12394 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12396 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12397 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 do {
12399 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12400 if ( !HAL_STATUS_SUCCESS(status) ) break;
12401 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12402 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12403 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 pBuf = &pMsg->sessionId;
12405 // sessionId
12406 *pBuf++ = (tANI_U8)sessionId;
12407 // transactionId
12408 *pBuf = 0;
12409 *( pBuf + 1 ) = 0;
12410 pBuf += sizeof(tANI_U16);
12411
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012412 if ( (pSession->pCurRoamProfile != NULL) &&
12413 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12414 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 {
12416 // Set the bssid address before sending the message to LIM
12417 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12418 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 // Set the peer MAC address before sending the message to LIM
12420 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12421 pBuf = pBuf + sizeof ( tSirMacAddr );
12422 }
12423 else
12424 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012425 // Set the peer MAC address before sending the message to LIM
12426 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12427 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12429 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 if(!HAL_STATUS_SUCCESS(status))
12432 {
12433 palFreeMemory(pMac->hHdd, pMsg);
12434 break;
12435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 // reasonCode
12437 wTmp = pal_cpu_to_be16(reasonCode);
12438 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12439 if(!HAL_STATUS_SUCCESS(status))
12440 {
12441 palFreeMemory(pMac->hHdd, pMsg);
12442 break;
12443 }
12444 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12446 Here we should not send the disassoc over the air to the AP */
12447 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12448#ifdef WLAN_FEATURE_VOWIFI_11R
12449 && csrRoamIs11rAssoc(pMac)
12450#endif
12451 )
12452 {
12453 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12454 }
12455 pBuf += sizeof(tANI_U8);
12456 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 return( status );
12459}
Jeff Johnson295189b2012-06-20 16:38:30 -070012460eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12461{
12462 eHalStatus status = eHAL_STATUS_SUCCESS;
12463 tSirSmeTkipCntrMeasReq *pMsg;
12464 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 do
12466 {
12467 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12468 if ( !HAL_STATUS_SUCCESS(status) ) break;
12469 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12470 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12471 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 pBuf = &pMsg->sessionId;
12473 // sessionId
12474 *pBuf++ = (tANI_U8)sessionId;
12475 // transactionId
12476 *pBuf = 0;
12477 *( pBuf + 1 ) = 0;
12478 pBuf += sizeof(tANI_U16);
12479 // bssid
12480 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12481 pBuf = pBuf + sizeof ( tSirMacAddr );
12482 // bEnable
12483 *pBuf = (tANI_BOOLEAN)bEnable;
12484 if(!HAL_STATUS_SUCCESS(status))
12485 {
12486 palFreeMemory(pMac->hHdd, pMsg);
12487 break;
12488 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012489 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 return( status );
12492}
Jeff Johnson295189b2012-06-20 16:38:30 -070012493eHalStatus
12494csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12495 VOS_MODULE_ID modId, tSirMacAddr bssId,
12496 void *pUsrContext, void *pfnSapEventCallback,
12497 tANI_U8 *pAssocStasBuf )
12498{
12499 eHalStatus status = eHAL_STATUS_SUCCESS;
12500 tSirSmeGetAssocSTAsReq *pMsg;
12501 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12502 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 do
12504 {
12505 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12506 if (!HAL_STATUS_SUCCESS(status)) break;
12507 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12508 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012509 pBuf = (tANI_U8 *)&pMsg->bssId;
12510 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 // bssId
12512 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12513 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 // modId
12515 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12516 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12517 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 // pUsrContext
12519 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12520 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12521 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 // pfnSapEventCallback
12523 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12524 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12525 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 // pAssocStasBuf
12527 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12528 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12529 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 status = palSendMBMessage( pMac->hHdd, pMsg );
12532 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 return( status );
12534 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012535eHalStatus
12536csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12537 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12538 {
12539 eHalStatus status = eHAL_STATUS_SUCCESS;
12540 tSirSmeGetWPSPBCSessionsReq *pMsg;
12541 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12542 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 do
12544 {
12545 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12546 if (!HAL_STATUS_SUCCESS(status)) break;
12547 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12548 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012549 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070012550 VOS_ASSERT(pBuf);
12551
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 // pUsrContext
12554 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12555 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12556 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 // pSapEventCallback
12558 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12559 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12560 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 // bssId
12562 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12563 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 // MAC Address of STA in WPS session
12565 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12566 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 return( status );
12571}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012572
12573eHalStatus
12574csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12575{
12576 tpSirChangeBIParams pMsg;
12577 tANI_U16 len = 0;
12578 eHalStatus status = eHAL_STATUS_SUCCESS;
12579 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12580
12581 if(!pSession)
12582 {
12583 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12584 return eHAL_STATUS_FAILURE;
12585 }
12586
12587 //NO need to update the Beacon Params if update beacon parameter flag is not set
12588 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12589 return eHAL_STATUS_SUCCESS;
12590
12591 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12592
12593 /* Create the message and send to lim */
12594 len = sizeof(tSirChangeBIParams);
12595 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12596 if(HAL_STATUS_SUCCESS(status))
12597 {
12598 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12599 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12600 pMsg->length = len;
12601
12602 // bssId
12603 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012604 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 -080012605 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12606 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12607 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012608 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012609 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12610 status = palSendMBMessage(pMac->hHdd, pMsg);
12611 }
12612 return status;
12613}
12614
Jeff Johnson295189b2012-06-20 16:38:30 -070012615eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12616{
12617 eHalStatus status = eHAL_STATUS_SUCCESS;
12618 tSirSmeDeauthReq *pMsg;
12619 tANI_U8 *pBuf;
12620 tANI_U16 wTmp;
12621 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12622 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12623 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 do {
12625 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12626 if ( !HAL_STATUS_SUCCESS(status) ) break;
12627 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12628 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12629 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12630 //sessionId
12631 pBuf = &pMsg->sessionId;
12632 *pBuf++ = (tANI_U8)sessionId;
12633
12634 //tansactionId
12635 *pBuf = 0;
12636 *(pBuf + 1 ) = 0;
12637 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12641 // Set the BSSID before sending the message to LIM
12642 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12643 pBuf = pBuf + sizeof(tSirMacAddr);
12644 }
12645 else
12646 {
12647 // Set the BSSID before sending the message to LIM
12648 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12649 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 }
12651 if(!HAL_STATUS_SUCCESS(status))
12652 {
12653 palFreeMemory(pMac->hHdd, pMsg);
12654 break;
12655 }
12656 // Set the peer MAC address before sending the message to LIM
12657 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12658 pBuf = pBuf + sizeof(tSirMacAddr);
12659 if(!HAL_STATUS_SUCCESS(status))
12660 {
12661 palFreeMemory(pMac->hHdd, pMsg);
12662 break;
12663 }
12664 wTmp = pal_cpu_to_be16(reasonCode);
12665 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12666 if(!HAL_STATUS_SUCCESS(status))
12667 {
12668 palFreeMemory(pMac->hHdd, pMsg);
12669 break;
12670 }
12671 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 return( status );
12674}
12675
Jeff Johnson295189b2012-06-20 16:38:30 -070012676eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12677{
12678 eHalStatus status = eHAL_STATUS_SUCCESS;
12679 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 do {
12681 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12682 if ( !HAL_STATUS_SUCCESS(status) ) break;
12683 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12684 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12685 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12686 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12687 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12688 if(!HAL_STATUS_SUCCESS(status))
12689 {
12690 palFreeMemory(pMac->hHdd, pMsg);
12691 break;
12692 }
12693//To test reconn
12694 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12695 if(!HAL_STATUS_SUCCESS(status))
12696 {
12697 palFreeMemory(pMac->hHdd, pMsg);
12698 break;
12699 }
12700//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 return( status );
12704}
12705
Jeff Johnson295189b2012-06-20 16:38:30 -070012706eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12707{
12708 eHalStatus status = eHAL_STATUS_SUCCESS;
12709 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 do {
12711 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12712 if ( !HAL_STATUS_SUCCESS(status) ) break;
12713 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12714 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12715 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12716 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12717 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12718 if(!HAL_STATUS_SUCCESS(status))
12719 {
12720 palFreeMemory(pMac->hHdd, pMsg);
12721 break;
12722 }
12723 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12724 if(!HAL_STATUS_SUCCESS(status))
12725 {
12726 palFreeMemory(pMac->hHdd, pMsg);
12727 break;
12728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 return( status );
12732}
Jeff Johnson295189b2012-06-20 16:38:30 -070012733eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12734{
12735 eHalStatus status = eHAL_STATUS_SUCCESS;
12736 tSirSmeAssocCnf *pMsg;
12737 tANI_U8 *pBuf;
12738 tSirResultCodes statusCode;
12739 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 do {
12741 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12742 if ( !HAL_STATUS_SUCCESS(status) ) break;
12743 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12744 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12745 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012746 pBuf = (tANI_U8 *)&pMsg->statusCode;
12747 if(HAL_STATUS_SUCCESS(Halstatus))
12748 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12749 else
12750 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12751 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12752 pBuf += sizeof(tSirResultCodes);
12753 // bssId
12754 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12755 pBuf += sizeof (tSirMacAddr);
12756 // peerMacAddr
12757 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12758 pBuf += sizeof (tSirMacAddr);
12759 // aid
12760 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12761 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12762 pBuf += sizeof (tANI_U16);
12763 // alternateBssId
12764 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12765 pBuf += sizeof (tSirMacAddr);
12766 // alternateChannelId
12767 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 status = palSendMBMessage( pMac->hHdd, pMsg );
12769 if(!HAL_STATUS_SUCCESS(status))
12770 {
12771 //pMsg is freed by palSendMBMessage
12772 break;
12773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 return( status );
12776}
Jeff Johnson295189b2012-06-20 16:38:30 -070012777eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12778 tpSirSmeAssocInd pAssocInd,
12779 eHalStatus Halstatus,
12780 tANI_U8 sessionId)
12781{
12782 tSirMsgQ msgQ;
12783 eHalStatus status = eHAL_STATUS_SUCCESS;
12784 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12785 tANI_U8 *pBuf;
12786 tSirResultCodes statusCode;
12787 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 do {
12789 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12790 if ( !HAL_STATUS_SUCCESS(status) ) break;
12791 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012792
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12794 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12795
12796 pMsg->sessionId = sessionId;
12797
12798 pBuf = (tANI_U8 *)&pMsg->statusCode;
12799 if(HAL_STATUS_SUCCESS(Halstatus))
12800 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12801 else
12802 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12803 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12804 pBuf += sizeof(tSirResultCodes);
12805 // bssId
12806 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12807 pBuf += sizeof (tSirMacAddr);
12808 // peerMacAddr
12809 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12810 pBuf += sizeof (tSirMacAddr);
12811 // StaId
12812 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12813 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12814 pBuf += sizeof (tANI_U16);
12815 // alternateBssId
12816 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12817 pBuf += sizeof (tSirMacAddr);
12818 // alternateChannelId
12819 *pBuf = 11;
12820 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012821 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 //Wmm
12823 *pBuf = pAssocInd->wmmEnabledSta;
12824 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 //RSN IE
12826 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12827 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 //Additional IE
12829 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12830 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 //reassocReq
12832 *pBuf = pAssocInd->reassocReq;
12833 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12835 msgQ.bodyptr = pMsg;
12836 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 return( status );
12840}
Jeff Johnson295189b2012-06-20 16:38:30 -070012841
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012842eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12844 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12845 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12846 tANI_U8 *pKeyRsc )
12847{
12848 tSirSmeSetContextReq *pMsg;
12849 tANI_U16 msgLen;
12850 eHalStatus status = eHAL_STATUS_FAILURE;
12851 tAniEdType tmpEdType;
12852 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012853 tANI_U8 *pBuf = NULL;
12854 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12859 // key set. Since we only support upto one key, we always allocate memory for 1 key
12860 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12861 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12862 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12863 ( sizeof( pMsg->keyMaterial.key ) );
12864
12865 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12866 if ( !HAL_STATUS_SUCCESS(status) ) break;
12867 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12868 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12869 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 //sessionId
12871 pBuf = &pMsg->sessionId;
12872 *pBuf = (tANI_U8)sessionId;
12873 pBuf++;
12874 // transactionId
12875 *pBuf = 0;
12876 *(pBuf + 1) = 0;
12877 pBuf += sizeof(tANI_U16);
12878 // peerMacAddr
12879 palCopyMemory( pMac->hHdd, pBuf,
12880 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12881
12882 pBuf += sizeof(tSirMacAddr);
12883
12884 // bssId
12885 palCopyMemory( pMac->hHdd, pBuf,
12886 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12887
12888 pBuf += sizeof(tSirMacAddr);
12889
12890 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12892 // in the tSirKeyMaterial keyMaterial; field).
12893 //
12894 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12895 // shorter than this max size. Is LIM interpreting this ok ?
12896 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 -070012897 // set pMsg->keyMaterial.edType
12898 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12899 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12900 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 // set the pMsg->keyMaterial.numKeys field
12902 *p = numKeys;
12903 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 // set pSirKey->keyId = keyId;
12905 *p = keyId;
12906 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 // set pSirKey->unicast = (tANI_U8)fUnicast;
12908 *p = (tANI_U8)fUnicast;
12909 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 // set pSirKey->keyDirection = aniKeyDirection;
12911 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12912 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12913 p += sizeof(tAniKeyDirection);
12914 // pSirKey->keyRsc = ;;
12915 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12916 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 // set pSirKey->paeRole
12918 *p = paeRole; // 0 is Supplicant
12919 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012920 // set pSirKey->keyLength = keyLength;
12921 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 if ( keyLength && pKey )
12923 {
12924 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12925 if(keyLength == 16)
12926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012927 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 -070012928 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12929 pKey[5], pKey[6], pKey[7], pKey[8],
12930 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12931 }
12932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012935 return( status );
12936}
12937
Jeff Johnson295189b2012-06-20 16:38:30 -070012938eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12939 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12940{
12941 eHalStatus status;
12942 tSirSmeStartBssReq *pMsg;
12943 tANI_U8 *pBuf = NULL;
12944 tANI_U8 *wTmpBuf = NULL;
12945 tANI_U16 msgLen, wTmp;
12946 tANI_U32 dwTmp;
12947 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012948 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012951
12952 if(!pSession)
12953 {
12954 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12955 return eHAL_STATUS_FAILURE;
12956 }
12957
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 do {
12959 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12960 pSession->joinFailStatusCode.reasonCode = 0;
12961 msgLen = sizeof(tSirSmeStartBssReq);
12962 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12963 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12965 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 //sessionId
12969 *pBuf = (tANI_U8)sessionId;
12970 pBuf++;
12971 // transactionId
12972 *pBuf = 0;
12973 *(pBuf + 1) = 0;
12974 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012975 // bssid
12976 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12977 pBuf += sizeof(tSirMacAddr);
12978 // selfMacAddr
12979 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12980 pBuf += sizeof(tSirMacAddr);
12981 // beaconInterval
12982 if( pBssDesc && pBssDesc->beaconInterval )
12983 {
12984 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12985 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012986 else if(pParam->beaconInterval)
12987 {
12988 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012990 else
12991 {
12992 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12993 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012994 if(csrIsconcurrentsessionValid (pMac, sessionId,
12995 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012996 == eHAL_STATUS_SUCCESS )
12997 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012998 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012999 pParam->bssPersona);
13000 //Update the beacon Interval
13001 pParam->beaconInterval = wTmp;
13002 }
13003 else
13004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013005 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013006 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070013007 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070013008 return status;
13009 }
13010
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13012 pBuf += sizeof(tANI_U16);
13013 // dot11mode
13014 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13015 pBuf += 1;
13016 // bssType
13017 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
13018 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
13019 pBuf += sizeof(tSirBssType);
13020 // ssId
13021 if( pParam->ssId.length )
13022 {
13023 // ssId len
13024 *pBuf = pParam->ssId.length;
13025 pBuf++;
13026 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
13027 pBuf += pParam->ssId.length;
13028 }
13029 else
13030 {
13031 *pBuf = 0;
13032 pBuf++;
13033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 // set the channel Id
13035 *pBuf = pParam->operationChn;
13036 pBuf++;
13037 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013038 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
13039 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
13040 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013041
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 // Set privacy
13043 *pBuf = pParam->privacy;
13044 pBuf++;
13045
13046 //Set Uapsd
13047 *pBuf = pParam->ApUapsdEnable;
13048 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013049 //Set SSID hidden
13050 *pBuf = pParam->ssidHidden;
13051 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13053 pBuf++;
13054
13055 //Ht protection Enable/Disable
13056 *pBuf = (tANI_U8)pParam->protEnabled;
13057 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 //Enable Beacons to Receive for OBSS protection Enable/Disable
13059 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13060 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013061 //set cfg related to protection
13062 wTmp = pal_cpu_to_be16( pParam->ht_protection );
13063 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13064 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013065 // Set Auth type
13066 authType = pal_cpu_to_be32(pParam->authType);
13067 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
13068 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 // Set DTIM
13070 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
13071 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
13072 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 // Set wps_state
13074 *pBuf = pParam->wps_state;
13075 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 //Persona
13077 *pBuf = (tANI_U8)pParam->bssPersona;
13078 pBuf++;
13079
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013080 //txLdpcIniFeatureEnabled
13081 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13082 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013083
13084 // prop IE enabled in .ini file
13085 *pBuf = (tANI_U8)pMac->roam.configParam.enableOxygenNwk;
13086 pBuf++;
13087
13088 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13090 {
13091 status = eHAL_STATUS_INVALID_PARAMETER;
13092 palFreeMemory( pMac->hHdd, pMsg );
13093 break;
13094 }
13095 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
13096 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
13097 pBuf += sizeof(tANI_U16);
13098 if( wTmp )
13099 {
13100 wTmp = pParam->nRSNIELength;
13101 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13102 pBuf += wTmp;
13103 }
13104 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13105 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13106 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13108 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13110 pBuf += pParam->operationalRateSet.numRates ;
13111 *pBuf++ = pParam->extendedRateSet.numRates;
13112 if(0 != pParam->extendedRateSet.numRates)
13113 {
13114 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13115 pBuf += pParam->extendedRateSet.numRates;
13116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13118 pMsg->length = pal_cpu_to_be16(msgLen);
13119
13120 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013122 return( status );
13123}
13124
Jeff Johnson295189b2012-06-20 16:38:30 -070013125eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13126{
13127 eHalStatus status = eHAL_STATUS_FAILURE;
13128 tSirSmeStopBssReq *pMsg;
13129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13130 tANI_U8 *pBuf;
13131 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013132
13133 if(!pSession)
13134 {
13135 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13136 return eHAL_STATUS_FAILURE;
13137 }
13138
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 do {
13140 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13141 if ( !HAL_STATUS_SUCCESS(status) ) break;
13142 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13143 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13144 pBuf = &pMsg->sessionId;
13145 //sessionId
13146 *pBuf = (tANI_U8)sessionId;
13147 pBuf++;
13148 // transactionId
13149 *pBuf = 0;
13150 pBuf += sizeof(tANI_U16);
13151 //reason code
13152 *pBuf = 0;
13153 pBuf += sizeof(tSirResultCodes);
13154 // bssid
13155 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13156 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13157 {
13158 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13159 }
13160 else
13161 {
13162 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13163 }
13164 pBuf += sizeof(tSirMacAddr);
13165 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13166 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 status = palSendMBMessage( pMac->hHdd, pMsg );
13168#if 0
13169 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13170 if ( !HAL_STATUS_SUCCESS(status) ) break;
13171 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13172 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13173 pMsg->reasonCode = 0;
13174 // bssid
13175 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13176 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13177 {
13178 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13179 }
13180 else
13181 {
13182 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13183 }
13184 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13185 pMsg->transactionId = 0;
13186 pMsg->sessionId = (tANI_U8)sessionId;
13187 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13188 status = palSendMBMessage( pMac->hHdd, pMsg );
13189#endif
13190 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 return( status );
13192}
13193
Jeff Johnson295189b2012-06-20 16:38:30 -070013194eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13195 tCsrRoamModifyProfileFields *pModProfileFields,
13196 tANI_U32 *pRoamId, v_BOOL_t fForce)
13197{
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 eHalStatus status = eHAL_STATUS_FAILURE;
13199 tANI_U32 roamId = 0;
13200 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 if((csrIsConnStateConnected(pMac, sessionId)) &&
13202 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13203 &pSession->connectedProfile.modifyProfileFields,
13204 sizeof(tCsrRoamModifyProfileFields)))) )
13205 {
13206 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13207 if(pRoamId)
13208 {
13209 *pRoamId = roamId;
13210 }
13211
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13213 eCsrSmeIssuedReassocToSameAP, roamId,
13214 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 return status;
13217}
Jeff Johnson295189b2012-06-20 16:38:30 -070013218static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13219{
13220 eHalStatus status = eHAL_STATUS_SUCCESS;
13221 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13223 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13224 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13225 return (status);
13226}
Jeff Johnson295189b2012-06-20 16:38:30 -070013227eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13228{
13229 eHalStatus status = eHAL_STATUS_SUCCESS;
13230 tListElem *pEntry = NULL;
13231 tSmeCmd *pCommand = NULL;
13232 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 do
13234 {
13235 if(pMsg == NULL)
13236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013237 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 status = eHAL_STATUS_FAILURE;
13239 break;
13240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13242 if(pEntry)
13243 {
13244 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13245 if(eSmeCommandAddStaSession == pCommand->command)
13246 {
13247 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013248 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 //Remove this command out of the active list
13252 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13253 {
13254 //Now put this command back on the avilable command list
13255 csrReleaseCommand(pMac, pCommand);
13256 }
13257 smeProcessPendingQueue( pMac );
13258 }
13259 else
13260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013261 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 -070013262 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 status = eHAL_STATUS_FAILURE;
13264 break;
13265 }
13266 }
13267 else
13268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013269 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 -070013270 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 status = eHAL_STATUS_FAILURE;
13272 break;
13273 }
13274 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013276}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013277eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13278 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013279{
13280 tSirSmeAddStaSelfReq *pMsg;
13281 tANI_U16 msgLen;
13282 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013284 msgLen = sizeof(tSirSmeAddStaSelfReq);
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13286 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013288 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13289 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 // self station address
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013291 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr,
13292 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13293
13294 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13295
13296 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 pMsg->selfMacAddr[0],
13298 pMsg->selfMacAddr[1],
13299 pMsg->selfMacAddr[2],
13300 pMsg->selfMacAddr[3],
13301 pMsg->selfMacAddr[4],
13302 pMsg->selfMacAddr[5]);
13303 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 return( status );
13306}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013307eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13308 tANI_U32 sessionId,
13309 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013310{
13311 eHalStatus status = eHAL_STATUS_SUCCESS;
13312 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 pCommand = csrGetCommandBuffer(pMac);
13314 if(NULL == pCommand)
13315 {
13316 status = eHAL_STATUS_RESOURCES;
13317 }
13318 else
13319 {
13320 pCommand->command = eSmeCommandAddStaSession;
13321 pCommand->sessionId = (tANI_U8)sessionId;
13322 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013323 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13325 if( !HAL_STATUS_SUCCESS( status ) )
13326 {
13327 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013328 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 }
13330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 return (status);
13332}
Jeff Johnson295189b2012-06-20 16:38:30 -070013333eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13334{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013335 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013336}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013337eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13338 csrRoamCompleteCallback callback,
13339 void *pContext, tANI_U8 *pSelfMacAddr,
13340 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013341{
13342 eHalStatus status = eHAL_STATUS_SUCCESS;
13343 tANI_U32 i;
13344 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 *pbSessionId = CSR_SESSION_ID_INVALID;
13346 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13347 {
13348 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13349 {
13350 pSession = CSR_GET_SESSION( pMac, i );
13351 status = eHAL_STATUS_SUCCESS;
13352 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13353 pSession->sessionId = (tANI_U8)i;
13354 pSession->callback = callback;
13355 pSession->pContext = pContext;
13356 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13357 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013358 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13359 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013360 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013361 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013363 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 break;
13365 }
13366#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013367 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13368 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013370 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013372 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 break;
13374 }
13375#endif
13376 pSession->ibssJoinTimerInfo.pMac = pMac;
13377 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013378 status = vos_timer_init(&pSession->hTimerIbssJoining, VOS_TIMER_TYPE_SW,
13379 csrRoamIbssJoinTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 &pSession->ibssJoinTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013381 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013383 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 break;
13385 }
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 Koyyalamudia48c6812013-07-11 12:01:37 +053013572 vos_timer_destroy(&pSession->hTimerIbssJoining);
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 purgeSmeSessionCmdList(pMac, sessionId);
13574 purgeCsrSessionCmdList(pMac, sessionId);
13575 csrInitSession(pMac, sessionId);
13576 }
13577}
13578
Jeff Johnson295189b2012-06-20 16:38:30 -070013579eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13580 tANI_BOOLEAN fSync,
13581 csrRoamSessionCloseCallback callback,
13582 void *pContext )
13583{
13584 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13586 {
13587 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13588 if(fSync)
13589 {
13590 csrCleanupSession(pMac, sessionId);
13591 }
13592 else
13593 {
13594 purgeSmeSessionCmdList(pMac, sessionId);
13595 purgeCsrSessionCmdList(pMac, sessionId);
13596 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13597 pSession->selfMacAddr, callback, pContext);
13598 }
13599 }
13600 else
13601 {
13602 status = eHAL_STATUS_INVALID_PARAMETER;
13603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 return ( status );
13605}
13606
Jeff Johnson295189b2012-06-20 16:38:30 -070013607static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13608{
13609 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013610
13611 if(!pSession)
13612 {
13613 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13614 return;
13615 }
13616
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13618 pSession->sessionId = CSR_SESSION_ID_INVALID;
13619 pSession->callback = NULL;
13620 pSession->pContext = NULL;
13621 pSession->ibss_join_pending = FALSE;
13622 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13623 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13624 csrFreeRoamProfile( pMac, sessionId );
13625 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13626 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13627 csrFreeConnectBssDesc(pMac, sessionId);
13628 csrScanEnable(pMac);
13629 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13630 if(pSession->pWpaRsnReqIE)
13631 {
13632 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13633 pSession->pWpaRsnReqIE = NULL;
13634 }
13635 pSession->nWpaRsnReqIeLength = 0;
13636 if(pSession->pWpaRsnRspIE)
13637 {
13638 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13639 pSession->pWpaRsnRspIE = NULL;
13640 }
13641 pSession->nWpaRsnRspIeLength = 0;
13642#ifdef FEATURE_WLAN_WAPI
13643 if(pSession->pWapiReqIE)
13644 {
13645 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13646 pSession->pWapiReqIE = NULL;
13647 }
13648 pSession->nWapiReqIeLength = 0;
13649 if(pSession->pWapiRspIE)
13650 {
13651 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13652 pSession->pWapiRspIE = NULL;
13653 }
13654 pSession->nWapiRspIeLength = 0;
13655#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 if(pSession->pAddIEScan)
13657 {
13658 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13659 pSession->pAddIEScan = NULL;
13660 }
13661 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 if(pSession->pAddIEAssoc)
13663 {
13664 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13665 pSession->pAddIEAssoc = NULL;
13666}
13667 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013668}
13669
Jeff Johnson295189b2012-06-20 16:38:30 -070013670eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13671{
13672 eHalStatus status = eHAL_STATUS_FAILURE;
13673 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13675 {
13676 if( CSR_IS_SESSION_VALID( pMac, i ) )
13677 {
13678 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13679 {
13680 //Found it
13681 status = eHAL_STATUS_SUCCESS;
13682 *pSessionId = i;
13683 break;
13684 }
13685 }
13686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 return( status );
13688}
13689
Jeff Johnson295189b2012-06-20 16:38:30 -070013690//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13691//session because for IBSS, the bssid changes.
13692static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13693{
13694 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13695 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13697 {
13698 if( CSR_IS_SESSION_VALID( pMac, i ) )
13699 {
13700 pSession = CSR_GET_SESSION( pMac, i );
13701 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13702 {
13703 //Found it
13704 nRet = i;
13705 break;
13706 }
13707 }
13708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 return (nRet);
13710}
Jeff Johnson295189b2012-06-20 16:38:30 -070013711static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13712{
13713 /* Update the current BSS info in ho control block based on connected
13714 profile info from pmac global structure */
13715
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013716 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13718 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 /* Check for user misconfig of RSSI trigger threshold */
13720 pMac->roam.configParam.vccRssiThreshold =
13721 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13722 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13723 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 /* Check for user misconfig of UL MAC Loss trigger threshold */
13725 pMac->roam.configParam.vccUlMacLossThreshold =
13726 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13727 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013728#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13729 {
13730 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 /* Indicate the neighbor roal algorithm about the connect indication */
13732 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13733 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13734 }
13735#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013736}
13737
Jeff Johnson295189b2012-06-20 16:38:30 -070013738static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13739{
13740 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013741
13742 if(!pSession)
13743 {
13744 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13745 return;
13746 }
13747
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 //Only to handle the case for Handover on infra link
13749 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13750 {
13751 return;
13752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13754 csrRoamDeregStatisticsReq(pMac);
13755 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13756#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13757 /* Indicate the neighbor roal algorithm about the disconnect indication */
13758 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13759#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013760
13761 //Remove this code once SLM_Sessionization is supported
13762 //BMPS_WORKAROUND_NOT_NEEDED
13763 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013764 csrIsInfraApStarted( pMac ) &&
13765 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013766 {
13767 pMac->roam.configParam.doBMPSWorkaround = 0;
13768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013769}
13770
Jeff Johnson295189b2012-06-20 16:38:30 -070013771void csrRoamTlStatsTimerHandler(void *pv)
13772{
13773 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13774 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13776
Jeff Johnsone7245742012-09-05 17:12:55 -070013777 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13778
Jeff Johnson295189b2012-06-20 16:38:30 -070013779#if 0
13780 // TODO Persession .???
13781 //req TL for stats
13782 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013784 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 }
13786 else
13787 {
13788 //save in SME
13789 csrRoamSaveStatsFromTl(pMac, tlStats);
13790 }
13791#endif
13792 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13793 {
13794 if(pMac->roam.tlStatsReqInfo.periodicity)
13795 {
13796 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013797 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13798 pMac->roam.tlStatsReqInfo.periodicity);
13799 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013801 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 return;
13803 }
13804 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13805 }
13806 }
13807}
Jeff Johnson295189b2012-06-20 16:38:30 -070013808void csrRoamPeStatsTimerHandler(void *pv)
13809{
13810 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13811 eHalStatus status;
13812 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13813 VOS_STATUS vosStatus;
13814 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 pPeStatsReqListEntry->timerRunning = FALSE;
13816 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13817 {
13818 // If we entered here, meaning the timer could not be successfully
13819 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13820
13821 /* Destroy the timer */
13822 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13823 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013825 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 }
13827
13828 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013829 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 pPeStatsReqListEntry = NULL;
13831 }
13832 else
13833 {
13834 if(!pPeStatsReqListEntry->rspPending)
13835 {
13836 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13837 pPeStatsReqListEntry->staId);
13838 if(!HAL_STATUS_SUCCESS(status))
13839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013840 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 }
13842 else
13843 {
13844 pPeStatsReqListEntry->rspPending = TRUE;
13845 }
13846 }
13847
13848 //send down a req
13849 if(pPeStatsReqListEntry->periodicity &&
13850 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13851 {
13852 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13853 if(ePMC_FULL_POWER == powerState)
13854 {
13855 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13856 {
13857 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13858 }
13859 }
13860 else
13861 {
13862 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13863 {
13864 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13865 }
13866 }
13867 //start timer
13868 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13869 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013871 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 return;
13873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 pPeStatsReqListEntry->timerRunning = TRUE;
13875
13876 }
13877
13878 }
13879}
Jeff Johnson295189b2012-06-20 16:38:30 -070013880void csrRoamStatsClientTimerHandler(void *pv)
13881{
13882 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13884 {
13885#if 0
13886 // TODO Stats fix for multisession
13887 //start the timer
13888 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13889
13890 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013892 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 }
13894#endif
13895 }
13896#if 0
13897 //send up the stats report
13898 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13899 pStaEntry->staId, pStaEntry->pContext);
13900#endif
13901}
13902
13903
13904
Jeff Johnson295189b2012-06-20 16:38:30 -070013905eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13906{
13907 tAniGetPEStatsReq *pMsg;
13908 eHalStatus status = eHAL_STATUS_SUCCESS;
13909 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13910 if ( !HAL_STATUS_SUCCESS(status) )
13911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013912 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 return status;
13914 }
13915 // need to initiate a stats request to PE
13916 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13917 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13918 pMsg->staId = staId;
13919 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 if(!HAL_STATUS_SUCCESS(status))
13922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013923 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 return status;
13926}
Jeff Johnson295189b2012-06-20 16:38:30 -070013927void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13928{
13929 tAniGetPEStatsRsp *pSmeStatsRsp;
13930 eHalStatus status = eHAL_STATUS_FAILURE;
13931 tListElem *pEntry = NULL;
13932 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13933 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13934 tANI_U32 tempMask = 0;
13935 tANI_U8 counter = 0;
13936 tANI_U8 *pStats = NULL;
13937 tANI_U32 length = 0;
13938 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013939 v_S7_t rssi = 0, snr = 0;
13940 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013941 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13943 if(pSmeStatsRsp->rc)
13944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013945 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 goto post_update;
13947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 tempMask = pSmeStatsRsp->statsMask;
13949 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 /* subtract all statistics from this length, and after processing the entire
13951 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13952 * in this 'stats' message.
13953 */
13954 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 //new stats info from PE, fill up the stats strucutres in PMAC
13956 while(tempMask)
13957 {
13958 if(tempMask & 1)
13959 {
13960 switch(counter)
13961 {
13962 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013963 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13965 pStats, sizeof(tCsrSummaryStatsInfo));
13966 if(!HAL_STATUS_SUCCESS(status))
13967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013968 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 }
13970 pStats += sizeof(tCsrSummaryStatsInfo);
13971 length -= sizeof(tCsrSummaryStatsInfo);
13972 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013974 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13976 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13977 if(!HAL_STATUS_SUCCESS(status))
13978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013979 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 }
13981 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13982 length -= sizeof(tCsrGlobalClassAStatsInfo);
13983 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013985 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13987 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13988 if(!HAL_STATUS_SUCCESS(status))
13989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013990 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 }
13992 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13993 length -= sizeof(tCsrGlobalClassBStatsInfo);
13994 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013996 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13998 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13999 if(!HAL_STATUS_SUCCESS(status))
14000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014001 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 }
14003 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14004 length -= sizeof(tCsrGlobalClassCStatsInfo);
14005 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014006 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014007 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14009 {
14010 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14011 pStats, sizeof(tCsrPerStaStatsInfo));
14012 }
14013 else
14014 {
14015 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014016 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 VOS_ASSERT( 0 );
14018 }
14019 if(!HAL_STATUS_SUCCESS(status))
14020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014021 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 }
14023 pStats += sizeof(tCsrPerStaStatsInfo);
14024 length -= sizeof(tCsrPerStaStatsInfo);
14025 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014027 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 }
14030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 tempMask >>=1;
14032 counter++;
14033 }
14034 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14035 if (length != 0)
14036 {
14037 pRssi = (tANI_U32*)pStats;
14038 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014039 pStats += sizeof(tANI_U32);
14040 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 }
14042 else
14043 {
14044 /* If riva is not sending rssi, continue to use the hack */
14045 rssi = RSSI_HACK_BMPS;
14046 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014047
Jeff Johnson295189b2012-06-20 16:38:30 -070014048 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014049
14050 if (length != 0)
14051 {
14052 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014053 pStats += sizeof(tANI_U32);
14054 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014055 }
14056 else
14057 {
14058 linkCapacity = 0;
14059 }
14060
14061 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014062
14063 if (length != 0)
14064 {
14065 pSnr = (tANI_U32*)pStats;
14066 snr = (v_S7_t)*pSnr;
14067 }
14068 else
14069 {
14070 snr = SNR_HACK_BMPS;
14071 }
14072
14073 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014074post_update:
14075 //make sure to update the pe stats req list
14076 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14077 if(pEntry)
14078 {
14079 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14080 pPeStaEntry->rspPending = FALSE;
14081
14082 }
14083 //check the one timer cases
14084 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14085 if(pEntry)
14086 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 if(pTempStaEntry->timerExpired)
14089 {
14090 //send up the stats report
14091 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14092 pTempStaEntry->staId, pTempStaEntry->pContext);
14093 //also remove from the client list
14094 csrRoamRemoveStatListEntry(pMac, pEntry);
14095 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 }
14097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014098}
Jeff Johnson295189b2012-06-20 16:38:30 -070014099tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14100{
14101 tListElem *pEntry = NULL;
14102 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 if(!pEntry)
14105 {
14106 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014107 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 return NULL;
14109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 while( pEntry )
14111 {
14112 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 if(pTempStaEntry->statsMask == statsMask)
14114 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014115 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 break;
14117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 return pEntry;
14121}
14122
Jeff Johnson295189b2012-06-20 16:38:30 -070014123tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14124 tANI_BOOLEAN update)
14125{
14126 tListElem *pEntry;
14127 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 if(!pEntry)
14130 {
14131 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014132 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014133 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 return NULL;
14135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 while( pEntry )
14137 {
14138 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014139 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14140 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014142 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 if(update)
14144 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014145 pTempStaEntry->periodicity = pStaEntry->periodicity;
14146 pTempStaEntry->callback = pStaEntry->callback;
14147 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 }
14149 break;
14150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 return pEntry;
14154}
Jeff Johnson295189b2012-06-20 16:38:30 -070014155tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14156{
14157 tListElem *pEntry;
14158 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 if(!pEntry)
14161 {
14162 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014163 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014164 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 return NULL;
14166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 while( pEntry )
14168 {
14169 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14171 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014172 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 break;
14174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 return pEntry;
14178}
Jeff Johnson295189b2012-06-20 16:38:30 -070014179eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14180 csrRoamLinkQualityIndCallback callback,
14181 void *pContext)
14182{
14183 pMac->roam.linkQualityIndInfo.callback = callback;
14184 pMac->roam.linkQualityIndInfo.context = pContext;
14185 if( NULL == callback )
14186 {
14187 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14188 }
14189 else
14190 {
14191 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 /* do we need to invoke the callback to notify client of initial value ?? */
14193 }
14194 return eHAL_STATUS_SUCCESS;
14195}
Jeff Johnson295189b2012-06-20 16:38:30 -070014196void csrRoamVccTrigger(tpAniSirGlobal pMac)
14197{
14198 eCsrRoamLinkQualityInd newVccLinkQuality;
14199 tANI_U32 ul_mac_loss = 0;
14200 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14202 /*-------------------------------------------------------------------------
14203 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 Check for a change in link quality and notify client if necessary
14205 -------------------------------------------------------------------------*/
14206 ul_mac_loss_trigger_threshold =
14207 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014208 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014209 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014210 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014213 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14215 }
14216 else
14217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014218 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14222 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014225 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14227 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014228 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 newVccLinkQuality );
14230
14231 /* we now invoke the callback once to notify client of initial value */
14232 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14233 pMac->roam.linkQualityIndInfo.context );
14234 //event: EVENT_WLAN_VCC
14235 }
14236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 pMac->roam.vccLinkQuality = newVccLinkQuality;
14238
Jeff Johnson295189b2012-06-20 16:38:30 -070014239}
Jeff Johnson295189b2012-06-20 16:38:30 -070014240VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14241 v_U8_t rssiNotification,
14242 void * context)
14243{
14244 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14245 eCsrRoamLinkQualityInd newVccLinkQuality;
14246 // TODO : Session info unavailable
14247 tANI_U32 sessionId = 0;
14248 VOS_STATUS status = VOS_STATUS_SUCCESS;
14249 /*-------------------------------------------------------------------------
14250 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 Check for a change in link quality and notify client if necessary
14252 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014253 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014254 pMac->roam.configParam.vccRssiThreshold);
14255 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14256 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014257 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 return VOS_STATUS_SUCCESS;
14259 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014262 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14264 }
14265 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014267 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14269 }
14270 else
14271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014272 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 //Set to this so the code below won't do anything
14274 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014275 VOS_ASSERT(0);
14276 }
14277
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014280 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014283 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 /* we now invoke the callback once to notify client of initial value */
14286 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14287 pMac->roam.linkQualityIndInfo.context );
14288 //event: EVENT_WLAN_VCC
14289 }
14290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 return status;
14293}
Jeff Johnson295189b2012-06-20 16:38:30 -070014294tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14295 tDblLinkList *pStaList,
14296 tCsrStatsClientReqInfo *pStaEntry)
14297{
14298 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014299 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 //if same entity requested for same set of stats with different periodicity &
14301 // callback update it
14302 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14303 {
14304
14305 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14306 if (!HAL_STATUS_SUCCESS(status))
14307 {
14308 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014309 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 return NULL;
14311 }
14312
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 pNewStaEntry->callback = pStaEntry->callback;
14314 pNewStaEntry->pContext = pStaEntry->pContext;
14315 pNewStaEntry->periodicity = pStaEntry->periodicity;
14316 pNewStaEntry->requesterId = pStaEntry->requesterId;
14317 pNewStaEntry->statsMask = pStaEntry->statsMask;
14318 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14319 pNewStaEntry->pMac = pStaEntry->pMac;
14320 pNewStaEntry->staId = pStaEntry->staId;
14321 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14322
14323 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14324 }
14325 return pNewStaEntry;
14326}
14327
Jeff Johnson295189b2012-06-20 16:38:30 -070014328tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14329 tDblLinkList *pStaList,
14330 tCsrPeStatsReqInfo *pStaEntry)
14331{
14332 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14335 if (!HAL_STATUS_SUCCESS(status))
14336 {
14337 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014338 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 return NULL;
14340 }
14341
Jeff Johnson295189b2012-06-20 16:38:30 -070014342 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14343 pNewStaEntry->numClient = pStaEntry->numClient;
14344 pNewStaEntry->periodicity = pStaEntry->periodicity;
14345 pNewStaEntry->statsMask = pStaEntry->statsMask;
14346 pNewStaEntry->pMac = pStaEntry->pMac;
14347 pNewStaEntry->staId = pStaEntry->staId;
14348 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14349 pNewStaEntry->rspPending = pStaEntry->rspPending;
14350
14351 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 return pNewStaEntry;
14353}
Jeff Johnson295189b2012-06-20 16:38:30 -070014354eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14355 tCsrRssiCallback callback,
14356 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14357{
14358 eHalStatus status = eHAL_STATUS_SUCCESS;
14359 vos_msg_t msg;
14360 tANI_U32 sessionId;
14361
14362 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014363 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14365 if ( !HAL_STATUS_SUCCESS(status) )
14366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014367 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 return status;
14369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14371
14372 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14373 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14374 pMsg->sessionId = sessionId;
14375 pMsg->staId = staId;
14376 pMsg->rssiCallback = callback;
14377 pMsg->pDevContext = pContext;
14378 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 msg.type = eWNI_SME_GET_RSSI_REQ;
14380 msg.bodyptr = pMsg;
14381 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014384 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014385 palFreeMemory(pMac->hHdd, (void *)pMsg);
14386 status = eHAL_STATUS_FAILURE;
14387 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014388 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014389 return status;
14390}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014391
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014392eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14393 tCsrSnrCallback callback,
14394 tANI_U8 staId, tCsrBssid bssId,
14395 void *pContext)
14396{
14397 eHalStatus status = eHAL_STATUS_SUCCESS;
14398 vos_msg_t msg;
14399 tANI_U32 sessionId;
14400
14401 tAniGetSnrReq *pMsg;
14402
14403 smsLog(pMac, LOG2, FL("called"));
14404
14405 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14406 if (NULL == pMsg )
14407 {
14408 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14409 return status;
14410 }
14411
14412 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14413
14414 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14415 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14416 pMsg->sessionId = sessionId;
14417 pMsg->staId = staId;
14418 pMsg->snrCallback = callback;
14419 pMsg->pDevContext = pContext;
14420 msg.type = eWNI_SME_GET_SNR_REQ;
14421 msg.bodyptr = pMsg;
14422 msg.reserved = 0;
14423
14424 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14425 {
14426 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14427 vos_mem_free((v_VOID_t *)pMsg);
14428 status = eHAL_STATUS_FAILURE;
14429 }
14430
14431 smsLog(pMac, LOG2, FL("returned"));
14432 return status;
14433}
14434
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014435#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14436eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14437 tCsrRssiCallback callback,
14438 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14439{
14440 eHalStatus status = eHAL_STATUS_SUCCESS;
14441 tAniGetRssiReq *pMsg;
14442
14443 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14444 if ( !HAL_STATUS_SUCCESS(status) )
14445 {
14446 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14447 return status;
14448 }
14449 // need to initiate a stats request to PE
14450 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14451 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14452 pMsg->staId = staId;
14453 pMsg->rssiCallback = callback;
14454 pMsg->pDevContext = pContext;
14455 pMsg->pVosContext = pVosContext;
14456 status = palSendMBMessage(pMac->hHdd, pMsg );
14457 if(!HAL_STATUS_SUCCESS(status))
14458 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014459 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14460 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014461 status = eHAL_STATUS_FAILURE;
14462 }
14463 return status;
14464}
14465#endif
14466
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053014467/* ---------------------------------------------------------------------------
14468 \fn csrGetTLSTAState
14469 \helper function to get teh TL STA State whenever the function is called.
14470
14471 \param staId - The staID to be passed to the TL
14472 to get the relevant TL STA State
14473 \return the state as tANI_U16
14474 ---------------------------------------------------------------------------*/
14475tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
14476{
14477 WLANTL_STAStateType tlSTAState;
14478 tlSTAState = WLANTL_STA_INIT;
14479
14480 //request TL for STA State
14481 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
14482 {
14483 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
14484 }
14485
14486 return tlSTAState;
14487}
14488
Jeff Johnson295189b2012-06-20 16:38:30 -070014489eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14490 tANI_U32 statsMask,
14491 tCsrStatsCallback callback,
14492 tANI_U32 periodicity, tANI_BOOLEAN cache,
14493 tANI_U8 staId, void *pContext)
14494{
14495 tCsrStatsClientReqInfo staEntry;
14496 tCsrStatsClientReqInfo *pStaEntry = NULL;
14497 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14498 tListElem *pEntry = NULL;
14499 tANI_BOOLEAN found = FALSE;
14500 eHalStatus status = eHAL_STATUS_SUCCESS;
14501 tANI_BOOLEAN insertInClientList = FALSE;
14502 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014503 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014504
14505 if( csrIsAllSessionDisconnected(pMac) )
14506 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014507 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 return eHAL_STATUS_FAILURE;
14509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 if((!statsMask) && (!callback))
14511 {
14512 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014513 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 return eHAL_STATUS_FAILURE;
14515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014516 //for the search list method for deregister
14517 staEntry.requesterId = requesterId;
14518 staEntry.statsMask = statsMask;
14519 //requester wants to deregister or just an error
14520 if((statsMask) && (!callback))
14521 {
14522 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14523 if(!pEntry)
14524 {
14525 //msg
14526 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014527 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 return eHAL_STATUS_FAILURE;
14529 }
14530 else
14531 {
14532 //clean up & return
14533 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014534 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014536 pStaEntry->pPeStaEntry->numClient--;
14537 //check if we need to delete the entry from peStatsReqList too
14538 if(!pStaEntry->pPeStaEntry->numClient)
14539 {
14540 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014542 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014543
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 //check if we need to stop the tl stats timer too
14545 pMac->roam.tlStatsReqInfo.numClient--;
14546 if(!pMac->roam.tlStatsReqInfo.numClient)
14547 {
14548 if(pMac->roam.tlStatsReqInfo.timerRunning)
14549 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014550 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14551 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014553 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 return eHAL_STATUS_FAILURE;
14555 }
14556 }
14557 pMac->roam.tlStatsReqInfo.periodicity = 0;
14558 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14559 }
14560 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 // Destroy the vos timer...
14562 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14563 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014565 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 csrRoamRemoveStatListEntry(pMac, pEntry);
14568 pStaEntry = NULL;
14569 return eHAL_STATUS_SUCCESS;
14570 }
14571 }
14572
14573 if(cache && !periodicity)
14574 {
14575 //return the cached stats
14576 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14577 }
14578 else
14579 {
14580 //add the request in the client req list
14581 staEntry.callback = callback;
14582 staEntry.pContext = pContext;
14583 staEntry.periodicity = periodicity;
14584 staEntry.pPeStaEntry = NULL;
14585 staEntry.staId = staId;
14586 staEntry.pMac = pMac;
14587 staEntry.timerExpired = FALSE;
14588
14589
Jeff Johnson295189b2012-06-20 16:38:30 -070014590 //if periodic report requested with non cached result from PE/TL
14591 if(periodicity)
14592 {
14593
14594 //if looking for stats from PE
14595 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14596 {
14597
14598 //check if same request made already & waiting for rsp
14599 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14600 periodicity, &found, staId);
14601 if(!pPeStaEntry)
14602 {
14603 //bail out, maxed out on number of req for PE
14604 return eHAL_STATUS_FAILURE;
14605 }
14606 else
14607 {
14608 staEntry.pPeStaEntry = pPeStaEntry;
14609 }
14610
14611 }
14612 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14613 if(statsMask & (1 << eCsrGlobalClassDStats))
14614 {
14615 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014617 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 }
14619 else
14620 {
14621
14622 //update periodicity
14623 if(pMac->roam.tlStatsReqInfo.periodicity)
14624 {
14625 pMac->roam.tlStatsReqInfo.periodicity =
14626 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14627 }
14628 else
14629 {
14630 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14631 }
14632 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14633 {
14634 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14635 }
14636
14637 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14638 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014639 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14640 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014642 //req TL for class D stats
14643 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014645 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014646 }
14647 else
14648 {
14649 //save in SME
14650 csrRoamSaveStatsFromTl(pMac, pTlStats);
14651 }
14652 vos_mem_free(pTlStats);
14653 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 }
14655 else
14656 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014657 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014659
Jeff Johnson295189b2012-06-20 16:38:30 -070014660 if(pMac->roam.tlStatsReqInfo.periodicity)
14661 {
14662 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014663 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14664 pMac->roam.tlStatsReqInfo.periodicity);
14665 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014667 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 return eHAL_STATUS_FAILURE;
14669 }
14670 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14671 }
14672 }
14673 }
14674 pMac->roam.tlStatsReqInfo.numClient++;
14675 }
14676
14677 insertInClientList = TRUE;
14678 }
14679 //if one time report requested with non cached result from PE/TL
14680 else if(!cache && !periodicity)
14681 {
14682 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14683 {
14684 //send down a req
14685 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14686 if(!HAL_STATUS_SUCCESS(status))
14687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014688 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 }
14690 //so that when the stats rsp comes back from PE we respond to upper layer
14691 //right away
14692 staEntry.timerExpired = TRUE;
14693 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 }
14695 if(statsMask & (1 << eCsrGlobalClassDStats))
14696 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014697 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14698 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014700 //req TL for class D stats
14701 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014703 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014704 }
14705 else
14706 {
14707 //save in SME
14708 csrRoamSaveStatsFromTl(pMac, pTlStats);
14709 }
14710 vos_mem_free(pTlStats);
14711 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 }
14713 else
14714 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014715 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014717
14718 }
14719 //if looking for stats from TL only
14720 if(!insertInClientList)
14721 {
14722 //return the stats
14723 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 if(insertInClientList)
14727 {
14728 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14729 if(!pStaEntry)
14730 {
14731 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014732 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 return eHAL_STATUS_FAILURE;
14734 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014735 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 //Init & start timer if needed
14737 if(periodicity)
14738 {
14739 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14740 csrRoamStatsClientTimerHandler, pStaEntry );
14741 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014743 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 return eHAL_STATUS_FAILURE;
14745 }
14746 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14747 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14748 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014749 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 return eHAL_STATUS_FAILURE;
14751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 }
14755 return eHAL_STATUS_SUCCESS;
14756}
14757
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014758#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14759
14760static tSirRetStatus
14761csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14762 tANI_U8* pBD,
14763 tANI_U8 type,
14764 tANI_U8 subType,
14765 tSirMacAddr peerAddr,
14766 tSirMacAddr selfMacAddr)
14767{
14768 tSirRetStatus statusCode = eSIR_SUCCESS;
14769 tpSirMacMgmtHdr pMacHdr;
14770
14771 /* Prepare MAC management header */
14772 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14773
14774 /* Prepare FC */
14775 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14776 pMacHdr->fc.type = type;
14777 pMacHdr->fc.subType = subType;
14778
14779 /* Prepare Address 1 */
14780 palCopyMemory( pMac->hHdd,
14781 (tANI_U8 *) pMacHdr->da,
14782 (tANI_U8 *) peerAddr,
14783 sizeof( tSirMacAddr ));
14784
14785 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14786
14787 /* Prepare Address 3 */
14788 palCopyMemory( pMac->hHdd,
14789 (tANI_U8 *) pMacHdr->bssId,
14790 (tANI_U8 *) peerAddr,
14791 sizeof( tSirMacAddr ));
14792 return statusCode;
14793} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14794
14795static tSirRetStatus
14796csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14797 tANI_U8 nChannelNum,
14798 tANI_U32 dot11mode,
14799 tSirMacAddr selfMacAddr,
14800 tANI_U8 *pFrame,
14801 tANI_U16 *pusLen)
14802{
14803 tDot11fProbeRequest pr;
14804 tANI_U32 nStatus, nBytes, nPayload;
14805 tSirRetStatus nSirStatus;
14806 /*Bcast tx*/
14807 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14808 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14809
14810
14811 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14812
14813 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14814
14815 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14816 {
14817 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14818 }
14819
14820
14821 if (IS_DOT11_MODE_HT(dot11mode))
14822 {
14823 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14824 }
14825
14826
14827 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14828 if ( DOT11F_FAILED( nStatus ) )
14829 {
14830 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14831 "Failed to calculate the packed size f"
14832 "or a Probe Request (0x%08x).\n", nStatus );
14833
14834
14835 nPayload = sizeof( tDot11fProbeRequest );
14836 }
14837 else if ( DOT11F_WARNED( nStatus ) )
14838 {
14839 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14840 "There were warnings while calculating"
14841 "the packed size for a Probe Request ("
14842 "0x%08x).\n", nStatus );
14843 }
14844
14845 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14846
14847 /* Prepare outgoing frame*/
14848 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14849
14850
14851 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014852 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014853
14854 if ( eSIR_SUCCESS != nSirStatus )
14855 {
14856 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14857 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14858 nSirStatus );
14859 return nSirStatus;
14860 }
14861
14862
14863 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14864 sizeof( tSirMacMgmtHdr ),
14865 nPayload, &nPayload );
14866 if ( DOT11F_FAILED( nStatus ) )
14867 {
14868 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14869 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14870 return eSIR_FAILURE;
14871 }
14872 else if ( DOT11F_WARNED( nStatus ) )
14873 {
14874 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14875 "There were warnings while packing a Probe Request (0x%08x).\n" );
14876 }
14877
14878 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14879 return eSIR_SUCCESS;
14880}
14881
14882eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14883{
14884 vos_msg_t msg;
14885 tSirRoamOffloadScanReq *pRequestBuf;
14886 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14887 tCsrRoamSession *pSession;
14888 tANI_U8 i,num_channels = 0, ucDot11Mode;
14889 tANI_U8 *ChannelList = NULL;
14890 tANI_U32 sessionId;
14891 eHalStatus status = eHAL_STATUS_SUCCESS;
14892 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070014893 tANI_U32 host_channels = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014894 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14895
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070014896 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014897 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014898 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014899 return eHAL_STATUS_FAILURE;
14900 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014901
14902 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
14903 {
14904 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
14905 return eHAL_STATUS_FAILURE;
14906 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014907 status = csrRoamGetSessionIdFromBSSID(pMac,
14908 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14909 &sessionId);
14910 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14911 * It is important to ensure that the command is passed down to the FW only
14912 * if the Infra Station is in a connected state.A connected station could also be
14913 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14914 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14915 * irrespective of whichever state we are in.*/
14916 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14917 (command != ROAM_SCAN_OFFLOAD_STOP))
14918 {
14919 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14920 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14921 return eHAL_STATUS_FAILURE;
14922 }
14923
14924 if ( !HAL_STATUS_SUCCESS( status ) )
14925 {
14926 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14927 return eHAL_STATUS_FAILURE;
14928 }
14929 pSession = CSR_GET_SESSION( pMac, sessionId );
14930 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14931 if (NULL == pRequestBuf)
14932 {
14933 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14934 return eHAL_STATUS_FAILED_ALLOC;
14935 }
14936
14937 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14938 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14939 * host driver reloads, but Riva still up and running*/
14940 if(command == ROAM_SCAN_OFFLOAD_STOP)
14941 pRequestBuf->RoamScanOffloadEnabled = 0;
14942 else
14943 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14944 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14945 sizeof(tCsrBssid));
14946 pRequestBuf->ConnectedNetwork.ssId.length =
14947 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14948 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14949 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14950 pRequestBuf->ConnectedNetwork.ssId.length);
14951 pRequestBuf->ConnectedNetwork.authentication =
14952 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14953 pRequestBuf->ConnectedNetwork.encryption =
14954 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14955 pRequestBuf->ConnectedNetwork.mcencryption =
14956 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14957 pRequestBuf->LookupThreshold =
14958 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14959 pRequestBuf->RoamRssiDiff =
14960 pMac->roam.configParam.RoamRssiDiff;
14961 pRequestBuf->Command = command;
14962 pRequestBuf->StartScanReason = reason;
14963 pRequestBuf->NeighborScanTimerPeriod =
14964 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14965 pRequestBuf->NeighborRoamScanRefreshPeriod =
14966 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14967 pRequestBuf->NeighborScanChannelMinTime =
14968 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14969 pRequestBuf->NeighborScanChannelMaxTime =
14970 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14971 pRequestBuf->EmptyRefreshScanPeriod =
14972 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14973#ifdef FEATURE_WLAN_CCX
14974 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14975#endif
14976 if (
14977#ifdef FEATURE_WLAN_CCX
14978 ((pNeighborRoamInfo->isCCXAssoc) &&
14979 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14980 eANI_BOOLEAN_FALSE)) ||
14981 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14982#endif // CCX
14983 currChannelListInfo->numOfChannels == 0)
14984 {
14985
14986 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14987 * Give Preference to INI Channels.*/
14988 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14989 {
14990 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14991 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14992 {
14993 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14994 {
14995 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14996 }
14997 ChannelList++;
14998 }
14999 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15000 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15001 }
15002 else{
15003 ChannelList = pMac->scan.occupiedChannels.channelList;
15004 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15005 {
15006 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15007 {
15008 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15009 }
15010 ChannelList++;
15011 }
15012 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15013 /* If the profile changes as to what it was earlier, inform the FW through
15014 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15015 * for the earlier profile and try to learn them afresh.*/
15016 if (reason == REASON_FLUSH_CHANNEL_LIST)
15017 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15018 else {
15019 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15020 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15021 else
15022 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15023 }
15024 }
15025 }
15026#ifdef FEATURE_WLAN_CCX
15027 else
15028 {
15029 /* If CCX is enabled, and a neighbor Report is received,then
15030 * Ignore the INI Channels or the Occupied Channel List. Consider
15031 * the channels in the neighbor list sent by the CCX AP.*/
15032 if (currChannelListInfo->numOfChannels != 0)
15033 {
15034 ChannelList = currChannelListInfo->ChannelList;
15035 for (i=0;i<currChannelListInfo->numOfChannels;i++)
15036 {
15037 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15038 {
15039 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15040 }
15041 ChannelList++;
15042 }
15043 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15044 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15045 }
15046 }
15047#endif
15048 num_channels = 0;
15049 ChannelList = NULL;
15050
15051 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015052 host_channels = sizeof(pMac->roam.validChannelList);
15053 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015054 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015055 ChannelList = pMac->roam.validChannelList;
15056 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015057 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015058 else
15059 {
15060 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15061 "%s:Failed to get the valid channel list", __func__);
15062 return eHAL_STATUS_FAILURE;
15063 }
15064 for(i=0; i<pMac->roam.numValidChannels; i++)
15065 {
15066 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15067 {
15068 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15069 }
15070 ChannelList++;
15071 }
15072 pRequestBuf->ValidChannelCount = num_channels;
15073
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015074 pRequestBuf->MDID.mdiePresent =
15075 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15076 pRequestBuf->MDID.mobilityDomain =
15077 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015078 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15079
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015080 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015081
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015082 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15083 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15084 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15085 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15086 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15087
15088 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15089 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015090 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015091 msg.reserved = 0;
15092 msg.bodyptr = pRequestBuf;
15093 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15094 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015095 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15096 vos_mem_free(pRequestBuf);
15097 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015098 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015099 else
15100 {
15101 if (ROAM_SCAN_OFFLOAD_START == command)
15102 bRoamScanOffloadStarted = VOS_TRUE;
15103 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15104 bRoamScanOffloadStarted = VOS_FALSE;
15105 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015106
15107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15108 return status;
15109}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015110
15111eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15112{
15113 switch(reason)
15114 {
15115 case 0:
15116 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15117 break;
15118 case REASON_OS_REQUESTED_ROAMING_NOW:
15119 csrNeighborRoamProceedWithHandoffReq(pMac);
15120 break;
15121 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015122 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 -070015123 }
15124 return eHAL_STATUS_SUCCESS;
15125}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015126#endif
15127
Jeff Johnson295189b2012-06-20 16:38:30 -070015128tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15129 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15130{
15131 tANI_BOOLEAN found = FALSE;
15132 eHalStatus status = eHAL_STATUS_SUCCESS;
15133 tCsrPeStatsReqInfo staEntry;
15134 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15135 tListElem *pStaEntry = NULL;
15136 VOS_STATUS vosStatus;
15137 tPmcPowerState powerState;
15138 *pFound = FALSE;
15139
15140 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15141 if(pStaEntry)
15142 {
15143 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15144 if(pTempStaEntry->periodicity)
15145 {
15146 pTempStaEntry->periodicity =
15147 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15148 }
15149 else
15150 {
15151 pTempStaEntry->periodicity = periodicity;
15152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 pTempStaEntry->numClient++;
15154 found = TRUE;
15155 }
15156 else
15157 {
15158 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
15159 staEntry.numClient = 1;
15160 staEntry.periodicity = periodicity;
15161 staEntry.pMac = pMac;
15162 staEntry.rspPending = FALSE;
15163 staEntry.staId = staId;
15164 staEntry.statsMask = statsMask;
15165 staEntry.timerRunning = FALSE;
15166 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15167 if(!pTempStaEntry)
15168 {
15169 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015170 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015171 return NULL;
15172 }
15173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15175 if(ePMC_FULL_POWER == powerState)
15176 {
15177 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15178 {
15179 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15180 }
15181 }
15182 else
15183 {
15184 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15185 {
15186 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15187 }
15188 }
15189 if(!pTempStaEntry->timerRunning)
15190 {
15191 //send down a req in case of one time req, for periodic ones wait for timer to expire
15192 if(!pTempStaEntry->rspPending &&
15193 !pTempStaEntry->periodicity)
15194 {
15195 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15196 if(!HAL_STATUS_SUCCESS(status))
15197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015198 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 }
15200 else
15201 {
15202 pTempStaEntry->rspPending = TRUE;
15203 }
15204 }
15205 if(pTempStaEntry->periodicity)
15206 {
15207 if(!found)
15208 {
15209
15210 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15211 csrRoamPeStatsTimerHandler, pTempStaEntry );
15212 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015214 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 return NULL;
15216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015217 }
15218 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015219 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15221 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15222 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015223 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015224 return NULL;
15225 }
15226 pTempStaEntry->timerRunning = TRUE;
15227 }
15228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 *pFound = found;
15230 return pTempStaEntry;
15231}
15232
Jeff Johnson295189b2012-06-20 16:38:30 -070015233/*
15234 pStaEntry is no longer invalid upon the return of this function.
15235*/
15236static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15237{
15238 if(pEntry)
15239 {
15240 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15241 {
15242 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 }
15245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015246
15247void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15248{
15249 tListElem *pEntry;
15250 tCsrPeStatsReqInfo *pTempStaEntry;
15251 VOS_STATUS vosStatus;
15252 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 if(!pEntry)
15254 {
15255 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015256 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 return;
15258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015259 while( pEntry )
15260 {
15261 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015262 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015264 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 if(pTempStaEntry->timerRunning)
15266 {
15267 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15268 /* If we are not able to stop the timer here, just remove
15269 * the entry from the linked list. Destroy the timer object
15270 * and free the memory in the timer CB
15271 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015272 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 {
15274 /* the timer is successfully stopped */
15275 pTempStaEntry->timerRunning = FALSE;
15276
15277 /* Destroy the timer */
15278 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15279 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015281 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015282 }
15283 }
15284 else
15285 {
15286 // the timer could not be stopped. Hence destroy and free the
15287 // memory for the PE stat entry in the timer CB.
15288 pTempStaEntry->timerStopFailed = TRUE;
15289 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015291
15292 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15293 {
15294 // Only free the memory if we could stop the timer successfully
15295 if(!pTempStaEntry->timerStopFailed)
15296 {
15297 palFreeMemory(pMac->hHdd, pTempStaEntry);
15298 pTempStaEntry = NULL;
15299 }
15300 break;
15301 }
15302
15303 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15304 }
15305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 return;
15307}
15308
15309
Jeff Johnsone7245742012-09-05 17:12:55 -070015310void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015311{
15312
Jeff Johnsone7245742012-09-05 17:12:55 -070015313 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15314 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15315 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15316 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15317 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15318 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15319 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015321 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15322 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15323 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15324 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15325 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15326 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015327 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015328 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15329 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015330
15331}
15332
Jeff Johnson295189b2012-06-20 16:38:30 -070015333void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15334 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15335{
15336 tANI_U8 stats[500];
15337 tANI_U8 *pStats = NULL;
15338 tANI_U32 tempMask = 0;
15339 tANI_U8 counter = 0;
15340 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 if(!callback)
15342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015343 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 return;
15345 }
15346 if(!statsMask)
15347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015348 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 return;
15350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015353 while(tempMask)
15354 {
15355 if(tempMask & 1)
15356 {
15357 //new stats info from PE, fill up the stats strucutres in PMAC
15358 switch(counter)
15359 {
15360 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015361 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15363 sizeof(tCsrSummaryStatsInfo));
15364 if(!HAL_STATUS_SUCCESS(status))
15365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015366 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 }
15368 pStats += sizeof(tCsrSummaryStatsInfo);
15369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015371 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15373 sizeof(tCsrGlobalClassAStatsInfo));
15374 if(!HAL_STATUS_SUCCESS(status))
15375 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015376 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015377 }
15378 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015381 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15383 sizeof(tCsrGlobalClassBStatsInfo));
15384 if(!HAL_STATUS_SUCCESS(status))
15385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015386 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015387 }
15388 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015390 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015391 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15393 sizeof(tCsrGlobalClassCStatsInfo));
15394 if(!HAL_STATUS_SUCCESS(status))
15395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015396 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 }
15398 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015401 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015402 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15403 sizeof(tCsrGlobalClassDStatsInfo));
15404 if(!HAL_STATUS_SUCCESS(status))
15405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015406 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 }
15408 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015411 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015412 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15413 sizeof(tCsrPerStaStatsInfo));
15414 if(!HAL_STATUS_SUCCESS(status))
15415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015416 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 }
15418 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015421 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 }
15424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 tempMask >>=1;
15426 counter++;
15427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015429}
15430
Jeff Johnson295189b2012-06-20 16:38:30 -070015431eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15432{
15433 tListElem *pEntry = NULL;
15434 tListElem *pPrevEntry = NULL;
15435 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15436 eHalStatus status = eHAL_STATUS_SUCCESS;
15437 VOS_STATUS vosStatus;
15438 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 if(!pEntry)
15440 {
15441 //list empty
15442 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015443 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 return status;
15445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 while( pEntry )
15447 {
15448 if(pPrevEntry)
15449 {
15450 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15451 //send up the stats report
15452 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15453 pTempStaEntry->staId, pTempStaEntry->pContext);
15454 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15458 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015459 pTempStaEntry->pPeStaEntry->numClient--;
15460 //check if we need to delete the entry from peStatsReqList too
15461 if(!pTempStaEntry->pPeStaEntry->numClient)
15462 {
15463 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15464 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 //check if we need to stop the tl stats timer too
15467 pMac->roam.tlStatsReqInfo.numClient--;
15468 if(!pMac->roam.tlStatsReqInfo.numClient)
15469 {
15470 if(pMac->roam.tlStatsReqInfo.timerRunning)
15471 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015472 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15473 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015475 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 //we will continue
15477 }
15478 }
15479 pMac->roam.tlStatsReqInfo.periodicity = 0;
15480 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015482 if (pTempStaEntry->periodicity)
15483 {
15484 //While creating StaEntry in csrGetStatistics,
15485 //Initializing and starting timer only when periodicity is set.
15486 //So Stop and Destroy timer only when periodicity is set.
15487
Jeff Johnsone7245742012-09-05 17:12:55 -070015488 vos_timer_stop( &pTempStaEntry->timer );
15489 // Destroy the vos timer...
15490 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15491 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015493 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015496
Jeff Johnson295189b2012-06-20 16:38:30 -070015497
15498 pPrevEntry = pEntry;
15499 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15500 }
15501 //the last one
15502 if(pPrevEntry)
15503 {
15504 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15505 //send up the stats report
15506 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15507 pTempStaEntry->staId, pTempStaEntry->pContext);
15508 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015510 return status;
15511
15512}
15513
Jeff Johnson295189b2012-06-20 16:38:30 -070015514eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15515 tRequestFullPowerReason *pReason,
15516 tANI_BOOLEAN *pfNeedPower )
15517{
15518 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15519 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15520 tPmcState pmcState;
15521 eHalStatus status = eHAL_STATUS_SUCCESS;
15522 // TODO : Session info unavailable
15523 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015524 if( pfNeedPower )
15525 {
15526 *pfNeedPower = eANI_BOOLEAN_FALSE;
15527 }
15528 //We only handle CSR commands
15529 if( !(eSmeCsrCommandMask & pCommand->command) )
15530 {
15531 return eHAL_STATUS_SUCCESS;
15532 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015533 //Check PMC state first
15534 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015535 switch( pmcState )
15536 {
15537 case REQUEST_IMPS:
15538 case IMPS:
15539 if( eSmeCommandScan == pCommand->command )
15540 {
15541 switch( pCommand->u.scanCmd.reason )
15542 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015543#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15544 case eCsrScanGetLfrResult:
15545#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 case eCsrScanGetResult:
15547 case eCsrScanBGScanAbort:
15548 case eCsrScanBGScanEnable:
15549 case eCsrScanGetScanChnInfo:
15550 //Internal process, no need for full power
15551 fNeedFullPower = eANI_BOOLEAN_FALSE;
15552 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 default:
15554 //Other scans are real scan, ask for power
15555 fNeedFullPower = eANI_BOOLEAN_TRUE;
15556 break;
15557 } //switch
15558 }
15559 else
15560 {
15561 //ask for power for roam and status change
15562 fNeedFullPower = eANI_BOOLEAN_TRUE;
15563 }
15564 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015565 case REQUEST_BMPS:
15566 case BMPS:
15567 case REQUEST_START_UAPSD:
15568 case UAPSD:
15569 //We treat WOWL same as BMPS
15570 case REQUEST_ENTER_WOWL:
15571 case WOWL:
15572 if( eSmeCommandRoam == pCommand->command )
15573 {
15574 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15575 tCsrScanResult *pScanResult;
15576 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 switch ( pCommand->u.roamCmd.roamReason )
15578 {
15579 case eCsrForcedDisassoc:
15580 case eCsrForcedDisassocMICFailure:
15581 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15582 fNeedFullPower = eANI_BOOLEAN_TRUE;
15583 break;
15584 case eCsrSmeIssuedDisassocForHandoff:
15585 case eCsrForcedDeauth:
15586 case eCsrHddIssuedReassocToSameAP:
15587 case eCsrSmeIssuedReassocToSameAP:
15588 fNeedFullPower = eANI_BOOLEAN_TRUE;
15589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 case eCsrCapsChange:
15591 fNeedFullPower = eANI_BOOLEAN_TRUE;
15592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015593 default:
15594 //Check whether the profile is already connected. If so, no need for full power
15595 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15596 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15597 {
15598 //Only need to check the first one
15599 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15600 if( pEntry )
15601 {
15602 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15603#if 0
15604 // TODO : Session Specific info pConnectBssDesc
15605 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15606 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15607 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15608 {
15609 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15610 // with Authenticating first. To force this, stop the current association (Disassociate) and
15611 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15612 // a new Association.
15613 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15614 {
15615 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15616 {
15617 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15618 //No need for full power
15619 //Set the flag so the code later can avoid to do the above
15620 //check again.
15621 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15622 break;
15623 }
15624 }
15625 }
15626#endif
15627 }
15628 }
15629 //If we are here, full power is needed
15630 fNeedFullPower = eANI_BOOLEAN_TRUE;
15631 break;
15632 }
15633 }
15634 else if( eSmeCommandWmStatusChange == pCommand->command )
15635 {
15636 //need full power for all
15637 fNeedFullPower = eANI_BOOLEAN_TRUE;
15638 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15639 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015640#ifdef FEATURE_WLAN_TDLS
15641 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15642 {
15643 //TDLS link is getting established. need full power
15644 fNeedFullPower = eANI_BOOLEAN_TRUE;
15645 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15646 }
15647#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015649 case REQUEST_STOP_UAPSD:
15650 case REQUEST_EXIT_WOWL:
15651 if( eSmeCommandRoam == pCommand->command )
15652 {
15653 fNeedFullPower = eANI_BOOLEAN_TRUE;
15654 switch ( pCommand->u.roamCmd.roamReason )
15655 {
15656 case eCsrForcedDisassoc:
15657 case eCsrForcedDisassocMICFailure:
15658 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15659 break;
15660 default:
15661 break;
15662 }
15663 }
15664 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015665 case STOPPED:
15666 case REQUEST_STANDBY:
15667 case STANDBY:
15668 case LOW_POWER:
15669 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015670 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015671 status = eHAL_STATUS_FAILURE;
15672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 case FULL_POWER:
15674 case REQUEST_FULL_POWER:
15675 default:
15676 //No need to ask for full power. This has to be FULL_POWER state
15677 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 if( pReason )
15680 {
15681 *pReason = reason;
15682 }
15683 if( pfNeedPower )
15684 {
15685 *pfNeedPower = fNeedFullPower;
15686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015687 return ( status );
15688}
15689
Jeff Johnson295189b2012-06-20 16:38:30 -070015690static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15691{
15692 eHalStatus status = eHAL_STATUS_SUCCESS;
15693 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15694 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015696 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15697 {
15698 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15699 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 return ( status );
15701}
15702
Jeff Johnson295189b2012-06-20 16:38:30 -070015703tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15704{
15705 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015706 if( pCmd )
15707 {
15708 pMac->roam.sPendingCommands++;
15709 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015710 return ( pCmd );
15711}
15712
Jeff Johnson295189b2012-06-20 16:38:30 -070015713void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15714{
15715 if (pMac->roam.sPendingCommands > 0)
15716 {
15717 //All command allocated through csrGetCommandBuffer need to
15718 //decrement the pending count when releasing.
15719 pMac->roam.sPendingCommands--;
15720 smeReleaseCommand( pMac, pCommand );
15721 }
15722 else
15723 {
15724 smsLog(pMac, LOGE, FL( "no pending commands"));
15725 VOS_ASSERT(0);
15726 }
15727}
15728
Jeff Johnson295189b2012-06-20 16:38:30 -070015729//Return SUCCESS is the command is queued, failed
15730eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15731{
15732 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015733 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15734 {
15735 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15736 pCommand->u.scanCmd.reason);
15737 return eHAL_STATUS_CSR_WRONG_STATE;
15738 }
15739
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015740 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
15741 {
15742 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
15743 &pCommand->Link, LL_ACCESS_LOCK);
15744 // process the command queue...
15745 smeProcessPendingQueue(pMac);
15746 status = eHAL_STATUS_SUCCESS;
15747 goto end;
15748 }
15749
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 //We can call request full power first before putting the command into pending Q
15751 //because we are holding SME lock at this point.
15752 status = csrRequestFullPower( pMac, pCommand );
15753 if( HAL_STATUS_SUCCESS( status ) )
15754 {
15755 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015756 //make sure roamCmdPendingList is not empty first
15757 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15758 if( fNoCmdPending )
15759 {
15760 smePushCommand( pMac, pCommand, fHighPriority );
15761 }
15762 else
15763 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015764 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070015765 //no list lock is needed since SME lock is held
15766 if( !fHighPriority )
15767 {
15768 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15769 }
15770 else {
15771 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15772 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015774 }
15775 else if( eHAL_STATUS_PMC_PENDING == status )
15776 {
15777 //no list lock is needed since SME lock is held
15778 if( !fHighPriority )
15779 {
15780 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15781 }
15782 else {
15783 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15784 }
15785 //Let caller know the command is queue
15786 status = eHAL_STATUS_SUCCESS;
15787 }
15788 else
15789 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015790 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015792 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015794end:
Jeff Johnson295189b2012-06-20 16:38:30 -070015795 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015796}
Jeff Johnson295189b2012-06-20 16:38:30 -070015797eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15798{
15799 eHalStatus status = eHAL_STATUS_SUCCESS;
15800 tSirUpdateAPWPSIEsReq *pMsg;
15801 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15802
15803 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15804 if (NULL == pSession)
15805 {
15806 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15807 return eHAL_STATUS_FAILURE;
15808 }
15809
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 do
15811 {
15812 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15813 if (!HAL_STATUS_SUCCESS(status)) break;
15814 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15815 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15816
15817 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070015818 VOS_ASSERT(pBuf);
15819
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 // transactionId
15822 *pBuf = 0;
15823 *( pBuf + 1 ) = 0;
15824 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015825 // bssId
15826 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15827 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015828 //sessionId
15829 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015830 // APWPSIEs
15831 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15832 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015834 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015835 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 return ( status );
15837}
Jeff Johnson295189b2012-06-20 16:38:30 -070015838eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15839{
15840 eHalStatus status = eHAL_STATUS_SUCCESS;
15841 tSirUpdateAPWPARSNIEsReq *pMsg;
15842 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015843 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15844 if (NULL == pSession)
15845 {
15846 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15847 return eHAL_STATUS_FAILURE;
15848 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 do
15850 {
15851 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15852 if (!HAL_STATUS_SUCCESS(status)) break;
15853 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15854 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015855 pBuf = (tANI_U8 *)&pMsg->transactionId;
15856 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 // transactionId
15858 *pBuf = 0;
15859 *( pBuf + 1 ) = 0;
15860 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070015861 VOS_ASSERT(pBuf);
15862
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 // bssId
15864 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15865 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015866 // sessionId
15867 *pBuf++ = (tANI_U8)sessionId;
15868
15869 // APWPARSNIEs
15870 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15871 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015872 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015874 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015875 return ( status );
15876}
Jeff Johnson295189b2012-06-20 16:38:30 -070015877
15878#ifdef WLAN_FEATURE_VOWIFI_11R
15879//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15880eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15881{
15882 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15883 tpSirFTPreAuthReq pftPreAuthReq;
15884 tANI_U16 auth_req_len = 0;
15885 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015886 auth_req_len = sizeof(tSirFTPreAuthReq);
15887 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15888 if (pftPreAuthReq == NULL)
15889 {
15890 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15891 return eHAL_STATUS_RESOURCES;
15892 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015893 // Save the SME Session ID here. We need it while processing the preauth response
15894 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 vos_mem_zero(pftPreAuthReq, auth_req_len);
15896
15897 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15898 sizeof(pBssDescription->length) + pBssDescription->length);
15899
15900 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15901
15902 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15903
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015905 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15906
Jeff Johnson295189b2012-06-20 16:38:30 -070015907#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015908 if (csrRoamIs11rAssoc(pMac) &&
15909 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 {
15911 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15912 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15913 pMac->ft.ftSmeContext.auth_ft_ies_length);
15914 }
15915 else
15916#endif
15917 {
15918 pftPreAuthReq->ft_ies_length = 0;
15919 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015920 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15921 sizeof(pBssDescription->length) + pBssDescription->length);
15922 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015923 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15924}
Jeff Johnson295189b2012-06-20 16:38:30 -070015925/*--------------------------------------------------------------------------
15926 * This will receive and process the FT Pre Auth Rsp from the current
15927 * associated ap.
15928 *
15929 * This will invoke the hdd call back. This is so that hdd can now
15930 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15931 ------------------------------------------------------------------------*/
15932void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15933{
15934 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15935 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015936#ifdef FEATURE_WLAN_LFR
15937 tCsrRoamInfo roamInfo;
15938#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015939
15940#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015941 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015942#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015943#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015944 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015945 if (status != eHAL_STATUS_SUCCESS) {
15946 /*
15947 * Bail out if pre-auth was not even processed.
15948 */
15949 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15950 return;
15951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015952#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015953 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15954 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15955 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015956 // Implies a success
15957 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015958 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15959 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070015960 /* No need to notify qos module if this is a non 11r roam*/
15961 if (csrRoamIs11rAssoc(pMac))
15962 {
15963 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15966 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015967 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15968 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070015969 if (eHAL_STATUS_SUCCESS != status)
15970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015971 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015972 return;
15973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 // Save the received response
15975 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15976 if (csrRoamIs11rAssoc(pMac))
15977 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15978 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15979
15980 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015981#ifdef FEATURE_WLAN_LFR
15982 // If Legacy Fast Roaming is enabled, signal the supplicant
15983 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015984 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015985 {
15986 // Save the bssid from the received response
15987 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15988 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15989 }
15990
15991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015992
15993 // Done with it, init it.
15994 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15995}
15996#endif
15997#ifdef FEATURE_WLAN_BTAMP_UT_RF
15998void csrRoamJoinRetryTimerHandler(void *pv)
15999{
16000 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16001 tpAniSirGlobal pMac = pInfo->pMac;
16002 tANI_U32 sessionId = pInfo->sessionId;
16003 tCsrRoamSession *pSession;
16004
16005 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016007 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016008 pSession = CSR_GET_SESSION( pMac, sessionId );
16009 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16010 {
16011 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016013 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016014 }
16015 }
16016 }
16017}
Jeff Johnson295189b2012-06-20 16:38:30 -070016018eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16019{
16020 eHalStatus status = eHAL_STATUS_FAILURE;
16021 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16022
16023 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016025 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016026 pSession->maxRetryCount--;
16027 pSession->joinRetryTimerInfo.pMac = pMac;
16028 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016029 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16030 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016032 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016033 }
16034 }
16035 else
16036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016037 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016038 pSession->maxRetryCount);
16039 }
16040
16041 return (status);
16042}
Jeff Johnson295189b2012-06-20 16:38:30 -070016043eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16044{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016045 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16047 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016048 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016049 }
16050
16051 return eHAL_STATUS_SUCCESS;
16052}
16053#endif
16054
16055
16056/*
16057 pBuf points to the beginning of the message
16058 LIM packs disassoc rsp as below,
16059 messageType - 2 bytes
16060 messageLength - 2 bytes
16061 sessionId - 1 byte
16062 transactionId - 2 bytes (tANI_U16)
16063 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16064 peerMacAddr - 6 bytes
16065 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16066*/
16067static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16068{
16069 if(pBuf && pRsp)
16070 {
16071 pBuf += 4; //skip type and length
16072 pRsp->sessionId = *pBuf++;
16073 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16074 pBuf += 2;
16075 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16076 pBuf += 4;
16077 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16078 }
16079}
16080
Jeff Johnsond13512a2012-07-17 11:42:19 -070016081eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16082{
16083 static uNvTables nvTables;
16084 eHalStatus status = eHAL_STATUS_SUCCESS;
16085 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16086
16087 /* read the country code from NV and use it */
16088 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16089 {
16090 palCopyMemory( pMac->hHdd, pCountry,
16091 nvTables.defaultCountryTable.countryCode,
16092 WNI_CFG_COUNTRY_CODE_LEN );
16093 return status;
16094 }
16095 else
16096 {
16097 palCopyMemory( pMac->hHdd, pCountry,
16098 "XXX",
16099 WNI_CFG_COUNTRY_CODE_LEN );
16100 status = eHAL_STATUS_FAILURE;
16101 return status;
16102 }
16103}
16104
16105eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16106{
16107 palCopyMemory( pMac->hHdd, pCountry,
16108 pMac->scan.countryCode11d,
16109 WNI_CFG_COUNTRY_CODE_LEN );
16110 return eHAL_STATUS_SUCCESS;
16111}
schang86c22c42013-03-13 18:41:24 -070016112
16113eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16114{
16115 tSirSetTxPowerReq *pMsg = NULL;
16116 eHalStatus status = eHAL_STATUS_SUCCESS;
16117 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16118
16119 if (!pSession)
16120 {
16121 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16122 return eHAL_STATUS_FAILURE;
16123 }
16124
16125 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
16126 if (HAL_STATUS_SUCCESS(status))
16127 {
16128 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
16129 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16130 pMsg->length = sizeof(tSirSetTxPowerReq);
16131 pMsg->mwPower = mW;
16132 palCopyMemory( pMac->hHdd,
16133 (tSirMacAddr *)pMsg->bssId,
16134 &pSession->selfMacAddr,
16135 sizeof(tSirMacAddr) );
16136 status = palSendMBMessage(pMac->hHdd, pMsg);
16137 if (!HAL_STATUS_SUCCESS(status))
16138 {
16139 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016140 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016141 }
16142 }
16143 return status;
16144}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016145
16146/* Returns whether a session is in VOS_STA_MODE...or not */
16147tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16148{
16149 tCsrRoamSession *pSession = NULL;
16150 pSession = CSR_GET_SESSION ( pMac, sessionId );
16151 if(!pSession)
16152 {
16153 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16154 return eANI_BOOLEAN_FALSE;
16155 }
16156 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16157 {
16158 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16159 return eANI_BOOLEAN_FALSE;
16160 }
16161 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16162 {
16163 return eANI_BOOLEAN_FALSE;
16164 }
16165 /* There is a possibility that the above check may fail,because
16166 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16167 * when it is connected.So,we may sneak through the above check even
16168 * if we are not a STA mode INFRA station. So, if we sneak through
16169 * the above condition, we can use the following check if we are
16170 * really in STA Mode.*/
16171
16172 if ( NULL != pSession->pCurRoamProfile )
16173 {
16174 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16175 {
16176 return eANI_BOOLEAN_TRUE;
16177 } else {
16178 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16179 return eANI_BOOLEAN_FALSE;
16180 }
16181 }
16182
16183 return eANI_BOOLEAN_FALSE;
16184}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016185
16186#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16187eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16188 tCsrHandoffRequest *pHandoffInfo)
16189{
16190 eHalStatus status = eHAL_STATUS_SUCCESS;
16191 vos_msg_t msg;
16192
16193 tAniHandoffReq *pMsg;
16194 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
16195 if ( !HAL_STATUS_SUCCESS(status) )
16196 {
16197 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
16198 return status;
16199 }
16200 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16201 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16202 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16203 pMsg->channel = pHandoffInfo->channel;
16204 palCopyMemory(pMac->hHdd, pMsg->bssid,
16205 pHandoffInfo->bssid,
16206 6);
16207 msg.type = eWNI_SME_HANDOFF_REQ;
16208 msg.bodyptr = pMsg;
16209 msg.reserved = 0;
16210 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16211 {
16212 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
16213 palFreeMemory(pMac->hHdd, (void *)pMsg);
16214 status = eHAL_STATUS_FAILURE;
16215 }
16216 return status;
16217}
16218#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */