blob: 414346a69288ba86350826a5cec16813b9661cf6 [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;
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 }
1569
1570 return status;
1571}
1572
Jeff Johnson295189b2012-06-20 16:38:30 -07001573eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1574{
1575 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if(pParam)
1577 {
1578 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1579 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1580 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1581 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1582 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1583 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001584 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1585 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1587 pParam->phyMode = pMac->roam.configParam.phyMode;
1588 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1589 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1590 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1591 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1592 pParam->TxRate = pMac->roam.configParam.TxRate;
1593 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1594 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1595 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1596 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1597 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1599 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1600 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1601 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001602 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1603 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1604 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001605#ifdef WLAN_AP_STA_CONCURRENCY
1606 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1607 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1608 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1609 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1610 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001611 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1612 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001613#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 //Change the unit from microsecond to second
1615 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1616 pParam->eBand = pMac->roam.configParam.eBand;
1617 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1618 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1619 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1620 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1621 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1622 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1623 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1624 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1625 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1626 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1627 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1628 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1629 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1631 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1632 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1633 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1635 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1636 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1637 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1638 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001640 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001641 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001642 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643
1644#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1645 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1646#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001647#ifdef WLAN_FEATURE_11AC
1648 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001649 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001650 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001651#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001652#ifdef WLAN_FEATURE_VOWIFI_11R
1653 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1654#endif
1655#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1656 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1657 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1658 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1659 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1660 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001661 pParam->nProbes = pMac->roam.configParam.nProbes;
1662 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001663#endif
1664#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1665 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1666 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1667#endif
1668#ifdef FEATURE_WLAN_LFR
1669 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1670#endif
1671
1672#ifdef FEATURE_WLAN_CCX
1673 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1674#endif
1675#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1676 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1677 {
1678 int i;
1679 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1680 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1681 {
1682 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1683 }
1684 smsLog( pMac, LOG1, "");
1685 }
1686#endif
1687
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001688 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001689
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 csrSetChannels(pMac, pParam);
1691
1692 status = eHAL_STATUS_SUCCESS;
1693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 return (status);
1695}
1696
Jeff Johnson295189b2012-06-20 16:38:30 -07001697eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1698{
1699 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1700 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1701 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1702 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 do
1704 {
1705 if(eCSR_BAND_24 == eBand)
1706 {
1707 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1708 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1709 }
1710 if(eCSR_BAND_5G == eBand)
1711 {
1712 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1713 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1714 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1715 )
1716 {
1717 break;
1718 }
1719 }
1720 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1721 {
1722 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1723 }
1724 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1725 {
1726 newPhyMode = eCSR_DOT11_MODE_AUTO;
1727 }
1728 else
1729 {
1730 //Check for dual band and higher capability first
1731 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1732 {
1733 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1734 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1735 }
1736 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1737 {
1738 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1739 if(eCSR_BAND_24 == eBand) break;
1740 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1741 eBand = eCSR_BAND_5G;
1742 }
1743 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1744 {
1745 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1746 if(eCSR_BAND_5G == eBand) break;
1747 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1748 eBand = eCSR_BAND_24;
1749 }
1750 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1751 {
1752 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1753 if(eCSR_BAND_5G == eBand) break;
1754 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1755 eBand = eCSR_BAND_24;
1756 }
1757 else if(eCSR_DOT11_MODE_11n & phyMode)
1758 {
1759 newPhyMode = eCSR_DOT11_MODE_11n;
1760 }
1761 else if(eCSR_DOT11_MODE_abg & phyMode)
1762 {
1763 newPhyMode = eCSR_DOT11_MODE_abg;
1764 }
1765 else if(eCSR_DOT11_MODE_11a & phyMode)
1766 {
1767 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1768 {
1769 if(eCSR_BAND_ALL == eBand)
1770 {
1771 newPhyMode = eCSR_DOT11_MODE_abg;
1772 }
1773 else
1774 {
1775 //bad setting
1776 break;
1777 }
1778 }
1779 else
1780 {
1781 newPhyMode = eCSR_DOT11_MODE_11a;
1782 eBand = eCSR_BAND_5G;
1783 }
1784 }
1785 else if(eCSR_DOT11_MODE_11g & phyMode)
1786 {
1787 newPhyMode = eCSR_DOT11_MODE_11g;
1788 eBand = eCSR_BAND_24;
1789 }
1790 else if(eCSR_DOT11_MODE_11b & phyMode)
1791 {
1792 newPhyMode = eCSR_DOT11_MODE_11b;
1793 eBand = eCSR_BAND_24;
1794 }
1795 else
1796 {
1797 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001798 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 newPhyMode = eCSR_DOT11_MODE_AUTO;
1800 }
1801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 //Done validating
1803 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 //Now we need to check whether a restart is needed.
1805 if(eBand != pMac->roam.configParam.eBand)
1806 {
1807 fRestartNeeded = eANI_BOOLEAN_TRUE;
1808 break;
1809 }
1810 if(newPhyMode != pMac->roam.configParam.phyMode)
1811 {
1812 fRestartNeeded = eANI_BOOLEAN_TRUE;
1813 break;
1814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 if(HAL_STATUS_SUCCESS(status))
1817 {
1818 pMac->roam.configParam.eBand = eBand;
1819 pMac->roam.configParam.phyMode = newPhyMode;
1820 if(pfRestartNeeded)
1821 {
1822 *pfRestartNeeded = fRestartNeeded;
1823 }
1824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 return (status);
1826}
1827
Jeff Johnson295189b2012-06-20 16:38:30 -07001828void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1829{
1830 tANI_U8 Index;
1831 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 // for dual band NICs, don't need to trim the channel list....
1833 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1834 {
1835 // 2.4 GHz band operation requires the channel list to be trimmed to
1836 // the 2.4 GHz channels only...
1837 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1838 {
1839 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1840 Index++ )
1841 {
1842 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1843 {
1844 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1845 cChannels++;
1846 }
1847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1849 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1850 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1851 // only if we need to.
1852 //
1853 // The amount of memory to clear is the number of channesl that we trimmed
1854 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1855
1856 if ( pChannelList->numChannels > cChannels )
1857 {
1858 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1859 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1860
1861 }
1862
1863 pChannelList->numChannels = cChannels;
1864 }
1865 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1866 {
1867 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1868 {
1869 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1870 {
1871 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1872 cChannels++;
1873 }
1874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1876 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1877 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1878 // only if we need to.
1879 //
1880 // The amount of memory to clear is the number of channesl that we trimmed
1881 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1882 if ( pChannelList->numChannels > cChannels )
1883 {
1884 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1885 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1886 }
1887
1888 pChannelList->numChannels = cChannels;
1889 }
1890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001891}
Jeff Johnson295189b2012-06-20 16:38:30 -07001892#define INFRA_AP_DEFAULT_CHANNEL 6
1893eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1894{
1895 tANI_U8 index= 0;
1896 eHalStatus status = eHAL_STATUS_FAILURE;
1897 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1898 {
1899 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1900 status = eHAL_STATUS_SUCCESS;
1901 break;
1902 }
1903 }
1904 return status;
1905}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001906
1907eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1908{
1909 eHalStatus status = eHAL_STATUS_SUCCESS;
1910 tANI_U8 num20MHzChannelsFound = 0;
1911 VOS_STATUS vosStatus;
1912 tANI_U8 num40MHzChannelsFound = 0;
1913 tANI_U8 Index = 0;
1914 tANI_U8 channelList = 0;
1915
1916 // Updating the defaultpower Table for changed Domain Id
1917 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1918 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1919
1920 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1921 {
1922 smsLog( pMac, LOGE, FL("failed to get channels"));
1923 status = eHAL_STATUS_FAILURE;
1924 }
1925 else
1926 {
1927 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1928 {
1929 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1930 }
1931
1932 // Move the only 5GHZ channel list to the global data,
1933 // As 2.4GHZ list coming from the AP for the changed domain
1934 // structure -- this will be used as the scan list
1935 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1936 {
1937 // If Channel is 5GHz just break the for loop
1938 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1939 break;
1940 }
1941 // Update the 5G channels from nv.bin
1942 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1943 {
1944 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1945 {
Krunal Sonia75019a2013-05-01 01:08:22 -07001946 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1947 {
1948 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1949 channelList++;
1950 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001951 }
1952 }
1953
1954 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1955 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1956 // Filling the remaining index as Zero Just for causion
1957 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1958 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1959 }
1960 return status;
1961}
1962
1963eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1964{
1965 eHalStatus status = eHAL_STATUS_SUCCESS;
1966 tANI_U8 num20MHzChannelsFound = 0;
1967 VOS_STATUS vosStatus;
1968 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05301969 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001970 tANI_U8 num40MHzChannelsFound = 0;
1971 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1972 tANI_U8 channelList = 0;
1973
1974 // Read the scan channel list (including the power limit) from EEPROM
1975 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1976 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1977
1978 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1979 {
1980 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1981 status = eHAL_STATUS_FAILURE;
1982 }
1983 else
1984 {
1985 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1986 {
1987 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1988 }
1989
1990 // Move the 2.4GHZ channel list only to the global data,
1991 // As 5GHz list been provided by AP as part of 11d IE
1992 // structure -- this will be used as the scan list
1993 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1994 {
1995 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1996 {
1997 // First taking the 5GHz channel list backup
1998 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
1999 nuum5GchannelListBackup++;
2000 }
2001 }
2002 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302003 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002004 {
2005 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302006 {
2007 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2008 numChan++;
2009 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002010 }
2011 // Restoring the Backed up 5 GHZ channels
2012 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2013 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302014 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002015 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302016 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2017 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002018 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002019 }
2020
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302021 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2022 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002023 }
2024 return (status);
2025}
2026
Jeff Johnson295189b2012-06-20 16:38:30 -07002027eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2028{
2029 eHalStatus status = eHAL_STATUS_SUCCESS;
2030 tANI_U8 num20MHzChannelsFound = 0;
2031 VOS_STATUS vosStatus;
2032 tANI_U8 Index = 0;
2033 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002034
Jeff Johnson295189b2012-06-20 16:38:30 -07002035
2036 //TODO: this interface changed to include the 40MHz channel list
2037 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2038 // Read the scan channel list (including the power limit) from EEPROM
2039 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2040 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2041 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002043 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 status = eHAL_STATUS_FAILURE;
2045 }
2046 else
2047 {
2048 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2049 {
2050 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2051 }
2052 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2053 // Move the channel list to the global data
2054 // structure -- this will be used as the scan list
2055 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2056 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 }
2059 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2060 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2061 {
2062 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2063 }
2064 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2065 {
2066 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2067 }
2068 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 return (status);
2071}
2072
Jeff Johnson295189b2012-06-20 16:38:30 -07002073eHalStatus csrInitChannelList( tHalHandle hHal )
2074{
2075 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2076 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2078 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002079 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2080 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002082 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002083
2084 return (status);
2085}
Jeff Johnson295189b2012-06-20 16:38:30 -07002086eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2087 tCsrUpdateConfigParam *pUpdateConfigParam)
2088{
2089 eHalStatus status = eHAL_STATUS_FAILURE;
2090 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2092 status = CsrInit11dInfo(pMac, ps11dinfo);
2093 return status;
2094}
2095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2097{
2098 eHalStatus status = eHAL_STATUS_FAILURE;
2099 tANI_U8 index;
2100 tANI_U32 count=0;
2101 tSirMacChanInfo *pChanInfo;
2102 tSirMacChanInfo *pChanInfoStart;
2103 tANI_BOOLEAN applyConfig = TRUE;
2104
2105 if(!ps11dinfo)
2106 {
2107 return (status);
2108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2110 {
2111 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2112 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2113 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2114 if(!HAL_STATUS_SUCCESS(status)) return (status);
2115 }
2116 else
2117 {
2118 //No change
2119 return (eHAL_STATUS_SUCCESS);
2120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 //legacy maintenance
2122 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2123 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2124 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 //Tush: at csropen get this initialized with default, during csr reset if this
2126 // already set with some value no need initilaize with default again
2127 if(0 == pMac->scan.countryCodeCurrent[0])
2128 {
2129 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2130 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2131 if(!HAL_STATUS_SUCCESS(status)) return (status);
2132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 // need to add the max power channel list
2134 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2135 {
2136 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2137 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002138 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2139 {
2140 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2141 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2142 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2143 pChanInfo++;
2144 count++;
2145 }
2146 if(count)
2147 {
2148 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2149 }
2150 palFreeMemory(pMac->hHdd, pChanInfoStart);
2151 }
2152 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2153 if( HAL_STATUS_SUCCESS(status) )
2154 {
2155 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2156 {
2157 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2158 {
2159 applyConfig = FALSE;
2160 }
2161 }
2162
2163 if(TRUE == applyConfig)
2164 {
2165 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002166 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002167 }
2168
2169 }
2170 return (status);
2171}
2172/* Initialize the Channel + Power List in the local cache and in the CFG */
2173eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2174{
2175 tANI_U8 index;
2176 tANI_U32 count=0;
2177 tSirMacChanInfo *pChanInfo;
2178 tSirMacChanInfo *pChanInfoStart;
2179
2180 if(!ps11dinfo || !pMac)
2181 {
2182 return eHAL_STATUS_FAILURE;
2183 }
2184
2185 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2186 {
2187 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2188 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002189
2190 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2191 {
2192 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2193 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2194 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2195 pChanInfo++;
2196 count++;
2197 }
2198 if(count)
2199 {
2200 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2201 }
2202 palFreeMemory(pMac->hHdd, pChanInfoStart);
2203 }
2204
Jeff Johnsone7245742012-09-05 17:12:55 -07002205 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206}
2207
2208//pCommand may be NULL
2209//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2210void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2211{
2212 tListElem *pEntry, *pNextEntry;
2213 tSmeCmd *pDupCommand;
2214 tDblLinkList localList;
2215
2216 vos_mem_zero(&localList, sizeof(tDblLinkList));
2217 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2218 {
2219 smsLog(pMac, LOGE, FL(" failed to open list"));
2220 return;
2221 }
2222 csrLLLock( &pMac->sme.smeCmdPendingList );
2223 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2224 while( pEntry )
2225 {
2226 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2227 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 // Remove the previous command if..
2229 // - the new roam command is for the same RoamReason...
2230 // - the new roam command is a NewProfileList.
2231 // - the new roam command is a Forced Dissoc
2232 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2233 if (
2234 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2235 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002236 /* This peermac check is requried for Softap/GO scenarios
2237 * For STA scenario below OR check will suffice as pCommand will
2238 * always be NULL for STA scenarios
2239 */
2240 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2242 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2243 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2244 ||
2245 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002246 ( (sessionId == pDupCommand->sessionId) &&
2247 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 ((eCsrForcedDisassoc == eRoamReason) ||
2249 (eCsrHddIssued == eRoamReason))
2250 )
2251 )
2252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002253 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 // Remove the 'stale' roam command from the pending list...
2255 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2256 {
2257 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2258 }
2259 }
2260 pEntry = pNextEntry;
2261 }
2262 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2263
2264 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2265 {
2266 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2267 //Tell caller that the command is cancelled
2268 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2269 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2270 csrReleaseCommandRoam(pMac, pDupCommand);
2271 }
2272 csrLLClose(&localList);
2273}
Jeff Johnson295189b2012-06-20 16:38:30 -07002274eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2275 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2276{
2277 eHalStatus status = eHAL_STATUS_SUCCESS;
2278#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2279 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2280#endif
2281 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2283 {
2284 pSession = CSR_GET_SESSION( pMac, sessionId );
2285 }
2286 else
2287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002288 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 VOS_ASSERT(0);
2290 return eHAL_STATUS_FAILURE;
2291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002294 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002296 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2297 /*
2298 * Decrement bRefAssocStartCnt for FT reassoc failure.
2299 * Reason: For FT reassoc failures, we first call
2300 * csrRoamCallCallback before notifying a failed roam
2301 * completion through csrRoamComplete. The latter in
2302 * turn calls csrRoamProcessResults which tries to
2303 * once again call csrRoamCallCallback if bRefAssocStartCnt
2304 * is non-zero. Since this is redundant for FT reassoc
2305 * failure, decrement bRefAssocStartCnt.
2306 */
2307 pSession->bRefAssocStartCnt--;
2308 }
2309
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 if ( (pSession == NULL) ||
2311 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002313 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 return eHAL_STATUS_FAILURE;
2315 }
2316
2317 if(NULL != pSession->callback)
2318 {
2319 if( pRoamInfo )
2320 {
2321 pRoamInfo->sessionId = (tANI_U8)sessionId;
2322 }
2323
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302324 /* avoid holding the global lock when making the roaming callback, original change came
2325 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2326 is possible on other OS ports where the callback may need to take locks to protect
2327 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2329 that may actually depend on the lock being held */
2330 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2331 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2332 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2333 }
2334 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2335 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2336#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2337 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2338 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2339 {
2340 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2341 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2342 if(NULL != pRoamInfo->pBssDesc)
2343 {
2344 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2345 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2348 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2349 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2350 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2351 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2352 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2355 {
2356 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2357 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2358 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 if(eCSR_ROAM_RESULT_FORCED == u2)
2361 {
2362 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2363 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2364 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2367 {
2368 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2369 connectionStatus.reason = eCSR_REASON_DISASSOC;
2370 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2373 {
2374 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2375 connectionStatus.reason = eCSR_REASON_DEAUTH;
2376 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002378#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2379
2380 return (status);
2381}
Jeff Johnson295189b2012-06-20 16:38:30 -07002382// Returns whether handoff is currently in progress or not
2383tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2384{
2385#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2386 return csrNeighborRoamIsHandoffInProgress(pMac);
2387#else
2388 return eANI_BOOLEAN_FALSE;
2389#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002390}
Jeff Johnson295189b2012-06-20 16:38:30 -07002391eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2392 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2393{
2394 eHalStatus status = eHAL_STATUS_SUCCESS;
2395 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2396 tANI_U16 reasonCode;
2397 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002398
2399 if(!pSession)
2400 {
2401 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2402 return eHAL_STATUS_FAILURE;
2403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002404
2405 //Restore AC weight in case we change it
2406 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2407 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002408 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 -07002409 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2410 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2411 }
2412
2413 if ( fMICFailure )
2414 {
2415 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2416 }
2417 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2418 {
2419 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002420 }
2421 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 {
2423 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425#ifdef WLAN_FEATURE_VOWIFI_11R
2426 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2427 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2428 {
2429 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2430 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002431 }
2432 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002433#endif
2434 if(pSession->pConnectBssDesc)
2435 {
2436 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2437 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002438
Jeff Johnson295189b2012-06-20 16:38:30 -07002439
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002440 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2441 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2442 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2443
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2445
2446 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2447
2448 if(HAL_STATUS_SUCCESS(status))
2449 {
2450 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2452 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2453 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2454 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002455 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2457 }
2458#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002459 }
2460 else
2461 {
2462 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2463 }
2464
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 return (status);
2466}
Jeff Johnson295189b2012-06-20 16:38:30 -07002467
Jeff Johnson295189b2012-06-20 16:38:30 -07002468/* ---------------------------------------------------------------------------
2469 \fn csrRoamIssueDisassociateStaCmd
2470 \brief csr function that HDD calls to disassociate a associated station
2471 \param sessionId - session Id for Soft AP
2472 \param pPeerMacAddr - MAC of associated station to delete
2473 \param reason - reason code, be one of the tSirMacReasonCodes
2474 \return eHalStatus
2475 ---------------------------------------------------------------------------*/
2476eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2477 tANI_U32 sessionId,
2478 tANI_U8 *pPeerMacAddr,
2479 tANI_U32 reason)
2480{
2481 eHalStatus status = eHAL_STATUS_SUCCESS;
2482 tSmeCmd *pCommand;
2483
2484 do
2485 {
2486 pCommand = csrGetCommandBuffer( pMac );
2487 if ( !pCommand )
2488 {
2489 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2490 status = eHAL_STATUS_RESOURCES;
2491 break;
2492 }
2493 pCommand->command = eSmeCommandRoam;
2494 pCommand->sessionId = (tANI_U8)sessionId;
2495 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2496 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2497 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2498 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2499 if( !HAL_STATUS_SUCCESS( status ) )
2500 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002501 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 csrReleaseCommandRoam( pMac, pCommand );
2503 }
2504 }while(0);
2505
2506 return status;
2507}
2508
2509
Jeff Johnson295189b2012-06-20 16:38:30 -07002510/* ---------------------------------------------------------------------------
2511 \fn csrRoamIssueDeauthSta
2512 \brief csr function that HDD calls to delete a associated station
2513 \param sessionId - session Id for Soft AP
2514 \param pPeerMacAddr - MAC of associated station to delete
2515 \param reason - reason code, be one of the tSirMacReasonCodes
2516 \return eHalStatus
2517 ---------------------------------------------------------------------------*/
2518eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2519 tANI_U32 sessionId,
2520 tANI_U8 *pPeerMacAddr,
2521 tANI_U32 reason)
2522{
2523 eHalStatus status = eHAL_STATUS_SUCCESS;
2524 tSmeCmd *pCommand;
2525
2526 do
2527 {
2528 pCommand = csrGetCommandBuffer( pMac );
2529 if ( !pCommand )
2530 {
2531 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2532 status = eHAL_STATUS_RESOURCES;
2533 break;
2534 }
2535 pCommand->command = eSmeCommandRoam;
2536 pCommand->sessionId = (tANI_U8)sessionId;
2537 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2538 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2539 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2540 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2541 if( !HAL_STATUS_SUCCESS( status ) )
2542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002543 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 csrReleaseCommandRoam( pMac, pCommand );
2545 }
2546 }while(0);
2547
2548 return status;
2549}
Jeff Johnson295189b2012-06-20 16:38:30 -07002550eHalStatus
2551csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2552 tANI_BOOLEAN bEnable )
2553{
2554 eHalStatus status = eHAL_STATUS_FAILURE;
2555 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 if (!pSession)
2558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002559 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 return (status);
2561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 if (pSession->pConnectBssDesc)
2563 {
2564 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2565 }
2566 else
2567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002568 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 return (status);
2570 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002571 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 -07002572 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302573 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2575 return (status);
2576}
Jeff Johnson295189b2012-06-20 16:38:30 -07002577eHalStatus
2578csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2579 VOS_MODULE_ID modId, void *pUsrContext,
2580 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2581{
2582 eHalStatus status = eHAL_STATUS_SUCCESS;
2583 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 if (!pSession)
2586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002587 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 return (status);
2589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 if(pSession->pConnectBssDesc)
2591 {
2592 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2593 }
2594 else
2595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002596 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 return (status);
2598 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002599 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2601 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2603 return (status);
2604}
Jeff Johnson295189b2012-06-20 16:38:30 -07002605eHalStatus
2606csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2607 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2608{
2609 eHalStatus status = eHAL_STATUS_SUCCESS;
2610 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2612
2613 if (!pSession)
2614 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002615 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 return (status);
2617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 if(pSession->pConnectBssDesc)
2619 {
2620 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2621 }
2622 else
2623 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002624 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 return (status);
2626 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002627 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2629 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2630
2631 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2632
2633 return (status);
2634}
Jeff Johnson295189b2012-06-20 16:38:30 -07002635eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2636{
2637 eHalStatus status = eHAL_STATUS_SUCCESS;
2638 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2639 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002640
2641 if (!pSession)
2642 {
2643 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2644 return eHAL_STATUS_FAILURE;
2645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002646
2647 if(pSession->pConnectBssDesc)
2648 {
2649 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2650 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002651 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2653 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2655
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302656 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002657 if(!HAL_STATUS_SUCCESS(status))
2658 {
2659 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2660 }
2661
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 return (status);
2663}
2664
Jeff Johnson295189b2012-06-20 16:38:30 -07002665eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2666{
2667 eHalStatus status = eHAL_STATUS_SUCCESS;
2668 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2669 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002670
2671 if(!pSession)
2672 {
2673 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2674 return eHAL_STATUS_FAILURE;
2675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002676
2677 // If no BSS description was found in this connection (happens with start IBSS), then
2678 // nix the BSS description that we keep around for the connected BSS) and get out...
2679 if(NULL == pBssDesc)
2680 {
2681 csrFreeConnectBssDesc(pMac, sessionId);
2682 }
2683 else
2684 {
2685 size = pBssDesc->length + sizeof( pBssDesc->length );
2686 if(NULL != pSession->pConnectBssDesc)
2687 {
2688 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2689 {
2690 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2691 csrFreeConnectBssDesc(pMac, sessionId);
2692 }
2693 }
2694 if(NULL == pSession->pConnectBssDesc)
2695 {
2696 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2697 }
2698 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2699 {
2700 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2701 }
2702 }
2703
2704 return (status);
2705}
2706
Jeff Johnson295189b2012-06-20 16:38:30 -07002707eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2708 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2709 tDot11fBeaconIEs *pIes)
2710{
2711 eHalStatus status = eHAL_STATUS_SUCCESS;
2712 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302714 if (pIes == NULL)
2715 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002716
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 do
2718 {
2719 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2720 //get qos
2721 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2722 //get SSID
2723 if(pIes->SSID.present)
2724 {
2725 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2726 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2727 }
2728 else
2729 pBssConfig->SSID.length = 0;
2730 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002732 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 //Return failed if profile doesn't have an SSID either.
2734 if(pProfile->SSIDs.numOfSSIDs == 0)
2735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002736 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 status = eHAL_STATUS_FAILURE;
2738 break;
2739 }
2740 }
2741 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2742 {
2743 pBssConfig->eBand = eCSR_BAND_5G;
2744 }
2745 else
2746 {
2747 pBssConfig->eBand = eCSR_BAND_24;
2748 }
2749 //phymode
2750 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2751 {
2752 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2753 }
2754 else
2755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002756 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 //force it
2758 if(eCSR_BAND_24 == pBssConfig->eBand)
2759 {
2760 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2761 }
2762 else
2763 {
2764 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2765 }
2766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 //Qos
2768 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2769 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2770 {
2771 //Joining BSS is not 11n capable and WMM is disabled on client.
2772 //Disable QoS and WMM
2773 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2774 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302775
2776 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302777 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302778 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2779 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2780 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2781 {
2782 //Joining BSS is 11n capable and WMM is disabled on AP.
2783 //Assume all HT AP's are QOS AP's and enable WMM
2784 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2785 }
2786
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 //auth type
2788 switch( pProfile->negotiatedAuthType )
2789 {
2790 default:
2791 case eCSR_AUTH_TYPE_WPA:
2792 case eCSR_AUTH_TYPE_WPA_PSK:
2793 case eCSR_AUTH_TYPE_WPA_NONE:
2794 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2795 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 case eCSR_AUTH_TYPE_SHARED_KEY:
2798 pBssConfig->authType = eSIR_SHARED_KEY;
2799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 case eCSR_AUTH_TYPE_AUTOSWITCH:
2801 pBssConfig->authType = eSIR_AUTO_SWITCH;
2802 break;
2803 }
2804 //short slot time
2805 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2806 {
2807 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2808 }
2809 else
2810 {
2811 pBssConfig->uShortSlotTime = 0;
2812 }
2813 if(pBssConfig->BssCap.ibss)
2814 {
2815 //We don't support 11h on IBSS
2816 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2817 }
2818 else
2819 {
2820 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2821 }
2822 //power constraint
2823 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2824 //heartbeat
2825 if ( CSR_IS_11A_BSS( pBssDesc ) )
2826 {
2827 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2828 }
2829 else
2830 {
2831 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2832 }
2833 //Join timeout
2834 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002835 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 if ( pBssDesc->beaconInterval )
2837 {
2838 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002839 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
2841 else
2842 {
2843 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2844 }
2845 //validate CB
2846 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2847 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 return (status);
2849}
2850
Jeff Johnson295189b2012-06-20 16:38:30 -07002851static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2852 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2853{
2854 eHalStatus status = eHAL_STATUS_SUCCESS;
2855 tANI_U8 operationChannel = 0;
2856 tANI_U8 qAPisEnabled = FALSE;
2857 //SSID
2858 pBssConfig->SSID.length = 0;
2859 if(pProfile->SSIDs.numOfSSIDs)
2860 {
2861 //only use the first one
2862 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2863 }
2864 else
2865 {
2866 //SSID must present
2867 return eHAL_STATUS_FAILURE;
2868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 //Settomg up the capabilities
2870 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2871 {
2872 pBssConfig->BssCap.ibss = 1;
2873 }
2874 else
2875 {
2876 pBssConfig->BssCap.ess = 1;
2877 }
2878 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2879 {
2880 pBssConfig->BssCap.privacy = 1;
2881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 pBssConfig->eBand = pMac->roam.configParam.eBand;
2883 //phymode
2884 if(pProfile->ChannelInfo.ChannelList)
2885 {
2886 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2889 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 //QOS
2891 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 if ( pBssConfig->BssCap.ess == 1 )
2893 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 /*For Softap case enable WMM*/
2895 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2896 qAPisEnabled = TRUE;
2897 }
2898 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2900 qAPisEnabled = TRUE;
2901 } else {
2902 qAPisEnabled = FALSE;
2903 }
2904 } else {
2905 qAPisEnabled = TRUE;
2906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2908 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2909 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2910 )
2911 {
2912 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2913 } else {
2914 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2915 }
2916
2917 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002918 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 {
2920 default:
2921 case eCSR_AUTH_TYPE_WPA:
2922 case eCSR_AUTH_TYPE_WPA_PSK:
2923 case eCSR_AUTH_TYPE_WPA_NONE:
2924 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2925 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2926 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 case eCSR_AUTH_TYPE_SHARED_KEY:
2928 pBssConfig->authType = eSIR_SHARED_KEY;
2929 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 case eCSR_AUTH_TYPE_AUTOSWITCH:
2931 pBssConfig->authType = eSIR_AUTO_SWITCH;
2932 break;
2933 }
2934 //short slot time
2935 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2936 {
2937 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2938 }
2939 else
2940 {
2941 pBssConfig->uShortSlotTime = 0;
2942 }
2943 //power constraint. We don't support 11h on IBSS
2944 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2945 pBssConfig->uPowerLimit = 0;
2946 //heartbeat
2947 if ( eCSR_BAND_5G == pBssConfig->eBand )
2948 {
2949 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2950 }
2951 else
2952 {
2953 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2954 }
2955 //Join timeout
2956 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002957
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 return (status);
2959}
Jeff Johnson295189b2012-06-20 16:38:30 -07002960static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2961{
2962 eHalStatus status = eHAL_STATUS_FAILURE;
2963 tDot11fBeaconIEs *pIes = NULL;
2964
2965 do
2966 {
2967 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2968 {
2969 //err msg
2970 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002971 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 break;
2973 }
2974 //check if the AP is QAP & it supports APSD
2975 if( CSR_IS_QOS_BSS(pIes) )
2976 {
2977 return eHAL_STATUS_SUCCESS;
2978 }
2979 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 return status;
2981}
2982
Jeff Johnson295189b2012-06-20 16:38:30 -07002983void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2984{
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2986 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2987 // See !!Note: below in this function...
2988 tANI_U32 PrivacyEnabled = 0;
2989 tANI_U32 RsnEnabled = 0;
2990 tANI_U32 WepDefaultKeyId = 0;
2991 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2992 tANI_U32 Key0Length = 0;
2993 tANI_U32 Key1Length = 0;
2994 tANI_U32 Key2Length = 0;
2995 tANI_U32 Key3Length = 0;
2996
2997 // Reserve for the biggest key
2998 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2999 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3000 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3001 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3002
3003 switch ( pProfile->negotiatedUCEncryptionType )
3004 {
3005 case eCSR_ENCRYPT_TYPE_NONE:
3006
3007 // for NO encryption, turn off Privacy and Rsn.
3008 PrivacyEnabled = 0;
3009 RsnEnabled = 0;
3010
3011 // WEP key length and Wep Default Key ID don't matter in this case....
3012
3013 // clear out the WEP keys that may be hanging around.
3014 Key0Length = 0;
3015 Key1Length = 0;
3016 Key2Length = 0;
3017 Key3Length = 0;
3018
3019 break;
3020
3021 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303022 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003023
3024 // Privacy is ON. NO RSN for Wep40 static key.
3025 PrivacyEnabled = 1;
3026 RsnEnabled = 0;
3027
3028 // Set the Wep default key ID.
3029 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 // Wep key size if 5 bytes (40 bits).
3031 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3032
3033 // set encryption keys in the CFG database or clear those that are not present in this profile.
3034 if ( pProfile->Keys.KeyLength[0] )
3035 {
3036 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3037 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3038 }
3039 else
3040 {
3041 Key0Length = 0;
3042 }
3043
3044 if ( pProfile->Keys.KeyLength[1] )
3045 {
3046 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3047 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3048 }
3049 else
3050 {
3051 Key1Length = 0;
3052 }
3053
3054 if ( pProfile->Keys.KeyLength[2] )
3055 {
3056 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3057 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3058 }
3059 else
3060 {
3061 Key2Length = 0;
3062 }
3063
3064 if ( pProfile->Keys.KeyLength[3] )
3065 {
3066 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3067 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3068 }
3069 else
3070 {
3071 Key3Length = 0;
3072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 break;
3074
3075 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303076 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003077
3078 // Privacy is ON. NO RSN for Wep40 static key.
3079 PrivacyEnabled = 1;
3080 RsnEnabled = 0;
3081
3082 // Set the Wep default key ID.
3083 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3084
3085 // Wep key size if 13 bytes (104 bits).
3086 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3087
3088 // set encryption keys in the CFG database or clear those that are not present in this profile.
3089 if ( pProfile->Keys.KeyLength[0] )
3090 {
3091 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3092 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3093 }
3094 else
3095 {
3096 Key0Length = 0;
3097 }
3098
3099 if ( pProfile->Keys.KeyLength[1] )
3100 {
3101 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3102 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3103 }
3104 else
3105 {
3106 Key1Length = 0;
3107 }
3108
3109 if ( pProfile->Keys.KeyLength[2] )
3110 {
3111 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3112 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3113 }
3114 else
3115 {
3116 Key2Length = 0;
3117 }
3118
3119 if ( pProfile->Keys.KeyLength[3] )
3120 {
3121 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3122 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3123 }
3124 else
3125 {
3126 Key3Length = 0;
3127 }
3128
3129 break;
3130
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 case eCSR_ENCRYPT_TYPE_TKIP:
3132 case eCSR_ENCRYPT_TYPE_AES:
3133#ifdef FEATURE_WLAN_WAPI
3134 case eCSR_ENCRYPT_TYPE_WPI:
3135#endif /* FEATURE_WLAN_WAPI */
3136 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3137 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3138 PrivacyEnabled = (0 != fPrivacy);
3139
3140 // turn on RSN enabled for WPA associations
3141 RsnEnabled = 1;
3142
3143 // WEP key length and Wep Default Key ID don't matter in this case....
3144
3145 // clear out the static WEP keys that may be hanging around.
3146 Key0Length = 0;
3147 Key1Length = 0;
3148 Key2Length = 0;
3149 Key3Length = 0;
3150
3151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 default:
3153 PrivacyEnabled = 0;
3154 RsnEnabled = 0;
3155 break;
3156 }
3157
3158 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3159 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3160 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3161 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3162 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3163 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3164 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3165 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3166}
3167
Jeff Johnson295189b2012-06-20 16:38:30 -07003168static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3169{
3170 tANI_U32 len = 0;
3171 if(pSSID->length <= WNI_CFG_SSID_LEN)
3172 {
3173 len = pSSID->length;
3174 }
3175 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3176}
3177
Jeff Johnson295189b2012-06-20 16:38:30 -07003178eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3179{
3180 eHalStatus status = eHAL_STATUS_SUCCESS;
3181 tANI_U32 QoSEnabled;
3182 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 // set the CFG enable/disable variables based on the qosType being configured...
3184 switch( qosType )
3185 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3187 QoSEnabled = FALSE;
3188 WmeEnabled = TRUE;
3189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3191 QoSEnabled = FALSE;
3192 WmeEnabled = TRUE;
3193 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3195 QoSEnabled = FALSE;
3196 WmeEnabled = TRUE;
3197 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3199 QoSEnabled = TRUE;
3200 WmeEnabled = FALSE;
3201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 case eCSR_MEDIUM_ACCESS_11e_HCF:
3203 QoSEnabled = TRUE;
3204 WmeEnabled = FALSE;
3205 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 default:
3207 case eCSR_MEDIUM_ACCESS_DCF:
3208 QoSEnabled = FALSE;
3209 WmeEnabled = FALSE;
3210 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 }
3212 //save the WMM setting for later use
3213 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3215 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 return (status);
3217}
Jeff Johnson295189b2012-06-20 16:38:30 -07003218static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3219 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3220{
3221 eHalStatus status = eHAL_STATUS_FAILURE;
3222 int i;
3223 eCsrCfgDot11Mode cfgDot11Mode;
3224 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3226 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003228
3229 if( NULL != pIes )
3230 {
3231 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 // Originally, we thought that for 11a networks, the 11a rates are always
3233 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3234 // appear in the Operational Rate set. Consequently, in either case, we
3235 // would blindly put the rates we support into our Operational Rate set
3236 // (including the basic rates, which we have already verified are
3237 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 // However, it turns out that this is not always the case. Some AP's
3239 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3240 // too. Now, we're a little more careful:
3241 pDstRate = pOpRateSet->rate;
3242 if(pIes->SuppRates.present)
3243 {
3244 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3245 {
3246 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3247 {
3248 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003249 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 }
3251 }
3252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3254 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3255 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3256 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3257 {
3258 // If there are Extended Rates in the beacon, we will reflect those
3259 // extended rates that we support in out Extended Operational Rate
3260 // set:
3261 pDstRate = pExRateSet->rate;
3262 if(pIes->ExtSuppRates.present)
3263 {
3264 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3265 {
3266 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3267 {
3268 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3269 pExRateSet->numRates++;
3270 }
3271 }
3272 }
3273 }
3274 }//Parsing BSSDesc
3275 else
3276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003277 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
3279 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3280 return status;
3281}
3282
3283static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3284 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3285{
3286 int i;
3287 tANI_U8 *pDstRate;
3288 eCsrCfgDot11Mode cfgDot11Mode;
3289 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3290 tANI_U32 OperationalRatesLength = 0;
3291 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3292 tANI_U32 ExtendedOperationalRatesLength = 0;
3293 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3294 tANI_U32 ProprietaryOperationalRatesLength = 0;
3295 tANI_U32 PropRatesEnable = 0;
3296 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3297 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 if( NULL != pIes )
3300 {
3301 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 // Originally, we thought that for 11a networks, the 11a rates are always
3303 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3304 // appear in the Operational Rate set. Consequently, in either case, we
3305 // would blindly put the rates we support into our Operational Rate set
3306 // (including the basic rates, which we have already verified are
3307 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 // However, it turns out that this is not always the case. Some AP's
3309 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3310 // too. Now, we're a little more careful:
3311 pDstRate = OperationalRates;
3312 if(pIes->SuppRates.present)
3313 {
3314 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3315 {
3316 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3317 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3318 {
3319 *pDstRate++ = pIes->SuppRates.rates[ i ];
3320 OperationalRatesLength++;
3321 }
3322 }
3323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3325 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3326 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3327 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3328 {
3329 // If there are Extended Rates in the beacon, we will reflect those
3330 // extended rates that we support in out Extended Operational Rate
3331 // set:
3332 pDstRate = ExtendedOperationalRates;
3333 if(pIes->ExtSuppRates.present)
3334 {
3335 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3336 {
3337 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3338 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3339 {
3340 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3341 ExtendedOperationalRatesLength++;
3342 }
3343 }
3344 }
3345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 // Enable proprietary MAC features if peer node is Airgo node and STA
3347 // user wants to use them
3348 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3349 {
3350 PropRatesEnable = 1;
3351 }
3352 else
3353 {
3354 PropRatesEnable = 0;
3355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 // For ANI network companions, we need to populate the proprietary rate
3357 // set with any proprietary rates we found in the beacon, only if user
3358 // allows them...
3359 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3360 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3361 {
3362 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3363 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3364 {
3365 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3366 }
3367 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3368 }
3369 else {
3370 // No proprietary modes...
3371 ProprietaryOperationalRatesLength = 0;
3372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 /* Get MCS Rate */
3374 pDstRate = MCSRateIdxSet;
3375 if ( pIes->HTCaps.present )
3376 {
3377 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3378 {
3379 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3380 {
3381 MCSRateLength++;
3382 *pDstRate++ = i;
3383 }
3384 }
3385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 // Set the operational rate set CFG variables...
3387 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3388 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3389 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3390 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3391 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3392 ProprietaryOperationalRates,
3393 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3394 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3395 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3396 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3397 }//Parsing BSSDesc
3398 else
3399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003400 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 }
3402}
3403
Jeff Johnson295189b2012-06-20 16:38:30 -07003404static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3405 tCsrRoamProfile *pProfile )
3406{
3407 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3408 { 8,
3409 { SIR_MAC_RATE_6,
3410 SIR_MAC_RATE_9,
3411 SIR_MAC_RATE_12,
3412 SIR_MAC_RATE_18,
3413 SIR_MAC_RATE_24,
3414 SIR_MAC_RATE_36,
3415 SIR_MAC_RATE_48,
3416 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3418 { 4,
3419 { SIR_MAC_RATE_1,
3420 SIR_MAC_RATE_2,
3421 SIR_MAC_RATE_5_5,
3422 SIR_MAC_RATE_11 } } };
3423
3424
3425 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3426 { SIR_MAC_RATE_72,
3427 SIR_MAC_RATE_96,
3428 SIR_MAC_RATE_108 } };
3429 eCsrCfgDot11Mode cfgDot11Mode;
3430 eCsrBand eBand;
3431 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3432 tANI_U32 OperationalRatesLength = 0;
3433 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3434 tANI_U32 ExtendedOperationalRatesLength = 0;
3435 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3436 tANI_U32 ProprietaryOperationalRatesLength = 0;
3437 tANI_U32 PropRatesEnable = 0;
3438 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 if(pProfile->ChannelInfo.ChannelList)
3440 {
3441 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3445 // networks, the 11b rates appear in the Operational Rate set. In either case,
3446 // we can blindly put the rates we support into our Operational Rate set
3447 // (including the basic rates, which we have already verified are supported
3448 // earlier in the roaming decision).
3449 if ( eCSR_BAND_5G == eBand )
3450 {
3451 // 11a rates into the Operational Rate Set.
3452 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3453 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3454 palCopyMemory( pMac->hHdd, OperationalRates,
3455 DefaultSupportedRates11a.supportedRateSet.rate,
3456 OperationalRatesLength );
3457
3458 // Nothing in the Extended rate set.
3459 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 // populate proprietary rates if user allows them
3461 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3462 {
3463 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3464 sizeof(*DefaultSupportedPropRates.propRate);
3465 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3466 DefaultSupportedPropRates.propRate,
3467 ProprietaryOperationalRatesLength );
3468 }
3469 else
3470 {
3471 // No proprietary modes
3472 ProprietaryOperationalRatesLength = 0;
3473 }
3474 }
3475 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3476 {
3477 // 11b rates into the Operational Rate Set.
3478 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3479 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3480 palCopyMemory( pMac->hHdd, OperationalRates,
3481 DefaultSupportedRates11b.supportedRateSet.rate,
3482 OperationalRatesLength );
3483 // Nothing in the Extended rate set.
3484 ExtendedOperationalRatesLength = 0;
3485 // No proprietary modes
3486 ProprietaryOperationalRatesLength = 0;
3487 }
3488 else
3489 {
3490 // 11G
3491
3492 // 11b rates into the Operational Rate Set.
3493 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3494 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3495 palCopyMemory( pMac->hHdd, OperationalRates,
3496 DefaultSupportedRates11b.supportedRateSet.rate,
3497 OperationalRatesLength );
3498
3499 // 11a rates go in the Extended rate set.
3500 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3501 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3502 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3503 DefaultSupportedRates11a.supportedRateSet.rate,
3504 ExtendedOperationalRatesLength );
3505
3506 // populate proprietary rates if user allows them
3507 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3508 {
3509 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3510 sizeof(*DefaultSupportedPropRates.propRate);
3511 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3512 DefaultSupportedPropRates.propRate,
3513 ProprietaryOperationalRatesLength );
3514 }
3515 else
3516 {
3517 // No proprietary modes
3518 ProprietaryOperationalRatesLength = 0;
3519 }
3520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3522 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3523 {
3524 PropRatesEnable = 1;
3525 }
3526 else
3527 {
3528 PropRatesEnable = 0;
3529 }
3530
3531 // Set the operational rate set CFG variables...
3532 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3533 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3534 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3535 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3536 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3537 ProprietaryOperationalRates,
3538 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3539 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540}
Jeff Johnson295189b2012-06-20 16:38:30 -07003541void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3542{
3543 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003544
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3546 tANI_U32 sessionId;
3547 tSmeCmd *pCommand = NULL;
3548
3549 if(NULL == pEntry)
3550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003551 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 return;
3553 }
3554 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3555 sessionId = pCommand->sessionId;
3556
3557 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3558 {
3559 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3560 }
3561}
3562
Jeff Johnson295189b2012-06-20 16:38:30 -07003563//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3564tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3565{
3566 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3567 {
3568 return (WNI_CFG_PHY_MODE_11B);
3569 }
3570 else
3571 {
3572 if(eCSR_BAND_24 == band)
3573 return (WNI_CFG_PHY_MODE_11G);
3574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 return (WNI_CFG_PHY_MODE_11A);
3576}
Jeff Johnson295189b2012-06-20 16:38:30 -07003577
Jeff Johnsone7245742012-09-05 17:12:55 -07003578
3579#ifdef WLAN_FEATURE_11AC
3580ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3581{
3582 switch ( aniCBMode )
3583 {
3584 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3585 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3586 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3587 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3588 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3589 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3590 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3591 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3592 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003593 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003594 return PHY_SINGLE_CHANNEL_CENTERED;
3595 }
3596}
3597#endif
3598
Jeff Johnson295189b2012-06-20 16:38:30 -07003599//pIes may be NULL
3600eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3601 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303602 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003603{
3604 eHalStatus status = eHAL_STATUS_SUCCESS;
3605 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3606 tANI_U8 channel = 0;
3607 //Make sure we have the domain info for the BSS we try to connect to.
3608 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303609 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303611 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 {
3613 //Make sure the 11d info from this BSSDesc can be applied
3614 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303615 if (VOS_TRUE == resetCountry)
3616 {
3617 csrApplyCountryInformation(pMac, FALSE);
3618 }
3619 else
3620 {
3621 csrApplyCountryInformation(pMac, TRUE);
3622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 }
Kiran4a17ebe2013-01-31 10:43:43 -08003624 if ((csrIs11dSupported (pMac)) && pIes)
3625 {
3626 if (!pIes->Country.present)
3627 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 //Qos
3631 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3632 //SSID
3633 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3634 //fragment threshold
3635 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3636 //RTS threshold
3637 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3638
3639 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3640
3641 //Auth type
3642 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3643 //encryption type
3644 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3645 //short slot time
3646 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 //11d
3648 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3649 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3650 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 /*//11h
3652 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3653 */
3654 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3655 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003656
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003657 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 {
3659 channel = pProfile->operationChannel;
3660 }
3661 else
3662 {
3663 if(pBssDesc)
3664 {
3665 channel = pBssDesc->channelId;
3666 }
3667 }
3668 if(0 != channel)
3669 {
3670 if(CSR_IS_CHANNEL_24GHZ(channel))
3671 {//for now if we are on 2.4 Ghz, CB will be always disabled
3672 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3673 }
3674 else
3675 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003676 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 }
3678 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003679#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003680 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3681 // in function csrConvertCBIniValueToPhyCBState()
3682 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3683 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003684 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003685 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003686 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003687 }
3688 else
3689 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003690 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003691 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003692 }
3693 else
3694#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3696 //Rate
3697 //Fixed Rate
3698 if(pBssDesc)
3699 {
3700 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3701 }
3702 else
3703 {
3704 csrSetCfgRateSetFromProfile(pMac, pProfile);
3705 }
3706 //Make this the last CFG to set. The callback will trigger a join_req
3707 //Join time out
3708 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3709
3710 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 return (status);
3712}
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3715 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3716{
3717 eHalStatus status;
3718 tBssConfigParam *pBssConfig;
3719 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003720
3721 if(!pSession)
3722 {
3723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3724 return eHAL_STATUS_FAILURE;
3725 }
3726
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3728 if(HAL_STATUS_SUCCESS(status))
3729 {
3730 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3731 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3732 if(HAL_STATUS_SUCCESS(status))
3733 {
3734 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003735 /* This will allow to pass cbMode during join req */
3736 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 //For IBSS, we need to prepare some more information
3738 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 )
3741 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003742 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 }
3744 // If we are in an IBSS, then stop the IBSS...
3745 ////Not worry about WDS connection for now
3746 if ( csrIsConnStateIbss( pMac, sessionId ) )
3747 {
3748 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3749 }
3750 else
3751 {
3752 // if we are in an Infrastructure association....
3753 if ( csrIsConnStateInfra( pMac, sessionId ) )
3754 {
3755 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3756 // across SSIDs (roaming to a new SSID)... //
3757 //Not worry about WDS connection for now
3758 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303759 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 {
3761 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303762 status = csrRoamIssueDisassociate( pMac, sessionId,
3763 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303765 else
3766 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3768 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303769 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303771 // Set parameters for this Bss.
3772 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3773 pBssDesc, pBssConfig,
3774 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303778 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 {
3780 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3781 // Nothing to stop.
3782 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303784 )
3785 {
3786 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3787 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3788 // Set parameters for this Bss.
3789 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3790 pBssDesc, pBssConfig,
3791 pIes, is11rRoamingFlag);
3792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 }
3794 }
3795 }//Success getting BSS config info
3796 palFreeMemory(pMac->hHdd, pBssConfig);
3797 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 return (status);
3799}
3800
Jeff Johnson295189b2012-06-20 16:38:30 -07003801eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3802 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3803{
3804 eCsrJoinState eRoamState = eCsrContinueRoaming;
3805 eHalStatus status;
3806 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3807 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3808 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003809
3810 if(!pSession)
3811 {
3812 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3813 return (eCsrStopRoaming);
3814 }
3815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 if( CSR_IS_WDS_STA( pProfile ) )
3817 {
3818 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3819 if( !HAL_STATUS_SUCCESS( status ) )
3820 {
3821 eRoamState = eCsrStopRoaming;
3822 }
3823 }
3824 else
3825 {
3826 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3827 {
3828 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3829 return (eCsrStopRoaming);
3830 }
3831 if ( csrIsInfraBssDesc( pBssDesc ) )
3832 {
3833 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3834 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3835 // have changed and handle the changes (without disturbing the current association).
3836
3837 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3838 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3839 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3840 )
3841 {
3842 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3843 // with Authenticating first. To force this, stop the current association (Disassociate) and
3844 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3845 // a new Association.
3846 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003848 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3850 {
3851 eRoamState = eCsrReassocToSelfNoCapChange;
3852 }
3853 else
3854 {
3855 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 //The key changes
3857 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3858 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3859 if(HAL_STATUS_SUCCESS(status))
3860 {
3861 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003862 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303864 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3865 pBssDesc, &bssConfig,
3866 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 if(!HAL_STATUS_SUCCESS(status))
3868 {
3869 eRoamState = eCsrStopRoaming;
3870 }
3871 }
3872 else
3873 {
3874 eRoamState = eCsrStopRoaming;
3875 }
3876 }//same profile
3877 }
3878 else
3879 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303880 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003883 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303887 }
3888 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 {
3890 // 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 +05303891 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 // work much better.
3893 //
3894 //
3895 // stop the existing network before attempting to join the new network...
3896 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3897 {
3898 eRoamState = eCsrStopRoaming;
3899 }
3900 }
3901 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303902 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 {
3904 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3905 {
3906 eRoamState = eCsrStopRoaming;
3907 }
3908 }
3909 if( pIesLocal && !pScanResult->pvIes )
3910 {
3911 palFreeMemory(pMac->hHdd, pIesLocal);
3912 }
3913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 return( eRoamState );
3915}
3916
Jeff Johnson295189b2012-06-20 16:38:30 -07003917eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3918 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3919{
3920 eHalStatus status = eHAL_STATUS_SUCCESS;
3921 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3923 roamInfo.pBssDesc = pBssDesc;
3924 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3925 return (status);
3926}
Jeff Johnson295189b2012-06-20 16:38:30 -07003927//In case no matching BSS is found, use whatever default we can find
3928static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3929{
3930 //Need to get all negotiated types in place first
3931 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003932 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 {
3934 default:
3935 case eCSR_AUTH_TYPE_WPA:
3936 case eCSR_AUTH_TYPE_WPA_PSK:
3937 case eCSR_AUTH_TYPE_WPA_NONE:
3938 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3939 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3940 break;
3941
3942 case eCSR_AUTH_TYPE_SHARED_KEY:
3943 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3944 break;
3945
3946 case eCSR_AUTH_TYPE_AUTOSWITCH:
3947 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3948 break;
3949 }
3950 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3951 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3952 //In this case, the multicast encryption needs to follow the uncast ones.
3953 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3954 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3955}
3956
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003957
3958static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3959{
3960 switch(pCommand->u.roamCmd.roamReason)
3961 {
3962 case eCsrLostLink1:
3963 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3964 break;
3965 case eCsrLostLink2:
3966 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3967 break;
3968 case eCsrLostLink3:
3969 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3970 break;
3971 default:
3972 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3973 pCommand->u.roamCmd.roamReason);
3974 break;
3975 }
3976}
3977
Jeff Johnson295189b2012-06-20 16:38:30 -07003978static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3979{
3980 eHalStatus status;
3981 tCsrScanResult *pScanResult = NULL;
3982 eCsrJoinState eRoamState = eCsrStopRoaming;
3983 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3984 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3985 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3986#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3987 v_U8_t acm_mask = 0;
3988#endif
3989 tANI_U32 sessionId = pCommand->sessionId;
3990 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3991 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3992 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003993
3994 if(!pSession)
3995 {
3996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3997 return (eCsrStopRoaming);
3998 }
3999
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 do
4001 {
4002 // Check for Cardbus eject condition, before trying to Roam to any BSS
4003 //***if( !balIsCardPresent(pAdapter) ) break;
4004
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004005 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4006 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 if(NULL != pBSSList)
4008 {
4009 // When handling AP's capability change, continue to associate to
4010 // same BSS and make sure pRoamBssEntry is not Null.
4011 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4012 {
4013 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4014 {
4015 //Try the first BSS
4016 pCommand->u.roamCmd.pLastRoamBss = NULL;
4017 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4018 }
4019 else
4020 {
4021 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4022 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4023 {
4024 //Done with all the BSSs
4025 //In this case, will tell HDD the completion
4026 break;
4027 }
4028 else
4029 {
4030 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004031 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4033 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4034 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4035 pRoamInfo = &roamInfo;
4036 }
4037 }
4038 while(pCommand->u.roamCmd.pRoamBssEntry)
4039 {
4040 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 /*If concurrency enabled take the concurrent connected channel first. */
4042 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004043 if (vos_concurrent_sessions_running() &&
4044 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 {
4046 concurrentChannel =
4047 csrGetConcurrentOperationChannel(pMac);
4048 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004049 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 if ((concurrentChannel) &&
4051 (concurrentChannel ==
4052 pScanResult->Result.BssDescriptor.channelId))
4053 {
4054 //make this 0 because we do not want the
4055 //below check to pass as we don't want to
4056 //connect on other channel
4057 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4058 FL("Concurrent channel match =%d"),
4059 concurrentChannel);
4060 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 }
4062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004063
4064 if (!concurrentChannel)
4065 {
4066
4067 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4068 sessionId, &pScanResult->Result.BssDescriptor,
4069 pCommand->u.roamCmd.roamId)))
4070 {
4071 //Ok to roam this
4072 break;
4073 }
4074 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004075 else
4076 {
4077 eRoamState = eCsrStopRoamingDueToConcurrency;
4078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4080 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4081 {
4082 //Done with all the BSSs
4083 fDone = eANI_BOOLEAN_TRUE;
4084 break;
4085 }
4086 }
4087 if(fDone)
4088 {
4089 break;
4090 }
4091 }
4092 }
4093 //We have something to roam, tell HDD when it is infra.
4094 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4095 //For WDS, the indication is eCSR_ROAM_WDS_IND
4096 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4097 {
4098 if(pRoamInfo)
4099 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004100 if(pSession->bRefAssocStartCnt)
4101 {
4102 pSession->bRefAssocStartCnt--;
4103 //Complete the last association attemp because a new one is about to be tried
4104 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4105 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004107 }
4108 }
4109 /* If the roaming has stopped, not to continue the roaming command*/
4110 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4111 {
4112 //No need to complete roaming here as it already completes
4113 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4114 pCommand->u.roamCmd.roamReason);
4115 eRoamState = eCsrStopRoaming;
4116 csrSetAbortRoamingCommand(pMac, pCommand);
4117 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 }
4119 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4120 if(pScanResult)
4121 {
4122 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004125 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 fDone = eANI_BOOLEAN_TRUE;
4127 eRoamState = eCsrStopRoaming;
4128 break;
4129 }
4130 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4131 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4132 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4133 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4134 CSR_IS_QOS_BSS(pIesLocal) &&
4135 CSR_IS_UAPSD_BSS(pIesLocal) )
4136 {
4137#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4139 pIesLocal);
4140 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4141#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 }
4143 else
4144 {
4145 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4146 }
4147 if( pIesLocal && !pScanResult->Result.pvIes)
4148 {
4149 palFreeMemory(pMac->hHdd, pIesLocal);
4150 }
4151 }
4152 else
4153 {
4154 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4155 }
4156 roamInfo.pProfile = pProfile;
4157 pSession->bRefAssocStartCnt++;
4158 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4159 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4162 {
4163 // If this is a start IBSS profile, then we need to start the IBSS.
4164 if ( CSR_IS_START_IBSS(pProfile) )
4165 {
4166 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 // Attempt to start this IBSS...
4168 csrRoamAssignDefaultParam( pMac, pCommand );
4169 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4170 if(HAL_STATUS_SUCCESS(status))
4171 {
4172 if ( fSameIbss )
4173 {
4174 eRoamState = eCsrStartIbssSameIbss;
4175 }
4176 else
4177 {
4178 eRoamState = eCsrContinueRoaming;
4179 }
4180 }
4181 else
4182 {
4183 //it somehow fail need to stop
4184 eRoamState = eCsrStopRoaming;
4185 }
4186 break;
4187 }
4188 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 )
4191 {
4192 // Attempt to start this WDS...
4193 csrRoamAssignDefaultParam( pMac, pCommand );
4194 /* For AP WDS, we dont have any BSSDescription */
4195 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4196 if(HAL_STATUS_SUCCESS(status))
4197 {
4198 eRoamState = eCsrContinueRoaming;
4199 }
4200 else
4201 {
4202 //it somehow fail need to stop
4203 eRoamState = eCsrStopRoaming;
4204 }
4205 }
4206 else
4207 {
4208 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004209 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 eRoamState = eCsrStopRoaming;
4211 break;
4212 }
4213 }
4214 else //We have BSS
4215 {
4216 //Need to assign these value because they are used in csrIsSameProfile
4217 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4218 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4219 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4220 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4221 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4222 {
4223 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4224 {
4225 eRoamState = eCsrStartIbssSameIbss;
4226 break;
4227 }
4228 }
4229 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4230 {
4231 //trying to connect to the one already connected
4232 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4233 eRoamState = eCsrReassocToSelfNoCapChange;
4234 break;
4235 }
4236 // Attempt to Join this Bss...
4237 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4238 break;
4239 }
4240
4241 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4243 {
4244 //Need to indicate association_completion if association_start has been done
4245 if(pSession->bRefAssocStartCnt > 0)
4246 {
4247 pSession->bRefAssocStartCnt--;
4248 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004249 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4251 eCSR_ROAM_ASSOCIATION_COMPLETION,
4252 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4253 }
4254 }
4255
4256 return( eRoamState );
4257}
4258
Jeff Johnson295189b2012-06-20 16:38:30 -07004259static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4260{
4261 eHalStatus status = eHAL_STATUS_SUCCESS;
4262 eCsrJoinState RoamState;
4263 tANI_U32 sessionId = pCommand->sessionId;
4264
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 //***if( hddIsRadioStateOn( pAdapter ) )
4266 {
4267 // Attept to join a Bss...
4268 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004269
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004271 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 {
4273 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 // and if connected in Infrastructure mode...
4275 if ( csrIsConnStateInfra(pMac, sessionId) )
4276 {
4277 //... then we need to issue a disassociation
4278 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4279 if(!HAL_STATUS_SUCCESS(status))
4280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004281 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 //roam command is completed by caller in the failed case
4283 fComplete = eANI_BOOLEAN_TRUE;
4284 }
4285 }
4286 else if( csrIsConnStateIbss(pMac, sessionId) )
4287 {
4288 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4289 if(!HAL_STATUS_SUCCESS(status))
4290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004291 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 //roam command is completed by caller in the failed case
4293 fComplete = eANI_BOOLEAN_TRUE;
4294 }
4295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4297 {
4298 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4299 if(!HAL_STATUS_SUCCESS(status))
4300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004301 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 //roam command is completed by caller in the failed case
4303 fComplete = eANI_BOOLEAN_TRUE;
4304 }
4305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 else
4307 {
4308 fComplete = eANI_BOOLEAN_TRUE;
4309 }
4310 if(fComplete)
4311 {
4312 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004313 if(eCsrStopRoamingDueToConcurrency == RoamState)
4314 {
4315 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4316 }
4317 else
4318 {
4319 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 }
4322 }
4323 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4324 {
4325 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4326 }
4327 else if ( eCsrStartIbssSameIbss == RoamState )
4328 {
4329 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4330 }
4331 }//hddIsRadioStateOn
4332
4333 return status;
4334}
Jeff Johnson295189b2012-06-20 16:38:30 -07004335eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4336{
4337 tANI_U32 sessionId;
4338 tCsrRoamSession *pSession;
4339 tCsrScanResult *pScanResult = NULL;
4340 tSirBssDescription *pBssDesc = NULL;
4341 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 sessionId = pCommand->sessionId;
4343 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004344
4345 if(!pSession)
4346 {
4347 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4348 return eHAL_STATUS_FAILURE;
4349 }
4350
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4352 {
4353 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004354 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4356 return eHAL_STATUS_FAILURE;
4357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 if (pCommand->u.roamCmd.pRoamBssEntry)
4359 {
4360 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4361 pBssDesc = &pScanResult->Result.BssDescriptor;
4362 }
4363 else
4364 {
4365 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004366 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4368 return eHAL_STATUS_FAILURE;
4369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4371 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4372 return status;
4373}
4374
Jeff Johnson295189b2012-06-20 16:38:30 -07004375eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4376{
4377 eHalStatus status = eHAL_STATUS_SUCCESS;
4378 tCsrRoamInfo roamInfo;
4379 tANI_U32 sessionId = pCommand->sessionId;
4380 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004381
4382 if(!pSession)
4383 {
4384 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4385 return eHAL_STATUS_FAILURE;
4386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004387
4388 switch ( pCommand->u.roamCmd.roamReason )
4389 {
4390 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004392 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 case eCsrSmeIssuedDisassocForHandoff:
4395 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4396#if 0 // TODO : Confirm this change
4397 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4398#else
4399 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4400#endif
4401
4402 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004405 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004409 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 case eCsrHddIssuedReassocToSameAP:
4412 case eCsrSmeIssuedReassocToSameAP:
4413 {
4414 tDot11fBeaconIEs *pIes = NULL;
4415
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 if( pSession->pConnectBssDesc )
4417 {
4418 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4419 if(!HAL_STATUS_SUCCESS(status) )
4420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004421 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 }
4423 else
4424 {
4425 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4426 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4427 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4429 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4430 pSession->bRefAssocStartCnt++;
4431 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4432 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4433
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004434 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004435 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4436 &pCommand->u.roamCmd.roamProfile );
4437 if(!HAL_STATUS_SUCCESS(status))
4438 {
4439 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004440 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004441 }
4442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 palFreeMemory(pMac->hHdd, pIes);
4444 pIes = NULL;
4445 }
4446 }
4447 break;
4448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004450 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4452 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4453 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004455 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4457 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004458
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 case eCsrStopBss:
4460 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4461 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4462 break;
4463
4464 case eCsrForcedDisassocSta:
4465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4466 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4467 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4468 pCommand->u.roamCmd.reason);
4469 break;
4470
4471 case eCsrForcedDeauthSta:
4472 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4473 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4474 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4475 pCommand->u.roamCmd.reason);
4476 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004477
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004478 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004479 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004480 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4481 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004483
4484 default:
4485 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4486
4487 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4488 {
4489 //Remember the roaming profile
4490 csrFreeRoamProfile(pMac, sessionId);
4491 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4492 {
4493 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4494 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4495 }
4496 }
4497
4498 //At this point, original uapsd_mask is saved in pCurRoamProfile
4499 //uapsd_mask in the pCommand may change from this point on.
4500
4501 // Attempt to roam with the new scan results (if we need to..)
4502 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004503 if(!HAL_STATUS_SUCCESS(status))
4504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004505 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 break;
4508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 return (status);
4510}
4511
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004512void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4513{
4514 pCommand->u.roamCmd.pLastRoamBss = NULL;
4515 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4516 //Because u.roamCmd is union and share with scanCmd and StatusChange
4517 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4518}
4519
Jeff Johnson295189b2012-06-20 16:38:30 -07004520void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4521{
4522 if(pCommand->u.roamCmd.fReleaseBssList)
4523 {
4524 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4525 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4526 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4527 }
4528 if(pCommand->u.roamCmd.fReleaseProfile)
4529 {
4530 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4531 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4532 }
4533 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4534 //Because u.roamCmd is union and share with scanCmd and StatusChange
4535 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4536}
4537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4539{
4540 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4541}
Jeff Johnson295189b2012-06-20 16:38:30 -07004542void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4543{
4544 tListElem *pEntry;
4545 tSmeCmd *pCommand;
4546 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004547 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4549 if ( pEntry )
4550 {
4551 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 // If the head of the queue is Active and it is a ROAM command, remove
4553 // and put this on the Free queue.
4554 if ( eSmeCommandRoam == pCommand->command )
4555 {
4556 //we need to process the result first before removing it from active list because state changes
4557 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4558 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4559 if( fReleaseCommand )
4560 {
4561 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4562 {
4563 csrReleaseCommandRoam( pMac, pCommand );
4564 }
4565 else
4566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004567 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004568 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 }
4570 }
4571 else
4572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004573 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004574 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
4576 }
4577 else
4578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004579 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 }
4581 }
4582 else
4583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004584 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 if( fReleaseCommand )
4587 {
4588 smeProcessPendingQueue( pMac );
4589 }
4590}
4591
Jeff Johnson295189b2012-06-20 16:38:30 -07004592void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4593{
4594 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004595 if(!pSession)
4596 {
4597 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4598 return;
4599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4601 pSession->NumPmkidCandidate = 0;
4602}
Jeff Johnson295189b2012-06-20 16:38:30 -07004603#ifdef FEATURE_WLAN_WAPI
4604void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4605{
4606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004607 if(!pSession)
4608 {
4609 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4610 return;
4611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4613 pSession->NumBkidCandidate = 0;
4614}
4615#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004616extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4617
Jeff Johnson295189b2012-06-20 16:38:30 -07004618static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4619 tSirBssDescription *pSirBssDesc,
4620 tDot11fBeaconIEs *pIes)
4621{
4622 eHalStatus status = eHAL_STATUS_SUCCESS;
4623 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4624 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004625
4626 if(!pSession)
4627 {
4628 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4629 return eHAL_STATUS_FAILURE;
4630 }
4631
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 if((eCSR_AUTH_TYPE_WPA == authType) ||
4633 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4634 (eCSR_AUTH_TYPE_RSN == authType) ||
4635 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4636#if defined WLAN_FEATURE_VOWIFI_11R
4637 ||
4638 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4639 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4640#endif /* FEATURE_WLAN_WAPI */
4641#ifdef FEATURE_WLAN_WAPI
4642 ||
4643 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4644 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4645#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004646#ifdef WLAN_FEATURE_11W
4647 ||
4648 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4649#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 )
4651 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004654 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 }
4656 if( pIesLocal )
4657 {
4658 tANI_U32 nIeLen;
4659 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 if((eCSR_AUTH_TYPE_RSN == authType) ||
4661#if defined WLAN_FEATURE_VOWIFI_11R
4662 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4663 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4664#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004665#if defined WLAN_FEATURE_11W
4666 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4669 {
4670 if(pIesLocal->RSN.present)
4671 {
4672 //Calculate the actual length
4673 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4674 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4675 + 2 //akm_suite_count
4676 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4677 + 2; //reserved
4678 if( pIesLocal->RSN.pmkid_count )
4679 {
4680 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4681 }
4682 //nIeLen doesn't count EID and length fields
4683 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4684 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004685 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4687 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4688 //copy upto akm_suites
4689 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004690 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4691 pIeBuf += sizeof(pIesLocal->RSN.version);
4692 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4693 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4694 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4695 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 if( pIesLocal->RSN.pwise_cipher_suite_count )
4697 {
4698 //copy pwise_cipher_suites
4699 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4700 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4701 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4702 }
4703 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4704 pIeBuf += 2;
4705 if( pIesLocal->RSN.akm_suite_count )
4706 {
4707 //copy akm_suites
4708 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4709 pIesLocal->RSN.akm_suite_count * 4);
4710 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4711 }
4712 //copy the rest
4713 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4714 pIesLocal->RSN.akm_suite_count * 4,
4715 2 + pIesLocal->RSN.pmkid_count * 4);
4716 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4717 }
4718 }
4719 }
4720 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4721 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4722 {
4723 if(pIesLocal->WPA.present)
4724 {
4725 //Calculate the actual length
4726 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4727 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4728 + 2 //auth_suite_count
4729 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4730 // The WPA capabilities follows the Auth Suite (two octects)--
4731 // this field is optional, and we always "send" zero, so just
4732 // remove it. This is consistent with our assumptions in the
4733 // frames compiler; c.f. bug 15234:
4734 //nIeLen doesn't count EID and length fields
4735 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4736 {
4737 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4738 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4739 pIeBuf = pSession->pWpaRsnRspIE + 2;
4740 //Copy WPA OUI
4741 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4742 pIeBuf += 4;
4743 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4744 pIesLocal->WPA.unicast_cipher_count * 4);
4745 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4746 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4747 pIesLocal->WPA.auth_suite_count * 4);
4748 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4749 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4750 }
4751 }
4752 }
4753#ifdef FEATURE_WLAN_WAPI
4754 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4755 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4756 {
4757 if(pIesLocal->WAPI.present)
4758 {
4759 //Calculate the actual length
4760 nIeLen = 4 //version + akm_suite_count
4761 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4762 + 2 //pwise_cipher_suite_count
4763 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4764 + 6; //gp_cipher_suite + preauth + reserved
4765 if( pIesLocal->WAPI.bkid_count )
4766 {
4767 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4768 }
4769
4770 //nIeLen doesn't count EID and length fields
4771 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4772 {
4773 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4774 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4775 pIeBuf = pSession->pWapiRspIE + 2;
4776 //copy upto akm_suite_count
lukez3c809222013-05-03 10:23:02 -07004777 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 pIeBuf += 4;
4779 if( pIesLocal->WAPI.akm_suite_count )
4780 {
4781 //copy akm_suites
4782 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4783 pIesLocal->WAPI.akm_suite_count * 4);
4784 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4785 }
4786 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4787 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4789 {
4790 //copy pwise_cipher_suites
4791 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4792 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4793 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4794 }
lukez3c809222013-05-03 10:23:02 -07004795 //gp_cipher_suite
4796 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite, 4);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304797 //preauth + reserved
4798 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite + 4, 2);
4799 //bkid_count
4800 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 pIeBuf += 8;
4802 if( pIesLocal->WAPI.bkid_count )
4803 {
4804 //copy akm_suites
4805 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4806 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4807 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304808 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 }
4811 }
4812#endif /* FEATURE_WLAN_WAPI */
4813 if( !pIes )
4814 {
4815 //locally allocated
4816 palFreeMemory(pMac->hHdd, pIesLocal);
4817 }
4818 }
4819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 return (status);
4821}
4822
Jeff Johnson295189b2012-06-20 16:38:30 -07004823static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4824{
4825 v_U8_t bACWeights[WLANTL_MAX_AC];
4826 v_U8_t paramBk, paramBe, paramVi, paramVo;
4827 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4829 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4830 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4831 //This doesn't address the case where the lower AC needs a real higher weight
4832 if( pIEs->WMMParams.present )
4833 {
4834 //no change to the lowest ones
4835 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4836 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4837 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4838 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4839 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4840 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4841 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4842 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4843 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4844 {
4845 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4846 fWeightChange = VOS_TRUE;
4847 }
4848 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4849 {
4850 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4851 fWeightChange = VOS_TRUE;
4852 }
4853 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4854 {
4855 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4856 fWeightChange = VOS_TRUE;
4857 }
4858 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4859 {
4860 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4861 fWeightChange = VOS_TRUE;
4862 }
4863 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4864 {
4865 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4866 fWeightChange = VOS_TRUE;
4867 }
4868 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4869 {
4870 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4871 fWeightChange = VOS_TRUE;
4872 }
4873 if(fWeightChange)
4874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004875 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 bACWeights[2], bACWeights[3]);
4877 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4878 }
4879 }
4880}
Jeff Johnson295189b2012-06-20 16:38:30 -07004881#ifdef WLAN_FEATURE_VOWIFI_11R
4882//Returns whether the current association is a 11r assoc or not
4883tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4884{
4885#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4886 return csrNeighborRoamIs11rAssoc(pMac);
4887#else
4888 return eANI_BOOLEAN_FALSE;
4889#endif
4890}
4891#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004892#ifdef FEATURE_WLAN_CCX
4893//Returns whether the current association is a CCX assoc or not
4894tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4895{
4896#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4897 return csrNeighborRoamIsCCXAssoc(pMac);
4898#else
4899 return eANI_BOOLEAN_FALSE;
4900#endif
4901}
4902#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004903#ifdef FEATURE_WLAN_LFR
4904//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304905tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004906{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304907 tCsrRoamSession *pSession = NULL;
4908
4909 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4910 {
4911 pSession = CSR_GET_SESSION( pMac, sessionId );
4912 if (NULL != pSession->pCurRoamProfile)
4913 {
4914 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4915 {
4916 return eANI_BOOLEAN_FALSE;
4917 }
4918 }
4919 }
4920
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004921#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4922 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4923 {
4924 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
4925 }
4926 else
4927#endif
4928 {
4929 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004930 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004931 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004932}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004933
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004934#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4935//Returns whether "FW based BG scan" is currently enabled...or not
4936tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4937{
4938 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4939}
4940#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004941#endif
4942
Jeff Johnson295189b2012-06-20 16:38:30 -07004943//Return true means the command can be release, else not
4944static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4945 eCsrRoamCompleteResult Result, void *Context )
4946{
4947 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4948 tSirBssDescription *pSirBssDesc = NULL;
4949 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4950 tCsrScanResult *pScanResult = NULL;
4951 tCsrRoamInfo roamInfo;
4952 sme_QosAssocInfo assocInfo;
4953 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4954 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4955 tDot11fBeaconIEs *pIes = NULL;
4956 tANI_U32 sessionId = pCommand->sessionId;
4957 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4958 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4959 eRoamCmdStatus roamStatus;
4960 eCsrRoamResult roamResult;
4961 eHalStatus status;
4962 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004964
Jeff Johnson32d95a32012-09-10 13:15:23 -07004965 if(!pSession)
4966 {
4967 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4968 return eANI_BOOLEAN_FALSE;
4969 }
4970
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004971 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 switch( Result )
4973 {
4974 case eCsrJoinSuccess:
4975 // reset the IDLE timer
4976 // !!
4977 // !! fall through to the next CASE statement here is intentional !!
4978 // !!
4979 case eCsrReassocSuccess:
4980 if(eCsrReassocSuccess == Result)
4981 {
4982 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4983 }
4984 else
4985 {
4986 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4987 }
4988 // Success Join Response from LIM. Tell NDIS we are connected and save the
4989 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004990 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4992 //always free the memory here
4993 if(pSession->pWpaRsnRspIE)
4994 {
4995 pSession->nWpaRsnRspIeLength = 0;
4996 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4997 pSession->pWpaRsnRspIE = NULL;
4998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004999#ifdef FEATURE_WLAN_WAPI
5000 if(pSession->pWapiRspIE)
5001 {
5002 pSession->nWapiRspIeLength = 0;
5003 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
5004 pSession->pWapiRspIE = NULL;
5005 }
5006#endif /* FEATURE_WLAN_WAPI */
5007#ifdef FEATURE_WLAN_BTAMP_UT_RF
5008 //Reset counter so no join retry is needed.
5009 pSession->maxRetryCount = 0;
5010 csrRoamStopJoinRetryTimer(pMac, sessionId);
5011#endif
5012 /* This creates problem since we have not saved the connected profile.
5013 So moving this after saving the profile
5014 */
5015 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5016 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5017 {
5018 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5019 }
5020 else
5021 {
5022 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 //Use the last connected bssdesc for reassoc-ing to the same AP.
5025 //NOTE: What to do when reassoc to a different AP???
5026 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5027 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5028 {
5029 pSirBssDesc = pSession->pConnectBssDesc;
5030 if(pSirBssDesc)
5031 {
5032 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5033 }
5034 }
5035 else
5036 {
5037
5038 if(pCommand->u.roamCmd.pRoamBssEntry)
5039 {
5040 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5041 if(pScanResult != NULL)
5042 {
5043 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5044 //this can be NULL
5045 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5046 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5047 }
5048 }
5049 }
5050 if( pSirBssDesc )
5051 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5054 //Save WPA/RSN IE
5055 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5056#ifdef FEATURE_WLAN_CCX
5057 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5058#endif
5059
5060 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5061 // substate change.
5062 // Moving even save profile above so that below mentioned conditon is also met.
5063 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5064 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5066 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5067 // will be dropped for the security context may not be set properly.
5068 //
5069 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5070 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5071 //
5072 // this reordering was done on titan_prod_usb branch and is being replicated here.
5073 //
5074
5075 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5076 !pProfile->bWPSAssociation)
5077 {
5078 // Issue the set Context request to LIM to establish the Unicast STA context
5079 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5080 pProfile->negotiatedUCEncryptionType,
5081 pSirBssDesc, &(pSirBssDesc->bssId),
5082 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005084 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5086 }
5087 // Issue the set Context request to LIM to establish the Broadcast STA context
5088 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5089 pSirBssDesc, &BroadcastMac,
5090 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5091 }
5092 else
5093 {
5094 //Need to wait for supplicant authtication
5095 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 //Set the subestate to WaitForKey in case authentiation is needed
5097 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5098
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 if(pProfile->bWPSAssociation)
5100 {
5101 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5102 }
5103 else
5104 {
5105 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5106 }
5107
5108 //Save sessionId in case of timeout
5109 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5110 //This time should be long enough for the rest of the process plus setting key
5111 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5112 {
5113 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005114 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5116 }
5117 }
5118
5119 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5120 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 if(Context)
5122 {
5123 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5124 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5126 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5127#ifdef WLAN_FEATURE_VOWIFI_11R
5128 len += pJoinRsp->parsedRicRspLen;
5129#endif /* WLAN_FEATURE_VOWIFI_11R */
5130#ifdef FEATURE_WLAN_CCX
5131 len += pJoinRsp->tspecIeLen;
5132#endif
5133 if(len)
5134 {
5135 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5136 (void **)&pSession->connectedInfo.pbFrames, len)))
5137 {
5138 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5139 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5140 {
5141 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5142 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5143 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5144#ifdef WLAN_FEATURE_VOWIFI_11R
5145 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5146#endif /* WLAN_FEATURE_VOWIFI_11R */
5147#ifdef FEATURE_WLAN_CCX
5148 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5149#endif
5150 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5151 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5152 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5153 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5154 }
5155 else
5156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005157 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005158 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5160 pSession->connectedInfo.pbFrames = NULL;
5161 }
5162 }
5163 }
5164 if(pCommand->u.roamCmd.fReassoc)
5165 {
5166 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5167 }
5168 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5169 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5170 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5171 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5172 }
5173 else
5174 {
5175 if(pCommand->u.roamCmd.fReassoc)
5176 {
5177 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5178 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5179 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5180 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5181 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5182 }
5183 }
5184#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5185 // Indicate SME-QOS with reassoc success event, only after
5186 // copying the frames
5187 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 roamInfo.pBssDesc = pSirBssDesc;
5190 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5191 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5192#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5193 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5194#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5195 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5197 //It may be better to let QoS do this????
5198 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005200 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5202 pmcStartUapsd( pMac, NULL, NULL );
5203 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305204 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5206 if( pSession->bRefAssocStartCnt > 0 )
5207 {
5208 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005209 //Remove this code once SLM_Sessionization is supported
5210 //BMPS_WORKAROUND_NOT_NEEDED
5211 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005212 {
5213 pMac->roam.configParam.doBMPSWorkaround = 1;
5214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5216 }
5217
5218 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 // reset the PMKID candidate list
5220 csrResetPMKIDCandidateList( pMac, sessionId );
5221 //Update TL's AC weight base on the current EDCA parameters
5222 //These parameters may change in the course of the connection, that sictuation
5223 //is not taken care here. This change is mainly to address a WIFI WMM test where
5224 //BE has a equal or higher TX priority than VI.
5225 //We only do this for infra link
5226 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5227 {
5228 csrCheckAndUpdateACWeight(pMac, pIes);
5229 }
5230#ifdef FEATURE_WLAN_WAPI
5231 // reset the BKID candidate list
5232 csrResetBKIDCandidateList( pMac, sessionId );
5233#endif /* FEATURE_WLAN_WAPI */
5234 }
5235 else
5236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005237 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 csrScanCancelIdleScan(pMac);
5240 //Not to signal link up because keys are yet to be set.
5241 //The linkup function will overwrite the sub-state that we need to keep at this point.
5242 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5243 {
5244 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5247 //enough to let security and DHCP handshake succeed before entry into BMPS
5248 if (pmcShouldBmpsTimerRun(pMac))
5249 {
5250 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5251 != eHAL_STATUS_SUCCESS)
5252 {
5253 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5254 }
5255 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 break;
5258
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 case eCsrStartBssSuccess:
5260 // on the StartBss Response, LIM is returning the Bss Description that we
5261 // are beaconing. Add this Bss Description to our scan results and
5262 // chain the Profile to this Bss Description. On a Start BSS, there was no
5263 // detected Bss description (no partner) so we issued the Start Bss to
5264 // start the Ibss without any Bss description. Lim was kind enough to return
5265 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005266 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5270 if( CSR_IS_IBSS( pProfile ) )
5271 {
5272 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 else if (CSR_IS_INFRA_AP(pProfile))
5275 {
5276 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 else
5279 {
5280 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5281 }
5282 if( !CSR_IS_WDS_STA( pProfile ) )
5283 {
5284 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005288 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 roamInfo.pBssDesc = pSirBssDesc;
5290 //We need to associate_complete it first, becasue Associate_start already indicated.
5291 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5292 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5293 break;
5294 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005297 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 }
5299 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5300 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5301 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5302 if(pSirBssDesc)
5303 {
5304 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5305 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5306 }
5307 //We are doen with the IEs so free it
5308 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005309#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5310 {
5311 vos_log_ibss_pkt_type *pIbssLog;
5312 tANI_U32 bi;
5313
5314 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5315 if(pIbssLog)
5316 {
5317 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5318 {
5319 //We start the IBSS (didn't find any matched IBSS out there)
5320 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5321 }
5322 else
5323 {
5324 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5325 }
5326 if(pSirBssDesc)
5327 {
5328 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5329 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5330 }
5331 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5332 {
5333 //***U8 is not enough for beacon interval
5334 pIbssLog->beaconInterval = (v_U8_t)bi;
5335 }
5336 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5337 }
5338 }
5339#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5340 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5341 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5343 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5345 csrRoamIssueSetContextReq( pMac, sessionId,
5346 pProfile->negotiatedMCEncryptionType,
5347 pSirBssDesc, &BroadcastMac,
5348 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5349 }
5350 }
5351 else
5352 {
5353 //Keep the state to eCSR_ROAMING_STATE_JOINING
5354 //Need to send join_req.
5355 if(pCommand->u.roamCmd.pRoamBssEntry)
5356 {
5357 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5358 {
5359 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5360 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5361 // Set the roaming substate to 'join attempt'...
5362 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005363 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 }
5365 }
5366 else
5367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005368 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 VOS_ASSERT( 0 );
5370 }
5371 }
5372 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5373 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5374 //trigger the connection start indication in Vista
5375 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5376 {
5377 roamStatus = eCSR_ROAM_IBSS_IND;
5378 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5379 if( CSR_IS_WDS( pProfile ) )
5380 {
5381 roamStatus = eCSR_ROAM_WDS_IND;
5382 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 if( CSR_IS_INFRA_AP( pProfile ) )
5385 {
5386 roamStatus = eCSR_ROAM_INFRA_IND;
5387 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005389
5390 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5391 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5392 //trigger the connection start indication in Vista
5393 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5394 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5395 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5396 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5397 {
5398 //We start the IBSS (didn't find any matched IBSS out there)
5399 roamInfo.pBssDesc = pSirBssDesc;
5400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005402 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005403 //Remove this code once SLM_Sessionization is supported
5404 //BMPS_WORKAROUND_NOT_NEEDED
5405 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005406 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005407 {
5408 pMac->roam.configParam.doBMPSWorkaround = 1;
5409 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005410
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5412 }
5413
5414 csrScanCancelIdleScan(pMac);
5415 //Only use this timer for ibss. BAP has its own timer for WDS
5416 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5417 {
5418 //start the join IBSS timer
5419 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5420 pSession->ibss_join_pending = TRUE;
5421 }
5422 if( HAL_STATUS_SUCCESS( status ) )
5423 {
5424 //Already sent join_req for the WDS station
5425 fReleaseCommand = eANI_BOOLEAN_FALSE;
5426 }
5427 else if( CSR_IS_WDS_STA( pProfile ) )
5428 {
5429 //need to send stop BSS because we fail to send join_req
5430 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5431 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5432 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 case eCsrStartBssFailure:
5436#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5437 {
5438 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5440 if(pIbssLog)
5441 {
5442 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5443 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5444 }
5445 }
5446#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 roamStatus = eCSR_ROAM_IBSS_IND;
5448 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5449 if( CSR_IS_WDS( pProfile ) )
5450 {
5451 roamStatus = eCSR_ROAM_WDS_IND;
5452 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 if( CSR_IS_INFRA_AP( pProfile ) )
5455 {
5456 roamStatus = eCSR_ROAM_INFRA_IND;
5457 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 if(Context)
5460 {
5461 pSirBssDesc = (tSirBssDescription *)Context;
5462 }
5463 else
5464 {
5465 pSirBssDesc = NULL;
5466 }
5467 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5468 roamInfo.pBssDesc = pSirBssDesc;
5469 //We need to associate_complete it first, becasue Associate_start already indicated.
5470 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5471 csrSetDefaultDot11Mode( pMac );
5472 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 case eCsrSilentlyStopRoaming:
5474 // We are here because we try to start the same IBSS
5475 //No message to PE
5476 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005477 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5479 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5480 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5481 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5482 if( roamInfo.pBssDesc )
5483 {
5484 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5485 }
5486 //Since there is no change in the current state, simply pass back no result otherwise
5487 //HDD may be mistakenly mark to disconnected state.
5488 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5489 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 case eCsrSilentlyStopRoamingSaveState:
5492 //We are here because we try to connect to the same AP
5493 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005494 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5496
5497 //to aviod resetting the substate to NONE
5498 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5499 //No need to change substate to wai_for_key because there is no state change
5500 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5501 if( roamInfo.pBssDesc )
5502 {
5503 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5506 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5507 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5508 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5509 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5510 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5511 roamInfo.staId = pSession->connectedInfo.staId;
5512 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 pSession->bRefAssocStartCnt--;
5515 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5516 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5517 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5518 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 case eCsrReassocFailure:
5520#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5521 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5522#endif
5523 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005524 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 csrFreeConnectBssDesc(pMac, sessionId);
5526 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5527 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5528 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5529 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5530 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5531 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5532 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5533 eCSR_ROAM_WDS_IND,
5534 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5535 //Need to issue stop_bss
5536 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 case eCsrJoinFailure:
5538 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005539 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 default:
5541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005542 smsLog(pMac, LOGW, FL("receives no association indication"));
5543 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005544 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5546 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5547 {
5548 //do not free for the other profiles as we need to send down stop BSS later
5549 csrFreeConnectBssDesc(pMac, sessionId);
5550 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5551 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5552 csrSetDefaultDot11Mode( pMac );
5553 }
5554
5555 switch( pCommand->u.roamCmd.roamReason )
5556 {
5557 // If this transition is because of an 802.11 OID, then we transition
5558 // back to INIT state so we sit waiting for more OIDs to be issued and
5559 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005560 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 case eCsrSmeIssuedAssocToSimilarAP:
5562 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005563 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5565 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5566 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5567 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5568 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005569 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5570
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 /* Defeaturize this later if needed */
5572#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5573 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5574 if (csrRoamIsHandoffInProgress(pMac))
5575 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 /* Should indicate neighbor roam algorithm about the connect failure here */
5577 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005579#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 if(pSession->bRefAssocStartCnt > 0)
5581 {
5582 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005583 if(eCsrJoinFailureDueToConcurrency == Result)
5584 {
5585 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5586 eCSR_ROAM_ASSOCIATION_COMPLETION,
5587 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5588 }
5589 else
5590 {
5591 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 eCSR_ROAM_ASSOCIATION_COMPLETION,
5593 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005596 else
5597 {
5598 /* bRefAssocStartCnt is not incremented when
5599 * eRoamState == eCsrStopRoamingDueToConcurrency
5600 * in csrRoamJoinNextBss API. so handle this in
5601 * else case by sending assoc failure
5602 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005603 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005604 pCommand->u.scanCmd.roamId,
5605 eCSR_ROAM_ASSOCIATION_FAILURE,
5606 eCSR_ROAM_RESULT_FAILURE);
5607 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005608 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005609#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5610 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5611#endif
5612 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5613 csrScanStartIdleScan(pMac);
5614#ifdef FEATURE_WLAN_BTAMP_UT_RF
5615 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5616 //BT activity and not able to recevie WLAN traffic. Retry the join
5617 if( CSR_IS_WDS_STA(pProfile) )
5618 {
5619 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5620 }
5621#endif
5622 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 case eCsrHddIssuedReassocToSameAP:
5624 case eCsrSmeIssuedReassocToSameAP:
5625 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5626
5627 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5628#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5629 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5630#endif
5631 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5632 csrScanStartIdleScan(pMac);
5633 break;
5634 case eCsrForcedDisassoc:
5635 case eCsrForcedDeauth:
5636 case eCsrSmeIssuedIbssJoinFailure:
5637 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5638
5639 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5640 {
5641 // Notify HDD that IBSS join failed
5642 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5643 }
5644 else
5645 {
5646 csrRoamCallCallback(pMac, sessionId, NULL,
5647 pCommand->u.roamCmd.roamId,
5648 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5649 }
5650#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5651 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5652#endif
5653 csrRoamLinkDown(pMac, sessionId);
5654 csrScanStartIdleScan(pMac);
5655 break;
5656 case eCsrForcedIbssLeave:
5657 csrRoamCallCallback(pMac, sessionId, NULL,
5658 pCommand->u.roamCmd.roamId,
5659 eCSR_ROAM_IBSS_LEAVE,
5660 eCSR_ROAM_RESULT_IBSS_STOP);
5661 break;
5662 case eCsrForcedDisassocMICFailure:
5663 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5664
5665 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5666#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5667 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5668#endif
5669 csrScanStartIdleScan(pMac);
5670 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 case eCsrStopBss:
5672 csrRoamCallCallback(pMac, sessionId, NULL,
5673 pCommand->u.roamCmd.roamId,
5674 eCSR_ROAM_INFRA_IND,
5675 eCSR_ROAM_RESULT_INFRA_STOPPED);
5676 break;
5677 case eCsrForcedDisassocSta:
5678 case eCsrForcedDeauthSta:
5679 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5680 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5681 {
5682 pSession = CSR_GET_SESSION(pMac, sessionId);
5683 if (!pSession)
5684 break;
5685
5686 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5687 {
5688 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5689 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5690 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5691 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5692 roamInfo.statusCode = eSIR_SME_SUCCESS;
5693 status = csrRoamCallCallback(pMac, sessionId,
5694 &roamInfo, pCommand->u.roamCmd.roamId,
5695 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5696 }
5697 }
5698 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 case eCsrLostLink1:
5700 // if lost link roam1 failed, then issue lost link Scan2 ...
5701 csrScanRequestLostLink2(pMac, sessionId);
5702 break;
5703 case eCsrLostLink2:
5704 // if lost link roam2 failed, then issue lost link scan3 ...
5705 csrScanRequestLostLink3(pMac, sessionId);
5706 break;
5707 case eCsrLostLink3:
5708 default:
5709 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5710
5711 //We are done with one round of lostlink roaming here
5712 csrScanHandleFailedLostlink3(pMac, sessionId);
5713 break;
5714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 break;
5716 }
5717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 return ( fReleaseCommand );
5719}
5720
Jeff Johnson295189b2012-06-20 16:38:30 -07005721eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5722{
5723 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 return (status);
5725}
5726
Jeff Johnson295189b2012-06-20 16:38:30 -07005727eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5728{
5729 eHalStatus status = eHAL_STATUS_SUCCESS;
5730 tANI_U32 size = 0;
5731
5732 do
5733 {
5734 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5735 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5736 {
5737 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5738 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5739 if(!HAL_STATUS_SUCCESS(status))
5740 {
5741 break;
5742 }
5743 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5744 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5745 }
5746 if(pSrcProfile->SSIDs.numOfSSIDs)
5747 {
5748 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5749 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5750 if(!HAL_STATUS_SUCCESS(status))
5751 {
5752 break;
5753 }
5754 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5755 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5756 }
5757 if(pSrcProfile->nWPAReqIELength)
5758 {
5759 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5760 if(!HAL_STATUS_SUCCESS(status))
5761 {
5762 break;
5763 }
5764 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5765 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5766 }
5767 if(pSrcProfile->nRSNReqIELength)
5768 {
5769 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5770 if(!HAL_STATUS_SUCCESS(status))
5771 {
5772 break;
5773 }
5774 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5775 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5776 }
5777#ifdef FEATURE_WLAN_WAPI
5778 if(pSrcProfile->nWAPIReqIELength)
5779 {
5780 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5781 if(!HAL_STATUS_SUCCESS(status))
5782 {
5783 break;
5784 }
5785 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5786 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5787 }
5788#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 if(pSrcProfile->nAddIEScanLength)
5790 {
5791 status = palAllocateMemory(pMac->hHdd,
5792 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5793 if(!HAL_STATUS_SUCCESS(status))
5794 {
5795 break;
5796 }
5797 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5798 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5799 pSrcProfile->nAddIEScanLength);
5800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 if(pSrcProfile->nAddIEAssocLength)
5802 {
5803 status = palAllocateMemory(pMac->hHdd,
5804 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5805 if(!HAL_STATUS_SUCCESS(status))
5806 {
5807 break;
5808 }
5809 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5810 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5811 pSrcProfile->nAddIEAssocLength);
5812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 if(pSrcProfile->ChannelInfo.ChannelList)
5814 {
5815 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5816 if(!HAL_STATUS_SUCCESS(status))
5817 {
5818 break;
5819 }
5820 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5821 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 pDstProfile->AuthType = pSrcProfile->AuthType;
5824 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5825 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5826 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5827 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5828 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005829#ifdef WLAN_FEATURE_11W
5830 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5831 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5832 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5833#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 pDstProfile->BSSType = pSrcProfile->BSSType;
5835 pDstProfile->phyMode = pSrcProfile->phyMode;
5836 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5837
5838#ifdef FEATURE_WLAN_WAPI
5839 if(csrIsProfileWapi(pSrcProfile))
5840 {
5841 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5842 {
5843 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5844 }
5845 }
5846#endif /* FEATURE_WLAN_WAPI */
5847 pDstProfile->CBMode = pSrcProfile->CBMode;
5848 /*Save the WPS info*/
5849 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5850 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 pDstProfile->privacy = pSrcProfile->privacy;
5853 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5854 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5855 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5856 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5857 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5858 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5859 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5860 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5861 pDstProfile->wps_state = pSrcProfile->wps_state;
5862 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005864#ifdef WLAN_FEATURE_VOWIFI_11R
5865 if (pSrcProfile->MDID.mdiePresent)
5866 {
5867 pDstProfile->MDID.mdiePresent = 1;
5868 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5869 }
5870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 }while(0);
5872
5873 if(!HAL_STATUS_SUCCESS(status))
5874 {
5875 csrReleaseProfile(pMac, pDstProfile);
5876 pDstProfile = NULL;
5877 }
5878
5879 return (status);
5880}
Jeff Johnson295189b2012-06-20 16:38:30 -07005881eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5882{
5883 eHalStatus status = eHAL_STATUS_SUCCESS;
5884 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5885 do
5886 {
5887 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5888 if(pSrcProfile->bssid)
5889 {
5890 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5891 if(!HAL_STATUS_SUCCESS(status))
5892 {
5893 break;
5894 }
5895 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5896 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5897 }
5898 if(pSrcProfile->SSID.ssId)
5899 {
5900 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5901 if(!HAL_STATUS_SUCCESS(status))
5902 {
5903 break;
5904 }
5905 pDstProfile->SSIDs.numOfSSIDs = 1;
5906 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5907 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5908 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5909 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005910 if(pSrcProfile->nAddIEAssocLength)
5911 {
5912 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5913 if(!HAL_STATUS_SUCCESS(status))
5914 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005915 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005916 break;
5917 }
5918 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5919 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5920 pSrcProfile->nAddIEAssocLength);
5921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5923 if(!HAL_STATUS_SUCCESS(status))
5924 {
5925 break;
5926 }
5927 pDstProfile->ChannelInfo.numOfChannels = 1;
5928 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 pDstProfile->AuthType.numEntries = 1;
5930 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5931 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5932 pDstProfile->EncryptionType.numEntries = 1;
5933 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5934 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5935 pDstProfile->mcEncryptionType.numEntries = 1;
5936 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5937 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5938 pDstProfile->BSSType = pSrcProfile->BSSType;
5939 pDstProfile->CBMode = pSrcProfile->CBMode;
5940 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5941#ifdef WLAN_FEATURE_VOWIFI_11R
5942 if (pSrcProfile->MDID.mdiePresent)
5943 {
5944 pDstProfile->MDID.mdiePresent = 1;
5945 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5946 }
5947#endif
5948
5949 }while(0);
5950
5951 if(!HAL_STATUS_SUCCESS(status))
5952 {
5953 csrReleaseProfile(pMac, pDstProfile);
5954 pDstProfile = NULL;
5955 }
5956
5957 return (status);
5958}
5959
Jeff Johnson295189b2012-06-20 16:38:30 -07005960eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5961 tScanResultHandle hBSSList,
5962 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5963 tANI_BOOLEAN fClearScan)
5964{
5965 eHalStatus status = eHAL_STATUS_SUCCESS;
5966 tSmeCmd *pCommand;
5967
5968 pCommand = csrGetCommandBuffer(pMac);
5969 if(NULL == pCommand)
5970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005971 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 status = eHAL_STATUS_RESOURCES;
5973 }
5974 else
5975 {
5976 if( fClearScan )
5977 {
5978 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305979 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
5981 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5982 if(NULL == pProfile)
5983 {
5984 //We can roam now
5985 //Since pProfile is NULL, we need to build our own profile, set everything to default
5986 //We can only support open and no encryption
5987 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5988 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5989 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5990 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5991 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5992 }
5993 else
5994 {
5995 //make a copy of the profile
5996 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5997 if(HAL_STATUS_SUCCESS(status))
5998 {
5999 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6000 }
6001 }
6002 pCommand->command = eSmeCommandRoam;
6003 pCommand->sessionId = (tANI_U8)sessionId;
6004 pCommand->u.roamCmd.hBSSList = hBSSList;
6005 pCommand->u.roamCmd.roamId = roamId;
6006 pCommand->u.roamCmd.roamReason = reason;
6007 //We need to free the BssList when the command is done
6008 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6009 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6011 FL("CSR PERSONA=%d"),
6012 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6014 if( !HAL_STATUS_SUCCESS( status ) )
6015 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006016 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 csrReleaseCommandRoam( pMac, pCommand );
6018 }
6019 }
6020
6021 return (status);
6022}
Jeff Johnson295189b2012-06-20 16:38:30 -07006023eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6024 tCsrRoamModifyProfileFields *pMmodProfileFields,
6025 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6026{
6027 eHalStatus status = eHAL_STATUS_SUCCESS;
6028 tSmeCmd *pCommand;
6029
6030 pCommand = csrGetCommandBuffer(pMac);
6031 if(NULL == pCommand)
6032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006033 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 status = eHAL_STATUS_RESOURCES;
6035 }
6036 else
6037 {
6038 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306039 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 if(pProfile)
6041 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 //This is likely trying to reassoc to different profile
6043 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6044 //make a copy of the profile
6045 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6046 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 }
6048 else
6049 {
6050 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6051 //how to update WPA/WPA2 info in roamProfile??
6052 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 if(HAL_STATUS_SUCCESS(status))
6055 {
6056 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6057 }
6058 pCommand->command = eSmeCommandRoam;
6059 pCommand->sessionId = (tANI_U8)sessionId;
6060 pCommand->u.roamCmd.roamId = roamId;
6061 pCommand->u.roamCmd.roamReason = reason;
6062 //We need to free the BssList when the command is done
6063 //For reassoc there is no BSS list, so the boolean set to false
6064 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6065 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6066 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6068 if( !HAL_STATUS_SUCCESS( status ) )
6069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006070 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6072 csrReleaseCommandRoam( pMac, pCommand );
6073 }
6074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 return (status);
6076}
6077
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006078eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6079 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306080// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006081{
6082 eHalStatus status = eHAL_STATUS_SUCCESS;
6083 tSmeCmd *pCommand;
6084
6085 pCommand = csrGetCommandBuffer(pMac);
6086 if(NULL == pCommand)
6087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006088 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006089 status = eHAL_STATUS_RESOURCES;
6090 }
6091 else
6092 {
6093 if(pBssDescription)
6094 {
6095 //copy over the parameters we need later
6096 pCommand->command = eSmeCommandRoam;
6097 pCommand->sessionId = (tANI_U8)sessionId;
6098 pCommand->u.roamCmd.roamReason = reason;
6099 //this is the important parameter
6100 //in this case we are using this field for the "next" BSS
6101 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6102 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6103 if( !HAL_STATUS_SUCCESS( status ) )
6104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006105 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006106 csrReleaseCommandPreauth( pMac, pCommand );
6107 }
6108 }
6109 else
6110 {
6111 //Return failure
6112 status = eHAL_STATUS_RESOURCES;
6113 }
6114 }
6115 return (status);
6116}
6117
6118eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6119{
6120 tListElem *pEntry;
6121 tSmeCmd *pCommand;
6122 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6123 if ( pEntry )
6124 {
6125 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6126 if ( (eSmeCommandRoam == pCommand->command) &&
6127 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6128 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006129 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006130 pCommand->command, pCommand->u.roamCmd.roamReason);
6131 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6132 csrReleaseCommandPreauth( pMac, pCommand );
6133 }
6134 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006135 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006136 pCommand->command, pCommand->u.roamCmd.roamReason);
6137 }
6138 }
6139 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006140 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006141 }
6142 smeProcessPendingQueue( pMac );
6143 return eHAL_STATUS_SUCCESS;
6144}
6145
Jeff Johnson295189b2012-06-20 16:38:30 -07006146eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6147 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6148{
6149 eHalStatus status = eHAL_STATUS_FAILURE;
6150 tScanResultHandle hBSSList;
6151 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6153 if(HAL_STATUS_SUCCESS(status))
6154 {
6155 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6156 if(pRoamId)
6157 {
6158 *pRoamId = roamId;
6159 }
6160 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6161 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6162 if(!HAL_STATUS_SUCCESS(status))
6163 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006164 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 csrScanResultPurge(pMac, hBSSList);
6166 }
6167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 return (status);
6169}
6170
Jeff Johnson295189b2012-06-20 16:38:30 -07006171eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6172 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6173{
6174 eHalStatus status = eHAL_STATUS_SUCCESS;
6175 tScanResultHandle hBSSList;
6176 tCsrScanResultFilter *pScanFilter;
6177 tANI_U32 roamId = 0;
6178 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6179 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 if (NULL == pProfile)
6181 {
6182 smsLog(pMac, LOGP, FL("No profile specified"));
6183 return eHAL_STATUS_FAILURE;
6184 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006185 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 if( CSR_IS_WDS( pProfile ) &&
6188 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006190 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006191 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 return status;
6193 }
6194 csrRoamCancelRoaming(pMac, sessionId);
6195 csrScanRemoveFreshScanCommand(pMac, sessionId);
6196 csrScanCancelIdleScan(pMac);
6197 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306198 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6200 {
6201 csrScanDisable(pMac);
6202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6204 //Check whether ssid changes
6205 if(csrIsConnStateConnected(pMac, sessionId))
6206 {
6207 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6208 {
6209 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6210 }
6211 }
6212#ifdef FEATURE_WLAN_BTAMP_UT_RF
6213 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6214#endif
6215 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006217 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6219 if(pRoamId)
6220 {
6221 roamId = *pRoamId;
6222 }
6223 if(!HAL_STATUS_SUCCESS(status))
6224 {
6225 fCallCallback = eANI_BOOLEAN_TRUE;
6226 }
6227 }
6228 else
6229 {
6230 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6231 if(HAL_STATUS_SUCCESS(status))
6232 {
6233 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6234 //Try to connect to any BSS
6235 if(NULL == pProfile)
6236 {
6237 //No encryption
6238 pScanFilter->EncryptionType.numEntries = 1;
6239 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6240 }//we don't have a profile
6241 else
6242 {
6243 //Here is the profile we need to connect to
6244 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6245 }//We have a profile
6246 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6247 if(pRoamId)
6248 {
6249 *pRoamId = roamId;
6250 }
6251
6252 if(HAL_STATUS_SUCCESS(status))
6253 {
6254 /*Save the WPS info*/
6255 if(NULL != pProfile)
6256 {
6257 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6258 }
6259 else
6260 {
6261 pScanFilter->bWPSAssociation = 0;
6262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 do
6264 {
6265 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 )
6268 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006269 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6271 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6272 if(!HAL_STATUS_SUCCESS(status))
6273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006274 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 fCallCallback = eANI_BOOLEAN_TRUE;
6276 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006277 else
6278 {
6279 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 break;
6282 }
6283 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006284 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 if(HAL_STATUS_SUCCESS(status))
6286 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6288 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6289 if(!HAL_STATUS_SUCCESS(status))
6290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006291 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 csrScanResultPurge(pMac, hBSSList);
6293 fCallCallback = eANI_BOOLEAN_TRUE;
6294 }
6295 }//Have scan result
6296 else if(NULL != pProfile)
6297 {
6298 //Check whether it is for start ibss
6299 if(CSR_IS_START_IBSS(pProfile))
6300 {
6301 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6302 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6303 if(!HAL_STATUS_SUCCESS(status))
6304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006305 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 fCallCallback = eANI_BOOLEAN_TRUE;
6307 }
6308 }
6309 else
6310 {
6311 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006312 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 if(!HAL_STATUS_SUCCESS(status))
6314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006315 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 fCallCallback = eANI_BOOLEAN_TRUE;
6317 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006318 else
6319 {
6320 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 }
6323 }
6324 else
6325 {
6326 fCallCallback = eANI_BOOLEAN_TRUE;
6327 }
6328 } while (0);
6329 if(NULL != pProfile)
6330 {
6331 //we need to free memory for filter if profile exists
6332 csrFreeScanFilter(pMac, pScanFilter);
6333 }
6334 }//Got the scan filter from profile
6335
6336 palFreeMemory(pMac->hHdd, pScanFilter);
6337 }//allocated memory for pScanFilter
6338 }//No Bsslist coming in
6339 //tell the caller if we fail to trigger a join request
6340 if( fCallCallback )
6341 {
6342 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6343 }
6344
6345 return (status);
6346}
Jeff Johnson295189b2012-06-20 16:38:30 -07006347eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6348 tCsrRoamModifyProfileFields modProfileFields,
6349 tANI_U32 *pRoamId)
6350{
6351 eHalStatus status = eHAL_STATUS_SUCCESS;
6352 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6353 tANI_U32 roamId = 0;
6354 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 if (NULL == pProfile)
6356 {
6357 smsLog(pMac, LOGP, FL("No profile specified"));
6358 return eHAL_STATUS_FAILURE;
6359 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006360 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 -07006361 csrRoamCancelRoaming(pMac, sessionId);
6362 csrScanRemoveFreshScanCommand(pMac, sessionId);
6363 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306364 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 if(csrIsConnStateConnected(pMac, sessionId))
6367 {
6368 if(pProfile)
6369 {
6370 if(pProfile->SSIDs.numOfSSIDs &&
6371 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6372 {
6373 fCallCallback = eANI_BOOLEAN_FALSE;
6374 }
6375 else
6376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006377 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 }
6379 }
6380 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6381 &pSession->connectedProfile.modifyProfileFields,
6382 sizeof(tCsrRoamModifyProfileFields)))
6383 {
6384 fCallCallback = eANI_BOOLEAN_FALSE;
6385 }
6386 else
6387 {
6388 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006389 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 }
6391 }
6392 else
6393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006394 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 if(!fCallCallback)
6397 {
6398 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6399 if(pRoamId)
6400 {
6401 *pRoamId = roamId;
6402 }
6403
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6405 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 }
6407 else
6408 {
6409 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6410 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 return status;
6413}
Jeff Johnson295189b2012-06-20 16:38:30 -07006414eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6415{
6416 eHalStatus status = eHAL_STATUS_FAILURE;
6417 tScanResultHandle hBSSList = NULL;
6418 tCsrScanResultFilter *pScanFilter = NULL;
6419 tANI_U32 roamId;
6420 tCsrRoamProfile *pProfile = NULL;
6421 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006422
6423 if(!pSession)
6424 {
6425 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6426 return eHAL_STATUS_FAILURE;
6427 }
6428
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 do
6430 {
6431 if(pSession->pCurRoamProfile)
6432 {
6433 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306434 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6436 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6437 if(!HAL_STATUS_SUCCESS(status))
6438 break;
6439 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6440 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6441 if(!HAL_STATUS_SUCCESS(status))
6442 break;
6443 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6444 if(!HAL_STATUS_SUCCESS(status))
6445 {
6446 break;
6447 }
6448 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6449 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6450 if(!HAL_STATUS_SUCCESS(status))
6451 {
6452 break;
6453 }
6454 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6455 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6456 if(HAL_STATUS_SUCCESS(status))
6457 {
6458 //we want to put the last connected BSS to the very beginning, if possible
6459 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6460 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6461 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6462 if(!HAL_STATUS_SUCCESS(status))
6463 {
6464 csrScanResultPurge(pMac, hBSSList);
6465 break;
6466 }
6467 }
6468 else
6469 {
6470 //Do a scan on this profile
6471 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006472 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 if(!HAL_STATUS_SUCCESS(status))
6474 {
6475 break;
6476 }
6477 }
6478 }//We have a profile
6479 else
6480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006481 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 break;
6483 }
6484 }while(0);
6485 if(pScanFilter)
6486 {
6487 csrFreeScanFilter(pMac, pScanFilter);
6488 palFreeMemory(pMac->hHdd, pScanFilter);
6489 }
6490 if(NULL != pProfile)
6491 {
6492 csrReleaseProfile(pMac, pProfile);
6493 palFreeMemory(pMac->hHdd, pProfile);
6494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 return (status);
6496}
Jeff Johnson295189b2012-06-20 16:38:30 -07006497eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6498{
6499 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 if(csrIsConnStateConnected(pMac, sessionId))
6501 {
6502 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6503 if(HAL_STATUS_SUCCESS(status))
6504 {
6505 status = csrRoamJoinLastProfile(pMac, sessionId);
6506 }
6507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 return (status);
6509}
6510
Jeff Johnson295189b2012-06-20 16:38:30 -07006511eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6512{
6513 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006514 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 csrRoamCancelRoaming(pMac, sessionId);
6516 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6517 if(csrIsConnStateDisconnected(pMac, sessionId))
6518 {
6519 status = csrRoamJoinLastProfile(pMac, sessionId);
6520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 return (status);
6522}
6523
Jeff Johnson295189b2012-06-20 16:38:30 -07006524eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6525{
6526 eHalStatus status = eHAL_STATUS_SUCCESS;
6527 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6528 eCsrRoamSubState NewSubstate;
6529 tANI_U32 sessionId = pCommand->sessionId;
6530
6531 // change state to 'Roaming'...
6532 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6533
6534 if ( csrIsConnStateIbss( pMac, sessionId ) )
6535 {
6536 // If we are in an IBSS, then stop the IBSS...
6537 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6538 fComplete = (!HAL_STATUS_SUCCESS(status));
6539 }
6540 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006542 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 -07006543 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6544 //Restore AC weight in case we change it
6545 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6546 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6547 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6548 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6549 {
6550 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6551 }
6552 if( fDisassoc )
6553 {
6554 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6555 }
6556 else
6557 {
6558 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6559 }
6560 fComplete = (!HAL_STATUS_SUCCESS(status));
6561 }
6562 else if ( csrIsConnStateWds( pMac, sessionId ) )
6563 {
6564 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6565 {
6566 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6567 fComplete = (!HAL_STATUS_SUCCESS(status));
6568 }
6569 //This has to be WDS station
6570 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6571 {
6572
6573 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6574 if( fDisassoc )
6575 {
6576 status = csrRoamIssueDisassociate( pMac, sessionId,
6577 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6578 fComplete = (!HAL_STATUS_SUCCESS(status));
6579 }
6580 }
6581 } else {
6582 // we got a dis-assoc request while not connected to any peer
6583 // just complete the command
6584 fComplete = eANI_BOOLEAN_TRUE;
6585 status = eHAL_STATUS_FAILURE;
6586 }
6587 if(fComplete)
6588 {
6589 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6590 }
6591
6592 if(HAL_STATUS_SUCCESS(status))
6593 {
6594 if ( csrIsConnStateInfra( pMac, sessionId ) )
6595 {
6596 //Set the state to disconnect here
6597 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6598 }
6599 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006600 else
6601 {
6602 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 return (status);
6605}
6606
Jeff Johnson295189b2012-06-20 16:38:30 -07006607/* This is been removed from latest code base */
6608/*
6609static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6610{
6611 eHalStatus status;
6612 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6614 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006615 return ( status );
6616}
6617*/
6618
Jeff Johnson295189b2012-06-20 16:38:30 -07006619eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6620{
6621 eHalStatus status = eHAL_STATUS_SUCCESS;
6622 tSmeCmd *pCommand;
6623 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 do
6625 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006626 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 pCommand = csrGetCommandBuffer( pMac );
6628 if ( !pCommand )
6629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006630 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 status = eHAL_STATUS_RESOURCES;
6632 break;
6633 }
6634 //Change the substate in case it is wait-for-key
6635 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6636 {
6637 csrRoamStopWaitForKeyTimer( pMac );
6638 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6639 }
6640 pCommand->command = eSmeCommandRoam;
6641 pCommand->sessionId = (tANI_U8)sessionId;
6642 switch ( reason )
6643 {
6644 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6645 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 case eCSR_DISCONNECT_REASON_DEAUTH:
6648 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 case eCSR_DISCONNECT_REASON_HANDOFF:
6651 fHighPriority = eANI_BOOLEAN_TRUE;
6652 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6655 case eCSR_DISCONNECT_REASON_DISASSOC:
6656 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6659 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6660 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6662 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6663 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 default:
6665 break;
6666 }
6667 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6668 if( !HAL_STATUS_SUCCESS( status ) )
6669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006670 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 csrReleaseCommandRoam( pMac, pCommand );
6672 }
6673 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 return( status );
6675}
6676
Jeff Johnson295189b2012-06-20 16:38:30 -07006677eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6678{
6679 eHalStatus status = eHAL_STATUS_SUCCESS;
6680 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 pCommand = csrGetCommandBuffer( pMac );
6682 if ( NULL != pCommand )
6683 {
6684 //Change the substate in case it is wait-for-key
6685 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6686 {
6687 csrRoamStopWaitForKeyTimer( pMac );
6688 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6689 }
6690 pCommand->command = eSmeCommandRoam;
6691 pCommand->sessionId = (tANI_U8)sessionId;
6692 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6693 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6694 if( !HAL_STATUS_SUCCESS( status ) )
6695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006696 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 csrReleaseCommandRoam( pMac, pCommand );
6698 }
6699 }
6700 else
6701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006702 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 status = eHAL_STATUS_RESOURCES;
6704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 return ( status );
6706}
6707
Jeff Johnson295189b2012-06-20 16:38:30 -07006708eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6709{
6710 eHalStatus status = eHAL_STATUS_SUCCESS;
6711 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006712
6713 if(!pSession)
6714 {
6715 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6716 return eHAL_STATUS_FAILURE;
6717 }
6718
Jeff Johnson295189b2012-06-20 16:38:30 -07006719#ifdef FEATURE_WLAN_BTAMP_UT_RF
6720 //Stop te retry
6721 pSession->maxRetryCount = 0;
6722 csrRoamStopJoinRetryTimer(pMac, sessionId);
6723#endif
6724 //Not to call cancel roaming here
6725 //Only issue disconnect when necessary
6726 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6727 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6728 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6729
6730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006731 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 return (status);
6735}
6736
Jeff Johnson295189b2012-06-20 16:38:30 -07006737eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6738{
6739 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006740
6741 if(!pSession)
6742 {
6743 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6744 return eHAL_STATUS_FAILURE;
6745 }
6746
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 csrRoamCancelRoaming(pMac, sessionId);
6748 pSession->ibss_join_pending = FALSE;
6749 csrRoamStopIbssJoinTimer(pMac, sessionId);
6750 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6751
6752 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6753}
6754
Jeff Johnson295189b2012-06-20 16:38:30 -07006755eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6756 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6757{
6758 eHalStatus status = eHAL_STATUS_SUCCESS;
6759 tDot11fBeaconIEs *pIesTemp = pIes;
6760 tANI_U8 index;
6761 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6762 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006763
6764 if(!pSession)
6765 {
6766 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6767 return eHAL_STATUS_FAILURE;
6768 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006769
6770 if(pConnectProfile->pAddIEAssoc)
6771 {
6772 palFreeMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc);
6773 pConnectProfile->pAddIEAssoc = NULL;
6774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6776 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6777 pConnectProfile->AuthInfo = pProfile->AuthType;
6778 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6779 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6780 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6781 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6782 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6783 pConnectProfile->BSSType = pProfile->BSSType;
6784 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6785 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006786 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6787
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006789
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006790 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6791 if(pProfile->nAddIEAssocLength)
6792 {
6793 status = palAllocateMemory(pMac->hHdd,
6794 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6795 if(!HAL_STATUS_SUCCESS(status))
6796 {
6797 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6798 return eHAL_STATUS_FAILURE;
6799 }
6800 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6801 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6802 pProfile->nAddIEAssocLength);
6803 }
6804
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 //Save bssid
6806 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6807#ifdef WLAN_FEATURE_VOWIFI_11R
6808 if (pSirBssDesc->mdiePresent)
6809 {
6810 pConnectProfile->MDID.mdiePresent = 1;
6811 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6812 }
6813#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006814 if( NULL == pIesTemp )
6815 {
6816 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006818#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006819 if ((csrIsProfileCCX(pProfile) ||
6820 ((pIesTemp->CCXVersion.present)
6821 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6822 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6823 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6824 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006825#ifdef WLAN_FEATURE_11W
6826 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6827#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306828 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006829 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 {
6831 pConnectProfile->isCCXAssoc = 1;
6832 }
6833#endif
6834 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 if(HAL_STATUS_SUCCESS(status))
6836 {
6837 if(pIesTemp->SSID.present)
6838 {
6839 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6840 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6841 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6842 }
6843
6844 //Save the bss desc
6845 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306846
6847 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306849 //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 -07006850 pConnectProfile->qap = TRUE;
6851 }
6852 else
6853 {
6854 pConnectProfile->qap = FALSE;
6855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 if ( NULL == pIes )
6857 {
6858 //Free memory if it allocated locally
6859 palFreeMemory(pMac->hHdd, pIesTemp);
6860 }
6861 }
6862 //Save Qos connection
6863 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6864
6865 if(!HAL_STATUS_SUCCESS(status))
6866 {
6867 csrFreeConnectBssDesc(pMac, sessionId);
6868 }
6869 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6870 {
6871 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6872 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6873 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6874 {
6875 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6876 break;
6877 }
6878 pConnectProfile->handoffPermitted = FALSE;
6879 }
6880
6881 return (status);
6882}
6883
Jeff Johnson295189b2012-06-20 16:38:30 -07006884static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6885{
6886 tListElem *pEntry = NULL;
6887 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 //The head of the active list is the request we sent
6889 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6890 if(pEntry)
6891 {
6892 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6895 {
6896 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6897 {
6898#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6899 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6900#endif
6901 }
6902 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6903 }
6904 else
6905 {
6906 tANI_U32 roamId = 0;
6907 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006908 if(!pSession)
6909 {
6910 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6911 return;
6912 }
6913
Jeff Johnson295189b2012-06-20 16:38:30 -07006914
6915 //The head of the active list is the request we sent
6916 //Try to get back the same profile and roam again
6917 if(pCommand)
6918 {
6919 roamId = pCommand->u.roamCmd.roamId;
6920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6922 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006923 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006924#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6925 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6926 if (csrRoamIsHandoffInProgress(pMac))
6927 {
6928 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6929 /* Should indicate neighbor roam algorithm about the connect failure here */
6930 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6931 }
6932#endif
6933 if (pCommand)
6934 {
6935 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6936 {
6937 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6938 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6939 csrRoamReissueRoamCommand(pMac);
6940 }
6941 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6942 {
6943 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6944 }
6945 else
6946 {
6947 csrRoam(pMac, pCommand);
6948 }
6949 }
6950 else
6951 {
6952 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6953 }
6954 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6955}
6956
Jeff Johnson295189b2012-06-20 16:38:30 -07006957eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6958 tDot11fBeaconIEs *pIes,
6959 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6960{
6961 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006962 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6964 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6965
6966 // Set the roaming substate to 'join attempt'...
6967 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006969 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 return (status);
6971}
6972
Jeff Johnson295189b2012-06-20 16:38:30 -07006973static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6974 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6975{
6976 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 // Set the roaming substate to 'join attempt'...
6978 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6979
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006980 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006981
6982 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006983 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006984}
6985
Jeff Johnson295189b2012-06-20 16:38:30 -07006986void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6987{
6988 tListElem *pEntry;
6989 tSmeCmd *pCommand;
6990 tCsrRoamInfo roamInfo;
6991 tANI_U32 sessionId;
6992 tCsrRoamSession *pSession;
6993
6994 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6995 if(pEntry)
6996 {
6997 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6998 if ( eSmeCommandRoam == pCommand->command )
6999 {
7000 sessionId = pCommand->sessionId;
7001 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007002
7003 if(!pSession)
7004 {
7005 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7006 return;
7007 }
7008
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 if( pCommand->u.roamCmd.fStopWds )
7010 {
7011 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7012 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7013 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7014 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7017 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7018 eCSR_ROAM_WDS_IND,
7019 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7021 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7022 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7023 eCSR_ROAM_INFRA_IND,
7024 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7025 }
7026
Jeff Johnson295189b2012-06-20 16:38:30 -07007027
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7029 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007030 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7032 }
7033 }
7034 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007036 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7038 }
7039 }
7040 else
7041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007042 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 }
7044 }
7045 else
7046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007047 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 }
7049}
7050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7052{
7053 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7054 tListElem *pEntry;
7055 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 //alwasy lock active list before locking pending list
7057 csrLLLock( &pMac->sme.smeCmdActiveList );
7058 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7059 if(pEntry)
7060 {
7061 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7062 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7063 {
7064 fRet = eANI_BOOLEAN_TRUE;
7065 }
7066 }
7067 if(eANI_BOOLEAN_FALSE == fRet)
7068 {
7069 csrLLLock(&pMac->sme.smeCmdPendingList);
7070 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7071 while(pEntry)
7072 {
7073 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7074 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7075 {
7076 fRet = eANI_BOOLEAN_TRUE;
7077 break;
7078 }
7079 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7080 }
7081 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7082 }
7083 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 return (fRet);
7085}
7086
Jeff Johnson295189b2012-06-20 16:38:30 -07007087tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7088{
7089 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7090 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7092 {
7093 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7094 {
7095 break;
7096 }
7097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007098 return ( fRet );
7099}
7100
Jeff Johnson295189b2012-06-20 16:38:30 -07007101tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7102{
7103 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 //alwasy lock active list before locking pending list
7105 csrLLLock( &pMac->sme.smeCmdActiveList );
7106 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7107 if(eANI_BOOLEAN_FALSE == fRet)
7108 {
7109 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7110 }
7111 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 return (fRet);
7113}
7114
Jeff Johnson295189b2012-06-20 16:38:30 -07007115tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7116{
7117 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7118 tListElem *pEntry;
7119 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 //alwasy lock active list before locking pending list
7121 csrLLLock( &pMac->sme.smeCmdActiveList );
7122 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7123 if( pEntry )
7124 {
7125 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7126 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7127 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7128 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7129 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7130 {
7131 fRet = eANI_BOOLEAN_TRUE;
7132 }
7133 }
7134 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 return (fRet);
7136}
Jeff Johnson295189b2012-06-20 16:38:30 -07007137eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7138{
7139 eHalStatus status = eHAL_STATUS_SUCCESS;
7140 tSmeCmd *pCommand = NULL;
7141 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7142 tANI_BOOLEAN fRemoveCmd = FALSE;
7143 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 // Delete the old assoc command. All is setup for reassoc to be serialized
7145 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7146 if ( pEntry )
7147 {
7148 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7149 if ( !pCommand )
7150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007151 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 return eHAL_STATUS_RESOURCES;
7153 }
7154 if ( eSmeCommandRoam == pCommand->command )
7155 {
7156 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7157 {
7158 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7159 }
7160 else
7161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007162 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 }
7164 if (fRemoveCmd == FALSE)
7165 {
7166 // Implies we did not get the serialized assoc command we
7167 // were expecting
7168 pCommand = NULL;
7169 }
7170 }
7171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 if(NULL == pCommand)
7173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007174 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 return eHAL_STATUS_RESOURCES;
7176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 do
7178 {
7179 //Change the substate in case it is wait-for-key
7180 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7181 {
7182 csrRoamStopWaitForKeyTimer( pMac );
7183 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7184 }
7185 pCommand->command = eSmeCommandRoam;
7186 pCommand->sessionId = (tANI_U8)sessionId;
7187 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7189 if( !HAL_STATUS_SUCCESS( status ) )
7190 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007191 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 csrReleaseCommandRoam( pMac, pCommand );
7193 }
7194 } while( 0 );
7195
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 return( status );
7197}
7198static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7199{
7200 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7201 tCsrScanResult *pScanResult = NULL;
7202 tSirBssDescription *pBssDesc = NULL;
7203 tSmeCmd *pCommand = NULL;
7204 tANI_U32 sessionId;
7205 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 if(NULL == pEntry)
7207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007208 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 return;
7210 }
7211 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7212 sessionId = pCommand->sessionId;
7213 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007214
7215 if(!pSession)
7216 {
7217 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7218 return;
7219 }
7220
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7222 {
7223 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007224 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7226 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007227 /* If the roaming has stopped, not to continue the roaming command*/
7228 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7229 {
7230 //No need to complete roaming here as it already completes
7231 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7232 pCommand->u.roamCmd.roamReason);
7233 csrSetAbortRoamingCommand( pMac, pCommand );
7234 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 else
7237 {
7238 if ( CCM_IS_RESULT_SUCCESS(result) )
7239 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007240 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 // Successfully set the configuration parameters for the new Bss. Attempt to
7242 // join the roaming Bss.
7243 if(pCommand->u.roamCmd.pRoamBssEntry)
7244 {
7245 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7246 pBssDesc = &pScanResult->Result.BssDescriptor;
7247 }
7248 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7249 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 )
7252 {
7253 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7254 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7255 pBssDesc, pCommand->u.roamCmd.roamId )))
7256 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007257 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 //We need to complete the command
7259 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7260 }
7261 }
7262 else
7263 {
7264 if (!pCommand->u.roamCmd.pRoamBssEntry)
7265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007266 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 //We need to complete the command
7268 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7269 return;
7270 }
7271 // If we are roaming TO an Infrastructure BSS...
7272 VOS_ASSERT(pScanResult != NULL);
7273 if ( csrIsInfraBssDesc( pBssDesc ) )
7274 {
7275 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7277 {
7278 // ..and currently in an Infrastructure connection....
7279 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7280 {
7281 // ...and the SSIDs are equal, then we Reassoc.
7282 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7283 pIesLocal ) )
7284 // ..and currently in an infrastructure connection
7285 {
7286 // then issue a Reassoc.
7287 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7288 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7289 &pCommand->u.roamCmd.roamProfile );
7290 }
7291 else
7292 {
7293
7294 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7295 // previously associated AP.
7296 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7297 pIesLocal,
7298 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7299 {
7300 //try something else
7301 csrRoam( pMac, pCommand );
7302 }
7303 }
7304 }
7305 else
7306 {
7307 eHalStatus status = eHAL_STATUS_SUCCESS;
7308
7309 /* We need to come with other way to figure out that this is because of HO in BMP
7310 The below API will be only available for Android as it uses a different HO algorithm */
7311 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7312 * use join request */
7313#ifdef WLAN_FEATURE_VOWIFI_11R
7314 if (csrRoamIsHandoffInProgress(pMac) &&
7315 csrRoamIs11rAssoc(pMac))
7316 {
7317 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7318 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7319 }
7320 else
7321#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007322#ifdef FEATURE_WLAN_CCX
7323 if (csrRoamIsHandoffInProgress(pMac) &&
7324 csrRoamIsCCXAssoc(pMac))
7325 {
7326 // Now serialize the reassoc command.
7327 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7328 }
7329 else
7330#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007331#ifdef FEATURE_WLAN_LFR
7332 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307333 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007334 {
7335 // Now serialize the reassoc command.
7336 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7337 }
7338 else
7339#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 // else we are not connected and attempting to Join. Issue the
7341 // Join request.
7342 {
7343 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7344 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7345 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7346 }
7347 if(!HAL_STATUS_SUCCESS(status))
7348 {
7349 //try something else
7350 csrRoam( pMac, pCommand );
7351 }
7352 }
7353 if( !pScanResult->Result.pvIes )
7354 {
7355 //Locally allocated
7356 palFreeMemory(pMac->hHdd, pIesLocal);
7357 }
7358 }
7359 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7360 else
7361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007362 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 }
7364 }//else
7365 }//if ( WNI_CFG_SUCCESS == result )
7366 else
7367 {
7368 // In the event the configuration failed, for infra let the roam processor
7369 //attempt to join something else...
7370 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7371 {
7372 csrRoam(pMac, pCommand);
7373 }
7374 else
7375 {
7376 //We need to complete the command
7377 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7378 {
7379 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7380 }
7381 else
7382 {
7383 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7384 }
7385 }
7386 }
7387 }//we have active entry
7388}
7389
Jeff Johnson295189b2012-06-20 16:38:30 -07007390static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7391{
7392 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007393 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007396 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7398 // join the new one...
7399 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7401 }
7402 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007403 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 /***profHandleLostLinkAfterReset(pAdapter);
7405 // In the event the authenticate fails, let the roam processor attempt to join something else...
7406 roamRoam( pAdapter );***/
7407 }
7408}
7409
Jeff Johnson295189b2012-06-20 16:38:30 -07007410static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7411{
7412 eCsrRoamCompleteResult result;
7413 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7414 tCsrRoamInfo roamInfo;
7415 tANI_U32 roamId = 0;
7416
7417 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7418 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007419 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 /* Defeaturize this part later if needed */
7422#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7423 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7424 * we need the response contents while processing the result in csrRoamProcessResults() */
7425 if (csrRoamIsHandoffInProgress(pMac))
7426 {
7427 /* Need to dig more on indicating events to SME QoS module */
7428 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7429 csrRoamComplete( pMac, result, pSmeJoinRsp);
7430 }
7431 else
7432#endif
7433 {
7434 csrRoamComplete( pMac, result, NULL );
7435 }
7436 }
7437 /* Should we handle this similar to handling the join failure? Is it ok
7438 * to call csrRoamComplete() with state as CsrJoinFailure */
7439 else
7440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007441 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 result = eCsrReassocFailure;
7443#ifdef WLAN_FEATURE_VOWIFI_11R
7444 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7445 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7446 {
7447 // Inform HDD to turn off FT flag in HDD
7448 if (pNeighborRoamInfo)
7449 {
7450 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7451 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7452 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007453 /*
7454 * Since the above callback sends a disconnect
7455 * to HDD, we should clean-up our state
7456 * machine as well to be in sync with the upper
7457 * layers. There is no need to send a disassoc
7458 * since: 1) we will never reassoc to the current
7459 * AP in LFR, and 2) there is no need to issue a
7460 * disassoc to the AP with which we were trying
7461 * to reassoc.
7462 */
7463 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7464 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 }
7466 }
7467#endif
7468 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7469 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7470 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7471 //The disassoc rsp message will remove the command from active list
7472 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7473 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7474 {
7475 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7476 }
7477 }
7478}
7479
Jeff Johnson295189b2012-06-20 16:38:30 -07007480static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7481{
Jeff Johnson295189b2012-06-20 16:38:30 -07007482#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7483 {
7484 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7486 if(pIbssLog)
7487 {
7488 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7489 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7490 {
7491 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7492 }
7493 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7494 }
7495 }
7496#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7498 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7499 {
7500 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7501 }
7502 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7503 {
7504 csrRoamReissueRoamCommand(pMac);
7505 }
7506}
7507
Jeff Johnson295189b2012-06-20 16:38:30 -07007508void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7509{
7510 tSirResultCodes statusCode;
7511#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7512 tScanResultHandle hBSSList;
7513 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7514 eHalStatus status;
7515 tCsrRoamInfo roamInfo;
7516 tCsrScanResultFilter *pScanFilter = NULL;
7517 tANI_U32 roamId = 0;
7518 tCsrRoamProfile *pCurRoamProfile = NULL;
7519 tListElem *pEntry = NULL;
7520 tSmeCmd *pCommand = NULL;
7521#endif
7522 tANI_U32 sessionId;
7523 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007524
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 tSirSmeDisassocRsp SmeDisassocRsp;
7526
7527 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7528 sessionId = SmeDisassocRsp.sessionId;
7529 statusCode = SmeDisassocRsp.statusCode;
7530
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007531 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007532
7533 if ( csrIsConnStateInfra( pMac, sessionId ) )
7534 {
7535 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007538
7539 if(!pSession)
7540 {
7541 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7542 return;
7543 }
7544
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7546 {
7547 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7548 }
7549 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7550 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7551 {
7552 if ( eSIR_SME_SUCCESS == statusCode )
7553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007554 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7556 }
7557 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007561 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007562#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007563 /*
7564 * First ensure if the roam profile is in the scan cache.
7565 * If not, post a reassoc failure and disconnect.
7566 */
7567 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7568 if(HAL_STATUS_SUCCESS(status))
7569 {
7570 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7571 status = csrRoamPrepareFilterFromProfile(pMac,
7572 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7573 if(!HAL_STATUS_SUCCESS(status))
7574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007575 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007576 __func__, status);
7577 goto POST_ROAM_FAILURE;
7578 }
7579 else
7580 {
7581 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7582 if (!HAL_STATUS_SUCCESS(status))
7583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007584 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007585 __func__, status);
7586 goto POST_ROAM_FAILURE;
7587 }
7588 }
7589 }
7590 else
7591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007592 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007593 __func__, status);
7594 goto POST_ROAM_FAILURE;
7595 }
7596
7597 /*
7598 * After ensuring that the roam profile is in the scan result list,
7599 * dequeue the command from the active list.
7600 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7602 if ( pEntry )
7603 {
7604 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007605 /* If the head of the queue is Active and it is a ROAM command, remove
7606 * and put this on the Free queue.
7607 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 if ( eSmeCommandRoam == pCommand->command )
7609 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007610
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007611 /*
7612 * we need to process the result first before removing it from active list
7613 * because state changes still happening insides roamQProcessRoamResults so
7614 * no other roam command should be issued.
7615 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7617 if(pCommand->u.roamCmd.fReleaseProfile)
7618 {
7619 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7620 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 else
7625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007626 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007627 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 }
7629 }
7630 else
7631 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007632 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 }
7634 }
7635 else
7636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007637 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007639
7640 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7642
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007643 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7644 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7645 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007646
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007647 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7648 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007649
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007650 /* Copy the connected profile to apply the same for this connection as well */
7651 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7652 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007654 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7655 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7656 //make sure to put it at the head of the cmd queue
7657 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7658 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7659 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7660
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 if(!HAL_STATUS_SUCCESS(status))
7662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007663 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007664 __func__, status);
7665 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 }
7667
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007668 /* Notify sub-modules like QoS etc. that handoff happening */
7669 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007670 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007671 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 csrFreeScanFilter(pMac, pScanFilter);
7673 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007674 return;
7675 }
7676
7677POST_ROAM_FAILURE:
7678 if (pScanFilter)
7679 {
7680 csrFreeScanFilter(pMac, pScanFilter);
7681 palFreeMemory( pMac->hHdd, pScanFilter );
7682 }
7683 if (pCurRoamProfile)
7684 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7685
7686 /* Inform the upper layers that the reassoc failed */
7687 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7688 csrRoamCallCallback(pMac, sessionId,
7689 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7690
7691 /*
7692 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7693 * Upon success, we would re-enter this routine after receiving the disassoc
7694 * response and will fall into the reassoc fail sub-state. And, eventually
7695 * call csrRoamComplete which would remove the roam command from SME active
7696 * queue.
7697 */
7698 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7699 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007701 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007702 __func__, status);
7703 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007705#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007706
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7708 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7709 {
7710 // Disassoc due to Reassoc failure falls into this codepath....
7711 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7712 }
7713 else
7714 {
7715 if ( eSIR_SME_SUCCESS == statusCode )
7716 {
7717 // Successfully disassociated from the 'old' Bss...
7718 //
7719 // We get Disassociate response in three conditions.
7720 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7721 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7722 // Infrastructure network.
7723 // - Third is where we are doing an Infra to Infra roam between networks with different
7724 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7725
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007726 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 }
7728 else
7729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007730 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 }
7732 //We are not done yet. Get the data and continue roaming
7733 csrRoamReissueRoamCommand(pMac);
7734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007735}
7736
Jeff Johnson295189b2012-06-20 16:38:30 -07007737static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7738{
7739 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007741 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7743 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7744 {
7745 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7746 }
7747 else
7748 {
7749 if ( eSIR_SME_SUCCESS == statusCode )
7750 {
7751 // Successfully deauth from the 'old' Bss...
7752 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007753 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007754 }
7755 else
7756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007757 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 }
7759 //We are not done yet. Get the data and continue roaming
7760 csrRoamReissueRoamCommand(pMac);
7761 }
7762}
7763
Jeff Johnson295189b2012-06-20 16:38:30 -07007764static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7765{
7766 eCsrRoamCompleteResult result;
7767
7768 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007770 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007771 result = eCsrStartBssSuccess;
7772 }
7773 else
7774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007775 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007776 //Let csrRoamComplete decide what to do
7777 result = eCsrStartBssFailure;
7778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007780}
7781
Jeff Johnson295189b2012-06-20 16:38:30 -07007782/*
7783 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7784 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7785 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7786 For the messages where sender allocates memory for specific structures, then it can be
7787 cast accordingly.
7788*/
7789void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7790{
7791 tSirSmeRsp *pSmeRsp;
7792 tSmeIbssPeerInd *pIbssPeerInd;
7793 tCsrRoamInfo roamInfo;
7794 // TODO Session Id need to be acquired in this function
7795 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007796 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007797 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 pSmeRsp->messageType, pSmeRsp->messageType,
7799 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 pSmeRsp->messageType = (pSmeRsp->messageType);
7801 pSmeRsp->length = (pSmeRsp->length);
7802 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 switch (pSmeRsp->messageType)
7804 {
7805
7806 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7807 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7808 {
7809 //We sent a JOIN_REQ
7810 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7811 }
7812 break;
7813
7814 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7815 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7816 {
7817 //We sent a AUTH_REQ
7818 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7819 }
7820 break;
7821
7822 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7823 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7824 {
7825 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7826 }
7827 break;
7828
7829 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7830 {
7831 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7832 }
7833 break;
7834
7835 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7836 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7837 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7838 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7839 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7840 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7841//HO
7842 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007844 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7846 }
7847 break;
7848
7849 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7850 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7851 {
7852 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7853 }
7854 break;
7855
7856 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7857 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7858 {
7859 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7860 }
7861 break;
7862
7863 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7864 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7865 {
7866 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7870 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7871 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007872 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7874 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7875 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7876 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7877 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7878 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7879 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7880 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7881 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007883 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 pSmeRsp->messageType, pSmeRsp->messageType,
7885 pMac->roam.curSubState[pSmeRsp->sessionId] );
7886
7887 //If we are connected, check the link status change
7888 if(!csrIsConnStateDisconnected(pMac, sessionId))
7889 {
7890 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7891 }
7892 break;
7893 }
7894}
7895
Jeff Johnson295189b2012-06-20 16:38:30 -07007896void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7897{
7898 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 switch (pSirMsg->messageType)
7900 {
7901 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007902 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 csrRoamStatsRspProcessor( pMac, pSirMsg );
7904 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007905 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7906 {
7907 tCsrRoamSession *pSession;
7908 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7909 tCsrRoamInfo roamInfo;
7910 tCsrRoamInfo *pRoamInfo = NULL;
7911 tANI_U32 sessionId;
7912 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007913 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7915 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7917 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7918 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007919
7920 if(!pSession)
7921 {
7922 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7923 return;
7924 }
7925
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7927 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7929 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7930 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7932 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7934 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7937 {
7938 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7939 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7940 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7941 }
7942 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7943 {
7944 vos_sleep( 100 );
7945 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7946 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7947 }
7948
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 }
7950 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 default:
7952 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7953 break;
7954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007955}
7956
Jeff Johnson295189b2012-06-20 16:38:30 -07007957eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7958 tSirBssDescription *pBssDescription,
7959 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7960 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7961 tANI_U8 keyId, tANI_U16 keyLength,
7962 tANI_U8 *pKey, tANI_U8 paeRole )
7963{
7964 eHalStatus status = eHAL_STATUS_SUCCESS;
7965 tAniEdType edType;
7966
7967 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7968 {
7969 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7970 }
7971
7972 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7973
7974 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7975 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7976 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7977 addKey )
7978 {
7979 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 setKey.encType = EncryptType;
7981 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7982 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7983 setKey.paeRole = paeRole; //0 for supplicant
7984 setKey.keyId = keyId; // Kye index
7985 setKey.keyLength = keyLength;
7986 if( keyLength )
7987 {
7988 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7989 }
7990 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 return (status);
7993}
7994
Jeff Johnson295189b2012-06-20 16:38:30 -07007995static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7996 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7997{
7998 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7999 tSmeCmd *pCommand = NULL;
8000#ifdef FEATURE_WLAN_CCX
8001 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8002#endif /* FEATURE_WLAN_CCX */
8003
8004 do
8005 {
8006 pCommand = csrGetCommandBuffer(pMac);
8007 if(NULL == pCommand)
8008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008009 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 status = eHAL_STATUS_RESOURCES;
8011 break;
8012 }
8013 pCommand->command = eSmeCommandSetKey;
8014 pCommand->sessionId = (tANI_U8)sessionId;
8015 // validate the key length, Adjust if too long...
8016 // for static WEP the keys are not set thru' SetContextReq
8017 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8018 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8019 {
8020 //KeyLength maybe 0 for static WEP
8021 if( pSetKey->keyLength )
8022 {
8023 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008025 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008026 break;
8027 }
8028
8029 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
8030 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
8031 }
8032 }
8033 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8034 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8035 {
8036 //KeyLength maybe 0 for static WEP
8037 if( pSetKey->keyLength )
8038 {
8039 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008041 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 break;
8043 }
8044
8045 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8046 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8047 }
8048 }
8049 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8050 {
8051 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8052 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008053 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 break;
8055 }
8056 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8057 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8058 }
8059 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8060 {
8061 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008063 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 break;
8065 }
8066 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8067 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8068 }
8069#ifdef FEATURE_WLAN_WAPI
8070 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8071 {
8072 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008074 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 break;
8076 }
8077 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8078 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8079 }
8080#endif /* FEATURE_WLAN_WAPI */
8081#ifdef FEATURE_WLAN_CCX
8082 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8083 {
8084 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008086 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 break;
8088 }
8089 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8090 pSession->ccxCckmInfo.reassoc_req_num=1;
8091 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8092 status = eHAL_STATUS_SUCCESS;
8093 break;
8094 }
8095#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008096
Jeff Johnson295189b2012-06-20 16:38:30 -07008097#ifdef WLAN_FEATURE_11W
8098 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008099 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008101 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008103 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 break;
8105 }
8106 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008107 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008108 }
8109#endif
8110 status = eHAL_STATUS_SUCCESS;
8111 pCommand->u.setKeyCmd.roamId = roamId;
8112 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8113 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8114 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8115 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8116 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8117 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8118 //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
8119
8120 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8121 if( !HAL_STATUS_SUCCESS( status ) )
8122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008123 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 }
8125 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 // Free the command if there has been a failure, or it is a
8127 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008128 if ( ( NULL != pCommand ) &&
8129 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008130#ifdef FEATURE_WLAN_CCX
8131 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8132#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008133 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 {
8135 csrReleaseCommandSetKey( pMac, pCommand );
8136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 return( status );
8138}
8139
Jeff Johnson295189b2012-06-20 16:38:30 -07008140eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8141 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8142{
8143 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8144 tSmeCmd *pCommand = NULL;
8145 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 do
8147 {
8148 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008150 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 status = eHAL_STATUS_CSR_WRONG_STATE;
8152 break;
8153 }
8154 pCommand = csrGetCommandBuffer(pMac);
8155 if(NULL == pCommand)
8156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008157 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 status = eHAL_STATUS_RESOURCES;
8159 break;
8160 }
8161 pCommand->command = eSmeCommandRemoveKey;
8162 pCommand->sessionId = (tANI_U8)sessionId;
8163 pCommand->u.removeKeyCmd.roamId = roamId;
8164 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8165 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8166 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8167 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8168 {
8169 //in this case, put it to the end of the Q incase there is a set key pending.
8170 fImediate = eANI_BOOLEAN_FALSE;
8171 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008172 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008173 pRemoveKey->encType, pRemoveKey->keyId,
8174 pCommand->u.removeKeyCmd.peerMac[0],
8175 pCommand->u.removeKeyCmd.peerMac[1],
8176 pCommand->u.removeKeyCmd.peerMac[2],
8177 pCommand->u.removeKeyCmd.peerMac[3],
8178 pCommand->u.removeKeyCmd.peerMac[4],
8179 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8181 if( !HAL_STATUS_SUCCESS( status ) )
8182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008183 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 break;
8185 }
8186 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8188 {
8189 csrReleaseCommandRemoveKey( pMac, pCommand );
8190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 return (status );
8192}
8193
Jeff Johnson295189b2012-06-20 16:38:30 -07008194eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8195{
8196 eHalStatus status;
8197 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8198 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8199 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8200 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8202 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8203 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008204 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 {
8206 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8207 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8208 {
8209 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8210 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8211 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8212 }
8213 else
8214 {
8215 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8216 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8217 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8218 }
8219 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
lukez3c809222013-05-03 10:23:02 -07008220 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 {
8222 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 //It has to be static WEP here
8224 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8225 {
8226 setKeyEvent.keyId = (v_U8_t)defKeyId;
8227 }
8228 }
8229 else
8230 {
8231 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8232 }
8233 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8234 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8235 }
8236#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 if( csrIsSetKeyAllowed(pMac, sessionId) )
8238 {
8239 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8240 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8241 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8242 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8243 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8244 pCommand->u.setKeyCmd.keyRsc);
8245 }
8246 else
8247 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008248 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 //Set this status so the error handling take care of the case.
8250 status = eHAL_STATUS_CSR_WRONG_STATE;
8251 }
8252 if( !HAL_STATUS_SUCCESS(status) )
8253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008254 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008256#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008257 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 {
8259 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8260 {
8261 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8262 }
8263 else
8264 {
8265 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8266 }
8267 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8268 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8269 }
8270#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 return ( status );
8273}
8274
Jeff Johnson295189b2012-06-20 16:38:30 -07008275eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8276{
8277 eHalStatus status;
8278 tpSirSmeRemoveKeyReq pMsg = NULL;
8279 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8280 tANI_U8 *p;
8281 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008282#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8283 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8284 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8286 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8287 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8288 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8289 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8290 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8291 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8292 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8293#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 if( csrIsSetKeyAllowed(pMac, sessionId) )
8295 {
8296 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8297 }
8298 else
8299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008300 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 //Set the error status so error handling kicks in below
8302 status = eHAL_STATUS_CSR_WRONG_STATE;
8303 }
8304 if( HAL_STATUS_SUCCESS( status ) )
8305 {
8306 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8307 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8308 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 pMsg->sessionId = (tANI_U8)sessionId;
8310 pMsg->transactionId = 0;
8311 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8312 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8313 // bssId - copy from session Info
8314 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8315 p += sizeof(tSirMacAddr);
8316 // peerMacAddr
8317 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8318 p += sizeof(tSirMacAddr);
8319 // edType
8320 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8321 p++;
8322 // weptype
8323 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8324 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8325 {
8326 *p = (tANI_U8)eSIR_WEP_STATIC;
8327 }
8328 else
8329 {
8330 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8331 }
8332 p++;
8333 //keyid
8334 *p = pCommand->u.removeKeyCmd.keyId;
8335 p++;
8336 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 status = palSendMBMessage(pMac->hHdd, pMsg);
8338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 if( !HAL_STATUS_SUCCESS( status ) )
8340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008341 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008342#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8343 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008344 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8346#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 return ( status );
8350}
8351
Jeff Johnson295189b2012-06-20 16:38:30 -07008352eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8353{
8354 eHalStatus status;
8355
8356 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8357 {
8358 status = eHAL_STATUS_CSR_WRONG_STATE;
8359 }
8360 else
8361 {
8362 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 return ( status );
8365}
8366
Jeff Johnson295189b2012-06-20 16:38:30 -07008367/*
8368 Prepare a filter base on a profile for parsing the scan results.
8369 Upon successful return, caller MUST call csrFreeScanFilter on
8370 pScanFilter when it is done with the filter.
8371*/
8372eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8373 tCsrScanResultFilter *pScanFilter)
8374{
8375 eHalStatus status = eHAL_STATUS_SUCCESS;
8376 tANI_U32 size = 0;
8377 tANI_U8 index = 0;
8378
8379 do
8380 {
8381 if(pProfile->BSSIDs.numOfBSSIDs)
8382 {
8383 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8384 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8385 if(!HAL_STATUS_SUCCESS(status))
8386 {
8387 break;
8388 }
8389 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8390 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8391 }
8392 if(pProfile->SSIDs.numOfSSIDs)
8393 {
8394 if( !CSR_IS_WDS_STA( pProfile ) )
8395 {
8396 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8397 }
8398 else
8399 {
8400 //For WDS station
8401 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8402 pScanFilter->SSIDs.numOfSSIDs = 1;
8403 }
8404 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8405 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8406 if(!HAL_STATUS_SUCCESS(status))
8407 {
8408 break;
8409 }
8410 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8411 }
8412 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8413 {
8414 pScanFilter->ChannelInfo.numOfChannels = 0;
8415 pScanFilter->ChannelInfo.ChannelList = NULL;
8416 }
8417 else if(pProfile->ChannelInfo.numOfChannels)
8418 {
8419 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8420 pScanFilter->ChannelInfo.numOfChannels = 0;
8421 if(HAL_STATUS_SUCCESS(status))
8422 {
8423 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8424 {
8425 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8426 {
8427 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8428 = pProfile->ChannelInfo.ChannelList[index];
8429 pScanFilter->ChannelInfo.numOfChannels++;
8430 }
8431 else
8432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008433 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 }
8436 }
8437 else
8438 {
8439 break;
8440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 }
8442 else
8443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008444 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 status = eHAL_STATUS_FAILURE;
8446 break;
8447 }
8448 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8449 pScanFilter->authType = pProfile->AuthType;
8450 pScanFilter->EncryptionType = pProfile->EncryptionType;
8451 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8452 pScanFilter->BSSType = pProfile->BSSType;
8453 pScanFilter->phyMode = pProfile->phyMode;
8454#ifdef FEATURE_WLAN_WAPI
8455 //check if user asked for WAPI with 11n or auto mode, in that case modify
8456 //the phymode to 11g
8457 if(csrIsProfileWapi(pProfile))
8458 {
8459 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8460 {
8461 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8462 }
8463 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8464 {
8465 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8466 }
8467 if(!pScanFilter->phyMode)
8468 {
8469 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8470 }
8471 }
8472#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 /*Save the WPS info*/
8474 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 if( pProfile->countryCode[0] )
8476 {
8477 //This causes the matching function to use countryCode as one of the criteria.
8478 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8479 WNI_CFG_COUNTRY_CODE_LEN );
8480 }
8481#ifdef WLAN_FEATURE_VOWIFI_11R
8482 if (pProfile->MDID.mdiePresent)
8483 {
8484 pScanFilter->MDID.mdiePresent = 1;
8485 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8486 }
8487#endif
8488
8489 }while(0);
8490
8491 if(!HAL_STATUS_SUCCESS(status))
8492 {
8493 csrFreeScanFilter(pMac, pScanFilter);
8494 }
8495
8496 return(status);
8497}
8498
Jeff Johnson295189b2012-06-20 16:38:30 -07008499tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8500 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8501{
8502 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8503 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 do
8505 {
8506 // Validate the type is ok...
8507 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8508 pCommand = csrGetCommandBuffer( pMac );
8509 if ( !pCommand )
8510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008511 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 break;
8513 }
8514 //Change the substate in case it is waiting for key
8515 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8516 {
8517 csrRoamStopWaitForKeyTimer( pMac );
8518 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8519 }
8520 pCommand->command = eSmeCommandWmStatusChange;
8521 pCommand->sessionId = (tANI_U8)sessionId;
8522 pCommand->u.wmStatusChangeCmd.Type = Type;
8523 if ( eCsrDisassociated == Type )
8524 {
8525 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8526 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8527 }
8528 else
8529 {
8530 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8531 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8532 }
8533 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8534 {
8535 fCommandQueued = eANI_BOOLEAN_TRUE;
8536 }
8537 else
8538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008539 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 csrReleaseCommandWmStatusChange( pMac, pCommand );
8541 }
8542
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8544 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008546 return( fCommandQueued );
8547}
8548
Jeff Johnson295189b2012-06-20 16:38:30 -07008549static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8550{
8551 v_S7_t rssi = 0;
8552 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8553 if(pGetRssiReq)
8554 {
8555 if(NULL != pGetRssiReq->pVosContext)
8556 {
8557 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8558 }
8559 else
8560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008561 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 return;
8563 }
8564
8565 if(NULL != pGetRssiReq->rssiCallback)
8566 {
8567 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8568 }
8569 else
8570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008571 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 return;
8573 }
8574 }
8575 else
8576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008577 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 }
8579 return;
8580}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308581
8582static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8583{
8584 tANI_S8 snr = 0;
8585 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8586
8587 if (pGetSnrReq)
8588 {
8589 if (VOS_STATUS_SUCCESS !=
8590 WDA_GetSnr(pGetSnrReq->staId, &snr))
8591 {
8592 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8593 return;
8594 }
8595
8596 if (pGetSnrReq->snrCallback)
8597 {
8598 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8599 pGetSnrReq->pDevContext);
8600 }
8601 else
8602 {
8603 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8604 return;
8605 }
8606 }
8607 else
8608 {
8609 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8610 }
8611 return;
8612}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008613#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8614void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8615{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008616 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8617
Jeff Johnson36d483b2013-04-08 11:08:53 -07008618 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008619 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008620 /* Get roam Rssi request is backed up and passed back to the response,
8621 Extract the request message to fetch callback */
8622 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8623 v_S7_t rssi = pRoamRssiRsp->rssi;
8624
8625 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008626 {
8627 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8628 reqBkp->rssiCallback = NULL;
8629 vos_mem_free(reqBkp);
8630 }
8631 else
8632 {
8633 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8634 if (NULL != reqBkp)
8635 {
8636 vos_mem_free(reqBkp);
8637 }
8638 }
8639 }
8640 else
8641 {
8642 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8643 }
8644 return;
8645}
8646#endif
8647
Jeff Johnsone7245742012-09-05 17:12:55 -07008648static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8649{
8650 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8651 if(pTlRssiInd)
8652 {
8653 if(NULL != pTlRssiInd->tlCallback)
8654 {
8655 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008656 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008657 }
8658 else
8659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008660 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008661 }
8662 }
8663 else
8664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008665 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008666 }
8667 return;
8668}
Jeff Johnson295189b2012-06-20 16:38:30 -07008669
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308670eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8671{
8672 tpSirResetAPCapsChange pMsg;
8673 tANI_U16 len;
8674 eHalStatus status = eHAL_STATUS_SUCCESS;
8675
8676 /* Create the message and send to lim */
8677 len = sizeof(tSirResetAPCapsChange);
8678 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8679 if (HAL_STATUS_SUCCESS(status))
8680 {
8681 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8682 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8683 pMsg->length = len;
8684 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8685 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8686 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8687 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8688 status = palSendMBMessage(pMac->hHdd, pMsg);
8689 }
8690 else
8691 {
8692 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8693 }
8694 return status;
8695}
8696
Jeff Johnson295189b2012-06-20 16:38:30 -07008697void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8698{
8699 tSirSmeAssocInd *pAssocInd;
8700 tSirSmeDisassocInd *pDisassocInd;
8701 tSirSmeDeauthInd *pDeauthInd;
8702 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8703 tSirSmeNewBssInfo *pNewBss;
8704 tSmeIbssPeerInd *pIbssPeerInd;
8705 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8706 tSirSmeApNewCaps *pApNewCaps;
8707 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8708 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8709 tCsrRoamInfo *pRoamInfo = NULL;
8710 tCsrRoamInfo roamInfo;
8711 eHalStatus status;
8712 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8713 tCsrRoamSession *pSession = NULL;
8714 tpSirSmeSwitchChannelInd pSwitchChnInd;
8715 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008716 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 pSirMsg->messageType = (pSirMsg->messageType);
8718 pSirMsg->length = (pSirMsg->length);
8719 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 switch( pSirMsg->messageType )
8722 {
8723 case eWNI_SME_ASSOC_IND:
8724 {
8725 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008726 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8728 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8729 if( HAL_STATUS_SUCCESS( status ) )
8730 {
8731 pSession = CSR_GET_SESSION(pMac, sessionId);
8732
Jeff Johnson32d95a32012-09-10 13:15:23 -07008733 if(!pSession)
8734 {
8735 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8736 return;
8737 }
8738
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 pRoamInfo = &roamInfo;
8740
8741 // Required for indicating the frames to upper layer
8742 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8743 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8744
8745 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8746 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8747 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8748 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8749
8750 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8751 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8752 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8753
8754 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8755 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8757 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8759 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8762 {
8763 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8764 {
8765 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8766 pSession->pConnectBssDesc,
8767 &(pRoamInfo->peerMac),
8768 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8769 pRoamInfo->fAuthRequired = FALSE;
8770 }
8771 else
8772 {
8773 pRoamInfo->fAuthRequired = TRUE;
8774 }
8775 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8776 if (!HAL_STATUS_SUCCESS(status))
8777 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 /* Send Association completion message to PE */
8780 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8781
8782 /* send a message to CSR itself just to avoid the EAPOL frames going
8783 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8785 {
8786 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8789 {
8790 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8791 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8792 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008794 }
8795 }
8796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008798 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 // Check if AP dis-associated us because of MIC failure. If so,
8800 // then we need to take action immediately and not wait till the
8801 // the WmStatusChange requests is pushed and processed
8802 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8803 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8804 if( HAL_STATUS_SUCCESS( status ) )
8805 {
8806 // If we are in neighbor preauth done state then on receiving
8807 // disassoc or deauth we dont roam instead we just disassoc
8808 // from current ap and then go to disconnected state
8809 // This happens for CCX and 11r FT connections ONLY.
8810#ifdef WLAN_FEATURE_VOWIFI_11R
8811 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8812 {
8813 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8814 }
8815#endif
8816#ifdef FEATURE_WLAN_CCX
8817 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8818 {
8819 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8820 }
8821#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008822#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308823 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008824 {
8825 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8826 }
8827#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008828 pSession = CSR_GET_SESSION( pMac, sessionId );
8829
Jeff Johnson32d95a32012-09-10 13:15:23 -07008830 if(!pSession)
8831 {
8832 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8833 return;
8834 }
8835
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 if ( csrIsConnStateInfra( pMac, sessionId ) )
8837 {
8838 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008840#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8841 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8842#endif
8843 csrRoamLinkDown(pMac, sessionId);
8844 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008845 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8846 {
8847
8848 pRoamInfo = &roamInfo;
8849
8850 pRoamInfo->statusCode = pDisassocInd->statusCode;
8851 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8852
8853 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8854
8855 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8856 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8857
8858 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008859
8860 /*
8861 * STA/P2P client got disassociated so remove any pending deauth
8862 * commands in sme pending list
8863 */
8864 pCommand.command = eSmeCommandRoam;
8865 pCommand.sessionId = (tANI_U8)sessionId;
8866 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8867 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8868 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 }
8871 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008873 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8875 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8876 if( HAL_STATUS_SUCCESS( status ) )
8877 {
8878 // If we are in neighbor preauth done state then on receiving
8879 // disassoc or deauth we dont roam instead we just disassoc
8880 // from current ap and then go to disconnected state
8881 // This happens for CCX and 11r FT connections ONLY.
8882#ifdef WLAN_FEATURE_VOWIFI_11R
8883 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8884 {
8885 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8886 }
8887#endif
8888#ifdef FEATURE_WLAN_CCX
8889 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8890 {
8891 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8892 }
8893#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008894#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308895 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008896 {
8897 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8898 }
8899#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 pSession = CSR_GET_SESSION( pMac, sessionId );
8901
Jeff Johnson32d95a32012-09-10 13:15:23 -07008902 if(!pSession)
8903 {
8904 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8905 return;
8906 }
8907
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 if ( csrIsConnStateInfra( pMac, sessionId ) )
8909 {
8910 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008912#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8913 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8914#endif
8915 csrRoamLinkDown(pMac, sessionId);
8916 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8918 {
8919
8920 pRoamInfo = &roamInfo;
8921
8922 pRoamInfo->statusCode = pDeauthInd->statusCode;
8923 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8924
8925 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8926
8927 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8928 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8929
8930 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 }
8933 break;
8934
8935 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 -08008936 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8938 //Update with the new channel id.
8939 //The channel id is hidden in the statusCode.
8940 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8941 if( HAL_STATUS_SUCCESS( status ) )
8942 {
8943 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008944 if(!pSession)
8945 {
8946 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8947 return;
8948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8950 if(pSession->pConnectBssDesc)
8951 {
8952 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8953 }
8954 }
8955 break;
8956
8957 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008958 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008959 {
8960 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8961 sessionId = pDeauthRsp->sessionId;
8962 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8963 {
8964 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008965 if(!pSession)
8966 {
8967 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8968 return;
8969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8971 {
8972 pRoamInfo = &roamInfo;
8973 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8974 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8975 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8976 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8977 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8978 }
8979 }
8980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 break;
8982
8983 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008984 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008985 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 {
8987 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8988 sessionId = pDisassocRsp->sessionId;
8989 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8990 {
8991 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008992 if(!pSession)
8993 {
8994 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8995 return;
8996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8998 {
8999 pRoamInfo = &roamInfo;
9000 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9001 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
9002 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9003 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9004 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9005 }
9006 }
9007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 case eWNI_SME_MIC_FAILURE_IND:
9010 {
9011 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9012 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9013 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009014
9015 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9016 if( HAL_STATUS_SUCCESS( status ) )
9017 {
9018 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9019 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9020 pRoamInfo = &roamInfo;
9021 if(pMicInd->info.multicast)
9022 {
9023 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9024 }
9025 else
9026 {
9027 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9028 }
9029 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9030 }
9031
Jeff Johnson295189b2012-06-20 16:38:30 -07009032#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9033 {
lukez3c809222013-05-03 10:23:02 -07009034 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009036 if(!pSession)
9037 {
9038 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9039 return;
9040 }
lukez3c809222013-05-03 10:23:02 -07009041
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
9043 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9044 secEvent.encryptionModeMulticast =
9045 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9046 secEvent.encryptionModeUnicast =
9047 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9048 secEvent.authMode =
9049 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9050 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
9051 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9052 }
9053#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Leo Chang9b01ad92013-09-12 17:26:56 -07009054
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 }
9056 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9058 {
9059 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9060 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009061 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009062
9063 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9064 if( HAL_STATUS_SUCCESS( status ) )
9065 {
9066 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9067 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9068 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9069 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9070 }
9071 }
9072 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009073
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9075 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9076 switch( pStatusChangeMsg->statusChangeCode )
9077 {
9078 case eSIR_SME_IBSS_ACTIVE:
9079 sessionId = csrFindIbssSession( pMac );
9080 if( CSR_SESSION_ID_INVALID != sessionId )
9081 {
9082 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009083 if(!pSession)
9084 {
9085 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9086 return;
9087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009088 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9089 if(pSession->pConnectBssDesc)
9090 {
9091 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9092 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9093 pRoamInfo = &roamInfo;
9094 }
9095 else
9096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009097 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 }
9099 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9100 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9101 }
9102 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 case eSIR_SME_IBSS_INACTIVE:
9104 sessionId = csrFindIbssSession( pMac );
9105 if( CSR_SESSION_ID_INVALID != sessionId )
9106 {
9107 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009108 if(!pSession)
9109 {
9110 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9111 return;
9112 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9114 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9115 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9116 }
9117 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9119 sessionId = csrFindIbssSession( pMac );
9120 if( CSR_SESSION_ID_INVALID != sessionId )
9121 {
9122 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009123 if(!pSession)
9124 {
9125 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9126 return;
9127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 // update the connection state information
9129 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009130#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9131 {
9132 vos_log_ibss_pkt_type *pIbssLog;
9133 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009134 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9135 if(pIbssLog)
9136 {
9137 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9138 if(pNewBss)
9139 {
9140 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9141 if(pNewBss->ssId.length)
9142 {
9143 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9144 }
9145 pIbssLog->operatingChannel = pNewBss->channelNumber;
9146 }
9147 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9148 {
9149 //***U8 is not enough for beacon interval
9150 pIbssLog->beaconInterval = (v_U8_t)bi;
9151 }
9152 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9153 }
9154 }
9155#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009156 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009157
9158 if ((eCSR_ENCRYPT_TYPE_NONE ==
9159 pSession->connectedProfile.EncryptionType ))
9160 {
9161 csrRoamIssueSetContextReq( pMac, sessionId,
9162 pSession->connectedProfile.EncryptionType,
9163 pSession->pConnectBssDesc,
9164 &Broadcastaddr,
9165 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9168 roamStatus = eCSR_ROAM_IBSS_IND;
9169 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9170 pRoamInfo = &roamInfo;
9171 //This BSSID is th ereal BSSID, let's save it
9172 if(pSession->pConnectBssDesc)
9173 {
9174 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9175 }
9176 // Stop the join IBSS timer in case of join, for
9177 // genuine merge do nothing
9178 if(pSession->ibss_join_pending)
9179 {
9180 pSession->ibss_join_pending = FALSE;
9181 csrRoamStopIbssJoinTimer(pMac, sessionId);
9182 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9183 }
9184 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009185 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 // detection by LIM that the capabilities of the associated AP have changed.
9188 case eSIR_SME_AP_CAPS_CHANGED:
9189 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009190 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9192 if( HAL_STATUS_SUCCESS( status ) )
9193 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009194 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9195 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309196 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009197 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9198 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9199 )
9200 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309201 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9202 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009203 }
9204 else
9205 {
9206 smsLog(pMac, LOGW,
9207 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009208 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009209 pMac->roam.curState[sessionId],
9210 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309211 /* We ignore the caps change event if CSR is not in full connected state.
9212 * Send one event to PE to reset limSentCapsChangeNtf
9213 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9214 * otherwise lim cannot send any CAPS change events to SME */
9215 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 }
9218 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309219
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 default:
9221 roamStatus = eCSR_ROAM_FAILED;
9222 result = eCSR_ROAM_RESULT_NONE;
9223 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 } // end switch on statusChangeCode
9225 if(eCSR_ROAM_RESULT_NONE != result)
9226 {
9227 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9228 }
9229 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 case eWNI_SME_IBSS_NEW_PEER_IND:
9231 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009232#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9233 {
9234 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9236 if(pIbssLog)
9237 {
9238 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9239 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9240 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9241 }
9242 }
9243#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 sessionId = csrFindIbssSession( pMac );
9245 if( CSR_SESSION_ID_INVALID != sessionId )
9246 {
9247 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009248
9249 if(!pSession)
9250 {
9251 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9252 return;
9253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9255 if(pSession->pConnectBssDesc)
9256 {
9257 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9258 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9259 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9260 {
9261 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9262 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9263 if(HAL_STATUS_SUCCESS(status))
9264 {
9265 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9266 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9267 roamInfo.nBeaconLength);
9268 }
9269 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9270 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9271 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9272 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9273 pSession->pConnectBssDesc->length);
9274 if(HAL_STATUS_SUCCESS(status))
9275 {
9276 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9277 pSession->pConnectBssDesc->length);
9278 }
9279 if(HAL_STATUS_SUCCESS(status))
9280 {
9281 pRoamInfo = &roamInfo;
9282 }
9283 else
9284 {
9285 if(roamInfo.pbFrames)
9286 {
9287 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9288 }
9289 if(roamInfo.pBssDesc)
9290 {
9291 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9292 }
9293 }
9294 }
9295 else
9296 {
9297 pRoamInfo = &roamInfo;
9298 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009299 if ((eCSR_ENCRYPT_TYPE_NONE ==
9300 pSession->connectedProfile.EncryptionType ))
9301 {
9302 csrRoamIssueSetContextReq( pMac, sessionId,
9303 pSession->connectedProfile.EncryptionType,
9304 pSession->pConnectBssDesc,
9305 &(pIbssPeerInd->peerAddr),
9306 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009308 }
9309 else
9310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009311 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 }
9313 //send up the sec type for the new peer
9314 if (pRoamInfo)
9315 {
9316 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9317 }
9318 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9319 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9320 if(pRoamInfo)
9321 {
9322 if(roamInfo.pbFrames)
9323 {
9324 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9325 }
9326 if(roamInfo.pBssDesc)
9327 {
9328 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9329 }
9330 }
9331 }
9332 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9334 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9335 sessionId = csrFindIbssSession( pMac );
9336 if( CSR_SESSION_ID_INVALID != sessionId )
9337 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009338#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9339 {
9340 vos_log_ibss_pkt_type *pIbssLog;
9341
9342 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9343 if(pIbssLog)
9344 {
9345 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9346 if(pIbssPeerInd)
9347 {
9348 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9349 }
9350 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9351 }
9352 }
9353#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009354 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9356 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9357 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9358 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9359 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9360 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9361 }
9362 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 case eWNI_SME_SETCONTEXT_RSP:
9364 {
9365 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9366 tListElem *pEntry;
9367 tSmeCmd *pCommand;
9368
9369 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9370 if ( pEntry )
9371 {
9372 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9373 if ( eSmeCommandSetKey == pCommand->command )
9374 {
9375 sessionId = pCommand->sessionId;
9376 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009377
9378 if(!pSession)
9379 {
9380 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9381 return;
9382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009383
9384#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9385 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9386 {
9387 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9388 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9389 if( pRsp->peerMacAddr[0] & 0x01 )
9390 {
9391 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9392 }
9393 else
9394 {
9395 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9396 }
9397 setKeyEvent.encryptionModeMulticast =
9398 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9399 setKeyEvent.encryptionModeUnicast =
9400 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9401 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9402 setKeyEvent.authMode =
9403 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009404 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 {
9406 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9407 }
9408 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9409 }
9410#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9411 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9412 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009413 csrRoamStopWaitForKeyTimer( pMac );
9414
Jeff Johnson295189b2012-06-20 16:38:30 -07009415 //We are done with authentication, whethere succeed or not
9416 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 //We do it here because this linkup function is not called after association
9418 //when a key needs to be set.
9419 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9420 {
9421 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9422 }
9423 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009424 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 {
9426 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009427 //Make sure we install the GTK before indicating to HDD as authenticated
9428 //This is to prevent broadcast packets go out after PTK and before GTK.
9429 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9430 sizeof(tSirMacAddr) ) )
9431 {
Yathish9f22e662012-12-10 14:21:35 -08009432#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9433 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9434 {
9435 tpSirSetActiveModeSetBncFilterReq pMsg;
9436 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9437 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9438 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9439 pMsg->seesionId = sessionId;
9440 status = palSendMBMessage(pMac->hHdd, pMsg );
9441 }
9442#endif
9443 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009444 }
9445 else
9446 {
9447 result = eCSR_ROAM_RESULT_NONE;
9448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 pRoamInfo = &roamInfo;
9450 }
9451 else
9452 {
9453 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009454 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9456 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9457 }
9458 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9459 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9461 // can go ahead and initiate the TSPEC if any are pending
9462 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009463#ifdef FEATURE_WLAN_CCX
9464 //Send Adjacent AP repot to new AP.
9465 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9466 pSession->isPrevApInfoValid &&
9467 pSession->connectedProfile.isCCXAssoc)
9468 {
9469#ifdef WLAN_FEATURE_VOWIFI
9470 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9471#endif
9472 pSession->isPrevApInfoValid = FALSE;
9473 }
9474#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9476 {
9477 csrReleaseCommandSetKey( pMac, pCommand );
9478 }
9479 }
9480 else
9481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009482 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 }
9484 }
9485 else
9486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009487 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 smeProcessPendingQueue( pMac );
9490 }
9491 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 case eWNI_SME_REMOVEKEY_RSP:
9493 {
9494 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9495 tListElem *pEntry;
9496 tSmeCmd *pCommand;
9497
9498 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9499 if ( pEntry )
9500 {
9501 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9502 if ( eSmeCommandRemoveKey == pCommand->command )
9503 {
9504 sessionId = pCommand->sessionId;
9505 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009506
9507 if(!pSession)
9508 {
9509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9510 return;
9511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009512#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9513 {
9514 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9515 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9516 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9517 removeKeyEvent.encryptionModeMulticast =
9518 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9519 removeKeyEvent.encryptionModeUnicast =
9520 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9521 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9522 removeKeyEvent.authMode =
9523 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009524 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 {
9526 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9527 }
9528 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9529 }
9530#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009531 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 {
9533 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9534 result = eCSR_ROAM_RESULT_NONE;
9535 pRoamInfo = &roamInfo;
9536 }
9537 else
9538 {
9539 result = eCSR_ROAM_RESULT_FAILURE;
9540 }
9541 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9542 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9543 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9544 {
9545 csrReleaseCommandRemoveKey( pMac, pCommand );
9546 }
9547 }
9548 else
9549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009550 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 }
9552 }
9553 else
9554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009555 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 smeProcessPendingQueue( pMac );
9558 }
9559 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009561 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 csrRoamStatsRspProcessor( pMac, pSirMsg );
9563 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009564#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9565 case eWNI_SME_GET_ROAM_RSSI_RSP:
9566 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9567 csrRoamRssiRspProcessor( pMac, pSirMsg );
9568 break;
9569#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009571 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 csrUpdateRssi( pMac, pSirMsg );
9573 break;
9574
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309575 case eWNI_SME_GET_SNR_REQ:
9576 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9577 csrUpdateSnr(pMac, pSirMsg);
9578 break;
9579
Jeff Johnson295189b2012-06-20 16:38:30 -07009580#ifdef WLAN_FEATURE_VOWIFI_11R
9581 case eWNI_SME_FT_PRE_AUTH_RSP:
9582 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9583 break;
9584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9586 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009587 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 -07009588 sessionId = pSmeMaxAssocInd->sessionId;
9589 roamInfo.sessionId = sessionId;
9590 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9591 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9592 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9593 break;
9594
9595 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009596 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 btampEstablishLogLinkHdlr( pSirMsg );
9598 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009599 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009600 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009601 csrRoamRssiIndHdlr( pMac, pSirMsg );
9602 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009603#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9604 case eWNI_SME_CANDIDATE_FOUND_IND:
9605 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9606 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9607 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009608 case eWNI_SME_HANDOFF_REQ:
9609 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9610 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9611 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009613
9614 default:
9615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009617}
9618
Jeff Johnson295189b2012-06-20 16:38:30 -07009619void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9620 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9621{
9622 if(pSession)
9623 {
9624 if(pSession->bRefAssocStartCnt)
9625 {
9626 pSession->bRefAssocStartCnt--;
9627 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9628 //Need to call association_completion because there is an assoc_start pending.
9629 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9630 eCSR_ROAM_ASSOCIATION_COMPLETION,
9631 eCSR_ROAM_RESULT_FAILURE);
9632 }
9633 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9634 }
9635 else
9636 {
9637 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9638 }
9639}
9640
9641
9642eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9643{
9644 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9646 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9647 {
9648 status = csrScanRequestLostLink1( pMac, sessionId );
9649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 return(status);
9651}
9652
Jeff Johnson295189b2012-06-20 16:38:30 -07009653//return a boolean to indicate whether roaming completed or continue.
9654tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9655 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9656{
9657 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9658 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9659 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9660 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009661 if(!pSession)
9662 {
9663 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9664 return eANI_BOOLEAN_FALSE;
9665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 //Check whether time is up
9667 if(pSession->fCancelRoaming || fForce ||
9668 ((curTime - pSession->roamingStartTime) > roamTime) ||
9669 eCsrReassocRoaming == pSession->roamingReason ||
9670 eCsrDynamicRoaming == pSession->roamingReason)
9671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009672 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9674 {
9675 //roaming is cancelled, tell HDD to indicate disconnect
9676 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9677 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9678 //to be eSIR_BEACON_MISSED
9679 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9680 {
9681 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9682 }
9683 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9684 {
9685 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9686 }
9687 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9688 {
9689 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9690 }
9691 else
9692 {
9693 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9694 }
9695 }
9696 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9697 pSession->roamingReason = eCsrNotRoaming;
9698 }
9699 else
9700 {
9701 pSession->roamResult = roamResult;
9702 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9703 {
9704 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9705 pSession->roamingReason = eCsrNotRoaming;
9706 }
9707 else
9708 {
9709 fCompleted = eANI_BOOLEAN_FALSE;
9710 }
9711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 return(fCompleted);
9713}
9714
Jeff Johnson295189b2012-06-20 16:38:30 -07009715void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9716{
9717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009718
9719 if(!pSession)
9720 {
9721 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9722 return;
9723 }
9724
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 if(CSR_IS_ROAMING(pSession))
9726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009727 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9729 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9730 {
9731 //No need to do anything in here because the handler takes care of it
9732 }
9733 else
9734 {
9735 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9736 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9737 //Roaming is stopped after here
9738 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9739 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05309740 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 csrRoamStopRoamingTimer(pMac, sessionId);
9742 }
9743 }
9744}
9745
Jeff Johnson295189b2012-06-20 16:38:30 -07009746void csrRoamRoamingTimerHandler(void *pv)
9747{
9748 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9749 tpAniSirGlobal pMac = pInfo->pMac;
9750 tANI_U32 sessionId = pInfo->sessionId;
9751 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009752
9753 if(!pSession)
9754 {
9755 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9756 return;
9757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
9759 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9760 {
9761 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9762 {
9763 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9764 pSession->roamingReason = eCsrNotRoaming;
9765 }
9766 }
9767}
9768
Jeff Johnson295189b2012-06-20 16:38:30 -07009769eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9770{
9771 eHalStatus status;
9772 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009773
9774 if(!pSession)
9775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009776 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009777 return eHAL_STATUS_FAILURE;
9778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009779
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009780 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309782 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009783
9784 return (status);
9785}
9786
Jeff Johnson295189b2012-06-20 16:38:30 -07009787eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9788{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309789 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -07009790}
9791
Jeff Johnson295189b2012-06-20 16:38:30 -07009792void csrRoamWaitForKeyTimeOutHandler(void *pv)
9793{
9794 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9795 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009796 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9797
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009798 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009799 pMac->roam.neighborRoamInfo.neighborRoamState,
9800 pMac->roam.curSubState[pInfo->sessionId]);
9801
Jeff Johnson295189b2012-06-20 16:38:30 -07009802 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9803 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009804#ifdef FEATURE_WLAN_LFR
9805 if (csrNeighborRoamIsHandoffInProgress(pMac))
9806 {
9807 /*
9808 * Enable heartbeat timer when hand-off is in progress
9809 * and Key Wait timer expired.
9810 */
9811 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009812 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009813 pMac->roam.configParam.HeartbeatThresh24);
9814 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9815 pMac->roam.configParam.HeartbeatThresh24,
9816 NULL, eANI_BOOLEAN_FALSE);
9817 }
9818#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009819 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 //Change the substate so command queue is unblocked.
9821 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009822 if (pSession)
9823 {
9824 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9825 {
9826 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9827 smeProcessPendingQueue(pMac);
9828 }
9829 else
9830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009831 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009832 __func__);
9833 }
9834 }
9835 else
9836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009837 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009839 }
9840
9841}
9842
Jeff Johnson295189b2012-06-20 16:38:30 -07009843eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9844{
9845 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009846#ifdef FEATURE_WLAN_LFR
9847 if (csrNeighborRoamIsHandoffInProgress(pMac))
9848 {
9849 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009850 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009851 __func__,
9852 pMac->roam.neighborRoamInfo.neighborRoamState,
9853 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9854 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9855 }
9856#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009857 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309858 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009859
9860 return (status);
9861}
9862
Jeff Johnson295189b2012-06-20 16:38:30 -07009863eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9864{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009865 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009866 pMac->roam.neighborRoamInfo.neighborRoamState,
9867 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9868#ifdef FEATURE_WLAN_LFR
9869 if (csrNeighborRoamIsHandoffInProgress(pMac))
9870 {
9871 /*
9872 * Enable heartbeat timer when hand-off is in progress
9873 * and Key Wait timer got stopped for some reason
9874 */
9875 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009876 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009877 pMac->roam.configParam.HeartbeatThresh24);
9878 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9879 pMac->roam.configParam.HeartbeatThresh24,
9880 NULL, eANI_BOOLEAN_FALSE);
9881 }
9882#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309883 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009884}
9885
Jeff Johnson295189b2012-06-20 16:38:30 -07009886void csrRoamIbssJoinTimerHandler(void *pv)
9887{
9888 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9889 tpAniSirGlobal pMac = pInfo->pMac;
9890 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9891 tANI_U32 sessionId = pInfo->sessionId;
9892 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009893
9894 if(!pSession)
9895 {
9896 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9897 return;
9898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009899
9900 pSession->ibss_join_pending = FALSE;
9901 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9902 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9903 // Send an IBSS stop request to PE
9904 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009905}
Jeff Johnson295189b2012-06-20 16:38:30 -07009906eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9907{
9908 eHalStatus status;
9909 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009910
9911 if(!pSession)
9912 {
9913 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9914 return eHAL_STATUS_FAILURE;
9915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009916
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009917 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309919 status = vos_timer_start(&pSession->hTimerIbssJoining, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009920
9921 return (status);
9922}
Jeff Johnson295189b2012-06-20 16:38:30 -07009923eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9924{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309925 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerIbssJoining));
Jeff Johnson295189b2012-06-20 16:38:30 -07009926}
Jeff Johnson295189b2012-06-20 16:38:30 -07009927void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9928 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9929{
9930 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9931 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009932 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9933 /* To silence the KW tool Null chaeck is added */
9934 if(!pSession)
9935 {
9936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9937 return;
9938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009939
9940 if(pCommand)
9941 {
9942 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009943 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9946 {
9947 //if success, force roaming completion
9948 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9949 }
9950 else
9951 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009952 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009953 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9955 }
9956}
9957
Jeff Johnson295189b2012-06-20 16:38:30 -07009958eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9959{
9960 eHalStatus status = eHAL_STATUS_SUCCESS;
9961 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9962 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9963 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9964 tCsrRoamInfo *pRoamInfo = NULL;
9965 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009966 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009968 /* To silence the KW tool Null chaeck is added */
9969 if(!pSession)
9970 {
9971 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9972 return eHAL_STATUS_FAILURE;
9973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009975 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9977 if ( eWNI_SME_DISASSOC_IND == type )
9978 {
9979 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9980 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9981 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009982 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 }
9984 else if ( eWNI_SME_DEAUTH_IND == type )
9985 {
9986 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9987 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9988 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009989 /* Convert into proper reason code */
9990 pSession->joinFailStatusCode.reasonCode =
9991 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309992 0 : pDeauthIndMsg->reasonCode;
9993 /* cfg layer expects 0 as reason code if
9994 the driver dosent know the reason code
9995 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 }
9997 else
9998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009999 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010001 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 }
10003
10004 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 {
10007 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10008 }
10009
10010 if ( eWNI_SME_DISASSOC_IND == type )
10011 {
10012 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10013 }
10014 else if ( eWNI_SME_DEAUTH_IND == type )
10015 {
10016 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 if(!HAL_STATUS_SUCCESS(status))
10019 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010020 //If fail to send confirmation to PE, not to trigger roaming
10021 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 }
10023
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010024 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10026 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10027 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 if( eWNI_SME_DISASSOC_IND == type)
10029 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010030 //staMacAddr
10031 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10032 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 else if( eWNI_SME_DEAUTH_IND == type )
10035 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010036 //staMacAddr
10037 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10038 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10039 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010040 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010041
10042 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10043 that we are roaming. But if we cannot possibly roam, or if we are unable to
10044 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 if(fToRoam)
10046 {
10047 //Only remove the connected BSS in infrastructure mode
10048 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10049 //Not to do anying for lostlink with WDS
10050 if( pMac->roam.configParam.nRoamingTime )
10051 {
10052 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10053 ( eWNI_SME_DEAUTH_IND == type ) ?
10054 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10055 {
10056 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10057 //For IBSS, we need to give some more info to HDD
10058 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10059 {
10060 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10061 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10062 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10063 }
10064 else
10065 {
10066 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10067 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010068 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10070 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10071 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10072 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10073 }
10074 else
10075 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010076 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 fToRoam = eANI_BOOLEAN_FALSE;
10078 }
10079 }
10080 else
10081 {
10082 //We are told not to roam, indicate lostlink
10083 fToRoam = eANI_BOOLEAN_FALSE;
10084 }
10085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010086 if(!fToRoam)
10087 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010088 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010089 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010090 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010091 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10092 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10093 * csrRoamCheckForLinkStatusChange API.
10094 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010095 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10096 }
10097
10098 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 Still enable idle scan for polling in case concurrent sessions are running */
10100 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10101 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010102 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 }
10104 }
10105
10106 return (status);
10107}
10108
Jeff Johnson295189b2012-06-20 16:38:30 -070010109eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10110{
10111 eHalStatus status = eHAL_STATUS_SUCCESS;
10112 tListElem *pEntry = NULL;
10113 tSmeCmd *pCommand = NULL;
10114 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010115
10116 if(!pSession)
10117 {
10118 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10119 return eHAL_STATUS_FAILURE;
10120 }
10121
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 //Only remove the connected BSS in infrastructure mode
10124 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10125 if(pMac->roam.configParam.nRoamingTime)
10126 {
10127 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10128 {
10129 //before starting the lost link logic release the roam command for handoff
10130 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10131 if(pEntry)
10132 {
10133 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10134 }
10135 if(pCommand)
10136 {
10137 if (( eSmeCommandRoam == pCommand->command ) &&
10138 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10139 {
10140 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10141 {
10142 csrReleaseCommandRoam( pMac, pCommand );
10143 }
10144 }
10145 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010146 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 }
10148 }
10149 else
10150 {
10151 //We are told not to roam, indicate lostlink
10152 status = eHAL_STATUS_FAILURE;
10153 }
10154
10155 return (status);
10156}
Jeff Johnson295189b2012-06-20 16:38:30 -070010157void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10158{
10159 tListElem *pEntry;
10160 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10162 if ( pEntry )
10163 {
10164 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10165 if ( eSmeCommandWmStatusChange == pCommand->command )
10166 {
10167 // Nothing to process in a Lost Link completion.... It just kicks off a
10168 // roaming sequence.
10169 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10170 {
10171 csrReleaseCommandWmStatusChange( pMac, pCommand );
10172 }
10173 else
10174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010175 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 }
10177
10178 }
10179 else
10180 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010181 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 }
10183 }
10184 else
10185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010186 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010188 smeProcessPendingQueue( pMac );
10189}
10190
Jeff Johnson295189b2012-06-20 16:38:30 -070010191void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10192{
10193 eHalStatus status = eHAL_STATUS_FAILURE;
10194 tSirSmeRsp *pSirSmeMsg;
10195 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010196
10197 if(!pSession)
10198 {
10199 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10200 return;
10201 }
10202
Jeff Johnson295189b2012-06-20 16:38:30 -070010203 switch ( pCommand->u.wmStatusChangeCmd.Type )
10204 {
10205 case eCsrDisassociated:
10206 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10207 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10208 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010209 case eCsrDeauthenticated:
10210 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10211 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10212 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010214 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 break;
10216 }
10217 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10218 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10219 {
10220 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10221 {
10222 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010223 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010224 }
10225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10227 // command here since there is nothing else to do.
10228 csrRoamWmStatusChangeComplete( pMac );
10229}
10230
Jeff Johnson295189b2012-06-20 16:38:30 -070010231//This function returns band and mode information.
10232//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10233//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010234static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10235 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010236{
Jeff Johnson295189b2012-06-20 16:38:30 -070010237 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10238 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10239 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010241
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 //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 -070010243 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10244 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10245 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10246 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 {
10248 switch( pMac->roam.configParam.uCfgDot11Mode )
10249 {
10250 case eCSR_CFG_DOT11_MODE_11A:
10251 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10252 eBand = eCSR_BAND_5G;
10253 break;
10254 case eCSR_CFG_DOT11_MODE_11B:
10255 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10256 eBand = eCSR_BAND_24;
10257 break;
10258 case eCSR_CFG_DOT11_MODE_11G:
10259 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10260 eBand = eCSR_BAND_24;
10261 break;
10262 case eCSR_CFG_DOT11_MODE_11N:
10263 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010264 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10265 break;
10266#ifdef WLAN_FEATURE_11AC
10267 case eCSR_CFG_DOT11_MODE_11AC:
10268 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10269 {
10270 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10271 eBand = eCSR_BAND_5G;
10272 }
10273 else
10274 {
10275 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10276 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10277 }
10278 break;
10279 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10280 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10281 {
10282 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10283 eBand = eCSR_BAND_5G;
10284 }
10285 else
10286 {
10287 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10288 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10289 }
10290 break;
10291#endif
10292 case eCSR_CFG_DOT11_MODE_AUTO:
10293 eBand = pMac->roam.configParam.eBand;
10294 if (eCSR_BAND_24 == eBand)
10295 {
10296 // WiFi tests require IBSS networks to start in 11b mode
10297 // without any change to the default parameter settings
10298 // on the adapter. We use ACU to start an IBSS through
10299 // creation of a startIBSS profile. This startIBSS profile
10300 // has Auto MACProtocol and the adapter property setting
10301 // for dot11Mode is also AUTO. So in this case, let's
10302 // start the IBSS network in 11b mode instead of 11g mode.
10303 // So this is for Auto=profile->MacProtocol && Auto=Global.
10304 // dot11Mode && profile->channel is < 14, then start the IBSS
10305 // in b mode.
10306 //
10307 // Note: we used to have this start as an 11g IBSS for best
10308 // performance... now to specify that the user will have to
10309 // set the do11Mode in the property page to 11g to force it.
10310 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10311 }
10312 else
10313 {
10314#ifdef WLAN_FEATURE_11AC
10315 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10316 {
10317 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10318 eBand = eCSR_BAND_5G;
10319 }
10320 else
10321 {
10322 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10323 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10324 }
10325#else
10326 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10327 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10328#endif
10329 }
10330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010331 default:
10332 // Global dot11 Mode setting is 11a/b/g.
10333 // use the channel number to determine the Mode setting.
10334 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10335 {
10336 eBand = pMac->roam.configParam.eBand;
10337 if(eCSR_BAND_24 == eBand)
10338 {
10339 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10340 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10341 }
10342 else
10343 {
10344 //prefer 5GHz
10345 eBand = eCSR_BAND_5G;
10346 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10347 }
10348 }
10349 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10350 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010351 // WiFi tests require IBSS networks to start in 11b mode
10352 // without any change to the default parameter settings
10353 // on the adapter. We use ACU to start an IBSS through
10354 // creation of a startIBSS profile. This startIBSS profile
10355 // has Auto MACProtocol and the adapter property setting
10356 // for dot11Mode is also AUTO. So in this case, let's
10357 // start the IBSS network in 11b mode instead of 11g mode.
10358 // So this is for Auto=profile->MacProtocol && Auto=Global.
10359 // dot11Mode && profile->channel is < 14, then start the IBSS
10360 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010362 // Note: we used to have this start as an 11g IBSS for best
10363 // performance... now to specify that the user will have to
10364 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10366 eBand = eCSR_BAND_24;
10367 }
10368 else
10369 {
10370 // else, it's a 5.0GHz channel. Set mode to 11a.
10371 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10372 eBand = eCSR_BAND_5G;
10373 }
10374 break;
10375 }//switch
10376 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10377 else
10378 {
10379 //dot11 mode is set, lets pick the band
10380 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10381 {
10382 // channel is Auto also.
10383 eBand = pMac->roam.configParam.eBand;
10384 if(eCSR_BAND_ALL == eBand)
10385 {
10386 //prefer 5GHz
10387 eBand = eCSR_BAND_5G;
10388 }
10389 }
10390 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10391 {
10392 eBand = eCSR_BAND_24;
10393 }
10394 else
10395 {
10396 eBand = eCSR_BAND_5G;
10397 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010399 if(pBand)
10400 {
10401 *pBand = eBand;
10402 }
10403
10404 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010405 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10407 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010408
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010409 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10410 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 -070010411 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010412#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010413 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010414#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010415 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10416 {
10417 //We cannot do 11n here
10418 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10419 {
10420 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10421 }
10422 else
10423 {
10424 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10425 }
10426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010427 return( cfgDot11Mode );
10428}
10429
Jeff Johnson295189b2012-06-20 16:38:30 -070010430eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10431{
10432 eHalStatus status;
10433 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010434
10435 if(!pSession)
10436 {
10437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10438 return eHAL_STATUS_FAILURE;
10439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010440
10441#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10442 {
10443 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010444 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10445 if(pIbssLog)
10446 {
10447 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10448 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10449 }
10450 }
10451#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 pSession->ibss_join_pending = FALSE;
10453 csrRoamStopIbssJoinTimer(pMac, sessionId );
10454 // Set the roaming substate to 'stop Bss request'...
10455 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10456
10457 // attempt to stop the Bss (reason code is ignored...)
10458 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010459 if(!HAL_STATUS_SUCCESS(status))
10460 {
10461 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 return (status);
10464}
10465
Jeff Johnson295189b2012-06-20 16:38:30 -070010466//pNumChan is a caller allocated space with the sizeof pChannels
10467eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10468{
10469
10470 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10471 (tANI_U8 *)pChannels,
10472 pNumChan));
10473}
10474
Kiran4a17ebe2013-01-31 10:43:43 -080010475tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10476{
10477 tANI_U32 cfgLength = 0;
10478 tANI_U16 cfgId = 0;
10479 tPowerdBm maxTxPwr = 0;
10480 tANI_U8 *pCountryInfo = NULL;
10481 eHalStatus status;
10482 tANI_U8 count = 0;
10483 tANI_U8 firstChannel;
10484 tANI_U8 maxChannels;
10485
10486 if (CSR_IS_CHANNEL_5GHZ(channel))
10487 {
10488 cfgId = WNI_CFG_MAX_TX_POWER_5;
10489 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10490 }
10491 else if (CSR_IS_CHANNEL_24GHZ(channel))
10492 {
10493 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10494 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10495 }
10496 else
10497 return maxTxPwr;
10498
10499 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10500 if (status != eHAL_STATUS_SUCCESS)
10501 {
10502 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10503 FL("%s: palAllocateMemory() failed, status = %d"),
10504 __FUNCTION__, status);
10505 goto error;
10506 }
10507 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10508 if (status != eHAL_STATUS_SUCCESS)
10509 {
10510 goto error;
10511 }
10512 /* Identify the channel and maxtxpower */
10513 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10514 {
10515 firstChannel = pCountryInfo[count++];
10516 maxChannels = pCountryInfo[count++];
10517 maxTxPwr = pCountryInfo[count++];
10518
10519 if ((channel >= firstChannel) &&
10520 (channel < (firstChannel + maxChannels)))
10521 {
10522 break;
10523 }
10524 }
10525
10526error:
10527 if (NULL != pCountryInfo)
10528 palFreeMemory(pMac->hHdd, pCountryInfo);
10529
10530 return maxTxPwr;
10531}
10532
10533
Jeff Johnson295189b2012-06-20 16:38:30 -070010534tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10535{
10536 tANI_BOOLEAN fValid = FALSE;
10537 tANI_U32 idxValidChannels;
10538 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10539
10540 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10541 {
10542 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10543 {
10544 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10545 {
10546 fValid = TRUE;
10547 break;
10548 }
10549 }
10550 }
10551 pMac->roam.numValidChannels = len;
10552 return fValid;
10553}
10554
Jeff Johnson295189b2012-06-20 16:38:30 -070010555tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10556{
10557 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10558 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10560 {
10561 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10562 {
10563 fValid = eANI_BOOLEAN_TRUE;
10564 break;
10565 }
10566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 return (fValid);
10568}
10569
Jeff Johnson295189b2012-06-20 16:38:30 -070010570//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010571 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010572{
Jeff Johnsone7245742012-09-05 17:12:55 -070010573 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 tANI_U8 centerChn;
10575 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10577 {
10578 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10579 }
10580 else
10581 {
10582 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10583 }
10584 //Figure what the other side's CB mode
10585 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10586 {
10587 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10588 {
10589 if(pIes->HTInfo.present)
10590 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010591 /* This is called during INFRA STA/CLIENT and should use the merged value of
10592 * supported channel width and recommended tx width as per standard
10593 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010594 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010595 pIes->HTCaps.supportedChannelWidthSet,
10596 pIes->HTInfo.recommendedTxWidthSet,
10597 pIes->HTInfo.secondaryChannelOffset);
10598
10599 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10600 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010602 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10603 switch (eRet) {
10604 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10605 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10606 break;
10607 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10608 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10609 break;
10610 case PHY_SINGLE_CHANNEL_CENTERED:
10611 default:
10612 centerChn = primaryChn;
10613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010615 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010617 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010618 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 }
10620 }
10621 }
10622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 return eRet;
10624}
Jeff Johnson295189b2012-06-20 16:38:30 -070010625tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10626{
10627 tANI_BOOLEAN fFound = FALSE;
10628 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10630 {
10631 if( pCipherList->encryptionType[idx] == encryptionType )
10632 {
10633 fFound = TRUE;
10634 break;
10635 }
10636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 return fFound;
10638}
Jeff Johnson295189b2012-06-20 16:38:30 -070010639tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10640{
10641 tANI_BOOLEAN fFound = FALSE;
10642 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010643 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10644 {
10645 if( pAuthList->authType[idx] == authType )
10646 {
10647 fFound = TRUE;
10648 break;
10649 }
10650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010651 return fFound;
10652}
Jeff Johnson295189b2012-06-20 16:38:30 -070010653tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10654{
10655 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10656 tCsrScanResultFilter *pScanFilter = NULL;
10657 eHalStatus status = eHAL_STATUS_SUCCESS;
10658
10659 if(pProfile1 && pProfile2)
10660 {
10661 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10662 if(HAL_STATUS_SUCCESS(status))
10663 {
10664 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10665 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10666 if(HAL_STATUS_SUCCESS(status))
10667 {
10668 fCheck = eANI_BOOLEAN_FALSE;
10669 do
10670 {
10671 tANI_U32 i;
10672 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10673 {
10674 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10675 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10676 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10677 if ( fCheck ) break;
10678 }
10679 if(!fCheck)
10680 {
10681 break;
10682 }
10683 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10684 || pProfile2->BSSType != pProfile1->BSSType
10685 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10686 )
10687 {
10688 fCheck = eANI_BOOLEAN_FALSE;
10689 break;
10690 }
10691#ifdef WLAN_FEATURE_VOWIFI_11R
10692 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10693 {
10694 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10695 {
10696 fCheck = eANI_BOOLEAN_FALSE;
10697 break;
10698 }
10699 }
10700#endif
10701 //Match found
10702 fCheck = eANI_BOOLEAN_TRUE;
10703 }while(0);
10704 csrFreeScanFilter(pMac, pScanFilter);
10705 }
10706 palFreeMemory(pMac->hHdd, pScanFilter);
10707 }
10708 }
10709
10710 return (fCheck);
10711}
10712
Jeff Johnson295189b2012-06-20 16:38:30 -070010713tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10714{
10715 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10716 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 do
10718 {
10719 //Only check for static WEP
10720 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10721 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10722 {
10723 fCheck = eANI_BOOLEAN_TRUE;
10724 break;
10725 }
10726 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10727 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10728 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10729 {
10730 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10731 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10732 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10733 {
10734 break;
10735 }
10736 }
10737 if( i == CSR_MAX_NUM_KEY)
10738 {
10739 fCheck = eANI_BOOLEAN_TRUE;
10740 }
10741 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 return (fCheck);
10743}
10744
Jeff Johnson295189b2012-06-20 16:38:30 -070010745//IBSS
10746
Jeff Johnson295189b2012-06-20 16:38:30 -070010747tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10748{
10749 tANI_U8 channel = 0;
10750 tANI_U32 idx;
10751 tANI_U32 idxValidChannels;
10752 tANI_BOOLEAN fFound = FALSE;
10753 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10754
10755 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10756 {
10757 channel = pMac->roam.configParam.AdHocChannel5G;
10758 if(!csrRoamIsChannelValid(pMac, channel))
10759 {
10760 channel = 0;
10761 }
10762 }
10763 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10764 {
10765 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10766 {
10767 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10768 {
10769 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10770 {
10771 fFound = TRUE;
10772 channel = csrStartIbssChannels50[ idx ];
10773 }
10774 }
10775 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10777 if (!fFound)
10778 {
10779 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10780 {
10781 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10782 {
10783 channel = csrStartIbssChannels50[ idx ];
10784 break;
10785 }
10786 }
10787 }
10788 }//if
10789
10790 return( channel );
10791}
10792
Jeff Johnson295189b2012-06-20 16:38:30 -070010793tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10794{
10795 tANI_U8 channel = 1;
10796 tANI_U32 idx;
10797 tANI_U32 idxValidChannels;
10798 tANI_BOOLEAN fFound = FALSE;
10799 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10800
10801 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10802 {
10803 channel = pMac->roam.configParam.AdHocChannel24;
10804 if(!csrRoamIsChannelValid(pMac, channel))
10805 {
10806 channel = 0;
10807 }
10808 }
10809
10810 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10811 {
10812 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10813 {
10814 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10815 {
10816 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10817 {
10818 fFound = TRUE;
10819 channel = csrStartIbssChannels24[ idx ];
10820 }
10821 }
10822 }
10823 }
10824
10825 return( channel );
10826}
10827
Jeff Johnson295189b2012-06-20 16:38:30 -070010828static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10829 tCsrRoamStartBssParams *pParam )
10830{
10831 eCsrCfgDot11Mode cfgDot11Mode;
10832 eCsrBand eBand;
10833 tANI_U8 channel = 0;
10834 tSirNwType nwType;
10835 tANI_U8 operationChannel = 0;
10836
10837 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10838 {
10839 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10840 }
10841
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010843
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10845 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10846 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10847 )
10848 {
10849 /* This should never happen */
10850 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010851 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010852 pProfile->csrPersona);
10853 VOS_ASSERT(0);
10854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 switch( cfgDot11Mode )
10856 {
10857 case eCSR_CFG_DOT11_MODE_11G:
10858 nwType = eSIR_11G_NW_TYPE;
10859 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 case eCSR_CFG_DOT11_MODE_11B:
10861 nwType = eSIR_11B_NW_TYPE;
10862 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 case eCSR_CFG_DOT11_MODE_11A:
10864 nwType = eSIR_11A_NW_TYPE;
10865 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010866 default:
10867 case eCSR_CFG_DOT11_MODE_11N:
10868 case eCSR_CFG_DOT11_MODE_TAURUS:
10869 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10870 if(eCSR_BAND_24 == eBand)
10871 {
10872 nwType = eSIR_11G_NW_TYPE;
10873 }
10874 else
10875 {
10876 nwType = eSIR_11A_NW_TYPE;
10877 }
10878 break;
10879 }
10880
10881 pParam->extendedRateSet.numRates = 0;
10882
10883 switch ( nwType )
10884 {
10885 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010886 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 case eSIR_11A_NW_TYPE:
10888
10889 pParam->operationalRateSet.numRates = 8;
10890
10891 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10892 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10893 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10894 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10895 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10896 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10897 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10898 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10899
10900 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10901 {
10902 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10903 if( 0 == channel &&
10904 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10905 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10906 )
10907 {
10908 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10909 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10910 nwType = eSIR_11B_NW_TYPE;
10911 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10912 pParam->operationalRateSet.numRates = 4;
10913 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10914 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10915 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10916 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10917 }
10918 }
10919 else
10920 {
10921 channel = operationChannel;
10922 }
10923 break;
10924
10925 case eSIR_11B_NW_TYPE:
10926 pParam->operationalRateSet.numRates = 4;
10927 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10928 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10929 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10930 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10932 {
10933 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10934 }
10935 else
10936 {
10937 channel = operationChannel;
10938 }
10939
10940 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 /* For P2P Client and P2P GO, disable 11b rates */
10943 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10944 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10945 )
10946 {
10947 pParam->operationalRateSet.numRates = 8;
10948
10949 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10950 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10951 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10952 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10953 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10954 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10955 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10956 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10957 }
10958 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 {
10960 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010961 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10962 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10963 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10964 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10965
10966 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010967 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10968 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10969 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10970 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10971 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10972 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10973 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10974 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10975 }
10976
10977 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10978 {
10979 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10980 }
10981 else
10982 {
10983 channel = operationChannel;
10984 }
10985
10986 break;
10987 }
10988 pParam->operationChn = channel;
10989 pParam->sirNwType = nwType;
10990}
10991
Jeff Johnson295189b2012-06-20 16:38:30 -070010992static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10993 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10994{
10995
10996 if( pParam )
10997 {
10998 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010999 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 pParam->operationChn = pBssDesc->channelId;
11001 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
11002
11003 if( pIes )
11004 {
11005 if(pIes->SuppRates.present)
11006 {
11007 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11008 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011010 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 -070011011 pIes->SuppRates.num_rates);
11012 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11013 }
11014 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11015 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
11016 }
11017 if( pIes->SSID.present )
11018 {
11019 pParam->ssId.length = pIes->SSID.num_ssid;
11020 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
11021 }
11022 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 }
11024 else
11025 {
11026 pParam->ssId.length = 0;
11027 pParam->operationalRateSet.numRates = 0;
11028 }
11029 }
11030}
11031
Jeff Johnson295189b2012-06-20 16:38:30 -070011032static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11033{
11034 tANI_U8 MaxRate = 0;
11035 tANI_U32 i;
11036 tANI_U8 *pRate;
11037
11038 pRate = pSirRateSet->rate;
11039 for ( i = 0; i < pSirRateSet->numRates; i++ )
11040 {
11041 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11042 }
11043
11044 // Save the max rate in the connected state information...
11045
11046 // modify LastRates variable as well
11047
11048 return;
11049}
11050
Jeff Johnson295189b2012-06-20 16:38:30 -070011051eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11052 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11053{
11054 eHalStatus status = eHAL_STATUS_SUCCESS;
11055 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011056 // Set the roaming substate to 'Start BSS attempt'...
11057 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011058#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11059 //Need to figure out whether we need to log WDS???
11060 if( CSR_IS_IBSS( pProfile ) )
11061 {
11062 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11064 if(pIbssLog)
11065 {
11066 if(pBssDesc)
11067 {
11068 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
11069 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
11070 }
11071 else
11072 {
11073 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11074 }
11075 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11076 pParam->ssId.length);
11077 if(pProfile->ChannelInfo.numOfChannels == 0)
11078 {
11079 pIbssLog->channelSetting = AUTO_PICK;
11080 }
11081 else
11082 {
11083 pIbssLog->channelSetting = SPECIFIED;
11084 }
11085 pIbssLog->operatingChannel = pParam->operationChn;
11086 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11087 }
11088 }
11089#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11090 //Put RSN information in for Starting BSS
11091 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11092 pParam->pRSNIE = pProfile->pRSNReqIE;
11093
Jeff Johnson295189b2012-06-20 16:38:30 -070011094 pParam->privacy = pProfile->privacy;
11095 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11096 pParam->authType = pProfile->csr80211AuthType;
11097 pParam->beaconInterval = pProfile->beaconInterval;
11098 pParam->dtimPeriod = pProfile->dtimPeriod;
11099 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11100 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11101 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11102 {
11103 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11104 {
11105 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11106 }
11107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 pParam->protEnabled = pProfile->protEnabled;
11109 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11110 pParam->ht_protection = pProfile->cfg_protection;
11111 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011112
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11114 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 pParam->bssPersona = pProfile->csrPersona;
11116 // When starting an IBSS, start on the channel from the Profile.
11117 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 return (status);
11119}
11120
Jeff Johnson295189b2012-06-20 16:38:30 -070011121static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011122 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011123{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011124 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011125 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011127
11128 if(!pSession)
11129 {
11130 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11131 return;
11132 }
11133
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 if( pBssDesc )
11135 {
11136 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11137 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11138 //The following code has to be do after that.
11139 //For WDS station, use selfMac as the self BSSID
11140 if( CSR_IS_WDS_STA( pProfile ) )
11141 {
11142 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11143 }
11144 }
11145 else
11146 {
11147 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011148 //Use the first SSID
11149 if(pProfile->SSIDs.numOfSSIDs)
11150 {
11151 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11152 }
11153 //For WDS station, use selfMac as the self BSSID
11154 if( CSR_IS_WDS_STA( pProfile ) )
11155 {
11156 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11157 }
11158 //Use the first BSSID
11159 else if( pProfile->BSSIDs.numOfBSSIDs )
11160 {
11161 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11162 }
11163 else
11164 {
11165 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11166 }
11167 }
11168 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 //Set operating channel in pProfile which will be used
11170 //in csrRoamSetBssConfigCfg() to determine channel bonding
11171 //mode and will be configured in CFG later
11172 pProfile->operationChannel = Channel;
11173
11174 if(Channel == 0)
11175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011176 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 }
11178 else
11179 {
11180
11181 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011182 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011183 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011184 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011185 {
11186 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11187 }
11188 else
11189 {
11190 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11191 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011192 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011193 pBssConfig->cbMode = cbMode;
11194 pSession->bssParams.cbMode = cbMode;
11195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 }
11197}
11198
Jeff Johnson295189b2012-06-20 16:38:30 -070011199static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11200 tANI_BOOLEAN *pfSameIbss )
11201{
11202 eHalStatus status = eHAL_STATUS_SUCCESS;
11203 tANI_BOOLEAN fSameIbss = FALSE;
11204
11205 if ( csrIsConnStateIbss( pMac, sessionId ) )
11206 {
11207 // Check if any profile parameter has changed ? If any profile parameter
11208 // has changed then stop old BSS and start a new one with new parameters
11209 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11210 {
11211 fSameIbss = TRUE;
11212 }
11213 else
11214 {
11215 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11216 }
11217 }
11218 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11219 {
11220 // Disassociate from the connected Infrastructure network...
11221 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11222 }
11223 else
11224 {
11225 tBssConfigParam *pBssConfig;
11226
11227 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11228 if(HAL_STATUS_SUCCESS(status))
11229 {
11230 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11231 // there is no Bss description before we start an IBSS so we need to adopt
11232 // all Bss configuration parameters from the Profile.
11233 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11234 if(HAL_STATUS_SUCCESS(status))
11235 {
11236 //save dotMode
11237 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11238 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011239 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011240 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11241 NULL, pBssConfig,
11242 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 palFreeMemory(pMac->hHdd, pBssConfig);
11245 }//Allocate memory
11246 }
11247
11248 if(pfSameIbss)
11249 {
11250 *pfSameIbss = fSameIbss;
11251 }
11252 return( status );
11253}
11254
Jeff Johnson295189b2012-06-20 16:38:30 -070011255static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11256 tSirSmeNewBssInfo *pNewBss )
11257{
11258 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011259
11260 if(!pSession)
11261 {
11262 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11263 return;
11264 }
11265
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 if( pNewBss )
11267 {
11268 // Set the operating channel.
11269 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11270 // move the BSSId from the BSS description into the connected state information.
11271 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11272 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 return;
11275}
11276
Jeff Johnson295189b2012-06-20 16:38:30 -070011277#ifdef FEATURE_WLAN_WAPI
11278eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11279 tANI_U32 numItems )
11280{
11281 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11282 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011283 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011285 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011286 return status;
11287 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011288 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 pSession = CSR_GET_SESSION( pMac, sessionId );
11290 if(numItems <= CSR_MAX_BKID_ALLOWED)
11291 {
11292 status = eHAL_STATUS_SUCCESS;
11293 //numItems may be 0 to clear the cache
11294 pSession->NumBkidCache = (tANI_U16)numItems;
11295 if(numItems && pBKIDCache)
11296 {
11297 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11298 sizeof(tBkidCacheInfo) * numItems );
11299 }
11300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011301 return (status);
11302}
Jeff Johnson295189b2012-06-20 16:38:30 -070011303eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11304 tBkidCacheInfo *pBkidCache)
11305{
11306 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11307 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011310 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 return status;
11312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 pSession = CSR_GET_SESSION( pMac, sessionId );
11314 if(pNum && pBkidCache)
11315 {
11316 if(pSession->NumBkidCache == 0)
11317 {
11318 *pNum = 0;
11319 status = eHAL_STATUS_SUCCESS;
11320 }
11321 else if(*pNum >= pSession->NumBkidCache)
11322 {
11323 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011325 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 -070011326 pSession->NumBkidCache);
11327 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11328 }
11329 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11330 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11331 *pNum = pSession->NumBkidCache;
11332 status = eHAL_STATUS_SUCCESS;
11333 }
11334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011336}
Jeff Johnson295189b2012-06-20 16:38:30 -070011337tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11338{
11339 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011340}
11341#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011342eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11343 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11344{
11345 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011347
11348 if(!pSession)
11349 {
11350 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11351 return eHAL_STATUS_FAILURE;
11352 }
11353
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011354 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011355 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11356 {
11357#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11358 {
11359 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11360 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11361 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11362 secEvent.encryptionModeMulticast =
11363 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11364 secEvent.encryptionModeUnicast =
11365 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11366 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11367 secEvent.authMode =
11368 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11369 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11370 }
11371#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 status = eHAL_STATUS_SUCCESS;
11373 //numItems may be 0 to clear the cache
11374 pSession->NumPmkidCache = (tANI_U16)numItems;
11375 if(numItems && pPMKIDCache)
11376 {
11377 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11378 sizeof(tPmkidCacheInfo) * numItems );
11379 }
11380 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011381 return (status);
11382}
11383
Jeff Johnson295189b2012-06-20 16:38:30 -070011384tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11385{
11386 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11387}
11388
Jeff Johnson295189b2012-06-20 16:38:30 -070011389eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11390{
11391 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11392 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011393
11394 if(!pSession)
11395 {
11396 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11397 return eHAL_STATUS_FAILURE;
11398 }
11399
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 if(pNum && pPmkidCache)
11401 {
11402 if(pSession->NumPmkidCache == 0)
11403 {
11404 *pNum = 0;
11405 status = eHAL_STATUS_SUCCESS;
11406 }
11407 else if(*pNum >= pSession->NumPmkidCache)
11408 {
11409 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011411 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 -070011412 pSession->NumPmkidCache);
11413 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11414 }
11415 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11416 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11417 *pNum = pSession->NumPmkidCache;
11418 status = eHAL_STATUS_SUCCESS;
11419 }
11420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 return (status);
11422}
11423
Jeff Johnson295189b2012-06-20 16:38:30 -070011424eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11425{
11426 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11427 tANI_U32 len;
11428 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011429
11430 if(!pSession)
11431 {
11432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11433 return eHAL_STATUS_FAILURE;
11434 }
11435
Jeff Johnson295189b2012-06-20 16:38:30 -070011436 if(pLen)
11437 {
11438 len = *pLen;
11439 *pLen = pSession->nWpaRsnReqIeLength;
11440 if(pBuf)
11441 {
11442 if(len >= pSession->nWpaRsnReqIeLength)
11443 {
11444 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11445 }
11446 }
11447 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 return (status);
11449}
11450
Jeff Johnson295189b2012-06-20 16:38:30 -070011451eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11452{
11453 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11454 tANI_U32 len;
11455 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011456
11457 if(!pSession)
11458 {
11459 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11460 return eHAL_STATUS_FAILURE;
11461 }
11462
Jeff Johnson295189b2012-06-20 16:38:30 -070011463 if(pLen)
11464 {
11465 len = *pLen;
11466 *pLen = pSession->nWpaRsnRspIeLength;
11467 if(pBuf)
11468 {
11469 if(len >= pSession->nWpaRsnRspIeLength)
11470 {
11471 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11472 }
11473 }
11474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 return (status);
11476}
Jeff Johnson295189b2012-06-20 16:38:30 -070011477#ifdef FEATURE_WLAN_WAPI
11478eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11479{
11480 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11481 tANI_U32 len;
11482 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011483
11484 if(!pSession)
11485 {
11486 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11487 return eHAL_STATUS_FAILURE;
11488 }
11489
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 if(pLen)
11491 {
11492 len = *pLen;
11493 *pLen = pSession->nWapiReqIeLength;
11494 if(pBuf)
11495 {
11496 if(len >= pSession->nWapiReqIeLength)
11497 {
11498 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11499 }
11500 }
11501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 return (status);
11503}
Jeff Johnson295189b2012-06-20 16:38:30 -070011504eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11505{
11506 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11507 tANI_U32 len;
11508 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011509
11510 if(!pSession)
11511 {
11512 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11513 return eHAL_STATUS_FAILURE;
11514 }
11515
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 if(pLen)
11517 {
11518 len = *pLen;
11519 *pLen = pSession->nWapiRspIeLength;
11520 if(pBuf)
11521 {
11522 if(len >= pSession->nWapiRspIeLength)
11523 {
11524 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11525 }
11526 }
11527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 return (status);
11529}
11530#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011531eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11532{
11533 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011535
11536 if(!pSession)
11537 {
11538 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11539 return (retStatus);
11540 }
11541
Jeff Johnson295189b2012-06-20 16:38:30 -070011542 if(CSR_IS_ROAMING(pSession))
11543 {
11544 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11545 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011547 return (retStatus);
11548}
11549
Jeff Johnson295189b2012-06-20 16:38:30 -070011550//This function remove the connected BSS from te cached scan result
11551eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11552 tCsrRoamConnectedProfile *pConnProfile)
11553{
11554 eHalStatus status = eHAL_STATUS_FAILURE;
11555 tCsrScanResultFilter *pScanFilter = NULL;
11556 tListElem *pEntry;
11557 tCsrScanResult *pResult;
11558 tDot11fBeaconIEs *pIes;
11559 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11561 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11562 {
11563 do
11564 {
11565 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11566 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11567 if(!HAL_STATUS_SUCCESS(status)) break;
11568 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11569 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11570 if(!HAL_STATUS_SUCCESS(status)) break;
11571 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11572 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11573 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11574 {
11575 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11576 if(!HAL_STATUS_SUCCESS(status)) break;
11577 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11578 }
11579 pScanFilter->authType.numEntries = 1;
11580 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11581 pScanFilter->BSSType = pConnProfile->BSSType;
11582 pScanFilter->EncryptionType.numEntries = 1;
11583 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11584 pScanFilter->mcEncryptionType.numEntries = 1;
11585 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11586 //We ignore the channel for now, BSSID should be enough
11587 pScanFilter->ChannelInfo.numOfChannels = 0;
11588 //Also ignore the following fields
11589 pScanFilter->uapsd_mask = 0;
11590 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11591 pScanFilter->countryCode[0] = 0;
11592 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 csrLLLock(&pMac->scan.scanResultList);
11594 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11595 while( pEntry )
11596 {
11597 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11598 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11599 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11600 pScanFilter, NULL, NULL, NULL, &pIes);
11601 //Release the IEs allocated by csrMatchBSS is needed
11602 if( !pResult->Result.pvIes )
11603 {
11604 //need to free the IEs since it is allocated by csrMatchBSS
11605 palFreeMemory(pMac->hHdd, pIes);
11606 }
11607 if(fMatch)
11608 {
11609 //We found the one
11610 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11611 {
11612 //Free the memory
11613 csrFreeScanResultEntry( pMac, pResult );
11614 }
11615 break;
11616 }
11617 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11618 }//while
11619 csrLLUnlock(&pMac->scan.scanResultList);
11620 }while(0);
11621 if(pScanFilter)
11622 {
11623 csrFreeScanFilter(pMac, pScanFilter);
11624 palFreeMemory(pMac->hHdd, pScanFilter);
11625 }
11626 }
11627 return (status);
11628}
11629
Jeff Johnson295189b2012-06-20 16:38:30 -070011630//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011631eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11632{
11633 eHalStatus status = eHAL_STATUS_SUCCESS;
11634 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011635 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11636 {
11637 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11638 {
11639 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11640 {
11641 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011642 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011643 status = eHAL_STATUS_CSR_WRONG_STATE;
11644 break;
11645 }
11646 if( csrIsConnStateInfra( pMac, sessionId ) )
11647 {
11648 if( chnId &&
11649 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011651 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11653 status = eHAL_STATUS_CSR_WRONG_STATE;
11654 break;
11655 }
11656 }
11657 }
11658 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011659 return ( status );
11660}
11661
Jeff Johnson295189b2012-06-20 16:38:30 -070011662static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11663{
11664 eHalStatus status = eHAL_STATUS_SUCCESS;
11665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11666 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011667
11668 if(!pSession)
11669 {
11670 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11671 return eHAL_STATUS_FAILURE;
11672 }
11673
Jeff Johnson295189b2012-06-20 16:38:30 -070011674 if ( csrIsConnStateIbss( pMac, sessionId ) )
11675 {
11676 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11677 }
11678 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11679 {
11680 // Disassociate from the connected Infrastructure network...
11681 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11682 }
11683 else
11684 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011685 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11686 //Otherwise we need to add code to handle the
11687 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11688 //send stop_bss to PE, before we can continue.
11689 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11691 /* Assume HDD provide bssid in profile */
11692 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11693 // there is no Bss description before we start an WDS so we need
11694 // to adopt all Bss configuration parameters from the Profile.
11695 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11696 if(HAL_STATUS_SUCCESS(status))
11697 {
11698 //Save profile for late use
11699 csrFreeRoamProfile( pMac, sessionId );
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011700 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 (void **)&pSession->pCurRoamProfile,
11702 sizeof(tCsrRoamProfile))))
11703 {
11704 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11705 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11706 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011708 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011709 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11710 NULL, &bssConfig,
11711 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 }
11713 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011714
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 return( status );
11716}
11717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718////////////////////Mail box
11719
Jeff Johnson295189b2012-06-20 16:38:30 -070011720//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11721//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011722static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11723 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11725{
11726 tCsrChannelSet channelGroup;
11727 tSirMacCapabilityInfo *pAP_capabilityInfo;
11728 tAniBool fTmp;
11729 tANI_BOOLEAN found = FALSE;
11730 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011731 tANI_S8 pwrLimit = 0;
11732 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11734 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11735 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11736 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 // 802.11h
11738 //We can do this because it is in HOST CPU order for now.
11739 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011740 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11741 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11742 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 fTmp = (tAniBool)pal_cpu_to_be32(1);
11744 }
11745 else
11746 fTmp = (tAniBool)0;
11747
11748 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11749 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11750 pBuf += sizeof(tAniBool);
11751 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011752 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 // This is required for 11k test VoWiFi Ent: Test 2.
11754 // We need the power capabilities for Assoc Req.
11755 // This macro is provided by the halPhyCfg.h. We pick our
11756 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011757 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11758 if (0 != pwrLimit)
11759 {
11760 *pBuf++ = pwrLimit;
11761 }
11762 else
11763 {
11764 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 size = sizeof(pMac->roam.validChannelList);
11767 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11768 {
11769 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11770 for ( i = 0; i < size; i++)
11771 {
11772 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11773
11774 }
11775 }
11776 else
11777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011778 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 *pBuf++ = 0; //tSirSupChnl->numChnl
11780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 //Check whether it is ok to enter UAPSD
11782#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11783 if( btcIsReadyForUapsd(pMac) )
11784#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11785 {
11786 *pBuf++ = uapsdMask;
11787 }
11788#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11789 else
11790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011791 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011792 *pBuf++ = 0;
11793 }
11794#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11795
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 // move the entire BssDescription into the join request.
11797 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11798 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11800}
11801
Jeff Johnson295189b2012-06-20 16:38:30 -070011802/*
11803 * The communication between HDD and LIM is thru mailbox (MB).
11804 * Both sides will access the data structure "tSirSmeJoinReq".
11805 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11806 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11807 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11808 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11809 */
11810eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011811 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011812{
11813 eHalStatus status = eHAL_STATUS_SUCCESS;
11814 tSirSmeJoinReq *pMsg;
11815 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011816 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 tANI_U16 msgLen, wTmp, ieLen;
11818 tSirMacRateSet OpRateSet;
11819 tSirMacRateSet ExRateSet;
11820 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11821 tANI_U32 dwTmp;
11822 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011823 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011824
11825 if(!pSession)
11826 {
11827 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11828 return eHAL_STATUS_FAILURE;
11829 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011830 /* To satisfy klockworks */
11831 if (NULL == pBssDescription)
11832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011833 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011834 return eHAL_STATUS_FAILURE;
11835 }
11836
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 do {
11838 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11839 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011840 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11842 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11843 // IE fields, but the length field in the bssDescription needs to be interpreted to
11844 // determine length of the IE fields.
11845 //
11846 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11847 // add in the length from the bssDescription (then add the size of the 'length' field
11848 // itself because that is NOT included in the length field).
11849 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11850 pBssDescription->length + sizeof( pBssDescription->length ) +
11851 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 -070011852 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11853 if ( !HAL_STATUS_SUCCESS(status) ) break;
11854 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011855 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 pMsg->length = pal_cpu_to_be16(msgLen);
11857 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 // sessionId
11859 *pBuf = (tANI_U8)sessionId;
11860 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 // transactionId
11862 *pBuf = 0;
11863 *( pBuf + 1 ) = 0;
11864 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 // ssId
11866 if( pIes->SSID.present && pIes->SSID.num_ssid )
11867 {
11868 // ssId len
11869 *pBuf = pIes->SSID.num_ssid;
11870 pBuf++;
11871 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11872 pBuf += pIes->SSID.num_ssid;
11873 }
11874 else
11875 {
11876 *pBuf = 0;
11877 pBuf++;
11878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 // selfMacAddr
11880 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11881 pBuf += sizeof(tSirMacAddr);
11882 // bsstype
11883 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11884 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11885 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11886 pBuf += sizeof(tSirBssType);
11887 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011888 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11889 if (pBssDescription->channelId <= 14 &&
11890 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11891 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11892 {
11893 //Need to disable VHT operation in 2.4 GHz band
11894 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11895 }
11896 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011898 //Persona
11899 *pBuf = (tANI_U8)pProfile->csrPersona;
11900 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011901 //CBMode
11902 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11903 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011904
11905 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011906 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11907
Jeff Johnson295189b2012-06-20 16:38:30 -070011908 // uapsdPerAcBitmask
11909 *pBuf = pProfile->uapsd_mask;
11910 pBuf++;
11911
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011912
11913
Jeff Johnson295189b2012-06-20 16:38:30 -070011914 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011915 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 {
11917 // OperationalRateSet
11918 if (OpRateSet.numRates) {
11919 *pBuf++ = OpRateSet.numRates;
11920 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11921 pBuf += OpRateSet.numRates;
11922 } else *pBuf++ = 0;
11923 // ExtendedRateSet
11924 if (ExRateSet.numRates) {
11925 *pBuf++ = ExRateSet.numRates;
11926 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11927 pBuf += ExRateSet.numRates;
11928 } else *pBuf++ = 0;
11929 }
11930 else
11931 {
11932 *pBuf++ = 0;
11933 *pBuf++ = 0;
11934 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 // rsnIE
11936 if ( csrIsProfileWpa( pProfile ) )
11937 {
11938 // Insert the Wpa IE into the join request
11939 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11940 (tCsrWpaIe *)( wpaRsnIE ) );
11941 }
11942 else if( csrIsProfileRSN( pProfile ) )
11943 {
11944 // Insert the RSN IE into the join request
11945 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11946 (tCsrRSNIe *)( wpaRsnIE ) );
11947 }
11948#ifdef FEATURE_WLAN_WAPI
11949 else if( csrIsProfileWapi( pProfile ) )
11950 {
11951 // Insert the WAPI IE into the join request
11952 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11953 (tCsrWapiIe *)( wpaRsnIE ) );
11954 }
11955#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011956 else
11957 {
11958 ieLen = 0;
11959 }
11960 //remember the IE for future use
11961 if( ieLen )
11962 {
11963 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011965 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 -070011966 ieLen = DOT11F_IE_RSN_MAX_LEN;
11967 }
11968#ifdef FEATURE_WLAN_WAPI
11969 if( csrIsProfileWapi( pProfile ) )
11970 {
11971 //Check whether we need to allocate more memory
11972 if(ieLen > pSession->nWapiReqIeLength)
11973 {
11974 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11975 {
11976 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11977 }
11978 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11979 if(!HAL_STATUS_SUCCESS(status)) break;
11980 }
11981 pSession->nWapiReqIeLength = ieLen;
11982 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11983 wTmp = pal_cpu_to_be16( ieLen );
11984 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11985 pBuf += sizeof(tANI_U16);
11986 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11987 pBuf += ieLen;
11988 }
11989 else//should be WPA/WPA2 otherwise
11990#endif /* FEATURE_WLAN_WAPI */
11991 {
11992 //Check whether we need to allocate more memory
11993 if(ieLen > pSession->nWpaRsnReqIeLength)
11994 {
11995 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11996 {
11997 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11998 }
11999 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
12000 if(!HAL_STATUS_SUCCESS(status)) break;
12001 }
12002 pSession->nWpaRsnReqIeLength = ieLen;
12003 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
12004 wTmp = pal_cpu_to_be16( ieLen );
12005 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12006 pBuf += sizeof(tANI_U16);
12007 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12008 pBuf += ieLen;
12009 }
12010 }
12011 else
12012 {
12013 //free whatever old info
12014 pSession->nWpaRsnReqIeLength = 0;
12015 if(pSession->pWpaRsnReqIE)
12016 {
12017 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12018 pSession->pWpaRsnReqIE = NULL;
12019 }
12020#ifdef FEATURE_WLAN_WAPI
12021 pSession->nWapiReqIeLength = 0;
12022 if(pSession->pWapiReqIE)
12023 {
12024 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12025 pSession->pWapiReqIE = NULL;
12026 }
12027#endif /* FEATURE_WLAN_WAPI */
12028 //length is two bytes
12029 *pBuf = 0;
12030 *(pBuf + 1) = 0;
12031 pBuf += 2;
12032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012033#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012034 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012036 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 //length is two bytes
12038 *pBuf = 0;
12039 *(pBuf + 1) = 0;
12040 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012041 }
12042 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012044 // cckmIE
12045 if( csrIsProfileCCX( pProfile ) )
12046 {
12047 // Insert the CCKM IE into the join request
12048 ieLen = csrConstructCcxCckmIe( pMac,
12049 pSession,
12050 pProfile,
12051 pBssDescription,
12052 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 pSession->nWpaRsnReqIeLength,
12054 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012055 }
12056 else
12057 {
12058 ieLen = 0;
12059 }
12060 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12061 if( ieLen )
12062 {
12063 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12064 wTmp = pal_cpu_to_be16( ieLen );
12065 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12066 pBuf += sizeof(tANI_U16);
12067 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12068 pBuf += ieLen;
12069 }
12070 else
12071 {
12072 //Indicate you have no CCKM IE
12073 //length is two bytes
12074 *pBuf = 0;
12075 *(pBuf + 1) = 0;
12076 pBuf += 2;
12077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 }
12079#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 // addIEScan
12081 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12082 {
12083 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 if(ieLen > pSession->nAddIEScanLength)
12085 {
12086 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12087 {
12088 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12089 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012090 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012091 (void **)&pSession->pAddIEScan, ieLen);
12092 if(!HAL_STATUS_SUCCESS(status)) break;
12093 }
12094 pSession->nAddIEScanLength = ieLen;
12095 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12096 pProfile->pAddIEScan, ieLen);
12097 wTmp = pal_cpu_to_be16( ieLen );
12098 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12099 pBuf += sizeof(tANI_U16);
12100 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12101 pBuf += ieLen;
12102 }
12103 else
12104 {
12105 pSession->nAddIEScanLength = 0;
12106 if(pSession->pAddIEScan)
12107 {
12108 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12109 pSession->pAddIEScan = NULL;
12110 }
12111 *pBuf = 0;
12112 *(pBuf + 1) = 0;
12113 pBuf += 2;
12114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 // addIEAssoc
12116 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12117 {
12118 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 if(ieLen > pSession->nAddIEAssocLength)
12120 {
12121 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12122 {
12123 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12124 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012125 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 (void **)&pSession->pAddIEAssoc, ieLen);
12127 if(!HAL_STATUS_SUCCESS(status)) break;
12128 }
12129 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012130 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 pProfile->pAddIEAssoc, ieLen);
12132 wTmp = pal_cpu_to_be16( ieLen );
12133 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12134 pBuf += sizeof(tANI_U16);
12135 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12136 pBuf += ieLen;
12137 }
12138 else
12139 {
12140 pSession->nAddIEAssocLength = 0;
12141 if(pSession->pAddIEAssoc)
12142 {
12143 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12144 pSession->pAddIEAssoc = NULL;
12145 }
12146 *pBuf = 0;
12147 *(pBuf + 1) = 0;
12148 pBuf += 2;
12149 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012150
12151 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012153 //Unmask any AC in reassoc that is ACM-set
12154 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12155 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012157 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12158 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012159#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012160 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012161#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012162 uapsd_mask &= ~(acm_mask);
12163 }
12164 else
12165 {
12166 uapsd_mask = 0;
12167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 }
12169 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012170
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12172 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012173 pBuf += sizeof(tANI_U32);
12174
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12176 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012177 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012178#ifdef WLAN_FEATURE_11W
12179 //MgmtEncryption
12180 if (pProfile->MFPEnabled)
12181 {
12182 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12183 }
12184 else
12185 {
12186 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12187 }
12188 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12189 pBuf += sizeof(tANI_U32);
12190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012191#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012192 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012193 if (csrIsProfile11r( pProfile )
12194#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012195 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12196 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012197#endif
12198 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012199 {
12200 // is11Rconnection;
12201 dwTmp = pal_cpu_to_be32(TRUE);
12202 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12203 pBuf += sizeof(tAniBool);
12204 }
12205 else
12206 {
12207 // is11Rconnection;
12208 dwTmp = pal_cpu_to_be32(FALSE);
12209 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12210 pBuf += sizeof(tAniBool);
12211 }
12212#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012213#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012214
12215 // isCCXFeatureIniEnabled
12216 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12217 {
12218 dwTmp = pal_cpu_to_be32(TRUE);
12219 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12220 pBuf += sizeof(tAniBool);
12221 }
12222 else
12223 {
12224 dwTmp = pal_cpu_to_be32(FALSE);
12225 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12226 pBuf += sizeof(tAniBool);
12227 }
12228
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012229 /* A profile can not be both CCX and 11R. But an 802.11R AP
12230 * may be advertising support for CCX as well. So if we are
12231 * associating Open or explicitly CCX then we will get CCX.
12232 * If we are associating explictly 11R only then we will get
12233 * 11R.
12234 */
12235 if ((csrIsProfileCCX(pProfile) ||
12236 ((pIes->CCXVersion.present)
12237 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012238 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12239 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12240 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012241#ifdef WLAN_FEATURE_11W
12242 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12243#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012244 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012245 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12246 {
12247 // isCCXconnection;
12248 dwTmp = pal_cpu_to_be32(TRUE);
12249 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12250 pBuf += sizeof(tAniBool);
12251 }
12252 else
12253 {
12254 //isCCXconnection;
12255 dwTmp = pal_cpu_to_be32(FALSE);
12256 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12257 pBuf += sizeof(tAniBool);
12258 }
12259
12260 if (eWNI_SME_JOIN_REQ == messageType)
12261 {
12262 tCCXTspecInfo ccxTspec;
12263 // CCX-Tspec IEs in the ASSOC request is presently not supported
12264 // so nullify the TSPEC parameters
12265 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12266 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12267 pBuf += sizeof(tCCXTspecInfo);
12268 }
12269 else if (eWNI_SME_REASSOC_REQ == messageType)
12270 {
12271 if ((csrIsProfileCCX(pProfile) ||
12272 ((pIes->CCXVersion.present)
12273 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012274 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12275 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12276 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012277#ifdef WLAN_FEATURE_11W
12278 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12279#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012280 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012281 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012282 {
12283 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 // CCX Tspec information
12285 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12286 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12287 *pBuf = ccxTspec.numTspecs;
12288 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 // Copy the TSPEC information only if present
12290 if (ccxTspec.numTspecs) {
12291 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12292 }
12293 pBuf += sizeof(ccxTspec.tspec);
12294 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012295 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 tCCXTspecInfo ccxTspec;
12298 // CCX-Tspec IEs in the ASSOC request is presently not supported
12299 // so nullify the TSPEC parameters
12300 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12301 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12302 pBuf += sizeof(tCCXTspecInfo);
12303 }
12304 }
12305#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012306#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012308 if (pMac->roam.configParam.isFastTransitionEnabled
12309#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012310 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012311#endif
12312 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012314 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012316 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 }
12318 else
12319 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012320 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012321 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012322 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 }
12324#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012325#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012326 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012327 {
12328 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012329 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012330 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012331 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012332 }
12333 else
12334 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012335 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012336 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012337 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012338 }
12339#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012340
12341 // txLdpcIniFeatureEnabled
12342 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12343 pBuf++;
12344
Kiran4a17ebe2013-01-31 10:43:43 -080012345 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12346 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12347 {
12348 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12349 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12350 csrApplyPower2Current(pMac);
12351 }
12352
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012353#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012354 // txBFIniFeatureEnabled
12355 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12356 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012357
12358 // txBFCsnValue
12359 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12360 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012361#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012362 //BssDesc
12363 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12364 (tANI_U8)pProfile->uapsd_mask);
12365 status = palSendMBMessage(pMac->hHdd, pMsg );
12366 if(!HAL_STATUS_SUCCESS(status))
12367 {
12368 break;
12369 }
12370 else
12371 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012372#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012373 if (eWNI_SME_JOIN_REQ == messageType)
12374 {
12375 //Tush-QoS: notify QoS module that join happening
12376 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12377 }
12378 else if (eWNI_SME_REASSOC_REQ == messageType)
12379 {
12380 //Tush-QoS: notify QoS module that reassoc happening
12381 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012383#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012387}
12388
Jeff Johnson295189b2012-06-20 16:38:30 -070012389//
12390eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12391{
12392 eHalStatus status = eHAL_STATUS_SUCCESS;
12393 tSirSmeDisassocReq *pMsg;
12394 tANI_U8 *pBuf;
12395 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12397 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12398 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 do {
12400 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12401 if ( !HAL_STATUS_SUCCESS(status) ) break;
12402 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12403 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12404 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 pBuf = &pMsg->sessionId;
12406 // sessionId
12407 *pBuf++ = (tANI_U8)sessionId;
12408 // transactionId
12409 *pBuf = 0;
12410 *( pBuf + 1 ) = 0;
12411 pBuf += sizeof(tANI_U16);
12412
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012413 if ( (pSession->pCurRoamProfile != NULL) &&
12414 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12415 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012416 {
12417 // Set the bssid address before sending the message to LIM
12418 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12419 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012420 // Set the peer MAC address before sending the message to LIM
12421 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12422 pBuf = pBuf + sizeof ( tSirMacAddr );
12423 }
12424 else
12425 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 // Set the peer MAC address before sending the message to LIM
12427 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12428 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12430 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 if(!HAL_STATUS_SUCCESS(status))
12433 {
12434 palFreeMemory(pMac->hHdd, pMsg);
12435 break;
12436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 // reasonCode
12438 wTmp = pal_cpu_to_be16(reasonCode);
12439 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12440 if(!HAL_STATUS_SUCCESS(status))
12441 {
12442 palFreeMemory(pMac->hHdd, pMsg);
12443 break;
12444 }
12445 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12447 Here we should not send the disassoc over the air to the AP */
12448 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12449#ifdef WLAN_FEATURE_VOWIFI_11R
12450 && csrRoamIs11rAssoc(pMac)
12451#endif
12452 )
12453 {
12454 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12455 }
12456 pBuf += sizeof(tANI_U8);
12457 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 return( status );
12460}
Jeff Johnson295189b2012-06-20 16:38:30 -070012461eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12462{
12463 eHalStatus status = eHAL_STATUS_SUCCESS;
12464 tSirSmeTkipCntrMeasReq *pMsg;
12465 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 do
12467 {
12468 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12469 if ( !HAL_STATUS_SUCCESS(status) ) break;
12470 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12471 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12472 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 pBuf = &pMsg->sessionId;
12474 // sessionId
12475 *pBuf++ = (tANI_U8)sessionId;
12476 // transactionId
12477 *pBuf = 0;
12478 *( pBuf + 1 ) = 0;
12479 pBuf += sizeof(tANI_U16);
12480 // bssid
12481 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12482 pBuf = pBuf + sizeof ( tSirMacAddr );
12483 // bEnable
12484 *pBuf = (tANI_BOOLEAN)bEnable;
12485 if(!HAL_STATUS_SUCCESS(status))
12486 {
12487 palFreeMemory(pMac->hHdd, pMsg);
12488 break;
12489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 return( status );
12493}
Jeff Johnson295189b2012-06-20 16:38:30 -070012494eHalStatus
12495csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12496 VOS_MODULE_ID modId, tSirMacAddr bssId,
12497 void *pUsrContext, void *pfnSapEventCallback,
12498 tANI_U8 *pAssocStasBuf )
12499{
12500 eHalStatus status = eHAL_STATUS_SUCCESS;
12501 tSirSmeGetAssocSTAsReq *pMsg;
12502 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12503 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 do
12505 {
12506 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12507 if (!HAL_STATUS_SUCCESS(status)) break;
12508 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12509 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 pBuf = (tANI_U8 *)&pMsg->bssId;
12511 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012512 // bssId
12513 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12514 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 // modId
12516 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12517 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12518 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 // pUsrContext
12520 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12521 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12522 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 // pfnSapEventCallback
12524 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12525 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12526 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 // pAssocStasBuf
12528 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12529 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12530 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 status = palSendMBMessage( pMac->hHdd, pMsg );
12533 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 return( status );
12535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012536eHalStatus
12537csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12538 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12539 {
12540 eHalStatus status = eHAL_STATUS_SUCCESS;
12541 tSirSmeGetWPSPBCSessionsReq *pMsg;
12542 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12543 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 do
12545 {
12546 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12547 if (!HAL_STATUS_SUCCESS(status)) break;
12548 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12549 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012550 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070012551 VOS_ASSERT(pBuf);
12552
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012554 // pUsrContext
12555 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12556 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12557 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012558 // pSapEventCallback
12559 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12560 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12561 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 // bssId
12563 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12564 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 // MAC Address of STA in WPS session
12566 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12567 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 return( status );
12572}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012573
12574eHalStatus
12575csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12576{
12577 tpSirChangeBIParams pMsg;
12578 tANI_U16 len = 0;
12579 eHalStatus status = eHAL_STATUS_SUCCESS;
12580 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12581
12582 if(!pSession)
12583 {
12584 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12585 return eHAL_STATUS_FAILURE;
12586 }
12587
12588 //NO need to update the Beacon Params if update beacon parameter flag is not set
12589 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12590 return eHAL_STATUS_SUCCESS;
12591
12592 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12593
12594 /* Create the message and send to lim */
12595 len = sizeof(tSirChangeBIParams);
12596 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12597 if(HAL_STATUS_SUCCESS(status))
12598 {
12599 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12600 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12601 pMsg->length = len;
12602
12603 // bssId
12604 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012605 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 -080012606 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12607 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12608 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012609 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012610 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12611 status = palSendMBMessage(pMac->hHdd, pMsg);
12612 }
12613 return status;
12614}
12615
Jeff Johnson295189b2012-06-20 16:38:30 -070012616eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12617{
12618 eHalStatus status = eHAL_STATUS_SUCCESS;
12619 tSirSmeDeauthReq *pMsg;
12620 tANI_U8 *pBuf;
12621 tANI_U16 wTmp;
12622 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12623 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12624 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 do {
12626 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12627 if ( !HAL_STATUS_SUCCESS(status) ) break;
12628 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12629 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12630 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12631 //sessionId
12632 pBuf = &pMsg->sessionId;
12633 *pBuf++ = (tANI_U8)sessionId;
12634
12635 //tansactionId
12636 *pBuf = 0;
12637 *(pBuf + 1 ) = 0;
12638 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12642 // Set the BSSID before sending the message to LIM
12643 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12644 pBuf = pBuf + sizeof(tSirMacAddr);
12645 }
12646 else
12647 {
12648 // Set the BSSID before sending the message to LIM
12649 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12650 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 }
12652 if(!HAL_STATUS_SUCCESS(status))
12653 {
12654 palFreeMemory(pMac->hHdd, pMsg);
12655 break;
12656 }
12657 // Set the peer MAC address before sending the message to LIM
12658 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12659 pBuf = pBuf + sizeof(tSirMacAddr);
12660 if(!HAL_STATUS_SUCCESS(status))
12661 {
12662 palFreeMemory(pMac->hHdd, pMsg);
12663 break;
12664 }
12665 wTmp = pal_cpu_to_be16(reasonCode);
12666 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12667 if(!HAL_STATUS_SUCCESS(status))
12668 {
12669 palFreeMemory(pMac->hHdd, pMsg);
12670 break;
12671 }
12672 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 return( status );
12675}
12676
Jeff Johnson295189b2012-06-20 16:38:30 -070012677eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12678{
12679 eHalStatus status = eHAL_STATUS_SUCCESS;
12680 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 do {
12682 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12683 if ( !HAL_STATUS_SUCCESS(status) ) break;
12684 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12685 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12686 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12687 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12688 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12689 if(!HAL_STATUS_SUCCESS(status))
12690 {
12691 palFreeMemory(pMac->hHdd, pMsg);
12692 break;
12693 }
12694//To test reconn
12695 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12696 if(!HAL_STATUS_SUCCESS(status))
12697 {
12698 palFreeMemory(pMac->hHdd, pMsg);
12699 break;
12700 }
12701//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 return( status );
12705}
12706
Jeff Johnson295189b2012-06-20 16:38:30 -070012707eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12708{
12709 eHalStatus status = eHAL_STATUS_SUCCESS;
12710 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 do {
12712 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12713 if ( !HAL_STATUS_SUCCESS(status) ) break;
12714 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12715 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12716 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12717 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12718 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12719 if(!HAL_STATUS_SUCCESS(status))
12720 {
12721 palFreeMemory(pMac->hHdd, pMsg);
12722 break;
12723 }
12724 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12725 if(!HAL_STATUS_SUCCESS(status))
12726 {
12727 palFreeMemory(pMac->hHdd, pMsg);
12728 break;
12729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 return( status );
12733}
Jeff Johnson295189b2012-06-20 16:38:30 -070012734eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12735{
12736 eHalStatus status = eHAL_STATUS_SUCCESS;
12737 tSirSmeAssocCnf *pMsg;
12738 tANI_U8 *pBuf;
12739 tSirResultCodes statusCode;
12740 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 do {
12742 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12743 if ( !HAL_STATUS_SUCCESS(status) ) break;
12744 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12745 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12746 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 pBuf = (tANI_U8 *)&pMsg->statusCode;
12748 if(HAL_STATUS_SUCCESS(Halstatus))
12749 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12750 else
12751 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12752 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12753 pBuf += sizeof(tSirResultCodes);
12754 // bssId
12755 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12756 pBuf += sizeof (tSirMacAddr);
12757 // peerMacAddr
12758 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12759 pBuf += sizeof (tSirMacAddr);
12760 // aid
12761 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12762 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12763 pBuf += sizeof (tANI_U16);
12764 // alternateBssId
12765 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12766 pBuf += sizeof (tSirMacAddr);
12767 // alternateChannelId
12768 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 status = palSendMBMessage( pMac->hHdd, pMsg );
12770 if(!HAL_STATUS_SUCCESS(status))
12771 {
12772 //pMsg is freed by palSendMBMessage
12773 break;
12774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 return( status );
12777}
Jeff Johnson295189b2012-06-20 16:38:30 -070012778eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12779 tpSirSmeAssocInd pAssocInd,
12780 eHalStatus Halstatus,
12781 tANI_U8 sessionId)
12782{
12783 tSirMsgQ msgQ;
12784 eHalStatus status = eHAL_STATUS_SUCCESS;
12785 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12786 tANI_U8 *pBuf;
12787 tSirResultCodes statusCode;
12788 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 do {
12790 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12791 if ( !HAL_STATUS_SUCCESS(status) ) break;
12792 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012793
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12795 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12796
12797 pMsg->sessionId = sessionId;
12798
12799 pBuf = (tANI_U8 *)&pMsg->statusCode;
12800 if(HAL_STATUS_SUCCESS(Halstatus))
12801 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12802 else
12803 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12804 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12805 pBuf += sizeof(tSirResultCodes);
12806 // bssId
12807 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12808 pBuf += sizeof (tSirMacAddr);
12809 // peerMacAddr
12810 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12811 pBuf += sizeof (tSirMacAddr);
12812 // StaId
12813 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12814 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12815 pBuf += sizeof (tANI_U16);
12816 // alternateBssId
12817 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12818 pBuf += sizeof (tSirMacAddr);
12819 // alternateChannelId
12820 *pBuf = 11;
12821 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012822 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 //Wmm
12824 *pBuf = pAssocInd->wmmEnabledSta;
12825 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 //RSN IE
12827 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12828 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 //Additional IE
12830 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12831 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 //reassocReq
12833 *pBuf = pAssocInd->reassocReq;
12834 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12836 msgQ.bodyptr = pMsg;
12837 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 return( status );
12841}
Jeff Johnson295189b2012-06-20 16:38:30 -070012842
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012843eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12845 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12846 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12847 tANI_U8 *pKeyRsc )
12848{
12849 tSirSmeSetContextReq *pMsg;
12850 tANI_U16 msgLen;
12851 eHalStatus status = eHAL_STATUS_FAILURE;
12852 tAniEdType tmpEdType;
12853 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012854 tANI_U8 *pBuf = NULL;
12855 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12860 // key set. Since we only support upto one key, we always allocate memory for 1 key
12861 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12862 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12863 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12864 ( sizeof( pMsg->keyMaterial.key ) );
12865
12866 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12867 if ( !HAL_STATUS_SUCCESS(status) ) break;
12868 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12869 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12870 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 //sessionId
12872 pBuf = &pMsg->sessionId;
12873 *pBuf = (tANI_U8)sessionId;
12874 pBuf++;
12875 // transactionId
12876 *pBuf = 0;
12877 *(pBuf + 1) = 0;
12878 pBuf += sizeof(tANI_U16);
12879 // peerMacAddr
12880 palCopyMemory( pMac->hHdd, pBuf,
12881 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12882
12883 pBuf += sizeof(tSirMacAddr);
12884
12885 // bssId
12886 palCopyMemory( pMac->hHdd, pBuf,
12887 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12888
12889 pBuf += sizeof(tSirMacAddr);
12890
12891 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12893 // in the tSirKeyMaterial keyMaterial; field).
12894 //
12895 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12896 // shorter than this max size. Is LIM interpreting this ok ?
12897 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 -070012898 // set pMsg->keyMaterial.edType
12899 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12900 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12901 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 // set the pMsg->keyMaterial.numKeys field
12903 *p = numKeys;
12904 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 // set pSirKey->keyId = keyId;
12906 *p = keyId;
12907 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 // set pSirKey->unicast = (tANI_U8)fUnicast;
12909 *p = (tANI_U8)fUnicast;
12910 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 // set pSirKey->keyDirection = aniKeyDirection;
12912 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12913 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12914 p += sizeof(tAniKeyDirection);
12915 // pSirKey->keyRsc = ;;
12916 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12917 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 // set pSirKey->paeRole
12919 *p = paeRole; // 0 is Supplicant
12920 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 // set pSirKey->keyLength = keyLength;
12922 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 if ( keyLength && pKey )
12924 {
12925 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12926 if(keyLength == 16)
12927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012928 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 -070012929 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12930 pKey[5], pKey[6], pKey[7], pKey[8],
12931 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12932 }
12933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012935 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 return( status );
12937}
12938
Jeff Johnson295189b2012-06-20 16:38:30 -070012939eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12940 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12941{
12942 eHalStatus status;
12943 tSirSmeStartBssReq *pMsg;
12944 tANI_U8 *pBuf = NULL;
12945 tANI_U8 *wTmpBuf = NULL;
12946 tANI_U16 msgLen, wTmp;
12947 tANI_U32 dwTmp;
12948 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012949 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012952
12953 if(!pSession)
12954 {
12955 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12956 return eHAL_STATUS_FAILURE;
12957 }
12958
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 do {
12960 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12961 pSession->joinFailStatusCode.reasonCode = 0;
12962 msgLen = sizeof(tSirSmeStartBssReq);
12963 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12964 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012965 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12966 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 //sessionId
12970 *pBuf = (tANI_U8)sessionId;
12971 pBuf++;
12972 // transactionId
12973 *pBuf = 0;
12974 *(pBuf + 1) = 0;
12975 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 // bssid
12977 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12978 pBuf += sizeof(tSirMacAddr);
12979 // selfMacAddr
12980 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12981 pBuf += sizeof(tSirMacAddr);
12982 // beaconInterval
12983 if( pBssDesc && pBssDesc->beaconInterval )
12984 {
12985 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 else if(pParam->beaconInterval)
12988 {
12989 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 else
12992 {
12993 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12994 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012995 if(csrIsconcurrentsessionValid (pMac, sessionId,
12996 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012997 == eHAL_STATUS_SUCCESS )
12998 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012999 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013000 pParam->bssPersona);
13001 //Update the beacon Interval
13002 pParam->beaconInterval = wTmp;
13003 }
13004 else
13005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013006 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013007 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070013008 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070013009 return status;
13010 }
13011
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13013 pBuf += sizeof(tANI_U16);
13014 // dot11mode
13015 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13016 pBuf += 1;
13017 // bssType
13018 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
13019 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
13020 pBuf += sizeof(tSirBssType);
13021 // ssId
13022 if( pParam->ssId.length )
13023 {
13024 // ssId len
13025 *pBuf = pParam->ssId.length;
13026 pBuf++;
13027 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
13028 pBuf += pParam->ssId.length;
13029 }
13030 else
13031 {
13032 *pBuf = 0;
13033 pBuf++;
13034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 // set the channel Id
13036 *pBuf = pParam->operationChn;
13037 pBuf++;
13038 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013039 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
13040 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
13041 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013042
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 // Set privacy
13044 *pBuf = pParam->privacy;
13045 pBuf++;
13046
13047 //Set Uapsd
13048 *pBuf = pParam->ApUapsdEnable;
13049 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 //Set SSID hidden
13051 *pBuf = pParam->ssidHidden;
13052 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13054 pBuf++;
13055
13056 //Ht protection Enable/Disable
13057 *pBuf = (tANI_U8)pParam->protEnabled;
13058 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 //Enable Beacons to Receive for OBSS protection Enable/Disable
13060 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13061 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 //set cfg related to protection
13063 wTmp = pal_cpu_to_be16( pParam->ht_protection );
13064 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13065 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 // Set Auth type
13067 authType = pal_cpu_to_be32(pParam->authType);
13068 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
13069 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 // Set DTIM
13071 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
13072 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
13073 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 // Set wps_state
13075 *pBuf = pParam->wps_state;
13076 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 //Persona
13078 *pBuf = (tANI_U8)pParam->bssPersona;
13079 pBuf++;
13080
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013081 //txLdpcIniFeatureEnabled
13082 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13083 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013084
krunal soni4f087d22013-07-29 16:32:26 -070013085 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13087 {
13088 status = eHAL_STATUS_INVALID_PARAMETER;
13089 palFreeMemory( pMac->hHdd, pMsg );
13090 break;
13091 }
13092 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
13093 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
13094 pBuf += sizeof(tANI_U16);
13095 if( wTmp )
13096 {
13097 wTmp = pParam->nRSNIELength;
13098 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13099 pBuf += wTmp;
13100 }
13101 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13102 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13103 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13105 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13107 pBuf += pParam->operationalRateSet.numRates ;
13108 *pBuf++ = pParam->extendedRateSet.numRates;
13109 if(0 != pParam->extendedRateSet.numRates)
13110 {
13111 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13112 pBuf += pParam->extendedRateSet.numRates;
13113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13115 pMsg->length = pal_cpu_to_be16(msgLen);
13116
13117 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 return( status );
13120}
13121
Jeff Johnson295189b2012-06-20 16:38:30 -070013122eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13123{
13124 eHalStatus status = eHAL_STATUS_FAILURE;
13125 tSirSmeStopBssReq *pMsg;
13126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13127 tANI_U8 *pBuf;
13128 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013129
13130 if(!pSession)
13131 {
13132 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13133 return eHAL_STATUS_FAILURE;
13134 }
13135
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 do {
13137 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13138 if ( !HAL_STATUS_SUCCESS(status) ) break;
13139 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13140 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13141 pBuf = &pMsg->sessionId;
13142 //sessionId
13143 *pBuf = (tANI_U8)sessionId;
13144 pBuf++;
13145 // transactionId
13146 *pBuf = 0;
13147 pBuf += sizeof(tANI_U16);
13148 //reason code
13149 *pBuf = 0;
13150 pBuf += sizeof(tSirResultCodes);
13151 // bssid
13152 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13153 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13154 {
13155 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13156 }
13157 else
13158 {
13159 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13160 }
13161 pBuf += sizeof(tSirMacAddr);
13162 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13163 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 status = palSendMBMessage( pMac->hHdd, pMsg );
13165#if 0
13166 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13167 if ( !HAL_STATUS_SUCCESS(status) ) break;
13168 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13169 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13170 pMsg->reasonCode = 0;
13171 // bssid
13172 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13173 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13174 {
13175 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13176 }
13177 else
13178 {
13179 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13180 }
13181 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13182 pMsg->transactionId = 0;
13183 pMsg->sessionId = (tANI_U8)sessionId;
13184 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13185 status = palSendMBMessage( pMac->hHdd, pMsg );
13186#endif
13187 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 return( status );
13189}
13190
Jeff Johnson295189b2012-06-20 16:38:30 -070013191eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13192 tCsrRoamModifyProfileFields *pModProfileFields,
13193 tANI_U32 *pRoamId, v_BOOL_t fForce)
13194{
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 eHalStatus status = eHAL_STATUS_FAILURE;
13196 tANI_U32 roamId = 0;
13197 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 if((csrIsConnStateConnected(pMac, sessionId)) &&
13199 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13200 &pSession->connectedProfile.modifyProfileFields,
13201 sizeof(tCsrRoamModifyProfileFields)))) )
13202 {
13203 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13204 if(pRoamId)
13205 {
13206 *pRoamId = roamId;
13207 }
13208
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13210 eCsrSmeIssuedReassocToSameAP, roamId,
13211 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 return status;
13214}
Jeff Johnson295189b2012-06-20 16:38:30 -070013215static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13216{
13217 eHalStatus status = eHAL_STATUS_SUCCESS;
13218 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13220 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13221 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13222 return (status);
13223}
Jeff Johnson295189b2012-06-20 16:38:30 -070013224eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13225{
13226 eHalStatus status = eHAL_STATUS_SUCCESS;
13227 tListElem *pEntry = NULL;
13228 tSmeCmd *pCommand = NULL;
13229 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 do
13231 {
13232 if(pMsg == NULL)
13233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013234 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 status = eHAL_STATUS_FAILURE;
13236 break;
13237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13239 if(pEntry)
13240 {
13241 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13242 if(eSmeCommandAddStaSession == pCommand->command)
13243 {
13244 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013245 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 //Remove this command out of the active list
13249 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13250 {
13251 //Now put this command back on the avilable command list
13252 csrReleaseCommand(pMac, pCommand);
13253 }
13254 smeProcessPendingQueue( pMac );
13255 }
13256 else
13257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013258 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 -070013259 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 status = eHAL_STATUS_FAILURE;
13261 break;
13262 }
13263 }
13264 else
13265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013266 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 -070013267 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 status = eHAL_STATUS_FAILURE;
13269 break;
13270 }
13271 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013274eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13275 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013276{
13277 tSirSmeAddStaSelfReq *pMsg;
13278 tANI_U16 msgLen;
13279 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013281 msgLen = sizeof(tSirSmeAddStaSelfReq);
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13283 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13286 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 // self station address
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013288 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr,
13289 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13290
13291 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13292
13293 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 pMsg->selfMacAddr[0],
13295 pMsg->selfMacAddr[1],
13296 pMsg->selfMacAddr[2],
13297 pMsg->selfMacAddr[3],
13298 pMsg->selfMacAddr[4],
13299 pMsg->selfMacAddr[5]);
13300 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 return( status );
13303}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013304eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13305 tANI_U32 sessionId,
13306 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013307{
13308 eHalStatus status = eHAL_STATUS_SUCCESS;
13309 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 pCommand = csrGetCommandBuffer(pMac);
13311 if(NULL == pCommand)
13312 {
13313 status = eHAL_STATUS_RESOURCES;
13314 }
13315 else
13316 {
13317 pCommand->command = eSmeCommandAddStaSession;
13318 pCommand->sessionId = (tANI_U8)sessionId;
13319 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013320 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13322 if( !HAL_STATUS_SUCCESS( status ) )
13323 {
13324 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013325 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 }
13327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 return (status);
13329}
Jeff Johnson295189b2012-06-20 16:38:30 -070013330eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13331{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013332 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013333}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013334eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13335 csrRoamCompleteCallback callback,
13336 void *pContext, tANI_U8 *pSelfMacAddr,
13337 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013338{
13339 eHalStatus status = eHAL_STATUS_SUCCESS;
13340 tANI_U32 i;
13341 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 *pbSessionId = CSR_SESSION_ID_INVALID;
13343 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13344 {
13345 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13346 {
13347 pSession = CSR_GET_SESSION( pMac, i );
13348 status = eHAL_STATUS_SUCCESS;
13349 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13350 pSession->sessionId = (tANI_U8)i;
13351 pSession->callback = callback;
13352 pSession->pContext = pContext;
13353 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13354 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013355 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13356 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013358 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013360 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 break;
13362 }
13363#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013364 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13365 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013367 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013369 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 break;
13371 }
13372#endif
13373 pSession->ibssJoinTimerInfo.pMac = pMac;
13374 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013375 status = vos_timer_init(&pSession->hTimerIbssJoining, VOS_TIMER_TYPE_SW,
13376 csrRoamIbssJoinTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 &pSession->ibssJoinTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013378 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013380 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013381 break;
13382 }
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013383 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 break;
13385 }
13386 }
13387 if( CSR_ROAM_SESSION_MAX == i )
13388 {
13389 //No session is available
13390 status = eHAL_STATUS_RESOURCES;
13391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 return ( status );
13393}
Jeff Johnson295189b2012-06-20 16:38:30 -070013394eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13395{
13396 eHalStatus status = eHAL_STATUS_SUCCESS;
13397 tListElem *pEntry = NULL;
13398 tSmeCmd *pCommand = NULL;
13399 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 do
13401 {
13402 if(pMsg == NULL)
13403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013404 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 status = eHAL_STATUS_FAILURE;
13406 break;
13407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13409 if(pEntry)
13410 {
13411 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13412 if(eSmeCommandDelStaSession == pCommand->command)
13413 {
13414 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013416 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 //This session is done.
13418 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 if(pCommand->u.delStaSessionCmd.callback)
13420 {
13421
13422 status = sme_ReleaseGlobalLock( &pMac->sme );
13423 if ( HAL_STATUS_SUCCESS( status ) )
13424 {
13425 pCommand->u.delStaSessionCmd.callback(
13426 pCommand->u.delStaSessionCmd.pContext);
13427 status = sme_AcquireGlobalLock( &pMac->sme );
13428 if (! HAL_STATUS_SUCCESS( status ) )
13429 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013430 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 return status;
13432 }
13433 }
13434 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013435 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013436 }
13437 }
13438
13439 //Remove this command out of the active list
13440 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13441 {
13442 //Now put this command back on the avilable command list
13443 csrReleaseCommand(pMac, pCommand);
13444 }
13445 smeProcessPendingQueue( pMac );
13446 }
13447 else
13448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013449 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 -070013450 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 status = eHAL_STATUS_FAILURE;
13452 break;
13453 }
13454 }
13455 else
13456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013457 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 -070013458 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 status = eHAL_STATUS_FAILURE;
13460 break;
13461 }
13462 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013464}
Jeff Johnson295189b2012-06-20 16:38:30 -070013465eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13466{
13467 tSirSmeDelStaSelfReq *pMsg;
13468 tANI_U16 msgLen;
13469 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13472 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13474 if ( !HAL_STATUS_SUCCESS(status) ) break;
13475
13476 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13478 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 // self station address
13480 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 return( status );
13484}
Jeff Johnson295189b2012-06-20 16:38:30 -070013485eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13486 tSirMacAddr sessionMacAddr,
13487 csrRoamSessionCloseCallback callback,
13488 void *pContext)
13489{
13490 eHalStatus status = eHAL_STATUS_SUCCESS;
13491 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 pCommand = csrGetCommandBuffer(pMac);
13493 if(NULL == pCommand)
13494 {
13495 status = eHAL_STATUS_RESOURCES;
13496 }
13497 else
13498 {
13499 pCommand->command = eSmeCommandDelStaSession;
13500 pCommand->sessionId = (tANI_U8)sessionId;
13501 pCommand->u.delStaSessionCmd.callback = callback;
13502 pCommand->u.delStaSessionCmd.pContext = pContext;
13503 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13505 if( !HAL_STATUS_SUCCESS( status ) )
13506 {
13507 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013508 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 }
13510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 return (status);
13512}
Jeff Johnson295189b2012-06-20 16:38:30 -070013513eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13514{
13515 return csrSendMBDelSelfStaReqMsg( pMac,
13516 pCommand->u.delStaSessionCmd.selfMacAddr );
13517}
Jeff Johnson295189b2012-06-20 16:38:30 -070013518static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13519{
13520 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13521 tListElem *pEntry, *pNext;
13522 tSmeCmd *pCommand;
13523 tDblLinkList localList;
13524
13525 vos_mem_zero(&localList, sizeof(tDblLinkList));
13526 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13527 {
13528 smsLog(pMac, LOGE, FL(" failed to open list"));
13529 return;
13530 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 csrLLLock(pList);
13532 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13533 while(pEntry != NULL)
13534 {
13535 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13536 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13537 if(pCommand->sessionId == sessionId)
13538 {
13539 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13540 {
13541 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13542 }
13543 }
13544 pEntry = pNext;
13545 }
13546 csrLLUnlock(pList);
13547
13548 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13549 {
13550 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13551 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13552 }
13553 csrLLClose(&localList);
13554}
13555
Jeff Johnson295189b2012-06-20 16:38:30 -070013556void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13557{
13558 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13559 {
13560 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 csrRoamStop(pMac, sessionId);
13562 csrFreeConnectBssDesc(pMac, sessionId);
13563 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13564 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013565 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070013566#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013567 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013568#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013569 vos_timer_destroy(&pSession->hTimerIbssJoining);
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 purgeSmeSessionCmdList(pMac, sessionId);
13571 purgeCsrSessionCmdList(pMac, sessionId);
13572 csrInitSession(pMac, sessionId);
13573 }
13574}
13575
Jeff Johnson295189b2012-06-20 16:38:30 -070013576eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13577 tANI_BOOLEAN fSync,
13578 csrRoamSessionCloseCallback callback,
13579 void *pContext )
13580{
13581 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13583 {
13584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13585 if(fSync)
13586 {
13587 csrCleanupSession(pMac, sessionId);
13588 }
13589 else
13590 {
13591 purgeSmeSessionCmdList(pMac, sessionId);
13592 purgeCsrSessionCmdList(pMac, sessionId);
13593 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13594 pSession->selfMacAddr, callback, pContext);
13595 }
13596 }
13597 else
13598 {
13599 status = eHAL_STATUS_INVALID_PARAMETER;
13600 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 return ( status );
13602}
13603
Jeff Johnson295189b2012-06-20 16:38:30 -070013604static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13605{
13606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013607
13608 if(!pSession)
13609 {
13610 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13611 return;
13612 }
13613
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13615 pSession->sessionId = CSR_SESSION_ID_INVALID;
13616 pSession->callback = NULL;
13617 pSession->pContext = NULL;
13618 pSession->ibss_join_pending = FALSE;
13619 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13620 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13621 csrFreeRoamProfile( pMac, sessionId );
13622 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13623 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13624 csrFreeConnectBssDesc(pMac, sessionId);
13625 csrScanEnable(pMac);
13626 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13627 if(pSession->pWpaRsnReqIE)
13628 {
13629 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13630 pSession->pWpaRsnReqIE = NULL;
13631 }
13632 pSession->nWpaRsnReqIeLength = 0;
13633 if(pSession->pWpaRsnRspIE)
13634 {
13635 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13636 pSession->pWpaRsnRspIE = NULL;
13637 }
13638 pSession->nWpaRsnRspIeLength = 0;
13639#ifdef FEATURE_WLAN_WAPI
13640 if(pSession->pWapiReqIE)
13641 {
13642 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13643 pSession->pWapiReqIE = NULL;
13644 }
13645 pSession->nWapiReqIeLength = 0;
13646 if(pSession->pWapiRspIE)
13647 {
13648 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13649 pSession->pWapiRspIE = NULL;
13650 }
13651 pSession->nWapiRspIeLength = 0;
13652#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 if(pSession->pAddIEScan)
13654 {
13655 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13656 pSession->pAddIEScan = NULL;
13657 }
13658 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 if(pSession->pAddIEAssoc)
13660 {
13661 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13662 pSession->pAddIEAssoc = NULL;
13663}
13664 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013665}
13666
Jeff Johnson295189b2012-06-20 16:38:30 -070013667eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13668{
13669 eHalStatus status = eHAL_STATUS_FAILURE;
13670 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13672 {
13673 if( CSR_IS_SESSION_VALID( pMac, i ) )
13674 {
13675 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13676 {
13677 //Found it
13678 status = eHAL_STATUS_SUCCESS;
13679 *pSessionId = i;
13680 break;
13681 }
13682 }
13683 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 return( status );
13685}
13686
Jeff Johnson295189b2012-06-20 16:38:30 -070013687//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13688//session because for IBSS, the bssid changes.
13689static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13690{
13691 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13692 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13694 {
13695 if( CSR_IS_SESSION_VALID( pMac, i ) )
13696 {
13697 pSession = CSR_GET_SESSION( pMac, i );
13698 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13699 {
13700 //Found it
13701 nRet = i;
13702 break;
13703 }
13704 }
13705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 return (nRet);
13707}
Jeff Johnson295189b2012-06-20 16:38:30 -070013708static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13709{
13710 /* Update the current BSS info in ho control block based on connected
13711 profile info from pmac global structure */
13712
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013713 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13715 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 /* Check for user misconfig of RSSI trigger threshold */
13717 pMac->roam.configParam.vccRssiThreshold =
13718 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13719 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13720 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 /* Check for user misconfig of UL MAC Loss trigger threshold */
13722 pMac->roam.configParam.vccUlMacLossThreshold =
13723 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13724 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013725#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13726 {
13727 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013728 /* Indicate the neighbor roal algorithm about the connect indication */
13729 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13730 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13731 }
13732#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013733}
13734
Jeff Johnson295189b2012-06-20 16:38:30 -070013735static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13736{
13737 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013738
13739 if(!pSession)
13740 {
13741 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13742 return;
13743 }
13744
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 //Only to handle the case for Handover on infra link
13746 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13747 {
13748 return;
13749 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13751 csrRoamDeregStatisticsReq(pMac);
13752 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13753#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13754 /* Indicate the neighbor roal algorithm about the disconnect indication */
13755 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13756#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013757
13758 //Remove this code once SLM_Sessionization is supported
13759 //BMPS_WORKAROUND_NOT_NEEDED
13760 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013761 csrIsInfraApStarted( pMac ) &&
13762 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013763 {
13764 pMac->roam.configParam.doBMPSWorkaround = 0;
13765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013766}
13767
Jeff Johnson295189b2012-06-20 16:38:30 -070013768void csrRoamTlStatsTimerHandler(void *pv)
13769{
13770 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13771 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13773
Jeff Johnsone7245742012-09-05 17:12:55 -070013774 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13775
Jeff Johnson295189b2012-06-20 16:38:30 -070013776#if 0
13777 // TODO Persession .???
13778 //req TL for stats
13779 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13780 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013781 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 }
13783 else
13784 {
13785 //save in SME
13786 csrRoamSaveStatsFromTl(pMac, tlStats);
13787 }
13788#endif
13789 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13790 {
13791 if(pMac->roam.tlStatsReqInfo.periodicity)
13792 {
13793 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013794 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13795 pMac->roam.tlStatsReqInfo.periodicity);
13796 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013798 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 return;
13800 }
13801 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13802 }
13803 }
13804}
Jeff Johnson295189b2012-06-20 16:38:30 -070013805void csrRoamPeStatsTimerHandler(void *pv)
13806{
13807 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13808 eHalStatus status;
13809 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13810 VOS_STATUS vosStatus;
13811 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 pPeStatsReqListEntry->timerRunning = FALSE;
13813 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13814 {
13815 // If we entered here, meaning the timer could not be successfully
13816 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13817
13818 /* Destroy the timer */
13819 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13820 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13821 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013822 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 }
13824
13825 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013826 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 pPeStatsReqListEntry = NULL;
13828 }
13829 else
13830 {
13831 if(!pPeStatsReqListEntry->rspPending)
13832 {
13833 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13834 pPeStatsReqListEntry->staId);
13835 if(!HAL_STATUS_SUCCESS(status))
13836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013837 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 }
13839 else
13840 {
13841 pPeStatsReqListEntry->rspPending = TRUE;
13842 }
13843 }
13844
13845 //send down a req
13846 if(pPeStatsReqListEntry->periodicity &&
13847 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13848 {
13849 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13850 if(ePMC_FULL_POWER == powerState)
13851 {
13852 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13853 {
13854 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13855 }
13856 }
13857 else
13858 {
13859 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13860 {
13861 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13862 }
13863 }
13864 //start timer
13865 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13866 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013868 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 return;
13870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 pPeStatsReqListEntry->timerRunning = TRUE;
13872
13873 }
13874
13875 }
13876}
Jeff Johnson295189b2012-06-20 16:38:30 -070013877void csrRoamStatsClientTimerHandler(void *pv)
13878{
13879 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13881 {
13882#if 0
13883 // TODO Stats fix for multisession
13884 //start the timer
13885 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13886
13887 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013889 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 }
13891#endif
13892 }
13893#if 0
13894 //send up the stats report
13895 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13896 pStaEntry->staId, pStaEntry->pContext);
13897#endif
13898}
13899
13900
13901
Jeff Johnson295189b2012-06-20 16:38:30 -070013902eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13903{
13904 tAniGetPEStatsReq *pMsg;
13905 eHalStatus status = eHAL_STATUS_SUCCESS;
13906 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13907 if ( !HAL_STATUS_SUCCESS(status) )
13908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013909 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 return status;
13911 }
13912 // need to initiate a stats request to PE
13913 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13914 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13915 pMsg->staId = staId;
13916 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013917 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 if(!HAL_STATUS_SUCCESS(status))
13919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013920 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 return status;
13923}
Jeff Johnson295189b2012-06-20 16:38:30 -070013924void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13925{
13926 tAniGetPEStatsRsp *pSmeStatsRsp;
13927 eHalStatus status = eHAL_STATUS_FAILURE;
13928 tListElem *pEntry = NULL;
13929 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13930 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13931 tANI_U32 tempMask = 0;
13932 tANI_U8 counter = 0;
13933 tANI_U8 *pStats = NULL;
13934 tANI_U32 length = 0;
13935 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013936 v_S7_t rssi = 0, snr = 0;
13937 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013938 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13940 if(pSmeStatsRsp->rc)
13941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013942 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 goto post_update;
13944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 tempMask = pSmeStatsRsp->statsMask;
13946 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 /* subtract all statistics from this length, and after processing the entire
13948 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13949 * in this 'stats' message.
13950 */
13951 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 //new stats info from PE, fill up the stats strucutres in PMAC
13953 while(tempMask)
13954 {
13955 if(tempMask & 1)
13956 {
13957 switch(counter)
13958 {
13959 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013960 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13962 pStats, sizeof(tCsrSummaryStatsInfo));
13963 if(!HAL_STATUS_SUCCESS(status))
13964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013965 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 }
13967 pStats += sizeof(tCsrSummaryStatsInfo);
13968 length -= sizeof(tCsrSummaryStatsInfo);
13969 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013971 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13973 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13974 if(!HAL_STATUS_SUCCESS(status))
13975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013976 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 }
13978 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13979 length -= sizeof(tCsrGlobalClassAStatsInfo);
13980 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013982 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13984 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13985 if(!HAL_STATUS_SUCCESS(status))
13986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013987 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 }
13989 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13990 length -= sizeof(tCsrGlobalClassBStatsInfo);
13991 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013993 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13995 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13996 if(!HAL_STATUS_SUCCESS(status))
13997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013998 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 }
14000 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14001 length -= sizeof(tCsrGlobalClassCStatsInfo);
14002 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014004 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14006 {
14007 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14008 pStats, sizeof(tCsrPerStaStatsInfo));
14009 }
14010 else
14011 {
14012 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014013 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 VOS_ASSERT( 0 );
14015 }
14016 if(!HAL_STATUS_SUCCESS(status))
14017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014018 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 }
14020 pStats += sizeof(tCsrPerStaStatsInfo);
14021 length -= sizeof(tCsrPerStaStatsInfo);
14022 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014024 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 }
14027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 tempMask >>=1;
14029 counter++;
14030 }
14031 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14032 if (length != 0)
14033 {
14034 pRssi = (tANI_U32*)pStats;
14035 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014036 pStats += sizeof(tANI_U32);
14037 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 }
14039 else
14040 {
14041 /* If riva is not sending rssi, continue to use the hack */
14042 rssi = RSSI_HACK_BMPS;
14043 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014044
Jeff Johnson295189b2012-06-20 16:38:30 -070014045 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014046
14047 if (length != 0)
14048 {
14049 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014050 pStats += sizeof(tANI_U32);
14051 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014052 }
14053 else
14054 {
14055 linkCapacity = 0;
14056 }
14057
14058 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014059
14060 if (length != 0)
14061 {
14062 pSnr = (tANI_U32*)pStats;
14063 snr = (v_S7_t)*pSnr;
14064 }
14065 else
14066 {
14067 snr = SNR_HACK_BMPS;
14068 }
14069
14070 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014071post_update:
14072 //make sure to update the pe stats req list
14073 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14074 if(pEntry)
14075 {
14076 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14077 pPeStaEntry->rspPending = FALSE;
14078
14079 }
14080 //check the one timer cases
14081 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14082 if(pEntry)
14083 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 if(pTempStaEntry->timerExpired)
14086 {
14087 //send up the stats report
14088 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14089 pTempStaEntry->staId, pTempStaEntry->pContext);
14090 //also remove from the client list
14091 csrRoamRemoveStatListEntry(pMac, pEntry);
14092 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 }
14094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014095}
Jeff Johnson295189b2012-06-20 16:38:30 -070014096tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14097{
14098 tListElem *pEntry = NULL;
14099 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 if(!pEntry)
14102 {
14103 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014104 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 return NULL;
14106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 while( pEntry )
14108 {
14109 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 if(pTempStaEntry->statsMask == statsMask)
14111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014112 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 break;
14114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 return pEntry;
14118}
14119
Jeff Johnson295189b2012-06-20 16:38:30 -070014120tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14121 tANI_BOOLEAN update)
14122{
14123 tListElem *pEntry;
14124 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 if(!pEntry)
14127 {
14128 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014129 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014130 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 return NULL;
14132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 while( pEntry )
14134 {
14135 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14137 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014139 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 if(update)
14141 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014142 pTempStaEntry->periodicity = pStaEntry->periodicity;
14143 pTempStaEntry->callback = pStaEntry->callback;
14144 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 }
14146 break;
14147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 return pEntry;
14151}
Jeff Johnson295189b2012-06-20 16:38:30 -070014152tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14153{
14154 tListElem *pEntry;
14155 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014157 if(!pEntry)
14158 {
14159 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014160 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014161 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014162 return NULL;
14163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 while( pEntry )
14165 {
14166 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014169 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 break;
14171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 return pEntry;
14175}
Jeff Johnson295189b2012-06-20 16:38:30 -070014176eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14177 csrRoamLinkQualityIndCallback callback,
14178 void *pContext)
14179{
14180 pMac->roam.linkQualityIndInfo.callback = callback;
14181 pMac->roam.linkQualityIndInfo.context = pContext;
14182 if( NULL == callback )
14183 {
14184 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14185 }
14186 else
14187 {
14188 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014189 /* do we need to invoke the callback to notify client of initial value ?? */
14190 }
14191 return eHAL_STATUS_SUCCESS;
14192}
Jeff Johnson295189b2012-06-20 16:38:30 -070014193void csrRoamVccTrigger(tpAniSirGlobal pMac)
14194{
14195 eCsrRoamLinkQualityInd newVccLinkQuality;
14196 tANI_U32 ul_mac_loss = 0;
14197 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014198 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14199 /*-------------------------------------------------------------------------
14200 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 Check for a change in link quality and notify client if necessary
14202 -------------------------------------------------------------------------*/
14203 ul_mac_loss_trigger_threshold =
14204 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014206 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014208 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014210 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14212 }
14213 else
14214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014215 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14219 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014222 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014225 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 newVccLinkQuality );
14227
14228 /* we now invoke the callback once to notify client of initial value */
14229 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14230 pMac->roam.linkQualityIndInfo.context );
14231 //event: EVENT_WLAN_VCC
14232 }
14233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 pMac->roam.vccLinkQuality = newVccLinkQuality;
14235
Jeff Johnson295189b2012-06-20 16:38:30 -070014236}
Jeff Johnson295189b2012-06-20 16:38:30 -070014237VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14238 v_U8_t rssiNotification,
14239 void * context)
14240{
14241 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14242 eCsrRoamLinkQualityInd newVccLinkQuality;
14243 // TODO : Session info unavailable
14244 tANI_U32 sessionId = 0;
14245 VOS_STATUS status = VOS_STATUS_SUCCESS;
14246 /*-------------------------------------------------------------------------
14247 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 Check for a change in link quality and notify client if necessary
14249 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014250 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 pMac->roam.configParam.vccRssiThreshold);
14252 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014254 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 return VOS_STATUS_SUCCESS;
14256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14258 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014259 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14261 }
14262 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014264 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14266 }
14267 else
14268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014269 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 //Set to this so the code below won't do anything
14271 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 VOS_ASSERT(0);
14273 }
14274
Jeff Johnson295189b2012-06-20 16:38:30 -070014275 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014277 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014280 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014282 /* we now invoke the callback once to notify client of initial value */
14283 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14284 pMac->roam.linkQualityIndInfo.context );
14285 //event: EVENT_WLAN_VCC
14286 }
14287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 return status;
14290}
Jeff Johnson295189b2012-06-20 16:38:30 -070014291tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14292 tDblLinkList *pStaList,
14293 tCsrStatsClientReqInfo *pStaEntry)
14294{
14295 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 //if same entity requested for same set of stats with different periodicity &
14298 // callback update it
14299 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14300 {
14301
14302 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14303 if (!HAL_STATUS_SUCCESS(status))
14304 {
14305 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014306 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 return NULL;
14308 }
14309
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 pNewStaEntry->callback = pStaEntry->callback;
14311 pNewStaEntry->pContext = pStaEntry->pContext;
14312 pNewStaEntry->periodicity = pStaEntry->periodicity;
14313 pNewStaEntry->requesterId = pStaEntry->requesterId;
14314 pNewStaEntry->statsMask = pStaEntry->statsMask;
14315 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14316 pNewStaEntry->pMac = pStaEntry->pMac;
14317 pNewStaEntry->staId = pStaEntry->staId;
14318 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14319
14320 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14321 }
14322 return pNewStaEntry;
14323}
14324
Jeff Johnson295189b2012-06-20 16:38:30 -070014325tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14326 tDblLinkList *pStaList,
14327 tCsrPeStatsReqInfo *pStaEntry)
14328{
14329 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14332 if (!HAL_STATUS_SUCCESS(status))
14333 {
14334 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014335 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 return NULL;
14337 }
14338
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14340 pNewStaEntry->numClient = pStaEntry->numClient;
14341 pNewStaEntry->periodicity = pStaEntry->periodicity;
14342 pNewStaEntry->statsMask = pStaEntry->statsMask;
14343 pNewStaEntry->pMac = pStaEntry->pMac;
14344 pNewStaEntry->staId = pStaEntry->staId;
14345 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14346 pNewStaEntry->rspPending = pStaEntry->rspPending;
14347
14348 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 return pNewStaEntry;
14350}
Jeff Johnson295189b2012-06-20 16:38:30 -070014351eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14352 tCsrRssiCallback callback,
14353 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14354{
14355 eHalStatus status = eHAL_STATUS_SUCCESS;
14356 vos_msg_t msg;
14357 tANI_U32 sessionId;
14358
14359 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014360 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14362 if ( !HAL_STATUS_SUCCESS(status) )
14363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014364 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014365 return status;
14366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14368
14369 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14370 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14371 pMsg->sessionId = sessionId;
14372 pMsg->staId = staId;
14373 pMsg->rssiCallback = callback;
14374 pMsg->pDevContext = pContext;
14375 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014376 msg.type = eWNI_SME_GET_RSSI_REQ;
14377 msg.bodyptr = pMsg;
14378 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014381 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 palFreeMemory(pMac->hHdd, (void *)pMsg);
14383 status = eHAL_STATUS_FAILURE;
14384 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014385 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 return status;
14387}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014388
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014389eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14390 tCsrSnrCallback callback,
14391 tANI_U8 staId, tCsrBssid bssId,
14392 void *pContext)
14393{
14394 eHalStatus status = eHAL_STATUS_SUCCESS;
14395 vos_msg_t msg;
14396 tANI_U32 sessionId;
14397
14398 tAniGetSnrReq *pMsg;
14399
14400 smsLog(pMac, LOG2, FL("called"));
14401
14402 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14403 if (NULL == pMsg )
14404 {
14405 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14406 return status;
14407 }
14408
14409 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14410
14411 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14412 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14413 pMsg->sessionId = sessionId;
14414 pMsg->staId = staId;
14415 pMsg->snrCallback = callback;
14416 pMsg->pDevContext = pContext;
14417 msg.type = eWNI_SME_GET_SNR_REQ;
14418 msg.bodyptr = pMsg;
14419 msg.reserved = 0;
14420
14421 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14422 {
14423 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14424 vos_mem_free((v_VOID_t *)pMsg);
14425 status = eHAL_STATUS_FAILURE;
14426 }
14427
14428 smsLog(pMac, LOG2, FL("returned"));
14429 return status;
14430}
14431
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014432#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14433eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14434 tCsrRssiCallback callback,
14435 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14436{
14437 eHalStatus status = eHAL_STATUS_SUCCESS;
14438 tAniGetRssiReq *pMsg;
14439
14440 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14441 if ( !HAL_STATUS_SUCCESS(status) )
14442 {
14443 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14444 return status;
14445 }
14446 // need to initiate a stats request to PE
14447 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14448 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14449 pMsg->staId = staId;
14450 pMsg->rssiCallback = callback;
14451 pMsg->pDevContext = pContext;
14452 pMsg->pVosContext = pVosContext;
14453 status = palSendMBMessage(pMac->hHdd, pMsg );
14454 if(!HAL_STATUS_SUCCESS(status))
14455 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014456 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14457 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014458 status = eHAL_STATUS_FAILURE;
14459 }
14460 return status;
14461}
14462#endif
14463
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053014464/* ---------------------------------------------------------------------------
14465 \fn csrGetTLSTAState
14466 \helper function to get teh TL STA State whenever the function is called.
14467
14468 \param staId - The staID to be passed to the TL
14469 to get the relevant TL STA State
14470 \return the state as tANI_U16
14471 ---------------------------------------------------------------------------*/
14472tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
14473{
14474 WLANTL_STAStateType tlSTAState;
14475 tlSTAState = WLANTL_STA_INIT;
14476
14477 //request TL for STA State
14478 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
14479 {
14480 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
14481 }
14482
14483 return tlSTAState;
14484}
14485
Jeff Johnson295189b2012-06-20 16:38:30 -070014486eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14487 tANI_U32 statsMask,
14488 tCsrStatsCallback callback,
14489 tANI_U32 periodicity, tANI_BOOLEAN cache,
14490 tANI_U8 staId, void *pContext)
14491{
14492 tCsrStatsClientReqInfo staEntry;
14493 tCsrStatsClientReqInfo *pStaEntry = NULL;
14494 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14495 tListElem *pEntry = NULL;
14496 tANI_BOOLEAN found = FALSE;
14497 eHalStatus status = eHAL_STATUS_SUCCESS;
14498 tANI_BOOLEAN insertInClientList = FALSE;
14499 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014500 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014501
14502 if( csrIsAllSessionDisconnected(pMac) )
14503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014504 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014505 return eHAL_STATUS_FAILURE;
14506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 if((!statsMask) && (!callback))
14508 {
14509 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014510 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014511 return eHAL_STATUS_FAILURE;
14512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 //for the search list method for deregister
14514 staEntry.requesterId = requesterId;
14515 staEntry.statsMask = statsMask;
14516 //requester wants to deregister or just an error
14517 if((statsMask) && (!callback))
14518 {
14519 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14520 if(!pEntry)
14521 {
14522 //msg
14523 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014524 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014525 return eHAL_STATUS_FAILURE;
14526 }
14527 else
14528 {
14529 //clean up & return
14530 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014531 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014533 pStaEntry->pPeStaEntry->numClient--;
14534 //check if we need to delete the entry from peStatsReqList too
14535 if(!pStaEntry->pPeStaEntry->numClient)
14536 {
14537 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014540
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 //check if we need to stop the tl stats timer too
14542 pMac->roam.tlStatsReqInfo.numClient--;
14543 if(!pMac->roam.tlStatsReqInfo.numClient)
14544 {
14545 if(pMac->roam.tlStatsReqInfo.timerRunning)
14546 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014547 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14548 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014550 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 return eHAL_STATUS_FAILURE;
14552 }
14553 }
14554 pMac->roam.tlStatsReqInfo.periodicity = 0;
14555 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14556 }
14557 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 // Destroy the vos timer...
14559 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14560 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014562 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 csrRoamRemoveStatListEntry(pMac, pEntry);
14565 pStaEntry = NULL;
14566 return eHAL_STATUS_SUCCESS;
14567 }
14568 }
14569
14570 if(cache && !periodicity)
14571 {
14572 //return the cached stats
14573 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14574 }
14575 else
14576 {
14577 //add the request in the client req list
14578 staEntry.callback = callback;
14579 staEntry.pContext = pContext;
14580 staEntry.periodicity = periodicity;
14581 staEntry.pPeStaEntry = NULL;
14582 staEntry.staId = staId;
14583 staEntry.pMac = pMac;
14584 staEntry.timerExpired = FALSE;
14585
14586
Jeff Johnson295189b2012-06-20 16:38:30 -070014587 //if periodic report requested with non cached result from PE/TL
14588 if(periodicity)
14589 {
14590
14591 //if looking for stats from PE
14592 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14593 {
14594
14595 //check if same request made already & waiting for rsp
14596 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14597 periodicity, &found, staId);
14598 if(!pPeStaEntry)
14599 {
14600 //bail out, maxed out on number of req for PE
14601 return eHAL_STATUS_FAILURE;
14602 }
14603 else
14604 {
14605 staEntry.pPeStaEntry = pPeStaEntry;
14606 }
14607
14608 }
14609 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14610 if(statsMask & (1 << eCsrGlobalClassDStats))
14611 {
14612 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014614 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 }
14616 else
14617 {
14618
14619 //update periodicity
14620 if(pMac->roam.tlStatsReqInfo.periodicity)
14621 {
14622 pMac->roam.tlStatsReqInfo.periodicity =
14623 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14624 }
14625 else
14626 {
14627 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14628 }
14629 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14630 {
14631 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14632 }
14633
14634 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14635 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014636 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14637 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014638 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014639 //req TL for class D stats
14640 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014642 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014643 }
14644 else
14645 {
14646 //save in SME
14647 csrRoamSaveStatsFromTl(pMac, pTlStats);
14648 }
14649 vos_mem_free(pTlStats);
14650 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 }
14652 else
14653 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014654 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014656
Jeff Johnson295189b2012-06-20 16:38:30 -070014657 if(pMac->roam.tlStatsReqInfo.periodicity)
14658 {
14659 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014660 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14661 pMac->roam.tlStatsReqInfo.periodicity);
14662 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014664 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014665 return eHAL_STATUS_FAILURE;
14666 }
14667 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14668 }
14669 }
14670 }
14671 pMac->roam.tlStatsReqInfo.numClient++;
14672 }
14673
14674 insertInClientList = TRUE;
14675 }
14676 //if one time report requested with non cached result from PE/TL
14677 else if(!cache && !periodicity)
14678 {
14679 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14680 {
14681 //send down a req
14682 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14683 if(!HAL_STATUS_SUCCESS(status))
14684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014685 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 }
14687 //so that when the stats rsp comes back from PE we respond to upper layer
14688 //right away
14689 staEntry.timerExpired = TRUE;
14690 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 }
14692 if(statsMask & (1 << eCsrGlobalClassDStats))
14693 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014694 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14695 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014697 //req TL for class D stats
14698 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14699 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014700 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014701 }
14702 else
14703 {
14704 //save in SME
14705 csrRoamSaveStatsFromTl(pMac, pTlStats);
14706 }
14707 vos_mem_free(pTlStats);
14708 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 }
14710 else
14711 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014712 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014714
14715 }
14716 //if looking for stats from TL only
14717 if(!insertInClientList)
14718 {
14719 //return the stats
14720 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 if(insertInClientList)
14724 {
14725 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14726 if(!pStaEntry)
14727 {
14728 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014729 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 return eHAL_STATUS_FAILURE;
14731 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014732 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 //Init & start timer if needed
14734 if(periodicity)
14735 {
14736 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14737 csrRoamStatsClientTimerHandler, pStaEntry );
14738 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014740 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014741 return eHAL_STATUS_FAILURE;
14742 }
14743 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14744 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014746 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 return eHAL_STATUS_FAILURE;
14748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 }
14752 return eHAL_STATUS_SUCCESS;
14753}
14754
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014755#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14756
14757static tSirRetStatus
14758csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14759 tANI_U8* pBD,
14760 tANI_U8 type,
14761 tANI_U8 subType,
14762 tSirMacAddr peerAddr,
14763 tSirMacAddr selfMacAddr)
14764{
14765 tSirRetStatus statusCode = eSIR_SUCCESS;
14766 tpSirMacMgmtHdr pMacHdr;
14767
14768 /* Prepare MAC management header */
14769 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14770
14771 /* Prepare FC */
14772 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14773 pMacHdr->fc.type = type;
14774 pMacHdr->fc.subType = subType;
14775
14776 /* Prepare Address 1 */
14777 palCopyMemory( pMac->hHdd,
14778 (tANI_U8 *) pMacHdr->da,
14779 (tANI_U8 *) peerAddr,
14780 sizeof( tSirMacAddr ));
14781
14782 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14783
14784 /* Prepare Address 3 */
14785 palCopyMemory( pMac->hHdd,
14786 (tANI_U8 *) pMacHdr->bssId,
14787 (tANI_U8 *) peerAddr,
14788 sizeof( tSirMacAddr ));
14789 return statusCode;
14790} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14791
14792static tSirRetStatus
14793csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14794 tANI_U8 nChannelNum,
14795 tANI_U32 dot11mode,
14796 tSirMacAddr selfMacAddr,
14797 tANI_U8 *pFrame,
14798 tANI_U16 *pusLen)
14799{
14800 tDot11fProbeRequest pr;
14801 tANI_U32 nStatus, nBytes, nPayload;
14802 tSirRetStatus nSirStatus;
14803 /*Bcast tx*/
14804 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14805 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14806
14807
14808 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14809
14810 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14811
14812 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14813 {
14814 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14815 }
14816
14817
14818 if (IS_DOT11_MODE_HT(dot11mode))
14819 {
14820 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14821 }
14822
14823
14824 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14825 if ( DOT11F_FAILED( nStatus ) )
14826 {
14827 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14828 "Failed to calculate the packed size f"
14829 "or a Probe Request (0x%08x).\n", nStatus );
14830
14831
14832 nPayload = sizeof( tDot11fProbeRequest );
14833 }
14834 else if ( DOT11F_WARNED( nStatus ) )
14835 {
14836 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14837 "There were warnings while calculating"
14838 "the packed size for a Probe Request ("
14839 "0x%08x).\n", nStatus );
14840 }
14841
14842 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14843
14844 /* Prepare outgoing frame*/
14845 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14846
14847
14848 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014849 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014850
14851 if ( eSIR_SUCCESS != nSirStatus )
14852 {
14853 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14854 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14855 nSirStatus );
14856 return nSirStatus;
14857 }
14858
14859
14860 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14861 sizeof( tSirMacMgmtHdr ),
14862 nPayload, &nPayload );
14863 if ( DOT11F_FAILED( nStatus ) )
14864 {
14865 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14866 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14867 return eSIR_FAILURE;
14868 }
14869 else if ( DOT11F_WARNED( nStatus ) )
14870 {
14871 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14872 "There were warnings while packing a Probe Request (0x%08x).\n" );
14873 }
14874
14875 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14876 return eSIR_SUCCESS;
14877}
14878
14879eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14880{
14881 vos_msg_t msg;
14882 tSirRoamOffloadScanReq *pRequestBuf;
14883 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14884 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070014885 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014886 tANI_U8 *ChannelList = NULL;
14887 tANI_U32 sessionId;
14888 eHalStatus status = eHAL_STATUS_SUCCESS;
14889 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070014890 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070014891 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014892 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14893
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070014894 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014895 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014896 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014897 return eHAL_STATUS_FAILURE;
14898 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014899
14900 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
14901 {
14902 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
14903 return eHAL_STATUS_FAILURE;
14904 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014905 status = csrRoamGetSessionIdFromBSSID(pMac,
14906 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14907 &sessionId);
14908 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14909 * It is important to ensure that the command is passed down to the FW only
14910 * if the Infra Station is in a connected state.A connected station could also be
14911 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14912 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14913 * irrespective of whichever state we are in.*/
14914 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14915 (command != ROAM_SCAN_OFFLOAD_STOP))
14916 {
14917 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14918 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14919 return eHAL_STATUS_FAILURE;
14920 }
14921
14922 if ( !HAL_STATUS_SUCCESS( status ) )
14923 {
14924 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14925 return eHAL_STATUS_FAILURE;
14926 }
14927 pSession = CSR_GET_SESSION( pMac, sessionId );
14928 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14929 if (NULL == pRequestBuf)
14930 {
14931 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14932 return eHAL_STATUS_FAILED_ALLOC;
14933 }
14934
14935 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14936 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14937 * host driver reloads, but Riva still up and running*/
14938 if(command == ROAM_SCAN_OFFLOAD_STOP)
14939 pRequestBuf->RoamScanOffloadEnabled = 0;
14940 else
14941 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14942 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14943 sizeof(tCsrBssid));
14944 pRequestBuf->ConnectedNetwork.ssId.length =
14945 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14946 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14947 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14948 pRequestBuf->ConnectedNetwork.ssId.length);
14949 pRequestBuf->ConnectedNetwork.authentication =
14950 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14951 pRequestBuf->ConnectedNetwork.encryption =
14952 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14953 pRequestBuf->ConnectedNetwork.mcencryption =
14954 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14955 pRequestBuf->LookupThreshold =
14956 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14957 pRequestBuf->RoamRssiDiff =
14958 pMac->roam.configParam.RoamRssiDiff;
14959 pRequestBuf->Command = command;
14960 pRequestBuf->StartScanReason = reason;
14961 pRequestBuf->NeighborScanTimerPeriod =
14962 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14963 pRequestBuf->NeighborRoamScanRefreshPeriod =
14964 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14965 pRequestBuf->NeighborScanChannelMinTime =
14966 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14967 pRequestBuf->NeighborScanChannelMaxTime =
14968 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14969 pRequestBuf->EmptyRefreshScanPeriod =
14970 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14971#ifdef FEATURE_WLAN_CCX
14972 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14973#endif
14974 if (
14975#ifdef FEATURE_WLAN_CCX
14976 ((pNeighborRoamInfo->isCCXAssoc) &&
14977 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14978 eANI_BOOLEAN_FALSE)) ||
14979 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14980#endif // CCX
14981 currChannelListInfo->numOfChannels == 0)
14982 {
14983
14984 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14985 * Give Preference to INI Channels.*/
14986 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14987 {
14988 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14989 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14990 {
14991 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14992 {
14993 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14994 }
14995 ChannelList++;
14996 }
14997 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14998 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14999 }
15000 else{
15001 ChannelList = pMac->scan.occupiedChannels.channelList;
15002 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15003 {
15004 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15005 {
15006 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15007 }
15008 ChannelList++;
15009 }
15010 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15011 /* If the profile changes as to what it was earlier, inform the FW through
15012 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15013 * for the earlier profile and try to learn them afresh.*/
15014 if (reason == REASON_FLUSH_CHANNEL_LIST)
15015 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15016 else {
15017 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15018 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15019 else
15020 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15021 }
15022 }
15023 }
15024#ifdef FEATURE_WLAN_CCX
15025 else
15026 {
15027 /* If CCX is enabled, and a neighbor Report is received,then
15028 * Ignore the INI Channels or the Occupied Channel List. Consider
15029 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015030 if (currChannelListInfo->numOfChannels != 0)
15031 {
15032 ChannelList = currChannelListInfo->ChannelList;
15033 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015034 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015035 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15036 {
15037 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15038 }
15039 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015040 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015041 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15042 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15043 }
15044 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015045#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015046 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15047 {
15048 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15049 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15050 }
15051 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15052 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15053 pRequestBuf->ChannelCacheType,
15054 pRequestBuf->ConnectedNetwork.ChannelCount,
15055 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015056 num_channels = 0;
15057 ChannelList = NULL;
15058
15059 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015060 host_channels = sizeof(pMac->roam.validChannelList);
15061 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015062 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015063 ChannelList = pMac->roam.validChannelList;
15064 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015065 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015066 else
15067 {
15068 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15069 "%s:Failed to get the valid channel list", __func__);
15070 return eHAL_STATUS_FAILURE;
15071 }
15072 for(i=0; i<pMac->roam.numValidChannels; i++)
15073 {
15074 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15075 {
15076 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15077 }
15078 ChannelList++;
15079 }
15080 pRequestBuf->ValidChannelCount = num_channels;
15081
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015082 pRequestBuf->MDID.mdiePresent =
15083 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15084 pRequestBuf->MDID.mobilityDomain =
15085 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015086 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15087
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015088 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015089
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015090 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15091 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15092 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15093 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15094 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15095
15096 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15097 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015098 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015099 msg.reserved = 0;
15100 msg.bodyptr = pRequestBuf;
15101 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15102 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015103 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15104 vos_mem_free(pRequestBuf);
15105 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015106 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015107 else
15108 {
15109 if (ROAM_SCAN_OFFLOAD_START == command)
15110 bRoamScanOffloadStarted = VOS_TRUE;
15111 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15112 bRoamScanOffloadStarted = VOS_FALSE;
15113 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015114
15115 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15116 return status;
15117}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015118
15119eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15120{
15121 switch(reason)
15122 {
15123 case 0:
15124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15125 break;
15126 case REASON_OS_REQUESTED_ROAMING_NOW:
15127 csrNeighborRoamProceedWithHandoffReq(pMac);
15128 break;
15129 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015130 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 -070015131 }
15132 return eHAL_STATUS_SUCCESS;
15133}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015134#endif
15135
Jeff Johnson295189b2012-06-20 16:38:30 -070015136tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15137 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15138{
15139 tANI_BOOLEAN found = FALSE;
15140 eHalStatus status = eHAL_STATUS_SUCCESS;
15141 tCsrPeStatsReqInfo staEntry;
15142 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15143 tListElem *pStaEntry = NULL;
15144 VOS_STATUS vosStatus;
15145 tPmcPowerState powerState;
15146 *pFound = FALSE;
15147
15148 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15149 if(pStaEntry)
15150 {
15151 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15152 if(pTempStaEntry->periodicity)
15153 {
15154 pTempStaEntry->periodicity =
15155 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15156 }
15157 else
15158 {
15159 pTempStaEntry->periodicity = periodicity;
15160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 pTempStaEntry->numClient++;
15162 found = TRUE;
15163 }
15164 else
15165 {
15166 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
15167 staEntry.numClient = 1;
15168 staEntry.periodicity = periodicity;
15169 staEntry.pMac = pMac;
15170 staEntry.rspPending = FALSE;
15171 staEntry.staId = staId;
15172 staEntry.statsMask = statsMask;
15173 staEntry.timerRunning = FALSE;
15174 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15175 if(!pTempStaEntry)
15176 {
15177 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015178 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 return NULL;
15180 }
15181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15183 if(ePMC_FULL_POWER == powerState)
15184 {
15185 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15186 {
15187 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15188 }
15189 }
15190 else
15191 {
15192 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15193 {
15194 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15195 }
15196 }
15197 if(!pTempStaEntry->timerRunning)
15198 {
15199 //send down a req in case of one time req, for periodic ones wait for timer to expire
15200 if(!pTempStaEntry->rspPending &&
15201 !pTempStaEntry->periodicity)
15202 {
15203 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15204 if(!HAL_STATUS_SUCCESS(status))
15205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015206 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 }
15208 else
15209 {
15210 pTempStaEntry->rspPending = TRUE;
15211 }
15212 }
15213 if(pTempStaEntry->periodicity)
15214 {
15215 if(!found)
15216 {
15217
15218 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15219 csrRoamPeStatsTimerHandler, pTempStaEntry );
15220 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015222 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015223 return NULL;
15224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 }
15226 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015227 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15229 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015231 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 return NULL;
15233 }
15234 pTempStaEntry->timerRunning = TRUE;
15235 }
15236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015237 *pFound = found;
15238 return pTempStaEntry;
15239}
15240
Jeff Johnson295189b2012-06-20 16:38:30 -070015241/*
15242 pStaEntry is no longer invalid upon the return of this function.
15243*/
15244static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15245{
15246 if(pEntry)
15247 {
15248 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15249 {
15250 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 }
15253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015254
15255void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15256{
15257 tListElem *pEntry;
15258 tCsrPeStatsReqInfo *pTempStaEntry;
15259 VOS_STATUS vosStatus;
15260 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015261 if(!pEntry)
15262 {
15263 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015264 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 return;
15266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 while( pEntry )
15268 {
15269 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015272 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 if(pTempStaEntry->timerRunning)
15274 {
15275 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15276 /* If we are not able to stop the timer here, just remove
15277 * the entry from the linked list. Destroy the timer object
15278 * and free the memory in the timer CB
15279 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015280 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 {
15282 /* the timer is successfully stopped */
15283 pTempStaEntry->timerRunning = FALSE;
15284
15285 /* Destroy the timer */
15286 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15287 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15288 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015289 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 }
15291 }
15292 else
15293 {
15294 // the timer could not be stopped. Hence destroy and free the
15295 // memory for the PE stat entry in the timer CB.
15296 pTempStaEntry->timerStopFailed = TRUE;
15297 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015298 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015299
15300 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15301 {
15302 // Only free the memory if we could stop the timer successfully
15303 if(!pTempStaEntry->timerStopFailed)
15304 {
15305 palFreeMemory(pMac->hHdd, pTempStaEntry);
15306 pTempStaEntry = NULL;
15307 }
15308 break;
15309 }
15310
15311 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15312 }
15313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 return;
15315}
15316
15317
Jeff Johnsone7245742012-09-05 17:12:55 -070015318void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015319{
15320
Jeff Johnsone7245742012-09-05 17:12:55 -070015321 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15322 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15323 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15324 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15325 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15326 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15327 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015329 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15330 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15331 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15332 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15333 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15334 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015336 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15337 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015338
15339}
15340
Jeff Johnson295189b2012-06-20 16:38:30 -070015341void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15342 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15343{
15344 tANI_U8 stats[500];
15345 tANI_U8 *pStats = NULL;
15346 tANI_U32 tempMask = 0;
15347 tANI_U8 counter = 0;
15348 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 if(!callback)
15350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015351 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 return;
15353 }
15354 if(!statsMask)
15355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015356 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 return;
15358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 while(tempMask)
15362 {
15363 if(tempMask & 1)
15364 {
15365 //new stats info from PE, fill up the stats strucutres in PMAC
15366 switch(counter)
15367 {
15368 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015369 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15371 sizeof(tCsrSummaryStatsInfo));
15372 if(!HAL_STATUS_SUCCESS(status))
15373 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015374 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 }
15376 pStats += sizeof(tCsrSummaryStatsInfo);
15377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015379 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15381 sizeof(tCsrGlobalClassAStatsInfo));
15382 if(!HAL_STATUS_SUCCESS(status))
15383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015384 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 }
15386 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015389 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015390 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15391 sizeof(tCsrGlobalClassBStatsInfo));
15392 if(!HAL_STATUS_SUCCESS(status))
15393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015394 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 }
15396 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015399 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15401 sizeof(tCsrGlobalClassCStatsInfo));
15402 if(!HAL_STATUS_SUCCESS(status))
15403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015404 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 }
15406 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015409 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15411 sizeof(tCsrGlobalClassDStatsInfo));
15412 if(!HAL_STATUS_SUCCESS(status))
15413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015414 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015415 }
15416 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015419 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15421 sizeof(tCsrPerStaStatsInfo));
15422 if(!HAL_STATUS_SUCCESS(status))
15423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015424 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 }
15426 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015427 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015429 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 }
15432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 tempMask >>=1;
15434 counter++;
15435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015437}
15438
Jeff Johnson295189b2012-06-20 16:38:30 -070015439eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15440{
15441 tListElem *pEntry = NULL;
15442 tListElem *pPrevEntry = NULL;
15443 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15444 eHalStatus status = eHAL_STATUS_SUCCESS;
15445 VOS_STATUS vosStatus;
15446 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 if(!pEntry)
15448 {
15449 //list empty
15450 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015451 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015452 return status;
15453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 while( pEntry )
15455 {
15456 if(pPrevEntry)
15457 {
15458 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15459 //send up the stats report
15460 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15461 pTempStaEntry->staId, pTempStaEntry->pContext);
15462 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015465 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15466 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015467 pTempStaEntry->pPeStaEntry->numClient--;
15468 //check if we need to delete the entry from peStatsReqList too
15469 if(!pTempStaEntry->pPeStaEntry->numClient)
15470 {
15471 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 //check if we need to stop the tl stats timer too
15475 pMac->roam.tlStatsReqInfo.numClient--;
15476 if(!pMac->roam.tlStatsReqInfo.numClient)
15477 {
15478 if(pMac->roam.tlStatsReqInfo.timerRunning)
15479 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015480 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15481 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015483 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 //we will continue
15485 }
15486 }
15487 pMac->roam.tlStatsReqInfo.periodicity = 0;
15488 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015490 if (pTempStaEntry->periodicity)
15491 {
15492 //While creating StaEntry in csrGetStatistics,
15493 //Initializing and starting timer only when periodicity is set.
15494 //So Stop and Destroy timer only when periodicity is set.
15495
Jeff Johnsone7245742012-09-05 17:12:55 -070015496 vos_timer_stop( &pTempStaEntry->timer );
15497 // Destroy the vos timer...
15498 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15499 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15500 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015501 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015504
Jeff Johnson295189b2012-06-20 16:38:30 -070015505
15506 pPrevEntry = pEntry;
15507 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15508 }
15509 //the last one
15510 if(pPrevEntry)
15511 {
15512 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15513 //send up the stats report
15514 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15515 pTempStaEntry->staId, pTempStaEntry->pContext);
15516 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015518 return status;
15519
15520}
15521
Jeff Johnson295189b2012-06-20 16:38:30 -070015522eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15523 tRequestFullPowerReason *pReason,
15524 tANI_BOOLEAN *pfNeedPower )
15525{
15526 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15527 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15528 tPmcState pmcState;
15529 eHalStatus status = eHAL_STATUS_SUCCESS;
15530 // TODO : Session info unavailable
15531 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015532 if( pfNeedPower )
15533 {
15534 *pfNeedPower = eANI_BOOLEAN_FALSE;
15535 }
15536 //We only handle CSR commands
15537 if( !(eSmeCsrCommandMask & pCommand->command) )
15538 {
15539 return eHAL_STATUS_SUCCESS;
15540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 //Check PMC state first
15542 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 switch( pmcState )
15544 {
15545 case REQUEST_IMPS:
15546 case IMPS:
15547 if( eSmeCommandScan == pCommand->command )
15548 {
15549 switch( pCommand->u.scanCmd.reason )
15550 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015551#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15552 case eCsrScanGetLfrResult:
15553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 case eCsrScanGetResult:
15555 case eCsrScanBGScanAbort:
15556 case eCsrScanBGScanEnable:
15557 case eCsrScanGetScanChnInfo:
15558 //Internal process, no need for full power
15559 fNeedFullPower = eANI_BOOLEAN_FALSE;
15560 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015561 default:
15562 //Other scans are real scan, ask for power
15563 fNeedFullPower = eANI_BOOLEAN_TRUE;
15564 break;
15565 } //switch
15566 }
15567 else
15568 {
15569 //ask for power for roam and status change
15570 fNeedFullPower = eANI_BOOLEAN_TRUE;
15571 }
15572 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 case REQUEST_BMPS:
15574 case BMPS:
15575 case REQUEST_START_UAPSD:
15576 case UAPSD:
15577 //We treat WOWL same as BMPS
15578 case REQUEST_ENTER_WOWL:
15579 case WOWL:
15580 if( eSmeCommandRoam == pCommand->command )
15581 {
15582 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15583 tCsrScanResult *pScanResult;
15584 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015585 switch ( pCommand->u.roamCmd.roamReason )
15586 {
15587 case eCsrForcedDisassoc:
15588 case eCsrForcedDisassocMICFailure:
15589 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15590 fNeedFullPower = eANI_BOOLEAN_TRUE;
15591 break;
15592 case eCsrSmeIssuedDisassocForHandoff:
15593 case eCsrForcedDeauth:
15594 case eCsrHddIssuedReassocToSameAP:
15595 case eCsrSmeIssuedReassocToSameAP:
15596 fNeedFullPower = eANI_BOOLEAN_TRUE;
15597 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 case eCsrCapsChange:
15599 fNeedFullPower = eANI_BOOLEAN_TRUE;
15600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 default:
15602 //Check whether the profile is already connected. If so, no need for full power
15603 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15604 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15605 {
15606 //Only need to check the first one
15607 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15608 if( pEntry )
15609 {
15610 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15611#if 0
15612 // TODO : Session Specific info pConnectBssDesc
15613 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15614 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15615 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15616 {
15617 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15618 // with Authenticating first. To force this, stop the current association (Disassociate) and
15619 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15620 // a new Association.
15621 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15622 {
15623 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15624 {
15625 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15626 //No need for full power
15627 //Set the flag so the code later can avoid to do the above
15628 //check again.
15629 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15630 break;
15631 }
15632 }
15633 }
15634#endif
15635 }
15636 }
15637 //If we are here, full power is needed
15638 fNeedFullPower = eANI_BOOLEAN_TRUE;
15639 break;
15640 }
15641 }
15642 else if( eSmeCommandWmStatusChange == pCommand->command )
15643 {
15644 //need full power for all
15645 fNeedFullPower = eANI_BOOLEAN_TRUE;
15646 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15647 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015648#ifdef FEATURE_WLAN_TDLS
15649 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15650 {
15651 //TDLS link is getting established. need full power
15652 fNeedFullPower = eANI_BOOLEAN_TRUE;
15653 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15654 }
15655#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015657 case REQUEST_STOP_UAPSD:
15658 case REQUEST_EXIT_WOWL:
15659 if( eSmeCommandRoam == pCommand->command )
15660 {
15661 fNeedFullPower = eANI_BOOLEAN_TRUE;
15662 switch ( pCommand->u.roamCmd.roamReason )
15663 {
15664 case eCsrForcedDisassoc:
15665 case eCsrForcedDisassocMICFailure:
15666 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15667 break;
15668 default:
15669 break;
15670 }
15671 }
15672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 case STOPPED:
15674 case REQUEST_STANDBY:
15675 case STANDBY:
15676 case LOW_POWER:
15677 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015678 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 status = eHAL_STATUS_FAILURE;
15680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015681 case FULL_POWER:
15682 case REQUEST_FULL_POWER:
15683 default:
15684 //No need to ask for full power. This has to be FULL_POWER state
15685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015687 if( pReason )
15688 {
15689 *pReason = reason;
15690 }
15691 if( pfNeedPower )
15692 {
15693 *pfNeedPower = fNeedFullPower;
15694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015695 return ( status );
15696}
15697
Jeff Johnson295189b2012-06-20 16:38:30 -070015698static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15699{
15700 eHalStatus status = eHAL_STATUS_SUCCESS;
15701 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15702 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015704 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15705 {
15706 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 return ( status );
15709}
15710
Jeff Johnson295189b2012-06-20 16:38:30 -070015711tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15712{
15713 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015714 if( pCmd )
15715 {
15716 pMac->roam.sPendingCommands++;
15717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015718 return ( pCmd );
15719}
15720
Jeff Johnson295189b2012-06-20 16:38:30 -070015721void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15722{
15723 if (pMac->roam.sPendingCommands > 0)
15724 {
15725 //All command allocated through csrGetCommandBuffer need to
15726 //decrement the pending count when releasing.
15727 pMac->roam.sPendingCommands--;
15728 smeReleaseCommand( pMac, pCommand );
15729 }
15730 else
15731 {
15732 smsLog(pMac, LOGE, FL( "no pending commands"));
15733 VOS_ASSERT(0);
15734 }
15735}
15736
Jeff Johnson295189b2012-06-20 16:38:30 -070015737//Return SUCCESS is the command is queued, failed
15738eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15739{
15740 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15742 {
15743 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15744 pCommand->u.scanCmd.reason);
15745 return eHAL_STATUS_CSR_WRONG_STATE;
15746 }
15747
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015748 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
15749 {
15750 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
15751 &pCommand->Link, LL_ACCESS_LOCK);
15752 // process the command queue...
15753 smeProcessPendingQueue(pMac);
15754 status = eHAL_STATUS_SUCCESS;
15755 goto end;
15756 }
15757
Jeff Johnson295189b2012-06-20 16:38:30 -070015758 //We can call request full power first before putting the command into pending Q
15759 //because we are holding SME lock at this point.
15760 status = csrRequestFullPower( pMac, pCommand );
15761 if( HAL_STATUS_SUCCESS( status ) )
15762 {
15763 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015764 //make sure roamCmdPendingList is not empty first
15765 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15766 if( fNoCmdPending )
15767 {
15768 smePushCommand( pMac, pCommand, fHighPriority );
15769 }
15770 else
15771 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015772 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070015773 //no list lock is needed since SME lock is held
15774 if( !fHighPriority )
15775 {
15776 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15777 }
15778 else {
15779 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15780 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015782 }
15783 else if( eHAL_STATUS_PMC_PENDING == status )
15784 {
15785 //no list lock is needed since SME lock is held
15786 if( !fHighPriority )
15787 {
15788 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15789 }
15790 else {
15791 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15792 }
15793 //Let caller know the command is queue
15794 status = eHAL_STATUS_SUCCESS;
15795 }
15796 else
15797 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015798 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015800 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015801 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015802end:
Jeff Johnson295189b2012-06-20 16:38:30 -070015803 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015804}
Jeff Johnson295189b2012-06-20 16:38:30 -070015805eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15806{
15807 eHalStatus status = eHAL_STATUS_SUCCESS;
15808 tSirUpdateAPWPSIEsReq *pMsg;
15809 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15810
15811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15812 if (NULL == pSession)
15813 {
15814 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15815 return eHAL_STATUS_FAILURE;
15816 }
15817
Jeff Johnson295189b2012-06-20 16:38:30 -070015818 do
15819 {
15820 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15821 if (!HAL_STATUS_SUCCESS(status)) break;
15822 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15823 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15824
15825 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070015826 VOS_ASSERT(pBuf);
15827
Jeff Johnson295189b2012-06-20 16:38:30 -070015828 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015829 // transactionId
15830 *pBuf = 0;
15831 *( pBuf + 1 ) = 0;
15832 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 // bssId
15834 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15835 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 //sessionId
15837 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015838 // APWPSIEs
15839 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15840 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015841 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015843 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 return ( status );
15845}
Jeff Johnson295189b2012-06-20 16:38:30 -070015846eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15847{
15848 eHalStatus status = eHAL_STATUS_SUCCESS;
15849 tSirUpdateAPWPARSNIEsReq *pMsg;
15850 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015851 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15852 if (NULL == pSession)
15853 {
15854 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15855 return eHAL_STATUS_FAILURE;
15856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 do
15858 {
15859 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15860 if (!HAL_STATUS_SUCCESS(status)) break;
15861 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15862 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 pBuf = (tANI_U8 *)&pMsg->transactionId;
15864 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015865 // transactionId
15866 *pBuf = 0;
15867 *( pBuf + 1 ) = 0;
15868 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070015869 VOS_ASSERT(pBuf);
15870
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 // bssId
15872 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15873 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015874 // sessionId
15875 *pBuf++ = (tANI_U8)sessionId;
15876
15877 // APWPARSNIEs
15878 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15879 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015881 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015882 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015883 return ( status );
15884}
Jeff Johnson295189b2012-06-20 16:38:30 -070015885
15886#ifdef WLAN_FEATURE_VOWIFI_11R
15887//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15888eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15889{
15890 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15891 tpSirFTPreAuthReq pftPreAuthReq;
15892 tANI_U16 auth_req_len = 0;
15893 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015894 auth_req_len = sizeof(tSirFTPreAuthReq);
15895 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15896 if (pftPreAuthReq == NULL)
15897 {
15898 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15899 return eHAL_STATUS_RESOURCES;
15900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 // Save the SME Session ID here. We need it while processing the preauth response
15902 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015903 vos_mem_zero(pftPreAuthReq, auth_req_len);
15904
15905 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15906 sizeof(pBssDescription->length) + pBssDescription->length);
15907
15908 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15909
15910 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15911
Jeff Johnson295189b2012-06-20 16:38:30 -070015912 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015913 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15914
Jeff Johnson295189b2012-06-20 16:38:30 -070015915#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015916 if (csrRoamIs11rAssoc(pMac) &&
15917 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015918 {
15919 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15920 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15921 pMac->ft.ftSmeContext.auth_ft_ies_length);
15922 }
15923 else
15924#endif
15925 {
15926 pftPreAuthReq->ft_ies_length = 0;
15927 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015928 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15929 sizeof(pBssDescription->length) + pBssDescription->length);
15930 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15932}
Jeff Johnson295189b2012-06-20 16:38:30 -070015933/*--------------------------------------------------------------------------
15934 * This will receive and process the FT Pre Auth Rsp from the current
15935 * associated ap.
15936 *
15937 * This will invoke the hdd call back. This is so that hdd can now
15938 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15939 ------------------------------------------------------------------------*/
15940void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15941{
15942 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15943 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015944#ifdef FEATURE_WLAN_LFR
15945 tCsrRoamInfo roamInfo;
15946#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015947
15948#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015949 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015950#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015951#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015952 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015953 if (status != eHAL_STATUS_SUCCESS) {
15954 /*
15955 * Bail out if pre-auth was not even processed.
15956 */
15957 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15958 return;
15959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015960#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015961 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15962 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15963 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015964 // Implies a success
15965 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015966 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15967 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070015968 /* No need to notify qos module if this is a non 11r roam*/
15969 if (csrRoamIs11rAssoc(pMac))
15970 {
15971 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15972 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015973 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15974 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015975 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15976 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 if (eHAL_STATUS_SUCCESS != status)
15978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015979 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015980 return;
15981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015982 // Save the received response
15983 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15984 if (csrRoamIs11rAssoc(pMac))
15985 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15986 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15987
15988 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015989#ifdef FEATURE_WLAN_LFR
15990 // If Legacy Fast Roaming is enabled, signal the supplicant
15991 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015992 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015993 {
15994 // Save the bssid from the received response
15995 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15996 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15997 }
15998
15999#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016000
16001 // Done with it, init it.
16002 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16003}
16004#endif
16005#ifdef FEATURE_WLAN_BTAMP_UT_RF
16006void csrRoamJoinRetryTimerHandler(void *pv)
16007{
16008 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16009 tpAniSirGlobal pMac = pInfo->pMac;
16010 tANI_U32 sessionId = pInfo->sessionId;
16011 tCsrRoamSession *pSession;
16012
16013 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016015 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 pSession = CSR_GET_SESSION( pMac, sessionId );
16017 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16018 {
16019 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016021 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 }
16023 }
16024 }
16025}
Jeff Johnson295189b2012-06-20 16:38:30 -070016026eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16027{
16028 eHalStatus status = eHAL_STATUS_FAILURE;
16029 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16030
16031 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016033 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016034 pSession->maxRetryCount--;
16035 pSession->joinRetryTimerInfo.pMac = pMac;
16036 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016037 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16038 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016040 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 }
16042 }
16043 else
16044 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016045 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016046 pSession->maxRetryCount);
16047 }
16048
16049 return (status);
16050}
Jeff Johnson295189b2012-06-20 16:38:30 -070016051eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16052{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016053 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16055 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016056 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016057 }
16058
16059 return eHAL_STATUS_SUCCESS;
16060}
16061#endif
16062
16063
16064/*
16065 pBuf points to the beginning of the message
16066 LIM packs disassoc rsp as below,
16067 messageType - 2 bytes
16068 messageLength - 2 bytes
16069 sessionId - 1 byte
16070 transactionId - 2 bytes (tANI_U16)
16071 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16072 peerMacAddr - 6 bytes
16073 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16074*/
16075static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16076{
16077 if(pBuf && pRsp)
16078 {
16079 pBuf += 4; //skip type and length
16080 pRsp->sessionId = *pBuf++;
16081 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16082 pBuf += 2;
16083 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16084 pBuf += 4;
16085 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16086 }
16087}
16088
Jeff Johnsond13512a2012-07-17 11:42:19 -070016089eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16090{
16091 static uNvTables nvTables;
16092 eHalStatus status = eHAL_STATUS_SUCCESS;
16093 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16094
16095 /* read the country code from NV and use it */
16096 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16097 {
16098 palCopyMemory( pMac->hHdd, pCountry,
16099 nvTables.defaultCountryTable.countryCode,
16100 WNI_CFG_COUNTRY_CODE_LEN );
16101 return status;
16102 }
16103 else
16104 {
16105 palCopyMemory( pMac->hHdd, pCountry,
16106 "XXX",
16107 WNI_CFG_COUNTRY_CODE_LEN );
16108 status = eHAL_STATUS_FAILURE;
16109 return status;
16110 }
16111}
16112
16113eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16114{
16115 palCopyMemory( pMac->hHdd, pCountry,
16116 pMac->scan.countryCode11d,
16117 WNI_CFG_COUNTRY_CODE_LEN );
16118 return eHAL_STATUS_SUCCESS;
16119}
schang86c22c42013-03-13 18:41:24 -070016120
16121eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16122{
16123 tSirSetTxPowerReq *pMsg = NULL;
16124 eHalStatus status = eHAL_STATUS_SUCCESS;
16125 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16126
16127 if (!pSession)
16128 {
16129 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16130 return eHAL_STATUS_FAILURE;
16131 }
16132
16133 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
16134 if (HAL_STATUS_SUCCESS(status))
16135 {
16136 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
16137 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16138 pMsg->length = sizeof(tSirSetTxPowerReq);
16139 pMsg->mwPower = mW;
16140 palCopyMemory( pMac->hHdd,
16141 (tSirMacAddr *)pMsg->bssId,
16142 &pSession->selfMacAddr,
16143 sizeof(tSirMacAddr) );
16144 status = palSendMBMessage(pMac->hHdd, pMsg);
16145 if (!HAL_STATUS_SUCCESS(status))
16146 {
16147 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016148 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016149 }
16150 }
16151 return status;
16152}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016153
16154/* Returns whether a session is in VOS_STA_MODE...or not */
16155tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16156{
16157 tCsrRoamSession *pSession = NULL;
16158 pSession = CSR_GET_SESSION ( pMac, sessionId );
16159 if(!pSession)
16160 {
16161 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16162 return eANI_BOOLEAN_FALSE;
16163 }
16164 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16165 {
16166 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16167 return eANI_BOOLEAN_FALSE;
16168 }
16169 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16170 {
16171 return eANI_BOOLEAN_FALSE;
16172 }
16173 /* There is a possibility that the above check may fail,because
16174 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16175 * when it is connected.So,we may sneak through the above check even
16176 * if we are not a STA mode INFRA station. So, if we sneak through
16177 * the above condition, we can use the following check if we are
16178 * really in STA Mode.*/
16179
16180 if ( NULL != pSession->pCurRoamProfile )
16181 {
16182 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16183 {
16184 return eANI_BOOLEAN_TRUE;
16185 } else {
16186 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16187 return eANI_BOOLEAN_FALSE;
16188 }
16189 }
16190
16191 return eANI_BOOLEAN_FALSE;
16192}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016193
16194#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16195eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16196 tCsrHandoffRequest *pHandoffInfo)
16197{
16198 eHalStatus status = eHAL_STATUS_SUCCESS;
16199 vos_msg_t msg;
16200
16201 tAniHandoffReq *pMsg;
16202 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
16203 if ( !HAL_STATUS_SUCCESS(status) )
16204 {
16205 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
16206 return status;
16207 }
16208 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16209 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16210 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16211 pMsg->channel = pHandoffInfo->channel;
16212 palCopyMemory(pMac->hHdd, pMsg->bssid,
16213 pHandoffInfo->bssid,
16214 6);
16215 msg.type = eWNI_SME_HANDOFF_REQ;
16216 msg.bodyptr = pMsg;
16217 msg.reserved = 0;
16218 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16219 {
16220 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
16221 palFreeMemory(pMac->hHdd, (void *)pMsg);
16222 status = eHAL_STATUS_FAILURE;
16223 }
16224 return status;
16225}
16226#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */