blob: 2c60b9f7c995d62280bf0d3a0f9da28415e28dcf [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
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530919 smsLog( pMac, LOG1, "CSR RoamState[%hu]: [ %d <== %d ]", sessionId,
920 NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921
922 PreviousState = pMac->roam.curState[sessionId];
923
924 if ( NewRoamState != pMac->roam.curState[sessionId] )
925 {
926 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
927 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
928 {
929 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
930 }
931
932 pMac->roam.curState[sessionId] = NewRoamState;
933 }
934 return( PreviousState );
935}
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
938{
939 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 if(catOffset)
941 {
942 pMac->roam.configParam.bCatRssiOffset = catOffset;
943 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
944 {
945 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
946 }
947 }
948}
949
Jeff Johnson295189b2012-06-20 16:38:30 -0700950static void initConfigParam(tpAniSirGlobal pMac)
951{
952 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
954 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
955 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
958 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
959 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
960 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
961 pMac->roam.configParam.HeartbeatThresh24 = 40;
962 pMac->roam.configParam.HeartbeatThresh50 = 40;
963 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
964 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
965 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700966 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 pMac->roam.configParam.RTSThreshold = 2346;
968 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
969 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
970 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
971 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
972 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
973 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
974 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
975 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
976 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
977 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
978 {
979 pMac->roam.configParam.BssPreferValue[i] = i;
980 }
981 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
982 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
983 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
984 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
986 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
987 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
988 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
989 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
990 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800991 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
992 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700993 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700994#ifdef WLAN_AP_STA_CONCURRENCY
995 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
996 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
997 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
998 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
999 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001000 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1001 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001002#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1004 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1005 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1006 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001007#ifdef WLAN_FEATURE_VOWIFI_11R
1008 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1009#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001010#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1011 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1012 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1013 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1014 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1015 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1016 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1017 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1018 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1019 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1020 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1021 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001022 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001023#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001024#ifdef WLAN_FEATURE_11AC
1025 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001027
1028 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1029 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001030
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001031 //Remove this code once SLM_Sessionization is supported
1032 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001033 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001034
Jeff Johnsone7245742012-09-05 17:12:55 -07001035}
Jeff Johnson295189b2012-06-20 16:38:30 -07001036eCsrBand csrGetCurrentBand(tHalHandle hHal)
1037{
1038 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1039 return pMac->roam.configParam.bandCapability;
1040}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001041
1042#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001043/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001044 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001045*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001046eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001047{
1048 eHalStatus status = eHAL_STATUS_SUCCESS;
1049 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1050
1051 /* Free up the memory first (if required) */
1052 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1053 {
1054 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1055 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001056 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001057 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001058 return status;
1059}
1060
1061
1062
1063/*
1064 This function flushes the roam scan cache and creates fresh cache
1065 based on the input channel list
1066*/
1067eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1068 const tANI_U8 *pChannelList,
1069 const tANI_U8 numChannels)
1070{
1071 eHalStatus status = eHAL_STATUS_SUCCESS;
1072 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1073
Srinivas Girigowdade697412013-02-14 16:31:48 -08001074 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1075
1076 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1077 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1078
1079 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1080 {
1081 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1082 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1083 return eHAL_STATUS_RESOURCES;
1084 }
1085
1086 /* Update the roam global structure */
1087 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1088 pChannelList,
1089 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1090 return status;
1091}
1092
1093/* This function modifies the bgscan channel list set via config ini or
1094 runtime, whenever the band changes.
1095 if the band is auto, then no operation is performed on the channel list
1096 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1097 if the band is 5G, then make sure channel list contains only 5G valid channels
1098*/
1099eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1100 eCsrBand eBand)
1101{
1102 eHalStatus status = eHAL_STATUS_SUCCESS;
1103 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1104 tANI_U8 outNumChannels = 0;
1105 tANI_U8 inNumChannels = 0;
1106 tANI_U8 *inPtr = NULL;
1107 tANI_U8 i = 0;
1108 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1109
1110 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1111
1112 {
1113 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1114 "No update required for channel list "
1115 "either cfg.ini channel list is not set up or "
1116 "auto band (Band %d)", eBand);
1117 return status;
1118 }
1119
1120 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1121 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1122 if (eCSR_BAND_24 == eBand)
1123 {
1124 for (i = 0; i < inNumChannels; i++)
1125 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001126 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001127 {
1128 ChannelList[outNumChannels++] = inPtr[i];
1129 }
1130 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001131 csrFlushBgScanRoamChannelList(pMac);
1132 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001133 }
1134 else if (eCSR_BAND_5G == eBand)
1135 {
1136 for (i = 0; i < inNumChannels; i++)
1137 {
1138 /* Add 5G Non-DFS channel */
1139 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001140 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001141 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1142 {
1143 ChannelList[outNumChannels++] = inPtr[i];
1144 }
1145 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001146 csrFlushBgScanRoamChannelList(pMac);
1147 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001148 }
1149 else if (eCSR_BAND_ALL == eBand)
1150 {
1151 for (i = 0; i < inNumChannels; i++)
1152 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001153 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001154 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1155 {
1156 ChannelList[outNumChannels++] = inPtr[i];
1157 }
1158 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001159 csrFlushBgScanRoamChannelList(pMac);
1160 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001161 }
1162 else
1163 {
1164 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1165 "Invalid band, No operation carried out (Band %d)", eBand);
1166 status = eHAL_STATUS_INVALID_PARAMETER;
1167 }
1168
1169 return status;
1170}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001171#endif
1172
Jeff Johnson295189b2012-06-20 16:38:30 -07001173eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1174{
1175 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1176 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1178 (eBand == eCSR_BAND_24))
1179 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001180 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001182 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001183 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 pMac->roam.configParam.uCfgDot11Mode, eBand);
1185 return eHAL_STATUS_INVALID_PARAMETER;
1186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1188 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1189 (eBand == eCSR_BAND_5G))
1190 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001191 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001193 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001194 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 pMac->roam.configParam.uCfgDot11Mode, eBand);
1196 return eHAL_STATUS_INVALID_PARAMETER;
1197 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001198 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001199 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001200 pMac->roam.configParam.eBand = eBand;
1201 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001203#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1204 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1205#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 status = csrInitGetChannels( pMac );
1207 if (eHAL_STATUS_SUCCESS == status)
1208 csrInitChannelList( hHal );
1209 return status;
1210}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001211
1212
Jeff Johnsone7245742012-09-05 17:12:55 -07001213/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1214 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1215 * Ideally we should have kept the ini value and enum value same and representing the same
1216 * cb values as in 11n standard i.e.
1217 * Set to 1 (SCA) if the secondary channel is above the primary channel
1218 * Set to 3 (SCB) if the secondary channel is below the primary channel
1219 * Set to 0 (SCN) if no secondary channel is present
1220 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1221 * 0 - secondary none
1222 * 1 - secondary LOW
1223 * 2 - secondary HIGH
1224 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1225 * The enum values are as follows:
1226 * PHY_SINGLE_CHANNEL_CENTERED = 0
1227 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1228 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1229 */
1230ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1231{
1232
1233 ePhyChanBondState phyCbState;
1234 switch (cbIniValue) {
1235 // secondary none
1236 case 0:
1237 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1238 break;
1239 // secondary LOW
1240 case 1:
1241 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1242 break;
1243 // secondary HIGH
1244 case 2:
1245 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1246 break;
1247#ifdef WLAN_FEATURE_11AC
1248 case 3:
1249 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1250 break;
1251 case 4:
1252 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1253 break;
1254 case 5:
1255 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1256 break;
1257 case 6:
1258 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1259 break;
1260 case 7:
1261 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1262 break;
1263 case 8:
1264 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1265 break;
1266 case 9:
1267 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1268 break;
1269#endif
1270 default:
1271 // If an invalid value is passed, disable CHANNEL BONDING
1272 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1273 break;
1274 }
1275 return phyCbState;
1276}
1277
1278v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1279{
1280
1281 v_U32_t cbIniValue;
1282 switch (phyCbState) {
1283 // secondary none
1284 case PHY_SINGLE_CHANNEL_CENTERED:
1285 cbIniValue = 0;
1286 break;
1287 // secondary LOW
1288 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1289 cbIniValue = 1;
1290 break;
1291 // secondary HIGH
1292 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1293 cbIniValue = 2;
1294 break;
1295#ifdef WLAN_FEATURE_11AC
1296 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1297 cbIniValue = 3;
1298 break;
1299 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1300 cbIniValue = 4;
1301 break;
1302 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1303 cbIniValue = 5;
1304 break;
1305 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1306 cbIniValue = 6;
1307 break;
1308 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1309 cbIniValue = 7;
1310 break;
1311 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1312 cbIniValue = 8;
1313 break;
1314 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1315 cbIniValue = 9;
1316 break;
1317#endif
1318 default:
1319 // return some invalid value
1320 cbIniValue = 10;
1321 break;
1322 }
1323 return cbIniValue;
1324}
Jeff Johnson295189b2012-06-20 16:38:30 -07001325
1326eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1327{
1328 eHalStatus status = eHAL_STATUS_SUCCESS;
1329
1330 if(pParam)
1331 {
1332 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1333 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1334 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1335 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1336 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1337 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1338
1339 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001340 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1341
Jeff Johnsone7245742012-09-05 17:12:55 -07001342 /* channelBondingMode5GHz plays a dual role right now
1343 * 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
1344 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1345 */
1346 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001348 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 }
1350 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1351 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001353 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001354 }
1355 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1357 pMac->roam.configParam.phyMode = pParam->phyMode;
1358 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1359 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1360 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1361 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1362 pMac->roam.configParam.TxRate = pParam->TxRate;
1363 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1364 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1365 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1366 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1367 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001368 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 //if HDD passed down non zero values then only update,
1370 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001371 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 {
1373 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1374 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001375 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 {
1377 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1378 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001379 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 {
1381 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1382 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001383 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 {
1385 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1386 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001387 if (pParam->nActiveMaxChnTimeBtc)
1388 {
1389 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1390 }
1391 if (pParam->nActiveMinChnTimeBtc)
1392 {
1393 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1394 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001395#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001396 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001397 {
1398 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1399 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001400 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001401 {
1402 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1403 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001404 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001405 {
1406 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1407 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001408 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001409 {
1410 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1411 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001412 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001413 {
1414 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1415 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001416 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001417 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001418 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1419 }
1420 if (pParam->nNumP2PChanCombinedConc)
1421 {
1422 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001423 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001424#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001426 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 {
1428 //Change the unit from second to microsecond
1429 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1431 {
1432 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1433 }
1434 else
1435 {
1436 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1437 }
1438 }
1439 else
1440 {
1441 pMac->roam.configParam.impsSleepTime = 0;
1442 }
1443 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1445 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 //if HDD passed down non zero values for age params, then only update,
1447 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001448 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001449 {
1450 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 if(pParam->scanAgeTimeNCNPS)
1453 {
1454 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 if(pParam->scanAgeTimeNCPS)
1457 {
1458 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 if(pParam->scanAgeTimeCNPS)
1461 {
1462 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1463 }
1464 if(pParam->scanAgeTimeCPS)
1465 {
1466 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1467 }
1468
1469 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1470 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1471 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1472 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1473 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1474 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1476 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1478 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1479 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1480 //Assign this before calling CsrInit11dInfo
1481 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001482 if( csrIs11dSupported( pMac ) )
1483 {
1484 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1485 }
1486 else
1487 {
1488 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1489 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001490
1491 /* Initialize the power + channel information if 11h is enabled.
1492 If 11d is enabled this information has already been initialized */
1493 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1494 {
1495 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1496 }
1497
1498
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301499#ifdef WLAN_FEATURE_VOWIFI_11R
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001501 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001503#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001505 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001506 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001507 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001508 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001509 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001510 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001511 pMac->roam.configParam.nProbes = pParam->nProbes;
1512 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001514#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1515 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001516 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001517#endif
1518#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001519 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1520#endif
1521
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301522#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1524#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001525#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1526 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001527 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1528 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1529 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1530 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1531 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1532 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1533 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1534 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 {
1536 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001537 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 -07001538 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1539 {
1540 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1541 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001542 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001543 }
1544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1546 pMac->scan.fValidateList = pParam->fValidateList;
1547 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1548 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001549 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001551 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1552 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1553 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1554 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1555 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1556 * single session
1557 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001558 //Remove this code once SLM_Sessionization is supported
1559 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001560 pMac->roam.configParam.doBMPSWorkaround = 0;
1561
Jeff Johnsone7245742012-09-05 17:12:55 -07001562#ifdef WLAN_FEATURE_11AC
1563 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001564 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001565 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001566 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001567#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001568 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001569
1570 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 }
1572
1573 return status;
1574}
1575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1577{
1578 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 if(pParam)
1580 {
1581 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1582 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1583 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1584 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1585 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1586 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001587 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1588 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1590 pParam->phyMode = pMac->roam.configParam.phyMode;
1591 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1592 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1593 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1594 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1595 pParam->TxRate = pMac->roam.configParam.TxRate;
1596 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1597 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1598 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1599 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1600 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1602 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1603 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1604 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001605 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1606 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1607 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001608#ifdef WLAN_AP_STA_CONCURRENCY
1609 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1610 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1611 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1612 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1613 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001614 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1615 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001616#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 //Change the unit from microsecond to second
1618 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1619 pParam->eBand = pMac->roam.configParam.eBand;
1620 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1621 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1622 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1623 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1624 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1625 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1626 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1627 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1628 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1629 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1630 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1631 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1632 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1634 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1635 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1636 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1638 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1639 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1640 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1641 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001642 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001643 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001644 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001645 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001646
1647#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1648 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1649#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001650#ifdef WLAN_FEATURE_11AC
1651 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001652 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001653 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001654#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001655#ifdef WLAN_FEATURE_VOWIFI_11R
1656 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1657#endif
1658#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1659 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1660 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1661 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1662 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1663 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001664 pParam->nProbes = pMac->roam.configParam.nProbes;
1665 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001666#endif
1667#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1668 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1669 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1670#endif
1671#ifdef FEATURE_WLAN_LFR
1672 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1673#endif
1674
1675#ifdef FEATURE_WLAN_CCX
1676 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1677#endif
1678#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1679 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1680 {
1681 int i;
1682 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1683 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1684 {
1685 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1686 }
1687 smsLog( pMac, LOG1, "");
1688 }
1689#endif
1690
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001691 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001692
krunal soni5afa96c2013-09-06 22:19:02 -07001693 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
1694
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 csrSetChannels(pMac, pParam);
1696
1697 status = eHAL_STATUS_SUCCESS;
1698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 return (status);
1700}
1701
Jeff Johnson295189b2012-06-20 16:38:30 -07001702eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1703{
1704 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1705 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1706 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1707 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 do
1709 {
1710 if(eCSR_BAND_24 == eBand)
1711 {
1712 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1713 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1714 }
1715 if(eCSR_BAND_5G == eBand)
1716 {
1717 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1718 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1719 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1720 )
1721 {
1722 break;
1723 }
1724 }
1725 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1726 {
1727 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1728 }
1729 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1730 {
1731 newPhyMode = eCSR_DOT11_MODE_AUTO;
1732 }
1733 else
1734 {
1735 //Check for dual band and higher capability first
1736 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1737 {
1738 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1739 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1740 }
1741 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1742 {
1743 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1744 if(eCSR_BAND_24 == eBand) break;
1745 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1746 eBand = eCSR_BAND_5G;
1747 }
1748 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1749 {
1750 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1751 if(eCSR_BAND_5G == eBand) break;
1752 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1753 eBand = eCSR_BAND_24;
1754 }
1755 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1756 {
1757 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1758 if(eCSR_BAND_5G == eBand) break;
1759 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1760 eBand = eCSR_BAND_24;
1761 }
1762 else if(eCSR_DOT11_MODE_11n & phyMode)
1763 {
1764 newPhyMode = eCSR_DOT11_MODE_11n;
1765 }
1766 else if(eCSR_DOT11_MODE_abg & phyMode)
1767 {
1768 newPhyMode = eCSR_DOT11_MODE_abg;
1769 }
1770 else if(eCSR_DOT11_MODE_11a & phyMode)
1771 {
1772 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1773 {
1774 if(eCSR_BAND_ALL == eBand)
1775 {
1776 newPhyMode = eCSR_DOT11_MODE_abg;
1777 }
1778 else
1779 {
1780 //bad setting
1781 break;
1782 }
1783 }
1784 else
1785 {
1786 newPhyMode = eCSR_DOT11_MODE_11a;
1787 eBand = eCSR_BAND_5G;
1788 }
1789 }
1790 else if(eCSR_DOT11_MODE_11g & phyMode)
1791 {
1792 newPhyMode = eCSR_DOT11_MODE_11g;
1793 eBand = eCSR_BAND_24;
1794 }
1795 else if(eCSR_DOT11_MODE_11b & phyMode)
1796 {
1797 newPhyMode = eCSR_DOT11_MODE_11b;
1798 eBand = eCSR_BAND_24;
1799 }
1800 else
1801 {
1802 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001803 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 newPhyMode = eCSR_DOT11_MODE_AUTO;
1805 }
1806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 //Done validating
1808 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 //Now we need to check whether a restart is needed.
1810 if(eBand != pMac->roam.configParam.eBand)
1811 {
1812 fRestartNeeded = eANI_BOOLEAN_TRUE;
1813 break;
1814 }
1815 if(newPhyMode != pMac->roam.configParam.phyMode)
1816 {
1817 fRestartNeeded = eANI_BOOLEAN_TRUE;
1818 break;
1819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 if(HAL_STATUS_SUCCESS(status))
1822 {
1823 pMac->roam.configParam.eBand = eBand;
1824 pMac->roam.configParam.phyMode = newPhyMode;
1825 if(pfRestartNeeded)
1826 {
1827 *pfRestartNeeded = fRestartNeeded;
1828 }
1829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 return (status);
1831}
1832
Jeff Johnson295189b2012-06-20 16:38:30 -07001833void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1834{
1835 tANI_U8 Index;
1836 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 // for dual band NICs, don't need to trim the channel list....
1838 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1839 {
1840 // 2.4 GHz band operation requires the channel list to be trimmed to
1841 // the 2.4 GHz channels only...
1842 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1843 {
1844 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1845 Index++ )
1846 {
1847 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1848 {
1849 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1850 cChannels++;
1851 }
1852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1854 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1855 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1856 // only if we need to.
1857 //
1858 // The amount of memory to clear is the number of channesl that we trimmed
1859 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1860
1861 if ( pChannelList->numChannels > cChannels )
1862 {
1863 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1864 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1865
1866 }
1867
1868 pChannelList->numChannels = cChannels;
1869 }
1870 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1871 {
1872 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1873 {
1874 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1875 {
1876 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1877 cChannels++;
1878 }
1879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1881 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1882 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1883 // only if we need to.
1884 //
1885 // The amount of memory to clear is the number of channesl that we trimmed
1886 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1887 if ( pChannelList->numChannels > cChannels )
1888 {
1889 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1890 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1891 }
1892
1893 pChannelList->numChannels = cChannels;
1894 }
1895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001896}
Jeff Johnson295189b2012-06-20 16:38:30 -07001897#define INFRA_AP_DEFAULT_CHANNEL 6
1898eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1899{
1900 tANI_U8 index= 0;
1901 eHalStatus status = eHAL_STATUS_FAILURE;
1902 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1903 {
1904 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1905 status = eHAL_STATUS_SUCCESS;
1906 break;
1907 }
1908 }
1909 return status;
1910}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001911
1912eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1913{
1914 eHalStatus status = eHAL_STATUS_SUCCESS;
1915 tANI_U8 num20MHzChannelsFound = 0;
1916 VOS_STATUS vosStatus;
1917 tANI_U8 num40MHzChannelsFound = 0;
1918 tANI_U8 Index = 0;
1919 tANI_U8 channelList = 0;
1920
1921 // Updating the defaultpower Table for changed Domain Id
1922 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1923 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1924
1925 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1926 {
1927 smsLog( pMac, LOGE, FL("failed to get channels"));
1928 status = eHAL_STATUS_FAILURE;
1929 }
1930 else
1931 {
1932 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1933 {
1934 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1935 }
1936
1937 // Move the only 5GHZ channel list to the global data,
1938 // As 2.4GHZ list coming from the AP for the changed domain
1939 // structure -- this will be used as the scan list
1940 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1941 {
1942 // If Channel is 5GHz just break the for loop
1943 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1944 break;
1945 }
1946 // Update the 5G channels from nv.bin
1947 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1948 {
1949 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1950 {
Krunal Sonia75019a2013-05-01 01:08:22 -07001951 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1952 {
1953 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1954 channelList++;
1955 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001956 }
1957 }
1958
1959 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1960 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1961 // Filling the remaining index as Zero Just for causion
1962 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1963 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1964 }
1965 return status;
1966}
1967
1968eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1969{
1970 eHalStatus status = eHAL_STATUS_SUCCESS;
1971 tANI_U8 num20MHzChannelsFound = 0;
1972 VOS_STATUS vosStatus;
1973 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05301974 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001975 tANI_U8 num40MHzChannelsFound = 0;
1976 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1977 tANI_U8 channelList = 0;
1978
1979 // Read the scan channel list (including the power limit) from EEPROM
1980 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1981 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1982
1983 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1984 {
1985 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1986 status = eHAL_STATUS_FAILURE;
1987 }
1988 else
1989 {
1990 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1991 {
1992 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1993 }
1994
1995 // Move the 2.4GHZ channel list only to the global data,
1996 // As 5GHz list been provided by AP as part of 11d IE
1997 // structure -- this will be used as the scan list
1998 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1999 {
2000 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
2001 {
2002 // First taking the 5GHz channel list backup
2003 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2004 nuum5GchannelListBackup++;
2005 }
2006 }
2007 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302008 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002009 {
2010 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302011 {
2012 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2013 numChan++;
2014 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002015 }
2016 // Restoring the Backed up 5 GHZ channels
2017 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2018 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302019 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002020 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302021 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2022 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002023 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002024 }
2025
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302026 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2027 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002028 }
2029 return (status);
2030}
2031
Jeff Johnson295189b2012-06-20 16:38:30 -07002032eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2033{
2034 eHalStatus status = eHAL_STATUS_SUCCESS;
2035 tANI_U8 num20MHzChannelsFound = 0;
2036 VOS_STATUS vosStatus;
2037 tANI_U8 Index = 0;
2038 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002039
Jeff Johnson295189b2012-06-20 16:38:30 -07002040
2041 //TODO: this interface changed to include the 40MHz channel list
2042 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2043 // Read the scan channel list (including the power limit) from EEPROM
2044 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2045 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2046 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002048 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 status = eHAL_STATUS_FAILURE;
2050 }
2051 else
2052 {
2053 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2054 {
2055 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2056 }
2057 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2058 // Move the channel list to the global data
2059 // structure -- this will be used as the scan list
2060 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2061 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 }
2064 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2065 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2066 {
2067 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2068 }
2069 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2070 {
2071 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2072 }
2073 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 return (status);
2076}
2077
Jeff Johnson295189b2012-06-20 16:38:30 -07002078eHalStatus csrInitChannelList( tHalHandle hHal )
2079{
2080 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2081 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2083 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002084 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2085 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002086 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002087 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002088
2089 return (status);
2090}
Jeff Johnson295189b2012-06-20 16:38:30 -07002091eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2092 tCsrUpdateConfigParam *pUpdateConfigParam)
2093{
2094 eHalStatus status = eHAL_STATUS_FAILURE;
2095 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2097 status = CsrInit11dInfo(pMac, ps11dinfo);
2098 return status;
2099}
2100
Jeff Johnson295189b2012-06-20 16:38:30 -07002101static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2102{
2103 eHalStatus status = eHAL_STATUS_FAILURE;
2104 tANI_U8 index;
2105 tANI_U32 count=0;
2106 tSirMacChanInfo *pChanInfo;
2107 tSirMacChanInfo *pChanInfoStart;
2108 tANI_BOOLEAN applyConfig = TRUE;
2109
2110 if(!ps11dinfo)
2111 {
2112 return (status);
2113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2115 {
2116 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2117 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2118 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2119 if(!HAL_STATUS_SUCCESS(status)) return (status);
2120 }
2121 else
2122 {
2123 //No change
2124 return (eHAL_STATUS_SUCCESS);
2125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 //legacy maintenance
2127 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2128 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2129 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 //Tush: at csropen get this initialized with default, during csr reset if this
2131 // already set with some value no need initilaize with default again
2132 if(0 == pMac->scan.countryCodeCurrent[0])
2133 {
2134 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2135 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2136 if(!HAL_STATUS_SUCCESS(status)) return (status);
2137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 // need to add the max power channel list
2139 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2140 {
2141 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2142 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002143 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2144 {
2145 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2146 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2147 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2148 pChanInfo++;
2149 count++;
2150 }
2151 if(count)
2152 {
2153 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2154 }
2155 palFreeMemory(pMac->hHdd, pChanInfoStart);
2156 }
2157 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2158 if( HAL_STATUS_SUCCESS(status) )
2159 {
2160 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2161 {
2162 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2163 {
2164 applyConfig = FALSE;
2165 }
2166 }
2167
2168 if(TRUE == applyConfig)
2169 {
2170 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002171 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002172 }
2173
2174 }
2175 return (status);
2176}
2177/* Initialize the Channel + Power List in the local cache and in the CFG */
2178eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2179{
2180 tANI_U8 index;
2181 tANI_U32 count=0;
2182 tSirMacChanInfo *pChanInfo;
2183 tSirMacChanInfo *pChanInfoStart;
2184
2185 if(!ps11dinfo || !pMac)
2186 {
2187 return eHAL_STATUS_FAILURE;
2188 }
2189
2190 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2191 {
2192 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2193 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002194
2195 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2196 {
2197 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2198 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2199 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2200 pChanInfo++;
2201 count++;
2202 }
2203 if(count)
2204 {
2205 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2206 }
2207 palFreeMemory(pMac->hHdd, pChanInfoStart);
2208 }
2209
Jeff Johnsone7245742012-09-05 17:12:55 -07002210 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002211}
2212
2213//pCommand may be NULL
2214//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2215void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2216{
2217 tListElem *pEntry, *pNextEntry;
2218 tSmeCmd *pDupCommand;
2219 tDblLinkList localList;
2220
2221 vos_mem_zero(&localList, sizeof(tDblLinkList));
2222 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2223 {
2224 smsLog(pMac, LOGE, FL(" failed to open list"));
2225 return;
2226 }
2227 csrLLLock( &pMac->sme.smeCmdPendingList );
2228 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2229 while( pEntry )
2230 {
2231 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2232 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 // Remove the previous command if..
2234 // - the new roam command is for the same RoamReason...
2235 // - the new roam command is a NewProfileList.
2236 // - the new roam command is a Forced Dissoc
2237 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2238 if (
2239 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2240 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002241 /* This peermac check is requried for Softap/GO scenarios
2242 * For STA scenario below OR check will suffice as pCommand will
2243 * always be NULL for STA scenarios
2244 */
2245 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2247 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2248 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2249 ||
2250 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002251 ( (sessionId == pDupCommand->sessionId) &&
2252 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 ((eCsrForcedDisassoc == eRoamReason) ||
2254 (eCsrHddIssued == eRoamReason))
2255 )
2256 )
2257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002258 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 // Remove the 'stale' roam command from the pending list...
2260 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2261 {
2262 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2263 }
2264 }
2265 pEntry = pNextEntry;
2266 }
2267 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2268
2269 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2270 {
2271 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2272 //Tell caller that the command is cancelled
2273 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2274 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2275 csrReleaseCommandRoam(pMac, pDupCommand);
2276 }
2277 csrLLClose(&localList);
2278}
Jeff Johnson295189b2012-06-20 16:38:30 -07002279eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2280 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2281{
2282 eHalStatus status = eHAL_STATUS_SUCCESS;
2283#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2284 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2285#endif
2286 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2288 {
2289 pSession = CSR_GET_SESSION( pMac, sessionId );
2290 }
2291 else
2292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002293 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 VOS_ASSERT(0);
2295 return eHAL_STATUS_FAILURE;
2296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002299 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002301 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2302 /*
2303 * Decrement bRefAssocStartCnt for FT reassoc failure.
2304 * Reason: For FT reassoc failures, we first call
2305 * csrRoamCallCallback before notifying a failed roam
2306 * completion through csrRoamComplete. The latter in
2307 * turn calls csrRoamProcessResults which tries to
2308 * once again call csrRoamCallCallback if bRefAssocStartCnt
2309 * is non-zero. Since this is redundant for FT reassoc
2310 * failure, decrement bRefAssocStartCnt.
2311 */
2312 pSession->bRefAssocStartCnt--;
2313 }
2314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 if ( (pSession == NULL) ||
2316 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2317 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002318 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 return eHAL_STATUS_FAILURE;
2320 }
2321
2322 if(NULL != pSession->callback)
2323 {
2324 if( pRoamInfo )
2325 {
2326 pRoamInfo->sessionId = (tANI_U8)sessionId;
2327 }
2328
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302329 /* avoid holding the global lock when making the roaming callback, original change came
2330 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2331 is possible on other OS ports where the callback may need to take locks to protect
2332 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002333 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2334 that may actually depend on the lock being held */
2335 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2336 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2337 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2338 }
2339 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2340 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2341#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2342 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2343 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2344 {
2345 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2346 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2347 if(NULL != pRoamInfo->pBssDesc)
2348 {
2349 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2350 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2351 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2353 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2354 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2355 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2356 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2357 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2360 {
2361 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2362 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2363 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 if(eCSR_ROAM_RESULT_FORCED == u2)
2366 {
2367 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2368 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2369 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2372 {
2373 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2374 connectionStatus.reason = eCSR_REASON_DISASSOC;
2375 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2378 {
2379 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2380 connectionStatus.reason = eCSR_REASON_DEAUTH;
2381 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002383#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2384
2385 return (status);
2386}
Jeff Johnson295189b2012-06-20 16:38:30 -07002387// Returns whether handoff is currently in progress or not
2388tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2389{
2390#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2391 return csrNeighborRoamIsHandoffInProgress(pMac);
2392#else
2393 return eANI_BOOLEAN_FALSE;
2394#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002395}
Jeff Johnson295189b2012-06-20 16:38:30 -07002396eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2397 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2398{
2399 eHalStatus status = eHAL_STATUS_SUCCESS;
2400 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2401 tANI_U16 reasonCode;
2402 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002403
2404 if(!pSession)
2405 {
2406 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2407 return eHAL_STATUS_FAILURE;
2408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002409
2410 //Restore AC weight in case we change it
2411 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2412 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002413 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 -07002414 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2415 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2416 }
2417
2418 if ( fMICFailure )
2419 {
2420 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2421 }
2422 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2423 {
2424 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002425 }
2426 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 {
2428 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002430#ifdef WLAN_FEATURE_VOWIFI_11R
2431 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2432 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2433 {
2434 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2435 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002436 }
2437 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002438#endif
2439 if(pSession->pConnectBssDesc)
2440 {
2441 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2442 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002443
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002445 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2446 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2447 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2448
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2450
2451 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2452
2453 if(HAL_STATUS_SUCCESS(status))
2454 {
2455 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2457 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2458 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2459 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002460 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2462 }
2463#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002464 }
2465 else
2466 {
2467 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2468 }
2469
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 return (status);
2471}
Jeff Johnson295189b2012-06-20 16:38:30 -07002472
Jeff Johnson295189b2012-06-20 16:38:30 -07002473/* ---------------------------------------------------------------------------
2474 \fn csrRoamIssueDisassociateStaCmd
2475 \brief csr function that HDD calls to disassociate a associated station
2476 \param sessionId - session Id for Soft AP
2477 \param pPeerMacAddr - MAC of associated station to delete
2478 \param reason - reason code, be one of the tSirMacReasonCodes
2479 \return eHalStatus
2480 ---------------------------------------------------------------------------*/
2481eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2482 tANI_U32 sessionId,
2483 tANI_U8 *pPeerMacAddr,
2484 tANI_U32 reason)
2485{
2486 eHalStatus status = eHAL_STATUS_SUCCESS;
2487 tSmeCmd *pCommand;
2488
2489 do
2490 {
2491 pCommand = csrGetCommandBuffer( pMac );
2492 if ( !pCommand )
2493 {
2494 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2495 status = eHAL_STATUS_RESOURCES;
2496 break;
2497 }
2498 pCommand->command = eSmeCommandRoam;
2499 pCommand->sessionId = (tANI_U8)sessionId;
2500 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2501 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2502 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2503 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2504 if( !HAL_STATUS_SUCCESS( status ) )
2505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002506 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 csrReleaseCommandRoam( pMac, pCommand );
2508 }
2509 }while(0);
2510
2511 return status;
2512}
2513
2514
Jeff Johnson295189b2012-06-20 16:38:30 -07002515/* ---------------------------------------------------------------------------
2516 \fn csrRoamIssueDeauthSta
2517 \brief csr function that HDD calls to delete a associated station
2518 \param sessionId - session Id for Soft AP
2519 \param pPeerMacAddr - MAC of associated station to delete
2520 \param reason - reason code, be one of the tSirMacReasonCodes
2521 \return eHalStatus
2522 ---------------------------------------------------------------------------*/
2523eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2524 tANI_U32 sessionId,
2525 tANI_U8 *pPeerMacAddr,
2526 tANI_U32 reason)
2527{
2528 eHalStatus status = eHAL_STATUS_SUCCESS;
2529 tSmeCmd *pCommand;
2530
2531 do
2532 {
2533 pCommand = csrGetCommandBuffer( pMac );
2534 if ( !pCommand )
2535 {
2536 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2537 status = eHAL_STATUS_RESOURCES;
2538 break;
2539 }
2540 pCommand->command = eSmeCommandRoam;
2541 pCommand->sessionId = (tANI_U8)sessionId;
2542 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2543 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2544 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2545 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2546 if( !HAL_STATUS_SUCCESS( status ) )
2547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002548 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 csrReleaseCommandRoam( pMac, pCommand );
2550 }
2551 }while(0);
2552
2553 return status;
2554}
Jeff Johnson295189b2012-06-20 16:38:30 -07002555eHalStatus
2556csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2557 tANI_BOOLEAN bEnable )
2558{
2559 eHalStatus status = eHAL_STATUS_FAILURE;
2560 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2561 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 if (!pSession)
2563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002564 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 return (status);
2566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 if (pSession->pConnectBssDesc)
2568 {
2569 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2570 }
2571 else
2572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002573 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 return (status);
2575 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002576 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 -07002577 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302578 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2580 return (status);
2581}
Jeff Johnson295189b2012-06-20 16:38:30 -07002582eHalStatus
2583csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2584 VOS_MODULE_ID modId, void *pUsrContext,
2585 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2586{
2587 eHalStatus status = eHAL_STATUS_SUCCESS;
2588 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 if (!pSession)
2591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002592 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 return (status);
2594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 if(pSession->pConnectBssDesc)
2596 {
2597 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2598 }
2599 else
2600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002601 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 return (status);
2603 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002604 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2606 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2608 return (status);
2609}
Jeff Johnson295189b2012-06-20 16:38:30 -07002610eHalStatus
2611csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2612 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2613{
2614 eHalStatus status = eHAL_STATUS_SUCCESS;
2615 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2616 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2617
2618 if (!pSession)
2619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002620 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 return (status);
2622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 if(pSession->pConnectBssDesc)
2624 {
2625 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2626 }
2627 else
2628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002629 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 return (status);
2631 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002632 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2634 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2635
2636 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2637
2638 return (status);
2639}
Jeff Johnson295189b2012-06-20 16:38:30 -07002640eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2641{
2642 eHalStatus status = eHAL_STATUS_SUCCESS;
2643 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2644 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002645
2646 if (!pSession)
2647 {
2648 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2649 return eHAL_STATUS_FAILURE;
2650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002651
2652 if(pSession->pConnectBssDesc)
2653 {
2654 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2655 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002656 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2658 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2660
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302661 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002662 if(!HAL_STATUS_SUCCESS(status))
2663 {
2664 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2665 }
2666
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 return (status);
2668}
2669
Jeff Johnson295189b2012-06-20 16:38:30 -07002670eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2671{
2672 eHalStatus status = eHAL_STATUS_SUCCESS;
2673 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2674 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002675
2676 if(!pSession)
2677 {
2678 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2679 return eHAL_STATUS_FAILURE;
2680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002681
2682 // If no BSS description was found in this connection (happens with start IBSS), then
2683 // nix the BSS description that we keep around for the connected BSS) and get out...
2684 if(NULL == pBssDesc)
2685 {
2686 csrFreeConnectBssDesc(pMac, sessionId);
2687 }
2688 else
2689 {
2690 size = pBssDesc->length + sizeof( pBssDesc->length );
2691 if(NULL != pSession->pConnectBssDesc)
2692 {
2693 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2694 {
2695 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2696 csrFreeConnectBssDesc(pMac, sessionId);
2697 }
2698 }
2699 if(NULL == pSession->pConnectBssDesc)
2700 {
2701 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2702 }
2703 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2704 {
2705 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2706 }
2707 }
2708
2709 return (status);
2710}
2711
Jeff Johnson295189b2012-06-20 16:38:30 -07002712eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2713 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2714 tDot11fBeaconIEs *pIes)
2715{
2716 eHalStatus status = eHAL_STATUS_SUCCESS;
2717 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302719 if (pIes == NULL)
2720 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002721
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 do
2723 {
2724 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2725 //get qos
2726 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2727 //get SSID
2728 if(pIes->SSID.present)
2729 {
2730 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2731 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2732 }
2733 else
2734 pBssConfig->SSID.length = 0;
2735 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2736 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002737 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 //Return failed if profile doesn't have an SSID either.
2739 if(pProfile->SSIDs.numOfSSIDs == 0)
2740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002741 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 status = eHAL_STATUS_FAILURE;
2743 break;
2744 }
2745 }
2746 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2747 {
2748 pBssConfig->eBand = eCSR_BAND_5G;
2749 }
2750 else
2751 {
2752 pBssConfig->eBand = eCSR_BAND_24;
2753 }
2754 //phymode
2755 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2756 {
2757 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2758 }
2759 else
2760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002761 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 //force it
2763 if(eCSR_BAND_24 == pBssConfig->eBand)
2764 {
2765 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2766 }
2767 else
2768 {
2769 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2770 }
2771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 //Qos
2773 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2774 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2775 {
2776 //Joining BSS is not 11n capable and WMM is disabled on client.
2777 //Disable QoS and WMM
2778 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2779 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302780
2781 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302782 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302783 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2784 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2785 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2786 {
2787 //Joining BSS is 11n capable and WMM is disabled on AP.
2788 //Assume all HT AP's are QOS AP's and enable WMM
2789 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2790 }
2791
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 //auth type
2793 switch( pProfile->negotiatedAuthType )
2794 {
2795 default:
2796 case eCSR_AUTH_TYPE_WPA:
2797 case eCSR_AUTH_TYPE_WPA_PSK:
2798 case eCSR_AUTH_TYPE_WPA_NONE:
2799 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2800 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 case eCSR_AUTH_TYPE_SHARED_KEY:
2803 pBssConfig->authType = eSIR_SHARED_KEY;
2804 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 case eCSR_AUTH_TYPE_AUTOSWITCH:
2806 pBssConfig->authType = eSIR_AUTO_SWITCH;
2807 break;
2808 }
2809 //short slot time
2810 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2811 {
2812 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2813 }
2814 else
2815 {
2816 pBssConfig->uShortSlotTime = 0;
2817 }
2818 if(pBssConfig->BssCap.ibss)
2819 {
2820 //We don't support 11h on IBSS
2821 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2822 }
2823 else
2824 {
2825 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2826 }
2827 //power constraint
2828 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2829 //heartbeat
2830 if ( CSR_IS_11A_BSS( pBssDesc ) )
2831 {
2832 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2833 }
2834 else
2835 {
2836 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2837 }
2838 //Join timeout
2839 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002840 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 if ( pBssDesc->beaconInterval )
2842 {
2843 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002844 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 }
2846 else
2847 {
2848 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2849 }
2850 //validate CB
2851 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2852 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 return (status);
2854}
2855
Jeff Johnson295189b2012-06-20 16:38:30 -07002856static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2857 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2858{
2859 eHalStatus status = eHAL_STATUS_SUCCESS;
2860 tANI_U8 operationChannel = 0;
2861 tANI_U8 qAPisEnabled = FALSE;
2862 //SSID
2863 pBssConfig->SSID.length = 0;
2864 if(pProfile->SSIDs.numOfSSIDs)
2865 {
2866 //only use the first one
2867 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2868 }
2869 else
2870 {
2871 //SSID must present
2872 return eHAL_STATUS_FAILURE;
2873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 //Settomg up the capabilities
2875 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2876 {
2877 pBssConfig->BssCap.ibss = 1;
2878 }
2879 else
2880 {
2881 pBssConfig->BssCap.ess = 1;
2882 }
2883 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2884 {
2885 pBssConfig->BssCap.privacy = 1;
2886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 pBssConfig->eBand = pMac->roam.configParam.eBand;
2888 //phymode
2889 if(pProfile->ChannelInfo.ChannelList)
2890 {
2891 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2894 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 //QOS
2896 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 if ( pBssConfig->BssCap.ess == 1 )
2898 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 /*For Softap case enable WMM*/
2900 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2901 qAPisEnabled = TRUE;
2902 }
2903 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2905 qAPisEnabled = TRUE;
2906 } else {
2907 qAPisEnabled = FALSE;
2908 }
2909 } else {
2910 qAPisEnabled = TRUE;
2911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2913 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2914 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2915 )
2916 {
2917 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2918 } else {
2919 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2920 }
2921
2922 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002923 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 {
2925 default:
2926 case eCSR_AUTH_TYPE_WPA:
2927 case eCSR_AUTH_TYPE_WPA_PSK:
2928 case eCSR_AUTH_TYPE_WPA_NONE:
2929 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2930 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2931 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 case eCSR_AUTH_TYPE_SHARED_KEY:
2933 pBssConfig->authType = eSIR_SHARED_KEY;
2934 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 case eCSR_AUTH_TYPE_AUTOSWITCH:
2936 pBssConfig->authType = eSIR_AUTO_SWITCH;
2937 break;
2938 }
2939 //short slot time
2940 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2941 {
2942 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2943 }
2944 else
2945 {
2946 pBssConfig->uShortSlotTime = 0;
2947 }
2948 //power constraint. We don't support 11h on IBSS
2949 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2950 pBssConfig->uPowerLimit = 0;
2951 //heartbeat
2952 if ( eCSR_BAND_5G == pBssConfig->eBand )
2953 {
2954 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2955 }
2956 else
2957 {
2958 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2959 }
2960 //Join timeout
2961 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002962
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 return (status);
2964}
Jeff Johnson295189b2012-06-20 16:38:30 -07002965static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2966{
2967 eHalStatus status = eHAL_STATUS_FAILURE;
2968 tDot11fBeaconIEs *pIes = NULL;
2969
2970 do
2971 {
2972 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2973 {
2974 //err msg
2975 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002976 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 break;
2978 }
2979 //check if the AP is QAP & it supports APSD
2980 if( CSR_IS_QOS_BSS(pIes) )
2981 {
2982 return eHAL_STATUS_SUCCESS;
2983 }
2984 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 return status;
2986}
2987
Jeff Johnson295189b2012-06-20 16:38:30 -07002988void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2989{
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2991 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2992 // See !!Note: below in this function...
2993 tANI_U32 PrivacyEnabled = 0;
2994 tANI_U32 RsnEnabled = 0;
2995 tANI_U32 WepDefaultKeyId = 0;
2996 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2997 tANI_U32 Key0Length = 0;
2998 tANI_U32 Key1Length = 0;
2999 tANI_U32 Key2Length = 0;
3000 tANI_U32 Key3Length = 0;
3001
3002 // Reserve for the biggest key
3003 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3004 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3005 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3006 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3007
3008 switch ( pProfile->negotiatedUCEncryptionType )
3009 {
3010 case eCSR_ENCRYPT_TYPE_NONE:
3011
3012 // for NO encryption, turn off Privacy and Rsn.
3013 PrivacyEnabled = 0;
3014 RsnEnabled = 0;
3015
3016 // WEP key length and Wep Default Key ID don't matter in this case....
3017
3018 // clear out the WEP keys that may be hanging around.
3019 Key0Length = 0;
3020 Key1Length = 0;
3021 Key2Length = 0;
3022 Key3Length = 0;
3023
3024 break;
3025
3026 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303027 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003028
3029 // Privacy is ON. NO RSN for Wep40 static key.
3030 PrivacyEnabled = 1;
3031 RsnEnabled = 0;
3032
3033 // Set the Wep default key ID.
3034 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 // Wep key size if 5 bytes (40 bits).
3036 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3037
3038 // set encryption keys in the CFG database or clear those that are not present in this profile.
3039 if ( pProfile->Keys.KeyLength[0] )
3040 {
3041 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3042 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3043 }
3044 else
3045 {
3046 Key0Length = 0;
3047 }
3048
3049 if ( pProfile->Keys.KeyLength[1] )
3050 {
3051 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3052 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3053 }
3054 else
3055 {
3056 Key1Length = 0;
3057 }
3058
3059 if ( pProfile->Keys.KeyLength[2] )
3060 {
3061 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3062 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3063 }
3064 else
3065 {
3066 Key2Length = 0;
3067 }
3068
3069 if ( pProfile->Keys.KeyLength[3] )
3070 {
3071 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3072 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3073 }
3074 else
3075 {
3076 Key3Length = 0;
3077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 break;
3079
3080 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303081 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003082
3083 // Privacy is ON. NO RSN for Wep40 static key.
3084 PrivacyEnabled = 1;
3085 RsnEnabled = 0;
3086
3087 // Set the Wep default key ID.
3088 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3089
3090 // Wep key size if 13 bytes (104 bits).
3091 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3092
3093 // set encryption keys in the CFG database or clear those that are not present in this profile.
3094 if ( pProfile->Keys.KeyLength[0] )
3095 {
3096 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3097 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3098 }
3099 else
3100 {
3101 Key0Length = 0;
3102 }
3103
3104 if ( pProfile->Keys.KeyLength[1] )
3105 {
3106 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3107 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3108 }
3109 else
3110 {
3111 Key1Length = 0;
3112 }
3113
3114 if ( pProfile->Keys.KeyLength[2] )
3115 {
3116 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3117 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3118 }
3119 else
3120 {
3121 Key2Length = 0;
3122 }
3123
3124 if ( pProfile->Keys.KeyLength[3] )
3125 {
3126 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3127 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3128 }
3129 else
3130 {
3131 Key3Length = 0;
3132 }
3133
3134 break;
3135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 case eCSR_ENCRYPT_TYPE_TKIP:
3137 case eCSR_ENCRYPT_TYPE_AES:
3138#ifdef FEATURE_WLAN_WAPI
3139 case eCSR_ENCRYPT_TYPE_WPI:
3140#endif /* FEATURE_WLAN_WAPI */
3141 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3142 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3143 PrivacyEnabled = (0 != fPrivacy);
3144
3145 // turn on RSN enabled for WPA associations
3146 RsnEnabled = 1;
3147
3148 // WEP key length and Wep Default Key ID don't matter in this case....
3149
3150 // clear out the static WEP keys that may be hanging around.
3151 Key0Length = 0;
3152 Key1Length = 0;
3153 Key2Length = 0;
3154 Key3Length = 0;
3155
3156 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 default:
3158 PrivacyEnabled = 0;
3159 RsnEnabled = 0;
3160 break;
3161 }
3162
3163 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3164 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3165 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3166 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3167 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3168 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3169 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3170 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3171}
3172
Jeff Johnson295189b2012-06-20 16:38:30 -07003173static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3174{
3175 tANI_U32 len = 0;
3176 if(pSSID->length <= WNI_CFG_SSID_LEN)
3177 {
3178 len = pSSID->length;
3179 }
3180 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3181}
3182
Jeff Johnson295189b2012-06-20 16:38:30 -07003183eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3184{
3185 eHalStatus status = eHAL_STATUS_SUCCESS;
3186 tANI_U32 QoSEnabled;
3187 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 // set the CFG enable/disable variables based on the qosType being configured...
3189 switch( qosType )
3190 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3192 QoSEnabled = FALSE;
3193 WmeEnabled = TRUE;
3194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3196 QoSEnabled = FALSE;
3197 WmeEnabled = TRUE;
3198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3200 QoSEnabled = FALSE;
3201 WmeEnabled = TRUE;
3202 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3204 QoSEnabled = TRUE;
3205 WmeEnabled = FALSE;
3206 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 case eCSR_MEDIUM_ACCESS_11e_HCF:
3208 QoSEnabled = TRUE;
3209 WmeEnabled = FALSE;
3210 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 default:
3212 case eCSR_MEDIUM_ACCESS_DCF:
3213 QoSEnabled = FALSE;
3214 WmeEnabled = FALSE;
3215 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 }
3217 //save the WMM setting for later use
3218 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3220 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 return (status);
3222}
Jeff Johnson295189b2012-06-20 16:38:30 -07003223static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3224 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3225{
3226 eHalStatus status = eHAL_STATUS_FAILURE;
3227 int i;
3228 eCsrCfgDot11Mode cfgDot11Mode;
3229 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3231 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234 if( NULL != pIes )
3235 {
3236 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 // Originally, we thought that for 11a networks, the 11a rates are always
3238 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3239 // appear in the Operational Rate set. Consequently, in either case, we
3240 // would blindly put the rates we support into our Operational Rate set
3241 // (including the basic rates, which we have already verified are
3242 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 // However, it turns out that this is not always the case. Some AP's
3244 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3245 // too. Now, we're a little more careful:
3246 pDstRate = pOpRateSet->rate;
3247 if(pIes->SuppRates.present)
3248 {
3249 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3250 {
3251 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3252 {
3253 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003254 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 }
3256 }
3257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3259 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3260 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3261 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3262 {
3263 // If there are Extended Rates in the beacon, we will reflect those
3264 // extended rates that we support in out Extended Operational Rate
3265 // set:
3266 pDstRate = pExRateSet->rate;
3267 if(pIes->ExtSuppRates.present)
3268 {
3269 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3270 {
3271 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3272 {
3273 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3274 pExRateSet->numRates++;
3275 }
3276 }
3277 }
3278 }
3279 }//Parsing BSSDesc
3280 else
3281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003282 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 }
3284 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3285 return status;
3286}
3287
3288static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3289 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3290{
3291 int i;
3292 tANI_U8 *pDstRate;
3293 eCsrCfgDot11Mode cfgDot11Mode;
3294 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3295 tANI_U32 OperationalRatesLength = 0;
3296 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3297 tANI_U32 ExtendedOperationalRatesLength = 0;
3298 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3299 tANI_U32 ProprietaryOperationalRatesLength = 0;
3300 tANI_U32 PropRatesEnable = 0;
3301 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3302 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 if( NULL != pIes )
3305 {
3306 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 // Originally, we thought that for 11a networks, the 11a rates are always
3308 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3309 // appear in the Operational Rate set. Consequently, in either case, we
3310 // would blindly put the rates we support into our Operational Rate set
3311 // (including the basic rates, which we have already verified are
3312 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 // However, it turns out that this is not always the case. Some AP's
3314 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3315 // too. Now, we're a little more careful:
3316 pDstRate = OperationalRates;
3317 if(pIes->SuppRates.present)
3318 {
3319 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3320 {
3321 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3322 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3323 {
3324 *pDstRate++ = pIes->SuppRates.rates[ i ];
3325 OperationalRatesLength++;
3326 }
3327 }
3328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3330 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3331 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3332 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3333 {
3334 // If there are Extended Rates in the beacon, we will reflect those
3335 // extended rates that we support in out Extended Operational Rate
3336 // set:
3337 pDstRate = ExtendedOperationalRates;
3338 if(pIes->ExtSuppRates.present)
3339 {
3340 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3341 {
3342 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3343 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3344 {
3345 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3346 ExtendedOperationalRatesLength++;
3347 }
3348 }
3349 }
3350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 // Enable proprietary MAC features if peer node is Airgo node and STA
3352 // user wants to use them
3353 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3354 {
3355 PropRatesEnable = 1;
3356 }
3357 else
3358 {
3359 PropRatesEnable = 0;
3360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 // For ANI network companions, we need to populate the proprietary rate
3362 // set with any proprietary rates we found in the beacon, only if user
3363 // allows them...
3364 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3365 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3366 {
3367 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3368 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3369 {
3370 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3371 }
3372 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3373 }
3374 else {
3375 // No proprietary modes...
3376 ProprietaryOperationalRatesLength = 0;
3377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 /* Get MCS Rate */
3379 pDstRate = MCSRateIdxSet;
3380 if ( pIes->HTCaps.present )
3381 {
3382 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3383 {
3384 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3385 {
3386 MCSRateLength++;
3387 *pDstRate++ = i;
3388 }
3389 }
3390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 // Set the operational rate set CFG variables...
3392 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3393 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3394 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3395 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3396 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3397 ProprietaryOperationalRates,
3398 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3399 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3400 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3401 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3402 }//Parsing BSSDesc
3403 else
3404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003405 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 }
3407}
3408
Jeff Johnson295189b2012-06-20 16:38:30 -07003409static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3410 tCsrRoamProfile *pProfile )
3411{
3412 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3413 { 8,
3414 { SIR_MAC_RATE_6,
3415 SIR_MAC_RATE_9,
3416 SIR_MAC_RATE_12,
3417 SIR_MAC_RATE_18,
3418 SIR_MAC_RATE_24,
3419 SIR_MAC_RATE_36,
3420 SIR_MAC_RATE_48,
3421 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3423 { 4,
3424 { SIR_MAC_RATE_1,
3425 SIR_MAC_RATE_2,
3426 SIR_MAC_RATE_5_5,
3427 SIR_MAC_RATE_11 } } };
3428
3429
3430 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3431 { SIR_MAC_RATE_72,
3432 SIR_MAC_RATE_96,
3433 SIR_MAC_RATE_108 } };
3434 eCsrCfgDot11Mode cfgDot11Mode;
3435 eCsrBand eBand;
3436 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3437 tANI_U32 OperationalRatesLength = 0;
3438 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3439 tANI_U32 ExtendedOperationalRatesLength = 0;
3440 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3441 tANI_U32 ProprietaryOperationalRatesLength = 0;
3442 tANI_U32 PropRatesEnable = 0;
3443 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 if(pProfile->ChannelInfo.ChannelList)
3445 {
3446 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3450 // networks, the 11b rates appear in the Operational Rate set. In either case,
3451 // we can blindly put the rates we support into our Operational Rate set
3452 // (including the basic rates, which we have already verified are supported
3453 // earlier in the roaming decision).
3454 if ( eCSR_BAND_5G == eBand )
3455 {
3456 // 11a rates into the Operational Rate Set.
3457 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3458 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3459 palCopyMemory( pMac->hHdd, OperationalRates,
3460 DefaultSupportedRates11a.supportedRateSet.rate,
3461 OperationalRatesLength );
3462
3463 // Nothing in the Extended rate set.
3464 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 // populate proprietary rates if user allows them
3466 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3467 {
3468 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3469 sizeof(*DefaultSupportedPropRates.propRate);
3470 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3471 DefaultSupportedPropRates.propRate,
3472 ProprietaryOperationalRatesLength );
3473 }
3474 else
3475 {
3476 // No proprietary modes
3477 ProprietaryOperationalRatesLength = 0;
3478 }
3479 }
3480 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3481 {
3482 // 11b rates into the Operational Rate Set.
3483 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3484 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3485 palCopyMemory( pMac->hHdd, OperationalRates,
3486 DefaultSupportedRates11b.supportedRateSet.rate,
3487 OperationalRatesLength );
3488 // Nothing in the Extended rate set.
3489 ExtendedOperationalRatesLength = 0;
3490 // No proprietary modes
3491 ProprietaryOperationalRatesLength = 0;
3492 }
3493 else
3494 {
3495 // 11G
3496
3497 // 11b rates into the Operational Rate Set.
3498 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3499 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3500 palCopyMemory( pMac->hHdd, OperationalRates,
3501 DefaultSupportedRates11b.supportedRateSet.rate,
3502 OperationalRatesLength );
3503
3504 // 11a rates go in the Extended rate set.
3505 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3506 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3507 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3508 DefaultSupportedRates11a.supportedRateSet.rate,
3509 ExtendedOperationalRatesLength );
3510
3511 // populate proprietary rates if user allows them
3512 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3513 {
3514 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3515 sizeof(*DefaultSupportedPropRates.propRate);
3516 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3517 DefaultSupportedPropRates.propRate,
3518 ProprietaryOperationalRatesLength );
3519 }
3520 else
3521 {
3522 // No proprietary modes
3523 ProprietaryOperationalRatesLength = 0;
3524 }
3525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3527 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3528 {
3529 PropRatesEnable = 1;
3530 }
3531 else
3532 {
3533 PropRatesEnable = 0;
3534 }
3535
3536 // Set the operational rate set CFG variables...
3537 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3538 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3539 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3540 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3541 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3542 ProprietaryOperationalRates,
3543 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3544 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003545}
Jeff Johnson295189b2012-06-20 16:38:30 -07003546void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3547{
3548 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003549
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3551 tANI_U32 sessionId;
3552 tSmeCmd *pCommand = NULL;
3553
3554 if(NULL == pEntry)
3555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003556 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 return;
3558 }
3559 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3560 sessionId = pCommand->sessionId;
3561
3562 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3563 {
3564 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3565 }
3566}
3567
Jeff Johnson295189b2012-06-20 16:38:30 -07003568//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3569tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3570{
3571 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3572 {
3573 return (WNI_CFG_PHY_MODE_11B);
3574 }
3575 else
3576 {
3577 if(eCSR_BAND_24 == band)
3578 return (WNI_CFG_PHY_MODE_11G);
3579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 return (WNI_CFG_PHY_MODE_11A);
3581}
Jeff Johnson295189b2012-06-20 16:38:30 -07003582
Jeff Johnsone7245742012-09-05 17:12:55 -07003583
3584#ifdef WLAN_FEATURE_11AC
3585ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3586{
3587 switch ( aniCBMode )
3588 {
3589 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3590 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3591 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3592 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3593 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3594 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3595 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3596 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3597 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003598 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003599 return PHY_SINGLE_CHANNEL_CENTERED;
3600 }
3601}
3602#endif
3603
Jeff Johnson295189b2012-06-20 16:38:30 -07003604//pIes may be NULL
3605eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3606 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303607 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003608{
3609 eHalStatus status = eHAL_STATUS_SUCCESS;
3610 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3611 tANI_U8 channel = 0;
3612 //Make sure we have the domain info for the BSS we try to connect to.
3613 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303614 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303616 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 {
3618 //Make sure the 11d info from this BSSDesc can be applied
3619 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303620 if (VOS_TRUE == resetCountry)
3621 {
3622 csrApplyCountryInformation(pMac, FALSE);
3623 }
3624 else
3625 {
3626 csrApplyCountryInformation(pMac, TRUE);
3627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 }
Kiran4a17ebe2013-01-31 10:43:43 -08003629 if ((csrIs11dSupported (pMac)) && pIes)
3630 {
3631 if (!pIes->Country.present)
3632 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 //Qos
3636 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3637 //SSID
3638 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3639 //fragment threshold
3640 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3641 //RTS threshold
3642 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3643
3644 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3645
3646 //Auth type
3647 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3648 //encryption type
3649 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3650 //short slot time
3651 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 //11d
3653 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3654 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3655 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 /*//11h
3657 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3658 */
3659 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3660 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003661
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003662 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 {
3664 channel = pProfile->operationChannel;
3665 }
3666 else
3667 {
3668 if(pBssDesc)
3669 {
3670 channel = pBssDesc->channelId;
3671 }
3672 }
3673 if(0 != channel)
3674 {
3675 if(CSR_IS_CHANNEL_24GHZ(channel))
3676 {//for now if we are on 2.4 Ghz, CB will be always disabled
3677 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3678 }
3679 else
3680 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003681 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 }
3683 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003684#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003685 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3686 // in function csrConvertCBIniValueToPhyCBState()
3687 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3688 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003689 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003690 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003691 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003692 }
3693 else
3694 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003695 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003696 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003697 }
3698 else
3699#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3701 //Rate
3702 //Fixed Rate
3703 if(pBssDesc)
3704 {
3705 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3706 }
3707 else
3708 {
3709 csrSetCfgRateSetFromProfile(pMac, pProfile);
3710 }
3711 //Make this the last CFG to set. The callback will trigger a join_req
3712 //Join time out
3713 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3714
3715 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 return (status);
3717}
3718
Jeff Johnson295189b2012-06-20 16:38:30 -07003719eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3720 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3721{
3722 eHalStatus status;
3723 tBssConfigParam *pBssConfig;
3724 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003725
3726 if(!pSession)
3727 {
3728 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3729 return eHAL_STATUS_FAILURE;
3730 }
3731
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3733 if(HAL_STATUS_SUCCESS(status))
3734 {
3735 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3736 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3737 if(HAL_STATUS_SUCCESS(status))
3738 {
3739 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003740 /* This will allow to pass cbMode during join req */
3741 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 //For IBSS, we need to prepare some more information
3743 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 )
3746 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003747 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 }
3749 // If we are in an IBSS, then stop the IBSS...
3750 ////Not worry about WDS connection for now
3751 if ( csrIsConnStateIbss( pMac, sessionId ) )
3752 {
3753 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3754 }
3755 else
3756 {
3757 // if we are in an Infrastructure association....
3758 if ( csrIsConnStateInfra( pMac, sessionId ) )
3759 {
3760 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3761 // across SSIDs (roaming to a new SSID)... //
3762 //Not worry about WDS connection for now
3763 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303764 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 {
3766 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303767 status = csrRoamIssueDisassociate( pMac, sessionId,
3768 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303770 else
3771 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3773 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303774 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303776 // Set parameters for this Bss.
3777 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3778 pBssDesc, pBssConfig,
3779 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303783 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 {
3785 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3786 // Nothing to stop.
3787 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303789 )
3790 {
3791 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3792 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3793 // Set parameters for this Bss.
3794 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3795 pBssDesc, pBssConfig,
3796 pIes, is11rRoamingFlag);
3797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 }
3799 }
3800 }//Success getting BSS config info
3801 palFreeMemory(pMac->hHdd, pBssConfig);
3802 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 return (status);
3804}
3805
Jeff Johnson295189b2012-06-20 16:38:30 -07003806eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3807 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3808{
3809 eCsrJoinState eRoamState = eCsrContinueRoaming;
3810 eHalStatus status;
3811 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3812 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003814
3815 if(!pSession)
3816 {
3817 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3818 return (eCsrStopRoaming);
3819 }
3820
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 if( CSR_IS_WDS_STA( pProfile ) )
3822 {
3823 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3824 if( !HAL_STATUS_SUCCESS( status ) )
3825 {
3826 eRoamState = eCsrStopRoaming;
3827 }
3828 }
3829 else
3830 {
3831 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3832 {
3833 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3834 return (eCsrStopRoaming);
3835 }
3836 if ( csrIsInfraBssDesc( pBssDesc ) )
3837 {
3838 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3839 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3840 // have changed and handle the changes (without disturbing the current association).
3841
3842 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3843 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3844 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3845 )
3846 {
3847 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3848 // with Authenticating first. To force this, stop the current association (Disassociate) and
3849 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3850 // a new Association.
3851 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003853 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3855 {
3856 eRoamState = eCsrReassocToSelfNoCapChange;
3857 }
3858 else
3859 {
3860 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 //The key changes
3862 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3863 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3864 if(HAL_STATUS_SUCCESS(status))
3865 {
3866 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003867 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303869 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3870 pBssDesc, &bssConfig,
3871 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 if(!HAL_STATUS_SUCCESS(status))
3873 {
3874 eRoamState = eCsrStopRoaming;
3875 }
3876 }
3877 else
3878 {
3879 eRoamState = eCsrStopRoaming;
3880 }
3881 }//same profile
3882 }
3883 else
3884 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303885 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003888 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303892 }
3893 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
3895 // 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 +05303896 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 // work much better.
3898 //
3899 //
3900 // stop the existing network before attempting to join the new network...
3901 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3902 {
3903 eRoamState = eCsrStopRoaming;
3904 }
3905 }
3906 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303907 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 {
3909 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3910 {
3911 eRoamState = eCsrStopRoaming;
3912 }
3913 }
3914 if( pIesLocal && !pScanResult->pvIes )
3915 {
3916 palFreeMemory(pMac->hHdd, pIesLocal);
3917 }
3918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 return( eRoamState );
3920}
3921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3923 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3924{
3925 eHalStatus status = eHAL_STATUS_SUCCESS;
3926 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3928 roamInfo.pBssDesc = pBssDesc;
3929 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3930 return (status);
3931}
Jeff Johnson295189b2012-06-20 16:38:30 -07003932//In case no matching BSS is found, use whatever default we can find
3933static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3934{
3935 //Need to get all negotiated types in place first
3936 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003937 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 {
3939 default:
3940 case eCSR_AUTH_TYPE_WPA:
3941 case eCSR_AUTH_TYPE_WPA_PSK:
3942 case eCSR_AUTH_TYPE_WPA_NONE:
3943 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3944 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3945 break;
3946
3947 case eCSR_AUTH_TYPE_SHARED_KEY:
3948 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3949 break;
3950
3951 case eCSR_AUTH_TYPE_AUTOSWITCH:
3952 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3953 break;
3954 }
3955 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3956 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3957 //In this case, the multicast encryption needs to follow the uncast ones.
3958 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3959 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3960}
3961
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003962
3963static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3964{
3965 switch(pCommand->u.roamCmd.roamReason)
3966 {
3967 case eCsrLostLink1:
3968 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3969 break;
3970 case eCsrLostLink2:
3971 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3972 break;
3973 case eCsrLostLink3:
3974 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3975 break;
3976 default:
3977 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3978 pCommand->u.roamCmd.roamReason);
3979 break;
3980 }
3981}
3982
Jeff Johnson295189b2012-06-20 16:38:30 -07003983static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3984{
3985 eHalStatus status;
3986 tCsrScanResult *pScanResult = NULL;
3987 eCsrJoinState eRoamState = eCsrStopRoaming;
3988 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3989 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3990 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3991#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3992 v_U8_t acm_mask = 0;
3993#endif
3994 tANI_U32 sessionId = pCommand->sessionId;
3995 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3996 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3997 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003998
3999 if(!pSession)
4000 {
4001 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4002 return (eCsrStopRoaming);
4003 }
4004
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 do
4006 {
4007 // Check for Cardbus eject condition, before trying to Roam to any BSS
4008 //***if( !balIsCardPresent(pAdapter) ) break;
4009
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004010 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4011 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 if(NULL != pBSSList)
4013 {
4014 // When handling AP's capability change, continue to associate to
4015 // same BSS and make sure pRoamBssEntry is not Null.
4016 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4017 {
4018 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4019 {
4020 //Try the first BSS
4021 pCommand->u.roamCmd.pLastRoamBss = NULL;
4022 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4023 }
4024 else
4025 {
4026 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4027 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4028 {
4029 //Done with all the BSSs
4030 //In this case, will tell HDD the completion
4031 break;
4032 }
4033 else
4034 {
4035 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004036 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4038 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4039 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4040 pRoamInfo = &roamInfo;
4041 }
4042 }
4043 while(pCommand->u.roamCmd.pRoamBssEntry)
4044 {
4045 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 /*If concurrency enabled take the concurrent connected channel first. */
4047 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004048 if (vos_concurrent_sessions_running() &&
4049 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 {
4051 concurrentChannel =
4052 csrGetConcurrentOperationChannel(pMac);
4053 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004054 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 if ((concurrentChannel) &&
4056 (concurrentChannel ==
4057 pScanResult->Result.BssDescriptor.channelId))
4058 {
4059 //make this 0 because we do not want the
4060 //below check to pass as we don't want to
4061 //connect on other channel
4062 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4063 FL("Concurrent channel match =%d"),
4064 concurrentChannel);
4065 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 }
4067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004068
4069 if (!concurrentChannel)
4070 {
4071
4072 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4073 sessionId, &pScanResult->Result.BssDescriptor,
4074 pCommand->u.roamCmd.roamId)))
4075 {
4076 //Ok to roam this
4077 break;
4078 }
4079 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004080 else
4081 {
4082 eRoamState = eCsrStopRoamingDueToConcurrency;
4083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4085 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4086 {
4087 //Done with all the BSSs
4088 fDone = eANI_BOOLEAN_TRUE;
4089 break;
4090 }
4091 }
4092 if(fDone)
4093 {
4094 break;
4095 }
4096 }
4097 }
4098 //We have something to roam, tell HDD when it is infra.
4099 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4100 //For WDS, the indication is eCSR_ROAM_WDS_IND
4101 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4102 {
4103 if(pRoamInfo)
4104 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004105 if(pSession->bRefAssocStartCnt)
4106 {
4107 pSession->bRefAssocStartCnt--;
4108 //Complete the last association attemp because a new one is about to be tried
4109 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4110 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004112 }
4113 }
4114 /* If the roaming has stopped, not to continue the roaming command*/
4115 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4116 {
4117 //No need to complete roaming here as it already completes
4118 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4119 pCommand->u.roamCmd.roamReason);
4120 eRoamState = eCsrStopRoaming;
4121 csrSetAbortRoamingCommand(pMac, pCommand);
4122 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 }
4124 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4125 if(pScanResult)
4126 {
4127 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4129 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004130 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 fDone = eANI_BOOLEAN_TRUE;
4132 eRoamState = eCsrStopRoaming;
4133 break;
4134 }
4135 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4136 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4137 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4138 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4139 CSR_IS_QOS_BSS(pIesLocal) &&
4140 CSR_IS_UAPSD_BSS(pIesLocal) )
4141 {
4142#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4144 pIesLocal);
4145 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4146#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 }
4148 else
4149 {
4150 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4151 }
4152 if( pIesLocal && !pScanResult->Result.pvIes)
4153 {
4154 palFreeMemory(pMac->hHdd, pIesLocal);
4155 }
4156 }
4157 else
4158 {
4159 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4160 }
4161 roamInfo.pProfile = pProfile;
4162 pSession->bRefAssocStartCnt++;
4163 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4164 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4167 {
4168 // If this is a start IBSS profile, then we need to start the IBSS.
4169 if ( CSR_IS_START_IBSS(pProfile) )
4170 {
4171 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004172 // Attempt to start this IBSS...
4173 csrRoamAssignDefaultParam( pMac, pCommand );
4174 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4175 if(HAL_STATUS_SUCCESS(status))
4176 {
4177 if ( fSameIbss )
4178 {
4179 eRoamState = eCsrStartIbssSameIbss;
4180 }
4181 else
4182 {
4183 eRoamState = eCsrContinueRoaming;
4184 }
4185 }
4186 else
4187 {
4188 //it somehow fail need to stop
4189 eRoamState = eCsrStopRoaming;
4190 }
4191 break;
4192 }
4193 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 )
4196 {
4197 // Attempt to start this WDS...
4198 csrRoamAssignDefaultParam( pMac, pCommand );
4199 /* For AP WDS, we dont have any BSSDescription */
4200 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4201 if(HAL_STATUS_SUCCESS(status))
4202 {
4203 eRoamState = eCsrContinueRoaming;
4204 }
4205 else
4206 {
4207 //it somehow fail need to stop
4208 eRoamState = eCsrStopRoaming;
4209 }
4210 }
4211 else
4212 {
4213 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004214 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 eRoamState = eCsrStopRoaming;
4216 break;
4217 }
4218 }
4219 else //We have BSS
4220 {
4221 //Need to assign these value because they are used in csrIsSameProfile
4222 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4223 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4224 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4225 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4226 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4227 {
4228 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4229 {
4230 eRoamState = eCsrStartIbssSameIbss;
4231 break;
4232 }
4233 }
4234 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4235 {
4236 //trying to connect to the one already connected
4237 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4238 eRoamState = eCsrReassocToSelfNoCapChange;
4239 break;
4240 }
4241 // Attempt to Join this Bss...
4242 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4243 break;
4244 }
4245
4246 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4248 {
4249 //Need to indicate association_completion if association_start has been done
4250 if(pSession->bRefAssocStartCnt > 0)
4251 {
4252 pSession->bRefAssocStartCnt--;
4253 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004254 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4256 eCSR_ROAM_ASSOCIATION_COMPLETION,
4257 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4258 }
4259 }
4260
4261 return( eRoamState );
4262}
4263
Jeff Johnson295189b2012-06-20 16:38:30 -07004264static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4265{
4266 eHalStatus status = eHAL_STATUS_SUCCESS;
4267 eCsrJoinState RoamState;
4268 tANI_U32 sessionId = pCommand->sessionId;
4269
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 //***if( hddIsRadioStateOn( pAdapter ) )
4271 {
4272 // Attept to join a Bss...
4273 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004274
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004276 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 {
4278 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 // and if connected in Infrastructure mode...
4280 if ( csrIsConnStateInfra(pMac, sessionId) )
4281 {
4282 //... then we need to issue a disassociation
4283 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4284 if(!HAL_STATUS_SUCCESS(status))
4285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004286 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 //roam command is completed by caller in the failed case
4288 fComplete = eANI_BOOLEAN_TRUE;
4289 }
4290 }
4291 else if( csrIsConnStateIbss(pMac, sessionId) )
4292 {
4293 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4294 if(!HAL_STATUS_SUCCESS(status))
4295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004296 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 //roam command is completed by caller in the failed case
4298 fComplete = eANI_BOOLEAN_TRUE;
4299 }
4300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4302 {
4303 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4304 if(!HAL_STATUS_SUCCESS(status))
4305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004306 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 //roam command is completed by caller in the failed case
4308 fComplete = eANI_BOOLEAN_TRUE;
4309 }
4310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 else
4312 {
4313 fComplete = eANI_BOOLEAN_TRUE;
4314 }
4315 if(fComplete)
4316 {
4317 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004318 if(eCsrStopRoamingDueToConcurrency == RoamState)
4319 {
4320 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4321 }
4322 else
4323 {
4324 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 }
4327 }
4328 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4329 {
4330 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4331 }
4332 else if ( eCsrStartIbssSameIbss == RoamState )
4333 {
4334 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4335 }
4336 }//hddIsRadioStateOn
4337
4338 return status;
4339}
Jeff Johnson295189b2012-06-20 16:38:30 -07004340eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4341{
4342 tANI_U32 sessionId;
4343 tCsrRoamSession *pSession;
4344 tCsrScanResult *pScanResult = NULL;
4345 tSirBssDescription *pBssDesc = NULL;
4346 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 sessionId = pCommand->sessionId;
4348 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004349
4350 if(!pSession)
4351 {
4352 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4353 return eHAL_STATUS_FAILURE;
4354 }
4355
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4357 {
4358 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004359 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4361 return eHAL_STATUS_FAILURE;
4362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 if (pCommand->u.roamCmd.pRoamBssEntry)
4364 {
4365 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4366 pBssDesc = &pScanResult->Result.BssDescriptor;
4367 }
4368 else
4369 {
4370 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004371 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4373 return eHAL_STATUS_FAILURE;
4374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4376 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4377 return status;
4378}
4379
Jeff Johnson295189b2012-06-20 16:38:30 -07004380eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4381{
4382 eHalStatus status = eHAL_STATUS_SUCCESS;
4383 tCsrRoamInfo roamInfo;
4384 tANI_U32 sessionId = pCommand->sessionId;
4385 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004386
4387 if(!pSession)
4388 {
4389 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4390 return eHAL_STATUS_FAILURE;
4391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004392
4393 switch ( pCommand->u.roamCmd.roamReason )
4394 {
4395 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004397 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 case eCsrSmeIssuedDisassocForHandoff:
4400 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4401#if 0 // TODO : Confirm this change
4402 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4403#else
4404 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4405#endif
4406
4407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004410 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004414 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 case eCsrHddIssuedReassocToSameAP:
4417 case eCsrSmeIssuedReassocToSameAP:
4418 {
4419 tDot11fBeaconIEs *pIes = NULL;
4420
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 if( pSession->pConnectBssDesc )
4422 {
4423 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4424 if(!HAL_STATUS_SUCCESS(status) )
4425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004426 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 }
4428 else
4429 {
4430 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4431 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4432 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4434 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4435 pSession->bRefAssocStartCnt++;
4436 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4437 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4438
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004439 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004440 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4441 &pCommand->u.roamCmd.roamProfile );
4442 if(!HAL_STATUS_SUCCESS(status))
4443 {
4444 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004445 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004446 }
4447
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 palFreeMemory(pMac->hHdd, pIes);
4449 pIes = NULL;
4450 }
4451 }
4452 break;
4453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004455 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4457 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4458 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004460 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4462 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004463
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 case eCsrStopBss:
4465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4466 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4467 break;
4468
4469 case eCsrForcedDisassocSta:
4470 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4471 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4472 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4473 pCommand->u.roamCmd.reason);
4474 break;
4475
4476 case eCsrForcedDeauthSta:
4477 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4478 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4479 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4480 pCommand->u.roamCmd.reason);
4481 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004482
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004483 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004484 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004485 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4486 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004487 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004488
4489 default:
4490 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4491
4492 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4493 {
4494 //Remember the roaming profile
4495 csrFreeRoamProfile(pMac, sessionId);
4496 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4497 {
4498 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4499 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4500 }
4501 }
4502
4503 //At this point, original uapsd_mask is saved in pCurRoamProfile
4504 //uapsd_mask in the pCommand may change from this point on.
4505
4506 // Attempt to roam with the new scan results (if we need to..)
4507 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004508 if(!HAL_STATUS_SUCCESS(status))
4509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004510 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 break;
4513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 return (status);
4515}
4516
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004517void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4518{
4519 pCommand->u.roamCmd.pLastRoamBss = NULL;
4520 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4521 //Because u.roamCmd is union and share with scanCmd and StatusChange
4522 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4523}
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4526{
4527 if(pCommand->u.roamCmd.fReleaseBssList)
4528 {
4529 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4530 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4531 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4532 }
4533 if(pCommand->u.roamCmd.fReleaseProfile)
4534 {
4535 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4536 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4537 }
4538 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4539 //Because u.roamCmd is union and share with scanCmd and StatusChange
4540 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4541}
4542
Jeff Johnson295189b2012-06-20 16:38:30 -07004543void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4544{
4545 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4546}
Jeff Johnson295189b2012-06-20 16:38:30 -07004547void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4548{
4549 tListElem *pEntry;
4550 tSmeCmd *pCommand;
4551 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004552 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4554 if ( pEntry )
4555 {
4556 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 // If the head of the queue is Active and it is a ROAM command, remove
4558 // and put this on the Free queue.
4559 if ( eSmeCommandRoam == pCommand->command )
4560 {
4561 //we need to process the result first before removing it from active list because state changes
4562 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4563 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4564 if( fReleaseCommand )
4565 {
4566 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4567 {
4568 csrReleaseCommandRoam( pMac, pCommand );
4569 }
4570 else
4571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004572 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004573 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 }
4575 }
4576 else
4577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004578 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004579 pCommand->u.roamCmd.roamReason );
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 ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 }
4586 }
4587 else
4588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004589 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 if( fReleaseCommand )
4592 {
4593 smeProcessPendingQueue( pMac );
4594 }
4595}
4596
Jeff Johnson295189b2012-06-20 16:38:30 -07004597void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4598{
4599 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004600 if(!pSession)
4601 {
4602 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4603 return;
4604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4606 pSession->NumPmkidCandidate = 0;
4607}
Jeff Johnson295189b2012-06-20 16:38:30 -07004608#ifdef FEATURE_WLAN_WAPI
4609void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4610{
4611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004612 if(!pSession)
4613 {
4614 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4615 return;
4616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4618 pSession->NumBkidCandidate = 0;
4619}
4620#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004621extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4622
Jeff Johnson295189b2012-06-20 16:38:30 -07004623static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4624 tSirBssDescription *pSirBssDesc,
4625 tDot11fBeaconIEs *pIes)
4626{
4627 eHalStatus status = eHAL_STATUS_SUCCESS;
4628 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4629 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004630
4631 if(!pSession)
4632 {
4633 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4634 return eHAL_STATUS_FAILURE;
4635 }
4636
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 if((eCSR_AUTH_TYPE_WPA == authType) ||
4638 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4639 (eCSR_AUTH_TYPE_RSN == authType) ||
4640 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4641#if defined WLAN_FEATURE_VOWIFI_11R
4642 ||
4643 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4644 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4645#endif /* FEATURE_WLAN_WAPI */
4646#ifdef FEATURE_WLAN_WAPI
4647 ||
4648 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4649 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4650#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004651#ifdef WLAN_FEATURE_11W
4652 ||
4653 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4654#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 )
4656 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004659 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 }
4661 if( pIesLocal )
4662 {
4663 tANI_U32 nIeLen;
4664 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 if((eCSR_AUTH_TYPE_RSN == authType) ||
4666#if defined WLAN_FEATURE_VOWIFI_11R
4667 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4668 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4669#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004670#if defined WLAN_FEATURE_11W
4671 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4672#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4674 {
4675 if(pIesLocal->RSN.present)
4676 {
4677 //Calculate the actual length
4678 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4679 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4680 + 2 //akm_suite_count
4681 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4682 + 2; //reserved
4683 if( pIesLocal->RSN.pmkid_count )
4684 {
4685 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4686 }
4687 //nIeLen doesn't count EID and length fields
4688 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4689 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004690 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4692 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4693 //copy upto akm_suites
4694 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004695 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4696 pIeBuf += sizeof(pIesLocal->RSN.version);
4697 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4698 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4699 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4700 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 if( pIesLocal->RSN.pwise_cipher_suite_count )
4702 {
4703 //copy pwise_cipher_suites
4704 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4705 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4706 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4707 }
4708 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4709 pIeBuf += 2;
4710 if( pIesLocal->RSN.akm_suite_count )
4711 {
4712 //copy akm_suites
4713 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4714 pIesLocal->RSN.akm_suite_count * 4);
4715 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4716 }
4717 //copy the rest
4718 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4719 pIesLocal->RSN.akm_suite_count * 4,
4720 2 + pIesLocal->RSN.pmkid_count * 4);
4721 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4722 }
4723 }
4724 }
4725 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4726 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4727 {
4728 if(pIesLocal->WPA.present)
4729 {
4730 //Calculate the actual length
4731 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4732 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4733 + 2 //auth_suite_count
4734 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4735 // The WPA capabilities follows the Auth Suite (two octects)--
4736 // this field is optional, and we always "send" zero, so just
4737 // remove it. This is consistent with our assumptions in the
4738 // frames compiler; c.f. bug 15234:
4739 //nIeLen doesn't count EID and length fields
4740 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4741 {
4742 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4743 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4744 pIeBuf = pSession->pWpaRsnRspIE + 2;
4745 //Copy WPA OUI
4746 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4747 pIeBuf += 4;
4748 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4749 pIesLocal->WPA.unicast_cipher_count * 4);
4750 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4751 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4752 pIesLocal->WPA.auth_suite_count * 4);
4753 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4754 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4755 }
4756 }
4757 }
4758#ifdef FEATURE_WLAN_WAPI
4759 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4760 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4761 {
4762 if(pIesLocal->WAPI.present)
4763 {
4764 //Calculate the actual length
4765 nIeLen = 4 //version + akm_suite_count
4766 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4767 + 2 //pwise_cipher_suite_count
4768 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4769 + 6; //gp_cipher_suite + preauth + reserved
4770 if( pIesLocal->WAPI.bkid_count )
4771 {
4772 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4773 }
4774
4775 //nIeLen doesn't count EID and length fields
4776 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4777 {
4778 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4779 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4780 pIeBuf = pSession->pWapiRspIE + 2;
4781 //copy upto akm_suite_count
lukez3c809222013-05-03 10:23:02 -07004782 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 pIeBuf += 4;
4784 if( pIesLocal->WAPI.akm_suite_count )
4785 {
4786 //copy akm_suites
4787 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4788 pIesLocal->WAPI.akm_suite_count * 4);
4789 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4790 }
4791 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4792 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4794 {
4795 //copy pwise_cipher_suites
4796 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4797 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4798 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4799 }
lukez3c809222013-05-03 10:23:02 -07004800 //gp_cipher_suite
4801 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite, 4);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304802 //preauth + reserved
4803 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite + 4, 2);
4804 //bkid_count
4805 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 pIeBuf += 8;
4807 if( pIesLocal->WAPI.bkid_count )
4808 {
4809 //copy akm_suites
4810 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4811 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4812 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304813 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 }
4816 }
4817#endif /* FEATURE_WLAN_WAPI */
4818 if( !pIes )
4819 {
4820 //locally allocated
4821 palFreeMemory(pMac->hHdd, pIesLocal);
4822 }
4823 }
4824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 return (status);
4826}
4827
Jeff Johnson295189b2012-06-20 16:38:30 -07004828static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4829{
4830 v_U8_t bACWeights[WLANTL_MAX_AC];
4831 v_U8_t paramBk, paramBe, paramVi, paramVo;
4832 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4834 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4835 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4836 //This doesn't address the case where the lower AC needs a real higher weight
4837 if( pIEs->WMMParams.present )
4838 {
4839 //no change to the lowest ones
4840 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4841 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4842 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4843 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4844 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4845 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4846 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4847 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4848 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4849 {
4850 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4851 fWeightChange = VOS_TRUE;
4852 }
4853 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4854 {
4855 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4856 fWeightChange = VOS_TRUE;
4857 }
4858 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4859 {
4860 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4861 fWeightChange = VOS_TRUE;
4862 }
4863 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4864 {
4865 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4866 fWeightChange = VOS_TRUE;
4867 }
4868 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4869 {
4870 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4871 fWeightChange = VOS_TRUE;
4872 }
4873 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4874 {
4875 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4876 fWeightChange = VOS_TRUE;
4877 }
4878 if(fWeightChange)
4879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004880 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 bACWeights[2], bACWeights[3]);
4882 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4883 }
4884 }
4885}
Jeff Johnson295189b2012-06-20 16:38:30 -07004886#ifdef WLAN_FEATURE_VOWIFI_11R
4887//Returns whether the current association is a 11r assoc or not
4888tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4889{
4890#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4891 return csrNeighborRoamIs11rAssoc(pMac);
4892#else
4893 return eANI_BOOLEAN_FALSE;
4894#endif
4895}
4896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004897#ifdef FEATURE_WLAN_CCX
4898//Returns whether the current association is a CCX assoc or not
4899tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4900{
4901#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4902 return csrNeighborRoamIsCCXAssoc(pMac);
4903#else
4904 return eANI_BOOLEAN_FALSE;
4905#endif
4906}
4907#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004908#ifdef FEATURE_WLAN_LFR
4909//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304910tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004911{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304912 tCsrRoamSession *pSession = NULL;
4913
4914 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4915 {
4916 pSession = CSR_GET_SESSION( pMac, sessionId );
4917 if (NULL != pSession->pCurRoamProfile)
4918 {
4919 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4920 {
4921 return eANI_BOOLEAN_FALSE;
4922 }
4923 }
4924 }
4925
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004926#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4927 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4928 {
4929 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
4930 }
4931 else
4932#endif
4933 {
4934 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004935 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004936 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004937}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004938
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004939#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4940//Returns whether "FW based BG scan" is currently enabled...or not
4941tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4942{
4943 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4944}
4945#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004946#endif
4947
Jeff Johnson295189b2012-06-20 16:38:30 -07004948//Return true means the command can be release, else not
4949static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4950 eCsrRoamCompleteResult Result, void *Context )
4951{
4952 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4953 tSirBssDescription *pSirBssDesc = NULL;
4954 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4955 tCsrScanResult *pScanResult = NULL;
4956 tCsrRoamInfo roamInfo;
4957 sme_QosAssocInfo assocInfo;
4958 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4959 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4960 tDot11fBeaconIEs *pIes = NULL;
4961 tANI_U32 sessionId = pCommand->sessionId;
4962 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4963 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4964 eRoamCmdStatus roamStatus;
4965 eCsrRoamResult roamResult;
4966 eHalStatus status;
4967 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004969
Jeff Johnson32d95a32012-09-10 13:15:23 -07004970 if(!pSession)
4971 {
4972 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4973 return eANI_BOOLEAN_FALSE;
4974 }
4975
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004976 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 switch( Result )
4978 {
4979 case eCsrJoinSuccess:
4980 // reset the IDLE timer
4981 // !!
4982 // !! fall through to the next CASE statement here is intentional !!
4983 // !!
4984 case eCsrReassocSuccess:
4985 if(eCsrReassocSuccess == Result)
4986 {
4987 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4988 }
4989 else
4990 {
4991 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4992 }
4993 // Success Join Response from LIM. Tell NDIS we are connected and save the
4994 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004995 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4997 //always free the memory here
4998 if(pSession->pWpaRsnRspIE)
4999 {
5000 pSession->nWpaRsnRspIeLength = 0;
5001 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
5002 pSession->pWpaRsnRspIE = NULL;
5003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005004#ifdef FEATURE_WLAN_WAPI
5005 if(pSession->pWapiRspIE)
5006 {
5007 pSession->nWapiRspIeLength = 0;
5008 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
5009 pSession->pWapiRspIE = NULL;
5010 }
5011#endif /* FEATURE_WLAN_WAPI */
5012#ifdef FEATURE_WLAN_BTAMP_UT_RF
5013 //Reset counter so no join retry is needed.
5014 pSession->maxRetryCount = 0;
5015 csrRoamStopJoinRetryTimer(pMac, sessionId);
5016#endif
5017 /* This creates problem since we have not saved the connected profile.
5018 So moving this after saving the profile
5019 */
5020 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5021 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5022 {
5023 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5024 }
5025 else
5026 {
5027 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 //Use the last connected bssdesc for reassoc-ing to the same AP.
5030 //NOTE: What to do when reassoc to a different AP???
5031 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5032 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5033 {
5034 pSirBssDesc = pSession->pConnectBssDesc;
5035 if(pSirBssDesc)
5036 {
5037 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5038 }
5039 }
5040 else
5041 {
5042
5043 if(pCommand->u.roamCmd.pRoamBssEntry)
5044 {
5045 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5046 if(pScanResult != NULL)
5047 {
5048 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5049 //this can be NULL
5050 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5051 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5052 }
5053 }
5054 }
5055 if( pSirBssDesc )
5056 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5059 //Save WPA/RSN IE
5060 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5061#ifdef FEATURE_WLAN_CCX
5062 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5063#endif
5064
5065 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5066 // substate change.
5067 // Moving even save profile above so that below mentioned conditon is also met.
5068 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5069 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5071 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5072 // will be dropped for the security context may not be set properly.
5073 //
5074 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5075 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5076 //
5077 // this reordering was done on titan_prod_usb branch and is being replicated here.
5078 //
5079
5080 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5081 !pProfile->bWPSAssociation)
5082 {
5083 // Issue the set Context request to LIM to establish the Unicast STA context
5084 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5085 pProfile->negotiatedUCEncryptionType,
5086 pSirBssDesc, &(pSirBssDesc->bssId),
5087 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5088 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005089 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5091 }
5092 // Issue the set Context request to LIM to establish the Broadcast STA context
5093 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5094 pSirBssDesc, &BroadcastMac,
5095 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5096 }
5097 else
5098 {
5099 //Need to wait for supplicant authtication
5100 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 //Set the subestate to WaitForKey in case authentiation is needed
5102 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5103
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 if(pProfile->bWPSAssociation)
5105 {
5106 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5107 }
5108 else
5109 {
5110 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5111 }
5112
5113 //Save sessionId in case of timeout
5114 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5115 //This time should be long enough for the rest of the process plus setting key
5116 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5117 {
5118 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005119 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5121 }
5122 }
5123
5124 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5125 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 if(Context)
5127 {
5128 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5129 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5131 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5132#ifdef WLAN_FEATURE_VOWIFI_11R
5133 len += pJoinRsp->parsedRicRspLen;
5134#endif /* WLAN_FEATURE_VOWIFI_11R */
5135#ifdef FEATURE_WLAN_CCX
5136 len += pJoinRsp->tspecIeLen;
5137#endif
5138 if(len)
5139 {
5140 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5141 (void **)&pSession->connectedInfo.pbFrames, len)))
5142 {
5143 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5144 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5145 {
5146 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5147 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5148 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5149#ifdef WLAN_FEATURE_VOWIFI_11R
5150 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5151#endif /* WLAN_FEATURE_VOWIFI_11R */
5152#ifdef FEATURE_WLAN_CCX
5153 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5154#endif
5155 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5156 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5157 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5158 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5159 }
5160 else
5161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005162 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005163 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5165 pSession->connectedInfo.pbFrames = NULL;
5166 }
5167 }
5168 }
5169 if(pCommand->u.roamCmd.fReassoc)
5170 {
5171 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5172 }
5173 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5174 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5175 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5176 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5177 }
5178 else
5179 {
5180 if(pCommand->u.roamCmd.fReassoc)
5181 {
5182 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5183 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5184 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5185 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5186 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5187 }
5188 }
5189#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5190 // Indicate SME-QOS with reassoc success event, only after
5191 // copying the frames
5192 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5193#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 roamInfo.pBssDesc = pSirBssDesc;
5195 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5196 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5197#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5198 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5199#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5200 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5202 //It may be better to let QoS do this????
5203 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5204 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005205 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5207 pmcStartUapsd( pMac, NULL, NULL );
5208 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305209 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5211 if( pSession->bRefAssocStartCnt > 0 )
5212 {
5213 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005214 //Remove this code once SLM_Sessionization is supported
5215 //BMPS_WORKAROUND_NOT_NEEDED
5216 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005217 {
5218 pMac->roam.configParam.doBMPSWorkaround = 1;
5219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5221 }
5222
5223 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 // reset the PMKID candidate list
5225 csrResetPMKIDCandidateList( pMac, sessionId );
5226 //Update TL's AC weight base on the current EDCA parameters
5227 //These parameters may change in the course of the connection, that sictuation
5228 //is not taken care here. This change is mainly to address a WIFI WMM test where
5229 //BE has a equal or higher TX priority than VI.
5230 //We only do this for infra link
5231 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5232 {
5233 csrCheckAndUpdateACWeight(pMac, pIes);
5234 }
5235#ifdef FEATURE_WLAN_WAPI
5236 // reset the BKID candidate list
5237 csrResetBKIDCandidateList( pMac, sessionId );
5238#endif /* FEATURE_WLAN_WAPI */
5239 }
5240 else
5241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005242 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 csrScanCancelIdleScan(pMac);
5245 //Not to signal link up because keys are yet to be set.
5246 //The linkup function will overwrite the sub-state that we need to keep at this point.
5247 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5248 {
5249 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5252 //enough to let security and DHCP handshake succeed before entry into BMPS
5253 if (pmcShouldBmpsTimerRun(pMac))
5254 {
5255 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5256 != eHAL_STATUS_SUCCESS)
5257 {
5258 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5259 }
5260 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 break;
5263
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 case eCsrStartBssSuccess:
5265 // on the StartBss Response, LIM is returning the Bss Description that we
5266 // are beaconing. Add this Bss Description to our scan results and
5267 // chain the Profile to this Bss Description. On a Start BSS, there was no
5268 // detected Bss description (no partner) so we issued the Start Bss to
5269 // start the Ibss without any Bss description. Lim was kind enough to return
5270 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005271 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5275 if( CSR_IS_IBSS( pProfile ) )
5276 {
5277 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 else if (CSR_IS_INFRA_AP(pProfile))
5280 {
5281 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 else
5284 {
5285 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5286 }
5287 if( !CSR_IS_WDS_STA( pProfile ) )
5288 {
5289 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005293 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 roamInfo.pBssDesc = pSirBssDesc;
5295 //We need to associate_complete it first, becasue Associate_start already indicated.
5296 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5297 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5298 break;
5299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005302 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 }
5304 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5305 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5306 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5307 if(pSirBssDesc)
5308 {
5309 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5310 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5311 }
5312 //We are doen with the IEs so free it
5313 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5315 {
5316 vos_log_ibss_pkt_type *pIbssLog;
5317 tANI_U32 bi;
5318
5319 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5320 if(pIbssLog)
5321 {
5322 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5323 {
5324 //We start the IBSS (didn't find any matched IBSS out there)
5325 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5326 }
5327 else
5328 {
5329 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5330 }
5331 if(pSirBssDesc)
5332 {
5333 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5334 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5335 }
5336 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5337 {
5338 //***U8 is not enough for beacon interval
5339 pIbssLog->beaconInterval = (v_U8_t)bi;
5340 }
5341 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5342 }
5343 }
5344#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5345 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5346 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5348 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5350 csrRoamIssueSetContextReq( pMac, sessionId,
5351 pProfile->negotiatedMCEncryptionType,
5352 pSirBssDesc, &BroadcastMac,
5353 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5354 }
5355 }
5356 else
5357 {
5358 //Keep the state to eCSR_ROAMING_STATE_JOINING
5359 //Need to send join_req.
5360 if(pCommand->u.roamCmd.pRoamBssEntry)
5361 {
5362 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5363 {
5364 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5365 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5366 // Set the roaming substate to 'join attempt'...
5367 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005368 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 }
5370 }
5371 else
5372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005373 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 VOS_ASSERT( 0 );
5375 }
5376 }
5377 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5378 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5379 //trigger the connection start indication in Vista
5380 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5381 {
5382 roamStatus = eCSR_ROAM_IBSS_IND;
5383 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5384 if( CSR_IS_WDS( pProfile ) )
5385 {
5386 roamStatus = eCSR_ROAM_WDS_IND;
5387 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 if( CSR_IS_INFRA_AP( pProfile ) )
5390 {
5391 roamStatus = eCSR_ROAM_INFRA_IND;
5392 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005394
5395 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5396 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5397 //trigger the connection start indication in Vista
5398 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5399 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5400 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5401 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5402 {
5403 //We start the IBSS (didn't find any matched IBSS out there)
5404 roamInfo.pBssDesc = pSirBssDesc;
5405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005407 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005408 //Remove this code once SLM_Sessionization is supported
5409 //BMPS_WORKAROUND_NOT_NEEDED
5410 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005411 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005412 {
5413 pMac->roam.configParam.doBMPSWorkaround = 1;
5414 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005415
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5417 }
5418
5419 csrScanCancelIdleScan(pMac);
5420 //Only use this timer for ibss. BAP has its own timer for WDS
5421 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5422 {
5423 //start the join IBSS timer
5424 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5425 pSession->ibss_join_pending = TRUE;
5426 }
5427 if( HAL_STATUS_SUCCESS( status ) )
5428 {
5429 //Already sent join_req for the WDS station
5430 fReleaseCommand = eANI_BOOLEAN_FALSE;
5431 }
5432 else if( CSR_IS_WDS_STA( pProfile ) )
5433 {
5434 //need to send stop BSS because we fail to send join_req
5435 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5436 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5437 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 case eCsrStartBssFailure:
5441#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5442 {
5443 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5445 if(pIbssLog)
5446 {
5447 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5448 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5449 }
5450 }
5451#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 roamStatus = eCSR_ROAM_IBSS_IND;
5453 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5454 if( CSR_IS_WDS( pProfile ) )
5455 {
5456 roamStatus = eCSR_ROAM_WDS_IND;
5457 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 if( CSR_IS_INFRA_AP( pProfile ) )
5460 {
5461 roamStatus = eCSR_ROAM_INFRA_IND;
5462 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 if(Context)
5465 {
5466 pSirBssDesc = (tSirBssDescription *)Context;
5467 }
5468 else
5469 {
5470 pSirBssDesc = NULL;
5471 }
5472 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5473 roamInfo.pBssDesc = pSirBssDesc;
5474 //We need to associate_complete it first, becasue Associate_start already indicated.
5475 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5476 csrSetDefaultDot11Mode( pMac );
5477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 case eCsrSilentlyStopRoaming:
5479 // We are here because we try to start the same IBSS
5480 //No message to PE
5481 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005482 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5484 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5485 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5486 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5487 if( roamInfo.pBssDesc )
5488 {
5489 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5490 }
5491 //Since there is no change in the current state, simply pass back no result otherwise
5492 //HDD may be mistakenly mark to disconnected state.
5493 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5494 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 case eCsrSilentlyStopRoamingSaveState:
5497 //We are here because we try to connect to the same AP
5498 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005499 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5501
5502 //to aviod resetting the substate to NONE
5503 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5504 //No need to change substate to wai_for_key because there is no state change
5505 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5506 if( roamInfo.pBssDesc )
5507 {
5508 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5511 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5512 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5513 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5514 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5515 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5516 roamInfo.staId = pSession->connectedInfo.staId;
5517 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 pSession->bRefAssocStartCnt--;
5520 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5521 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5522 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5523 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 case eCsrReassocFailure:
5525#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5526 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5527#endif
5528 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005529 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 csrFreeConnectBssDesc(pMac, sessionId);
5531 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5532 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5533 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5534 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5535 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5536 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5537 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5538 eCSR_ROAM_WDS_IND,
5539 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5540 //Need to issue stop_bss
5541 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 case eCsrJoinFailure:
5543 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005544 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 default:
5546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005547 smsLog(pMac, LOGW, FL("receives no association indication"));
5548 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005549 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5551 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5552 {
5553 //do not free for the other profiles as we need to send down stop BSS later
5554 csrFreeConnectBssDesc(pMac, sessionId);
5555 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5556 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5557 csrSetDefaultDot11Mode( pMac );
5558 }
5559
5560 switch( pCommand->u.roamCmd.roamReason )
5561 {
5562 // If this transition is because of an 802.11 OID, then we transition
5563 // back to INIT state so we sit waiting for more OIDs to be issued and
5564 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005565 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 case eCsrSmeIssuedAssocToSimilarAP:
5567 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005568 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5570 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5571 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5572 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5573 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005574 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5575
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 /* Defeaturize this later if needed */
5577#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5578 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5579 if (csrRoamIsHandoffInProgress(pMac))
5580 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 /* Should indicate neighbor roam algorithm about the connect failure here */
5582 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 if(pSession->bRefAssocStartCnt > 0)
5586 {
5587 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005588 if(eCsrJoinFailureDueToConcurrency == Result)
5589 {
5590 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5591 eCSR_ROAM_ASSOCIATION_COMPLETION,
5592 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5593 }
5594 else
5595 {
5596 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 eCSR_ROAM_ASSOCIATION_COMPLETION,
5598 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005601 else
5602 {
5603 /* bRefAssocStartCnt is not incremented when
5604 * eRoamState == eCsrStopRoamingDueToConcurrency
5605 * in csrRoamJoinNextBss API. so handle this in
5606 * else case by sending assoc failure
5607 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005608 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005609 pCommand->u.scanCmd.roamId,
5610 eCSR_ROAM_ASSOCIATION_FAILURE,
5611 eCSR_ROAM_RESULT_FAILURE);
5612 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005613 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005614#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5615 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5616#endif
5617 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5618 csrScanStartIdleScan(pMac);
5619#ifdef FEATURE_WLAN_BTAMP_UT_RF
5620 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5621 //BT activity and not able to recevie WLAN traffic. Retry the join
5622 if( CSR_IS_WDS_STA(pProfile) )
5623 {
5624 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5625 }
5626#endif
5627 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 case eCsrHddIssuedReassocToSameAP:
5629 case eCsrSmeIssuedReassocToSameAP:
5630 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5631
5632 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5633#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5634 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5635#endif
5636 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5637 csrScanStartIdleScan(pMac);
5638 break;
5639 case eCsrForcedDisassoc:
5640 case eCsrForcedDeauth:
5641 case eCsrSmeIssuedIbssJoinFailure:
5642 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5643
5644 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5645 {
5646 // Notify HDD that IBSS join failed
5647 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5648 }
5649 else
5650 {
5651 csrRoamCallCallback(pMac, sessionId, NULL,
5652 pCommand->u.roamCmd.roamId,
5653 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5654 }
5655#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5656 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5657#endif
5658 csrRoamLinkDown(pMac, sessionId);
5659 csrScanStartIdleScan(pMac);
5660 break;
5661 case eCsrForcedIbssLeave:
5662 csrRoamCallCallback(pMac, sessionId, NULL,
5663 pCommand->u.roamCmd.roamId,
5664 eCSR_ROAM_IBSS_LEAVE,
5665 eCSR_ROAM_RESULT_IBSS_STOP);
5666 break;
5667 case eCsrForcedDisassocMICFailure:
5668 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5669
5670 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5671#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5672 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5673#endif
5674 csrScanStartIdleScan(pMac);
5675 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 case eCsrStopBss:
5677 csrRoamCallCallback(pMac, sessionId, NULL,
5678 pCommand->u.roamCmd.roamId,
5679 eCSR_ROAM_INFRA_IND,
5680 eCSR_ROAM_RESULT_INFRA_STOPPED);
5681 break;
5682 case eCsrForcedDisassocSta:
5683 case eCsrForcedDeauthSta:
5684 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5685 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5686 {
5687 pSession = CSR_GET_SESSION(pMac, sessionId);
5688 if (!pSession)
5689 break;
5690
5691 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5692 {
5693 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5694 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5695 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5696 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5697 roamInfo.statusCode = eSIR_SME_SUCCESS;
5698 status = csrRoamCallCallback(pMac, sessionId,
5699 &roamInfo, pCommand->u.roamCmd.roamId,
5700 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5701 }
5702 }
5703 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 case eCsrLostLink1:
5705 // if lost link roam1 failed, then issue lost link Scan2 ...
5706 csrScanRequestLostLink2(pMac, sessionId);
5707 break;
5708 case eCsrLostLink2:
5709 // if lost link roam2 failed, then issue lost link scan3 ...
5710 csrScanRequestLostLink3(pMac, sessionId);
5711 break;
5712 case eCsrLostLink3:
5713 default:
5714 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5715
5716 //We are done with one round of lostlink roaming here
5717 csrScanHandleFailedLostlink3(pMac, sessionId);
5718 break;
5719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 break;
5721 }
5722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 return ( fReleaseCommand );
5724}
5725
Jeff Johnson295189b2012-06-20 16:38:30 -07005726eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5727{
5728 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 return (status);
5730}
5731
Jeff Johnson295189b2012-06-20 16:38:30 -07005732eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5733{
5734 eHalStatus status = eHAL_STATUS_SUCCESS;
5735 tANI_U32 size = 0;
5736
5737 do
5738 {
5739 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5740 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5741 {
5742 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5743 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5744 if(!HAL_STATUS_SUCCESS(status))
5745 {
5746 break;
5747 }
5748 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5749 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5750 }
5751 if(pSrcProfile->SSIDs.numOfSSIDs)
5752 {
5753 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5754 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5755 if(!HAL_STATUS_SUCCESS(status))
5756 {
5757 break;
5758 }
5759 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5760 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5761 }
5762 if(pSrcProfile->nWPAReqIELength)
5763 {
5764 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5765 if(!HAL_STATUS_SUCCESS(status))
5766 {
5767 break;
5768 }
5769 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5770 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5771 }
5772 if(pSrcProfile->nRSNReqIELength)
5773 {
5774 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5775 if(!HAL_STATUS_SUCCESS(status))
5776 {
5777 break;
5778 }
5779 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5780 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5781 }
5782#ifdef FEATURE_WLAN_WAPI
5783 if(pSrcProfile->nWAPIReqIELength)
5784 {
5785 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5786 if(!HAL_STATUS_SUCCESS(status))
5787 {
5788 break;
5789 }
5790 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5791 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5792 }
5793#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 if(pSrcProfile->nAddIEScanLength)
5795 {
5796 status = palAllocateMemory(pMac->hHdd,
5797 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5798 if(!HAL_STATUS_SUCCESS(status))
5799 {
5800 break;
5801 }
5802 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5803 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5804 pSrcProfile->nAddIEScanLength);
5805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 if(pSrcProfile->nAddIEAssocLength)
5807 {
5808 status = palAllocateMemory(pMac->hHdd,
5809 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5810 if(!HAL_STATUS_SUCCESS(status))
5811 {
5812 break;
5813 }
5814 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5815 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5816 pSrcProfile->nAddIEAssocLength);
5817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 if(pSrcProfile->ChannelInfo.ChannelList)
5819 {
5820 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5821 if(!HAL_STATUS_SUCCESS(status))
5822 {
5823 break;
5824 }
5825 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5826 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 pDstProfile->AuthType = pSrcProfile->AuthType;
5829 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5830 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5831 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5832 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5833 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005834#ifdef WLAN_FEATURE_11W
5835 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5836 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5837 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5838#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 pDstProfile->BSSType = pSrcProfile->BSSType;
5840 pDstProfile->phyMode = pSrcProfile->phyMode;
5841 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5842
5843#ifdef FEATURE_WLAN_WAPI
5844 if(csrIsProfileWapi(pSrcProfile))
5845 {
5846 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5847 {
5848 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5849 }
5850 }
5851#endif /* FEATURE_WLAN_WAPI */
5852 pDstProfile->CBMode = pSrcProfile->CBMode;
5853 /*Save the WPS info*/
5854 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5855 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 pDstProfile->privacy = pSrcProfile->privacy;
5858 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5859 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5860 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5861 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5862 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5863 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5864 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5865 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5866 pDstProfile->wps_state = pSrcProfile->wps_state;
5867 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005869#ifdef WLAN_FEATURE_VOWIFI_11R
5870 if (pSrcProfile->MDID.mdiePresent)
5871 {
5872 pDstProfile->MDID.mdiePresent = 1;
5873 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5874 }
5875#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 }while(0);
5877
5878 if(!HAL_STATUS_SUCCESS(status))
5879 {
5880 csrReleaseProfile(pMac, pDstProfile);
5881 pDstProfile = NULL;
5882 }
5883
5884 return (status);
5885}
Jeff Johnson295189b2012-06-20 16:38:30 -07005886eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5887{
5888 eHalStatus status = eHAL_STATUS_SUCCESS;
5889 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5890 do
5891 {
5892 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5893 if(pSrcProfile->bssid)
5894 {
5895 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5896 if(!HAL_STATUS_SUCCESS(status))
5897 {
5898 break;
5899 }
5900 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5901 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5902 }
5903 if(pSrcProfile->SSID.ssId)
5904 {
5905 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5906 if(!HAL_STATUS_SUCCESS(status))
5907 {
5908 break;
5909 }
5910 pDstProfile->SSIDs.numOfSSIDs = 1;
5911 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5912 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5913 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5914 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005915 if(pSrcProfile->nAddIEAssocLength)
5916 {
5917 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5918 if(!HAL_STATUS_SUCCESS(status))
5919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005920 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005921 break;
5922 }
5923 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5924 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5925 pSrcProfile->nAddIEAssocLength);
5926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5928 if(!HAL_STATUS_SUCCESS(status))
5929 {
5930 break;
5931 }
5932 pDstProfile->ChannelInfo.numOfChannels = 1;
5933 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 pDstProfile->AuthType.numEntries = 1;
5935 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5936 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5937 pDstProfile->EncryptionType.numEntries = 1;
5938 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5939 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5940 pDstProfile->mcEncryptionType.numEntries = 1;
5941 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5942 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5943 pDstProfile->BSSType = pSrcProfile->BSSType;
5944 pDstProfile->CBMode = pSrcProfile->CBMode;
5945 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5946#ifdef WLAN_FEATURE_VOWIFI_11R
5947 if (pSrcProfile->MDID.mdiePresent)
5948 {
5949 pDstProfile->MDID.mdiePresent = 1;
5950 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5951 }
5952#endif
5953
5954 }while(0);
5955
5956 if(!HAL_STATUS_SUCCESS(status))
5957 {
5958 csrReleaseProfile(pMac, pDstProfile);
5959 pDstProfile = NULL;
5960 }
5961
5962 return (status);
5963}
5964
Jeff Johnson295189b2012-06-20 16:38:30 -07005965eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5966 tScanResultHandle hBSSList,
5967 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5968 tANI_BOOLEAN fClearScan)
5969{
5970 eHalStatus status = eHAL_STATUS_SUCCESS;
5971 tSmeCmd *pCommand;
5972
5973 pCommand = csrGetCommandBuffer(pMac);
5974 if(NULL == pCommand)
5975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005976 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 status = eHAL_STATUS_RESOURCES;
5978 }
5979 else
5980 {
5981 if( fClearScan )
5982 {
5983 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305984 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 }
5986 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5987 if(NULL == pProfile)
5988 {
5989 //We can roam now
5990 //Since pProfile is NULL, we need to build our own profile, set everything to default
5991 //We can only support open and no encryption
5992 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5993 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5994 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5995 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5996 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5997 }
5998 else
5999 {
6000 //make a copy of the profile
6001 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6002 if(HAL_STATUS_SUCCESS(status))
6003 {
6004 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6005 }
6006 }
6007 pCommand->command = eSmeCommandRoam;
6008 pCommand->sessionId = (tANI_U8)sessionId;
6009 pCommand->u.roamCmd.hBSSList = hBSSList;
6010 pCommand->u.roamCmd.roamId = roamId;
6011 pCommand->u.roamCmd.roamReason = reason;
6012 //We need to free the BssList when the command is done
6013 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6014 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6016 FL("CSR PERSONA=%d"),
6017 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6019 if( !HAL_STATUS_SUCCESS( status ) )
6020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006021 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 csrReleaseCommandRoam( pMac, pCommand );
6023 }
6024 }
6025
6026 return (status);
6027}
Jeff Johnson295189b2012-06-20 16:38:30 -07006028eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6029 tCsrRoamModifyProfileFields *pMmodProfileFields,
6030 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6031{
6032 eHalStatus status = eHAL_STATUS_SUCCESS;
6033 tSmeCmd *pCommand;
6034
6035 pCommand = csrGetCommandBuffer(pMac);
6036 if(NULL == pCommand)
6037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006038 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 status = eHAL_STATUS_RESOURCES;
6040 }
6041 else
6042 {
6043 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306044 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 if(pProfile)
6046 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 //This is likely trying to reassoc to different profile
6048 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6049 //make a copy of the profile
6050 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6051 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 }
6053 else
6054 {
6055 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6056 //how to update WPA/WPA2 info in roamProfile??
6057 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 if(HAL_STATUS_SUCCESS(status))
6060 {
6061 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6062 }
6063 pCommand->command = eSmeCommandRoam;
6064 pCommand->sessionId = (tANI_U8)sessionId;
6065 pCommand->u.roamCmd.roamId = roamId;
6066 pCommand->u.roamCmd.roamReason = reason;
6067 //We need to free the BssList when the command is done
6068 //For reassoc there is no BSS list, so the boolean set to false
6069 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6070 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6071 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6073 if( !HAL_STATUS_SUCCESS( status ) )
6074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006075 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6077 csrReleaseCommandRoam( pMac, pCommand );
6078 }
6079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 return (status);
6081}
6082
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006083eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6084 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306085// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006086{
6087 eHalStatus status = eHAL_STATUS_SUCCESS;
6088 tSmeCmd *pCommand;
6089
6090 pCommand = csrGetCommandBuffer(pMac);
6091 if(NULL == pCommand)
6092 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006093 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006094 status = eHAL_STATUS_RESOURCES;
6095 }
6096 else
6097 {
6098 if(pBssDescription)
6099 {
6100 //copy over the parameters we need later
6101 pCommand->command = eSmeCommandRoam;
6102 pCommand->sessionId = (tANI_U8)sessionId;
6103 pCommand->u.roamCmd.roamReason = reason;
6104 //this is the important parameter
6105 //in this case we are using this field for the "next" BSS
6106 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6107 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6108 if( !HAL_STATUS_SUCCESS( status ) )
6109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006110 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006111 csrReleaseCommandPreauth( pMac, pCommand );
6112 }
6113 }
6114 else
6115 {
6116 //Return failure
6117 status = eHAL_STATUS_RESOURCES;
6118 }
6119 }
6120 return (status);
6121}
6122
6123eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6124{
6125 tListElem *pEntry;
6126 tSmeCmd *pCommand;
6127 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6128 if ( pEntry )
6129 {
6130 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6131 if ( (eSmeCommandRoam == pCommand->command) &&
6132 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6133 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006134 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006135 pCommand->command, pCommand->u.roamCmd.roamReason);
6136 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6137 csrReleaseCommandPreauth( pMac, pCommand );
6138 }
6139 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006140 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006141 pCommand->command, pCommand->u.roamCmd.roamReason);
6142 }
6143 }
6144 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006145 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006146 }
6147 smeProcessPendingQueue( pMac );
6148 return eHAL_STATUS_SUCCESS;
6149}
6150
Jeff Johnson295189b2012-06-20 16:38:30 -07006151eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6152 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6153{
6154 eHalStatus status = eHAL_STATUS_FAILURE;
6155 tScanResultHandle hBSSList;
6156 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6158 if(HAL_STATUS_SUCCESS(status))
6159 {
6160 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6161 if(pRoamId)
6162 {
6163 *pRoamId = roamId;
6164 }
6165 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6166 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6167 if(!HAL_STATUS_SUCCESS(status))
6168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006169 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 csrScanResultPurge(pMac, hBSSList);
6171 }
6172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 return (status);
6174}
6175
Jeff Johnson295189b2012-06-20 16:38:30 -07006176eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6177 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6178{
6179 eHalStatus status = eHAL_STATUS_SUCCESS;
6180 tScanResultHandle hBSSList;
6181 tCsrScanResultFilter *pScanFilter;
6182 tANI_U32 roamId = 0;
6183 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6184 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 if (NULL == pProfile)
6186 {
6187 smsLog(pMac, LOGP, FL("No profile specified"));
6188 return eHAL_STATUS_FAILURE;
6189 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006190 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 if( CSR_IS_WDS( pProfile ) &&
6193 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006195 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006196 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 return status;
6198 }
6199 csrRoamCancelRoaming(pMac, sessionId);
6200 csrScanRemoveFreshScanCommand(pMac, sessionId);
6201 csrScanCancelIdleScan(pMac);
6202 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306203 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6205 {
6206 csrScanDisable(pMac);
6207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006208 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6209 //Check whether ssid changes
6210 if(csrIsConnStateConnected(pMac, sessionId))
6211 {
6212 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6213 {
6214 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6215 }
6216 }
6217#ifdef FEATURE_WLAN_BTAMP_UT_RF
6218 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6219#endif
6220 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006222 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6224 if(pRoamId)
6225 {
6226 roamId = *pRoamId;
6227 }
6228 if(!HAL_STATUS_SUCCESS(status))
6229 {
6230 fCallCallback = eANI_BOOLEAN_TRUE;
6231 }
6232 }
6233 else
6234 {
6235 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6236 if(HAL_STATUS_SUCCESS(status))
6237 {
6238 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6239 //Try to connect to any BSS
6240 if(NULL == pProfile)
6241 {
6242 //No encryption
6243 pScanFilter->EncryptionType.numEntries = 1;
6244 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6245 }//we don't have a profile
6246 else
6247 {
6248 //Here is the profile we need to connect to
6249 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6250 }//We have a profile
6251 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6252 if(pRoamId)
6253 {
6254 *pRoamId = roamId;
6255 }
6256
6257 if(HAL_STATUS_SUCCESS(status))
6258 {
6259 /*Save the WPS info*/
6260 if(NULL != pProfile)
6261 {
6262 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6263 }
6264 else
6265 {
6266 pScanFilter->bWPSAssociation = 0;
6267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 do
6269 {
6270 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 )
6273 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006274 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6276 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6277 if(!HAL_STATUS_SUCCESS(status))
6278 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006279 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 fCallCallback = eANI_BOOLEAN_TRUE;
6281 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006282 else
6283 {
6284 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 break;
6287 }
6288 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006289 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 if(HAL_STATUS_SUCCESS(status))
6291 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6293 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6294 if(!HAL_STATUS_SUCCESS(status))
6295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006296 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 csrScanResultPurge(pMac, hBSSList);
6298 fCallCallback = eANI_BOOLEAN_TRUE;
6299 }
6300 }//Have scan result
6301 else if(NULL != pProfile)
6302 {
6303 //Check whether it is for start ibss
6304 if(CSR_IS_START_IBSS(pProfile))
6305 {
6306 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6307 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6308 if(!HAL_STATUS_SUCCESS(status))
6309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006310 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 fCallCallback = eANI_BOOLEAN_TRUE;
6312 }
6313 }
6314 else
6315 {
6316 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006317 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 if(!HAL_STATUS_SUCCESS(status))
6319 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006320 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 fCallCallback = eANI_BOOLEAN_TRUE;
6322 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006323 else
6324 {
6325 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 }
6328 }
6329 else
6330 {
6331 fCallCallback = eANI_BOOLEAN_TRUE;
6332 }
6333 } while (0);
6334 if(NULL != pProfile)
6335 {
6336 //we need to free memory for filter if profile exists
6337 csrFreeScanFilter(pMac, pScanFilter);
6338 }
6339 }//Got the scan filter from profile
6340
6341 palFreeMemory(pMac->hHdd, pScanFilter);
6342 }//allocated memory for pScanFilter
6343 }//No Bsslist coming in
6344 //tell the caller if we fail to trigger a join request
6345 if( fCallCallback )
6346 {
6347 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6348 }
6349
6350 return (status);
6351}
Jeff Johnson295189b2012-06-20 16:38:30 -07006352eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6353 tCsrRoamModifyProfileFields modProfileFields,
6354 tANI_U32 *pRoamId)
6355{
6356 eHalStatus status = eHAL_STATUS_SUCCESS;
6357 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6358 tANI_U32 roamId = 0;
6359 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 if (NULL == pProfile)
6361 {
6362 smsLog(pMac, LOGP, FL("No profile specified"));
6363 return eHAL_STATUS_FAILURE;
6364 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006365 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 -07006366 csrRoamCancelRoaming(pMac, sessionId);
6367 csrScanRemoveFreshScanCommand(pMac, sessionId);
6368 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306369 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 if(csrIsConnStateConnected(pMac, sessionId))
6372 {
6373 if(pProfile)
6374 {
6375 if(pProfile->SSIDs.numOfSSIDs &&
6376 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6377 {
6378 fCallCallback = eANI_BOOLEAN_FALSE;
6379 }
6380 else
6381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006382 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 }
6384 }
6385 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6386 &pSession->connectedProfile.modifyProfileFields,
6387 sizeof(tCsrRoamModifyProfileFields)))
6388 {
6389 fCallCallback = eANI_BOOLEAN_FALSE;
6390 }
6391 else
6392 {
6393 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006394 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 }
6396 }
6397 else
6398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006399 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 if(!fCallCallback)
6402 {
6403 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6404 if(pRoamId)
6405 {
6406 *pRoamId = roamId;
6407 }
6408
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6410 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 }
6412 else
6413 {
6414 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6415 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 return status;
6418}
Jeff Johnson295189b2012-06-20 16:38:30 -07006419eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6420{
6421 eHalStatus status = eHAL_STATUS_FAILURE;
6422 tScanResultHandle hBSSList = NULL;
6423 tCsrScanResultFilter *pScanFilter = NULL;
6424 tANI_U32 roamId;
6425 tCsrRoamProfile *pProfile = NULL;
6426 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006427
6428 if(!pSession)
6429 {
6430 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6431 return eHAL_STATUS_FAILURE;
6432 }
6433
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 do
6435 {
6436 if(pSession->pCurRoamProfile)
6437 {
6438 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306439 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6441 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6442 if(!HAL_STATUS_SUCCESS(status))
6443 break;
6444 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6445 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6446 if(!HAL_STATUS_SUCCESS(status))
6447 break;
6448 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6449 if(!HAL_STATUS_SUCCESS(status))
6450 {
6451 break;
6452 }
6453 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6454 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6455 if(!HAL_STATUS_SUCCESS(status))
6456 {
6457 break;
6458 }
6459 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6460 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6461 if(HAL_STATUS_SUCCESS(status))
6462 {
6463 //we want to put the last connected BSS to the very beginning, if possible
6464 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6465 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6466 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6467 if(!HAL_STATUS_SUCCESS(status))
6468 {
6469 csrScanResultPurge(pMac, hBSSList);
6470 break;
6471 }
6472 }
6473 else
6474 {
6475 //Do a scan on this profile
6476 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006477 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 if(!HAL_STATUS_SUCCESS(status))
6479 {
6480 break;
6481 }
6482 }
6483 }//We have a profile
6484 else
6485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006486 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 break;
6488 }
6489 }while(0);
6490 if(pScanFilter)
6491 {
6492 csrFreeScanFilter(pMac, pScanFilter);
6493 palFreeMemory(pMac->hHdd, pScanFilter);
6494 }
6495 if(NULL != pProfile)
6496 {
6497 csrReleaseProfile(pMac, pProfile);
6498 palFreeMemory(pMac->hHdd, pProfile);
6499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 return (status);
6501}
Jeff Johnson295189b2012-06-20 16:38:30 -07006502eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6503{
6504 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 if(csrIsConnStateConnected(pMac, sessionId))
6506 {
6507 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6508 if(HAL_STATUS_SUCCESS(status))
6509 {
6510 status = csrRoamJoinLastProfile(pMac, sessionId);
6511 }
6512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 return (status);
6514}
6515
Jeff Johnson295189b2012-06-20 16:38:30 -07006516eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6517{
6518 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006519 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 csrRoamCancelRoaming(pMac, sessionId);
6521 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6522 if(csrIsConnStateDisconnected(pMac, sessionId))
6523 {
6524 status = csrRoamJoinLastProfile(pMac, sessionId);
6525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 return (status);
6527}
6528
Jeff Johnson295189b2012-06-20 16:38:30 -07006529eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6530{
6531 eHalStatus status = eHAL_STATUS_SUCCESS;
6532 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6533 eCsrRoamSubState NewSubstate;
6534 tANI_U32 sessionId = pCommand->sessionId;
6535
6536 // change state to 'Roaming'...
6537 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6538
6539 if ( csrIsConnStateIbss( pMac, sessionId ) )
6540 {
6541 // If we are in an IBSS, then stop the IBSS...
6542 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6543 fComplete = (!HAL_STATUS_SUCCESS(status));
6544 }
6545 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006547 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 -07006548 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6549 //Restore AC weight in case we change it
6550 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6551 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6552 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6553 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6554 {
6555 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6556 }
6557 if( fDisassoc )
6558 {
6559 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6560 }
6561 else
6562 {
6563 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6564 }
6565 fComplete = (!HAL_STATUS_SUCCESS(status));
6566 }
6567 else if ( csrIsConnStateWds( pMac, sessionId ) )
6568 {
6569 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6570 {
6571 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6572 fComplete = (!HAL_STATUS_SUCCESS(status));
6573 }
6574 //This has to be WDS station
6575 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6576 {
6577
6578 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6579 if( fDisassoc )
6580 {
6581 status = csrRoamIssueDisassociate( pMac, sessionId,
6582 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6583 fComplete = (!HAL_STATUS_SUCCESS(status));
6584 }
6585 }
6586 } else {
6587 // we got a dis-assoc request while not connected to any peer
6588 // just complete the command
6589 fComplete = eANI_BOOLEAN_TRUE;
6590 status = eHAL_STATUS_FAILURE;
6591 }
6592 if(fComplete)
6593 {
6594 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6595 }
6596
6597 if(HAL_STATUS_SUCCESS(status))
6598 {
6599 if ( csrIsConnStateInfra( pMac, sessionId ) )
6600 {
6601 //Set the state to disconnect here
6602 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6603 }
6604 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006605 else
6606 {
6607 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 return (status);
6610}
6611
Jeff Johnson295189b2012-06-20 16:38:30 -07006612/* This is been removed from latest code base */
6613/*
6614static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6615{
6616 eHalStatus status;
6617 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6619 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 return ( status );
6621}
6622*/
6623
Jeff Johnson295189b2012-06-20 16:38:30 -07006624eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6625{
6626 eHalStatus status = eHAL_STATUS_SUCCESS;
6627 tSmeCmd *pCommand;
6628 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 do
6630 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006631 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 pCommand = csrGetCommandBuffer( pMac );
6633 if ( !pCommand )
6634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006635 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 status = eHAL_STATUS_RESOURCES;
6637 break;
6638 }
6639 //Change the substate in case it is wait-for-key
6640 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6641 {
6642 csrRoamStopWaitForKeyTimer( pMac );
6643 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6644 }
6645 pCommand->command = eSmeCommandRoam;
6646 pCommand->sessionId = (tANI_U8)sessionId;
6647 switch ( reason )
6648 {
6649 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6650 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 case eCSR_DISCONNECT_REASON_DEAUTH:
6653 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6654 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 case eCSR_DISCONNECT_REASON_HANDOFF:
6656 fHighPriority = eANI_BOOLEAN_TRUE;
6657 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6658 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6660 case eCSR_DISCONNECT_REASON_DISASSOC:
6661 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6662 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6664 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6665 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6667 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 default:
6670 break;
6671 }
6672 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6673 if( !HAL_STATUS_SUCCESS( status ) )
6674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006675 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 csrReleaseCommandRoam( pMac, pCommand );
6677 }
6678 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 return( status );
6680}
6681
Jeff Johnson295189b2012-06-20 16:38:30 -07006682eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6683{
6684 eHalStatus status = eHAL_STATUS_SUCCESS;
6685 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 pCommand = csrGetCommandBuffer( pMac );
6687 if ( NULL != pCommand )
6688 {
6689 //Change the substate in case it is wait-for-key
6690 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6691 {
6692 csrRoamStopWaitForKeyTimer( pMac );
6693 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6694 }
6695 pCommand->command = eSmeCommandRoam;
6696 pCommand->sessionId = (tANI_U8)sessionId;
6697 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6698 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6699 if( !HAL_STATUS_SUCCESS( status ) )
6700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006701 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 csrReleaseCommandRoam( pMac, pCommand );
6703 }
6704 }
6705 else
6706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006707 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 status = eHAL_STATUS_RESOURCES;
6709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 return ( status );
6711}
6712
Jeff Johnson295189b2012-06-20 16:38:30 -07006713eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6714{
6715 eHalStatus status = eHAL_STATUS_SUCCESS;
6716 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006717
6718 if(!pSession)
6719 {
6720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6721 return eHAL_STATUS_FAILURE;
6722 }
6723
Jeff Johnson295189b2012-06-20 16:38:30 -07006724#ifdef FEATURE_WLAN_BTAMP_UT_RF
6725 //Stop te retry
6726 pSession->maxRetryCount = 0;
6727 csrRoamStopJoinRetryTimer(pMac, sessionId);
6728#endif
6729 //Not to call cancel roaming here
6730 //Only issue disconnect when necessary
6731 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6732 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6733 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6734
6735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006736 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 return (status);
6740}
6741
Jeff Johnson295189b2012-06-20 16:38:30 -07006742eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6743{
6744 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006745
6746 if(!pSession)
6747 {
6748 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6749 return eHAL_STATUS_FAILURE;
6750 }
6751
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 csrRoamCancelRoaming(pMac, sessionId);
6753 pSession->ibss_join_pending = FALSE;
6754 csrRoamStopIbssJoinTimer(pMac, sessionId);
6755 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6756
6757 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6758}
6759
Jeff Johnson295189b2012-06-20 16:38:30 -07006760eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6761 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6762{
6763 eHalStatus status = eHAL_STATUS_SUCCESS;
6764 tDot11fBeaconIEs *pIesTemp = pIes;
6765 tANI_U8 index;
6766 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6767 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006768
6769 if(!pSession)
6770 {
6771 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6772 return eHAL_STATUS_FAILURE;
6773 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006774
6775 if(pConnectProfile->pAddIEAssoc)
6776 {
6777 palFreeMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc);
6778 pConnectProfile->pAddIEAssoc = NULL;
6779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6781 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6782 pConnectProfile->AuthInfo = pProfile->AuthType;
6783 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6784 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6785 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6786 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6787 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6788 pConnectProfile->BSSType = pProfile->BSSType;
6789 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6790 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006791 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6792
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006794
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006795 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6796 if(pProfile->nAddIEAssocLength)
6797 {
6798 status = palAllocateMemory(pMac->hHdd,
6799 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6800 if(!HAL_STATUS_SUCCESS(status))
6801 {
6802 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6803 return eHAL_STATUS_FAILURE;
6804 }
6805 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6806 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6807 pProfile->nAddIEAssocLength);
6808 }
6809
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 //Save bssid
6811 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6812#ifdef WLAN_FEATURE_VOWIFI_11R
6813 if (pSirBssDesc->mdiePresent)
6814 {
6815 pConnectProfile->MDID.mdiePresent = 1;
6816 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6817 }
6818#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006819 if( NULL == pIesTemp )
6820 {
6821 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006823#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006824 if ((csrIsProfileCCX(pProfile) ||
6825 ((pIesTemp->CCXVersion.present)
6826 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6827 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6828 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6829 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006830#ifdef WLAN_FEATURE_11W
6831 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6832#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306833 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006834 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 {
6836 pConnectProfile->isCCXAssoc = 1;
6837 }
6838#endif
6839 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 if(HAL_STATUS_SUCCESS(status))
6841 {
6842 if(pIesTemp->SSID.present)
6843 {
6844 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6845 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6846 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6847 }
6848
6849 //Save the bss desc
6850 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306851
6852 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306854 //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 -07006855 pConnectProfile->qap = TRUE;
6856 }
6857 else
6858 {
6859 pConnectProfile->qap = FALSE;
6860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 if ( NULL == pIes )
6862 {
6863 //Free memory if it allocated locally
6864 palFreeMemory(pMac->hHdd, pIesTemp);
6865 }
6866 }
6867 //Save Qos connection
6868 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6869
6870 if(!HAL_STATUS_SUCCESS(status))
6871 {
6872 csrFreeConnectBssDesc(pMac, sessionId);
6873 }
6874 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6875 {
6876 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6877 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6878 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6879 {
6880 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6881 break;
6882 }
6883 pConnectProfile->handoffPermitted = FALSE;
6884 }
6885
6886 return (status);
6887}
6888
Jeff Johnson295189b2012-06-20 16:38:30 -07006889static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6890{
6891 tListElem *pEntry = NULL;
6892 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006893 //The head of the active list is the request we sent
6894 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6895 if(pEntry)
6896 {
6897 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6900 {
6901 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6902 {
6903#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6904 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6905#endif
6906 }
6907 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6908 }
6909 else
6910 {
6911 tANI_U32 roamId = 0;
6912 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006913 if(!pSession)
6914 {
6915 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6916 return;
6917 }
6918
Jeff Johnson295189b2012-06-20 16:38:30 -07006919
6920 //The head of the active list is the request we sent
6921 //Try to get back the same profile and roam again
6922 if(pCommand)
6923 {
6924 roamId = pCommand->u.roamCmd.roamId;
6925 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6927 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006928 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006929#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6930 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6931 if (csrRoamIsHandoffInProgress(pMac))
6932 {
6933 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6934 /* Should indicate neighbor roam algorithm about the connect failure here */
6935 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6936 }
6937#endif
6938 if (pCommand)
6939 {
6940 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6941 {
6942 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6943 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6944 csrRoamReissueRoamCommand(pMac);
6945 }
6946 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6947 {
6948 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6949 }
6950 else
6951 {
6952 csrRoam(pMac, pCommand);
6953 }
6954 }
6955 else
6956 {
6957 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6958 }
6959 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6960}
6961
Jeff Johnson295189b2012-06-20 16:38:30 -07006962eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6963 tDot11fBeaconIEs *pIes,
6964 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6965{
6966 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006967 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6969 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6970
6971 // Set the roaming substate to 'join attempt'...
6972 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006974 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 return (status);
6976}
6977
Jeff Johnson295189b2012-06-20 16:38:30 -07006978static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6979 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6980{
6981 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 // Set the roaming substate to 'join attempt'...
6983 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6984
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006985 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006986
6987 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006988 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006989}
6990
Jeff Johnson295189b2012-06-20 16:38:30 -07006991void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6992{
6993 tListElem *pEntry;
6994 tSmeCmd *pCommand;
6995 tCsrRoamInfo roamInfo;
6996 tANI_U32 sessionId;
6997 tCsrRoamSession *pSession;
6998
6999 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7000 if(pEntry)
7001 {
7002 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7003 if ( eSmeCommandRoam == pCommand->command )
7004 {
7005 sessionId = pCommand->sessionId;
7006 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007007
7008 if(!pSession)
7009 {
7010 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7011 return;
7012 }
7013
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 if( pCommand->u.roamCmd.fStopWds )
7015 {
7016 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7017 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7018 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7019 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7022 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7023 eCSR_ROAM_WDS_IND,
7024 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7026 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7027 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7028 eCSR_ROAM_INFRA_IND,
7029 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7030 }
7031
Jeff Johnson295189b2012-06-20 16:38:30 -07007032
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007035 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7037 }
7038 }
7039 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007041 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7043 }
7044 }
7045 else
7046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007047 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 }
7049 }
7050 else
7051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007052 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 }
7054}
7055
Jeff Johnson295189b2012-06-20 16:38:30 -07007056tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7057{
7058 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7059 tListElem *pEntry;
7060 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 //alwasy lock active list before locking pending list
7062 csrLLLock( &pMac->sme.smeCmdActiveList );
7063 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7064 if(pEntry)
7065 {
7066 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7067 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7068 {
7069 fRet = eANI_BOOLEAN_TRUE;
7070 }
7071 }
7072 if(eANI_BOOLEAN_FALSE == fRet)
7073 {
7074 csrLLLock(&pMac->sme.smeCmdPendingList);
7075 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7076 while(pEntry)
7077 {
7078 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7079 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7080 {
7081 fRet = eANI_BOOLEAN_TRUE;
7082 break;
7083 }
7084 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7085 }
7086 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7087 }
7088 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 return (fRet);
7090}
7091
Jeff Johnson295189b2012-06-20 16:38:30 -07007092tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7093{
7094 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7095 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7097 {
7098 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7099 {
7100 break;
7101 }
7102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 return ( fRet );
7104}
7105
Jeff Johnson295189b2012-06-20 16:38:30 -07007106tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7107{
7108 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 //alwasy lock active list before locking pending list
7110 csrLLLock( &pMac->sme.smeCmdActiveList );
7111 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7112 if(eANI_BOOLEAN_FALSE == fRet)
7113 {
7114 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7115 }
7116 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 return (fRet);
7118}
7119
Jeff Johnson295189b2012-06-20 16:38:30 -07007120tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7121{
7122 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7123 tListElem *pEntry;
7124 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 //alwasy lock active list before locking pending list
7126 csrLLLock( &pMac->sme.smeCmdActiveList );
7127 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7128 if( pEntry )
7129 {
7130 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7131 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7132 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7133 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7134 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7135 {
7136 fRet = eANI_BOOLEAN_TRUE;
7137 }
7138 }
7139 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 return (fRet);
7141}
Jeff Johnson295189b2012-06-20 16:38:30 -07007142eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7143{
7144 eHalStatus status = eHAL_STATUS_SUCCESS;
7145 tSmeCmd *pCommand = NULL;
7146 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7147 tANI_BOOLEAN fRemoveCmd = FALSE;
7148 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 // Delete the old assoc command. All is setup for reassoc to be serialized
7150 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7151 if ( pEntry )
7152 {
7153 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7154 if ( !pCommand )
7155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007156 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 return eHAL_STATUS_RESOURCES;
7158 }
7159 if ( eSmeCommandRoam == pCommand->command )
7160 {
7161 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7162 {
7163 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7164 }
7165 else
7166 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007167 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 }
7169 if (fRemoveCmd == FALSE)
7170 {
7171 // Implies we did not get the serialized assoc command we
7172 // were expecting
7173 pCommand = NULL;
7174 }
7175 }
7176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 if(NULL == pCommand)
7178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007179 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 return eHAL_STATUS_RESOURCES;
7181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 do
7183 {
7184 //Change the substate in case it is wait-for-key
7185 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7186 {
7187 csrRoamStopWaitForKeyTimer( pMac );
7188 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7189 }
7190 pCommand->command = eSmeCommandRoam;
7191 pCommand->sessionId = (tANI_U8)sessionId;
7192 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7194 if( !HAL_STATUS_SUCCESS( status ) )
7195 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007196 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007197 csrReleaseCommandRoam( pMac, pCommand );
7198 }
7199 } while( 0 );
7200
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 return( status );
7202}
7203static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7204{
7205 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7206 tCsrScanResult *pScanResult = NULL;
7207 tSirBssDescription *pBssDesc = NULL;
7208 tSmeCmd *pCommand = NULL;
7209 tANI_U32 sessionId;
7210 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 if(NULL == pEntry)
7212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007213 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 return;
7215 }
7216 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7217 sessionId = pCommand->sessionId;
7218 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007219
7220 if(!pSession)
7221 {
7222 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7223 return;
7224 }
7225
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7227 {
7228 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007229 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7231 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007232 /* If the roaming has stopped, not to continue the roaming command*/
7233 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7234 {
7235 //No need to complete roaming here as it already completes
7236 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7237 pCommand->u.roamCmd.roamReason);
7238 csrSetAbortRoamingCommand( pMac, pCommand );
7239 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 else
7242 {
7243 if ( CCM_IS_RESULT_SUCCESS(result) )
7244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007245 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 // Successfully set the configuration parameters for the new Bss. Attempt to
7247 // join the roaming Bss.
7248 if(pCommand->u.roamCmd.pRoamBssEntry)
7249 {
7250 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7251 pBssDesc = &pScanResult->Result.BssDescriptor;
7252 }
7253 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7254 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007255 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 )
7257 {
7258 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7259 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7260 pBssDesc, pCommand->u.roamCmd.roamId )))
7261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007262 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 //We need to complete the command
7264 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7265 }
7266 }
7267 else
7268 {
7269 if (!pCommand->u.roamCmd.pRoamBssEntry)
7270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007271 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 //We need to complete the command
7273 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7274 return;
7275 }
7276 // If we are roaming TO an Infrastructure BSS...
7277 VOS_ASSERT(pScanResult != NULL);
7278 if ( csrIsInfraBssDesc( pBssDesc ) )
7279 {
7280 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7282 {
7283 // ..and currently in an Infrastructure connection....
7284 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7285 {
7286 // ...and the SSIDs are equal, then we Reassoc.
7287 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7288 pIesLocal ) )
7289 // ..and currently in an infrastructure connection
7290 {
7291 // then issue a Reassoc.
7292 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7293 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7294 &pCommand->u.roamCmd.roamProfile );
7295 }
7296 else
7297 {
7298
7299 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7300 // previously associated AP.
7301 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7302 pIesLocal,
7303 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7304 {
7305 //try something else
7306 csrRoam( pMac, pCommand );
7307 }
7308 }
7309 }
7310 else
7311 {
7312 eHalStatus status = eHAL_STATUS_SUCCESS;
7313
7314 /* We need to come with other way to figure out that this is because of HO in BMP
7315 The below API will be only available for Android as it uses a different HO algorithm */
7316 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7317 * use join request */
7318#ifdef WLAN_FEATURE_VOWIFI_11R
7319 if (csrRoamIsHandoffInProgress(pMac) &&
7320 csrRoamIs11rAssoc(pMac))
7321 {
7322 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7323 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7324 }
7325 else
7326#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007327#ifdef FEATURE_WLAN_CCX
7328 if (csrRoamIsHandoffInProgress(pMac) &&
7329 csrRoamIsCCXAssoc(pMac))
7330 {
7331 // Now serialize the reassoc command.
7332 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7333 }
7334 else
7335#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007336#ifdef FEATURE_WLAN_LFR
7337 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307338 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007339 {
7340 // Now serialize the reassoc command.
7341 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7342 }
7343 else
7344#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 // else we are not connected and attempting to Join. Issue the
7346 // Join request.
7347 {
7348 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7349 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7350 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7351 }
7352 if(!HAL_STATUS_SUCCESS(status))
7353 {
7354 //try something else
7355 csrRoam( pMac, pCommand );
7356 }
7357 }
7358 if( !pScanResult->Result.pvIes )
7359 {
7360 //Locally allocated
7361 palFreeMemory(pMac->hHdd, pIesLocal);
7362 }
7363 }
7364 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7365 else
7366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007367 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 }
7369 }//else
7370 }//if ( WNI_CFG_SUCCESS == result )
7371 else
7372 {
7373 // In the event the configuration failed, for infra let the roam processor
7374 //attempt to join something else...
7375 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7376 {
7377 csrRoam(pMac, pCommand);
7378 }
7379 else
7380 {
7381 //We need to complete the command
7382 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7383 {
7384 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7385 }
7386 else
7387 {
7388 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7389 }
7390 }
7391 }
7392 }//we have active entry
7393}
7394
Jeff Johnson295189b2012-06-20 16:38:30 -07007395static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7396{
7397 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007398 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007401 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7403 // join the new one...
7404 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7406 }
7407 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007408 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 /***profHandleLostLinkAfterReset(pAdapter);
7410 // In the event the authenticate fails, let the roam processor attempt to join something else...
7411 roamRoam( pAdapter );***/
7412 }
7413}
7414
Jeff Johnson295189b2012-06-20 16:38:30 -07007415static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7416{
7417 eCsrRoamCompleteResult result;
7418 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7419 tCsrRoamInfo roamInfo;
7420 tANI_U32 roamId = 0;
7421
7422 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007424 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 /* Defeaturize this part later if needed */
7427#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7428 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7429 * we need the response contents while processing the result in csrRoamProcessResults() */
7430 if (csrRoamIsHandoffInProgress(pMac))
7431 {
7432 /* Need to dig more on indicating events to SME QoS module */
7433 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7434 csrRoamComplete( pMac, result, pSmeJoinRsp);
7435 }
7436 else
7437#endif
7438 {
7439 csrRoamComplete( pMac, result, NULL );
7440 }
7441 }
7442 /* Should we handle this similar to handling the join failure? Is it ok
7443 * to call csrRoamComplete() with state as CsrJoinFailure */
7444 else
7445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007446 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 result = eCsrReassocFailure;
7448#ifdef WLAN_FEATURE_VOWIFI_11R
7449 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7450 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7451 {
7452 // Inform HDD to turn off FT flag in HDD
7453 if (pNeighborRoamInfo)
7454 {
7455 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7456 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7457 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007458 /*
7459 * Since the above callback sends a disconnect
7460 * to HDD, we should clean-up our state
7461 * machine as well to be in sync with the upper
7462 * layers. There is no need to send a disassoc
7463 * since: 1) we will never reassoc to the current
7464 * AP in LFR, and 2) there is no need to issue a
7465 * disassoc to the AP with which we were trying
7466 * to reassoc.
7467 */
7468 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7469 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 }
7471 }
7472#endif
7473 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7474 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7475 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7476 //The disassoc rsp message will remove the command from active list
7477 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7478 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7479 {
7480 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7481 }
7482 }
7483}
7484
Jeff Johnson295189b2012-06-20 16:38:30 -07007485static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7486{
Jeff Johnson295189b2012-06-20 16:38:30 -07007487#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7488 {
7489 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7491 if(pIbssLog)
7492 {
7493 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7494 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7495 {
7496 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7497 }
7498 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7499 }
7500 }
7501#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007502 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7503 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7504 {
7505 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7506 }
7507 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7508 {
7509 csrRoamReissueRoamCommand(pMac);
7510 }
7511}
7512
Jeff Johnson295189b2012-06-20 16:38:30 -07007513void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7514{
7515 tSirResultCodes statusCode;
7516#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7517 tScanResultHandle hBSSList;
7518 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7519 eHalStatus status;
7520 tCsrRoamInfo roamInfo;
7521 tCsrScanResultFilter *pScanFilter = NULL;
7522 tANI_U32 roamId = 0;
7523 tCsrRoamProfile *pCurRoamProfile = NULL;
7524 tListElem *pEntry = NULL;
7525 tSmeCmd *pCommand = NULL;
7526#endif
7527 tANI_U32 sessionId;
7528 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007529
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 tSirSmeDisassocRsp SmeDisassocRsp;
7531
7532 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7533 sessionId = SmeDisassocRsp.sessionId;
7534 statusCode = SmeDisassocRsp.statusCode;
7535
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007536 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007537
7538 if ( csrIsConnStateInfra( pMac, sessionId ) )
7539 {
7540 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007543
7544 if(!pSession)
7545 {
7546 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7547 return;
7548 }
7549
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7551 {
7552 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7553 }
7554 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7555 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7556 {
7557 if ( eSIR_SME_SUCCESS == statusCode )
7558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007559 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7561 }
7562 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007564 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007566 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007567#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007568 /*
7569 * First ensure if the roam profile is in the scan cache.
7570 * If not, post a reassoc failure and disconnect.
7571 */
7572 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7573 if(HAL_STATUS_SUCCESS(status))
7574 {
7575 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7576 status = csrRoamPrepareFilterFromProfile(pMac,
7577 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7578 if(!HAL_STATUS_SUCCESS(status))
7579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007580 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007581 __func__, status);
7582 goto POST_ROAM_FAILURE;
7583 }
7584 else
7585 {
7586 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7587 if (!HAL_STATUS_SUCCESS(status))
7588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007589 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007590 __func__, status);
7591 goto POST_ROAM_FAILURE;
7592 }
7593 }
7594 }
7595 else
7596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007597 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007598 __func__, status);
7599 goto POST_ROAM_FAILURE;
7600 }
7601
7602 /*
7603 * After ensuring that the roam profile is in the scan result list,
7604 * dequeue the command from the active list.
7605 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7607 if ( pEntry )
7608 {
7609 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007610 /* If the head of the queue is Active and it is a ROAM command, remove
7611 * and put this on the Free queue.
7612 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 if ( eSmeCommandRoam == pCommand->command )
7614 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007615
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007616 /*
7617 * we need to process the result first before removing it from active list
7618 * because state changes still happening insides roamQProcessRoamResults so
7619 * no other roam command should be issued.
7620 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7622 if(pCommand->u.roamCmd.fReleaseProfile)
7623 {
7624 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7625 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007629 else
7630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007631 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007632 __func__, pCommand->u.roamCmd.roamReason );
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: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 }
7639 }
7640 else
7641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007642 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007643 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007644
7645 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7647
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007648 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7649 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7650 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007651
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007652 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7653 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007654
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007655 /* Copy the connected profile to apply the same for this connection as well */
7656 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7657 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007659 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7660 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7661 //make sure to put it at the head of the cmd queue
7662 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7663 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7664 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7665
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 if(!HAL_STATUS_SUCCESS(status))
7667 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007668 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007669 __func__, status);
7670 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 }
7672
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007673 /* Notify sub-modules like QoS etc. that handoff happening */
7674 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007675 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007676 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 csrFreeScanFilter(pMac, pScanFilter);
7678 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007679 return;
7680 }
7681
7682POST_ROAM_FAILURE:
7683 if (pScanFilter)
7684 {
7685 csrFreeScanFilter(pMac, pScanFilter);
7686 palFreeMemory( pMac->hHdd, pScanFilter );
7687 }
7688 if (pCurRoamProfile)
7689 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7690
7691 /* Inform the upper layers that the reassoc failed */
7692 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7693 csrRoamCallCallback(pMac, sessionId,
7694 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7695
7696 /*
7697 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7698 * Upon success, we would re-enter this routine after receiving the disassoc
7699 * response and will fall into the reassoc fail sub-state. And, eventually
7700 * call csrRoamComplete which would remove the roam command from SME active
7701 * queue.
7702 */
7703 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7704 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007706 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007707 __func__, status);
7708 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007710#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007711
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7713 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7714 {
7715 // Disassoc due to Reassoc failure falls into this codepath....
7716 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7717 }
7718 else
7719 {
7720 if ( eSIR_SME_SUCCESS == statusCode )
7721 {
7722 // Successfully disassociated from the 'old' Bss...
7723 //
7724 // We get Disassociate response in three conditions.
7725 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7726 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7727 // Infrastructure network.
7728 // - Third is where we are doing an Infra to Infra roam between networks with different
7729 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7730
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007731 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007732 }
7733 else
7734 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007735 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 }
7737 //We are not done yet. Get the data and continue roaming
7738 csrRoamReissueRoamCommand(pMac);
7739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007740}
7741
Jeff Johnson295189b2012-06-20 16:38:30 -07007742static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7743{
7744 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007746 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007747 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7748 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7749 {
7750 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7751 }
7752 else
7753 {
7754 if ( eSIR_SME_SUCCESS == statusCode )
7755 {
7756 // Successfully deauth from the 'old' Bss...
7757 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007758 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 }
7760 else
7761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007762 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007763 }
7764 //We are not done yet. Get the data and continue roaming
7765 csrRoamReissueRoamCommand(pMac);
7766 }
7767}
7768
Jeff Johnson295189b2012-06-20 16:38:30 -07007769static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7770{
7771 eCsrRoamCompleteResult result;
7772
7773 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007775 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007776 result = eCsrStartBssSuccess;
7777 }
7778 else
7779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007780 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007781 //Let csrRoamComplete decide what to do
7782 result = eCsrStartBssFailure;
7783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007785}
7786
Jeff Johnson295189b2012-06-20 16:38:30 -07007787/*
7788 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7789 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7790 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7791 For the messages where sender allocates memory for specific structures, then it can be
7792 cast accordingly.
7793*/
7794void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7795{
7796 tSirSmeRsp *pSmeRsp;
7797 tSmeIbssPeerInd *pIbssPeerInd;
7798 tCsrRoamInfo roamInfo;
7799 // TODO Session Id need to be acquired in this function
7800 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007802 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 pSmeRsp->messageType, pSmeRsp->messageType,
7804 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 pSmeRsp->messageType = (pSmeRsp->messageType);
7806 pSmeRsp->length = (pSmeRsp->length);
7807 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 switch (pSmeRsp->messageType)
7809 {
7810
7811 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7812 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7813 {
7814 //We sent a JOIN_REQ
7815 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7816 }
7817 break;
7818
7819 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7820 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7821 {
7822 //We sent a AUTH_REQ
7823 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7824 }
7825 break;
7826
7827 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7828 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7829 {
7830 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7831 }
7832 break;
7833
7834 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7835 {
7836 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7837 }
7838 break;
7839
7840 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7841 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7842 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7843 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7844 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7845 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7846//HO
7847 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007849 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7851 }
7852 break;
7853
7854 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7855 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7856 {
7857 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7858 }
7859 break;
7860
7861 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7862 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7863 {
7864 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7865 }
7866 break;
7867
7868 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7869 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7870 {
7871 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7872 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007874 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7875 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7876 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007877 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7879 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7880 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7881 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7882 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7883 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7884 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7885 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007888 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007889 pSmeRsp->messageType, pSmeRsp->messageType,
7890 pMac->roam.curSubState[pSmeRsp->sessionId] );
7891
7892 //If we are connected, check the link status change
7893 if(!csrIsConnStateDisconnected(pMac, sessionId))
7894 {
7895 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7896 }
7897 break;
7898 }
7899}
7900
Jeff Johnson295189b2012-06-20 16:38:30 -07007901void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7902{
7903 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007904 switch (pSirMsg->messageType)
7905 {
7906 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007907 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 csrRoamStatsRspProcessor( pMac, pSirMsg );
7909 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7911 {
7912 tCsrRoamSession *pSession;
7913 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7914 tCsrRoamInfo roamInfo;
7915 tCsrRoamInfo *pRoamInfo = NULL;
7916 tANI_U32 sessionId;
7917 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007918 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007919 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7920 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7922 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7923 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007924
7925 if(!pSession)
7926 {
7927 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7928 return;
7929 }
7930
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7932 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7934 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7935 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7937 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7939 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7942 {
7943 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7944 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7945 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7946 }
7947 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7948 {
7949 vos_sleep( 100 );
7950 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7951 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7952 }
7953
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 }
7955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 default:
7957 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7958 break;
7959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007960}
7961
Jeff Johnson295189b2012-06-20 16:38:30 -07007962eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7963 tSirBssDescription *pBssDescription,
7964 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7965 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7966 tANI_U8 keyId, tANI_U16 keyLength,
7967 tANI_U8 *pKey, tANI_U8 paeRole )
7968{
7969 eHalStatus status = eHAL_STATUS_SUCCESS;
7970 tAniEdType edType;
7971
7972 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7973 {
7974 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7975 }
7976
7977 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7978
7979 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7980 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7981 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7982 addKey )
7983 {
7984 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 setKey.encType = EncryptType;
7986 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7987 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7988 setKey.paeRole = paeRole; //0 for supplicant
7989 setKey.keyId = keyId; // Kye index
7990 setKey.keyLength = keyLength;
7991 if( keyLength )
7992 {
7993 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7994 }
7995 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 return (status);
7998}
7999
Jeff Johnson295189b2012-06-20 16:38:30 -07008000static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8001 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8002{
8003 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8004 tSmeCmd *pCommand = NULL;
8005#ifdef FEATURE_WLAN_CCX
8006 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8007#endif /* FEATURE_WLAN_CCX */
8008
8009 do
8010 {
8011 pCommand = csrGetCommandBuffer(pMac);
8012 if(NULL == pCommand)
8013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008014 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008015 status = eHAL_STATUS_RESOURCES;
8016 break;
8017 }
8018 pCommand->command = eSmeCommandSetKey;
8019 pCommand->sessionId = (tANI_U8)sessionId;
8020 // validate the key length, Adjust if too long...
8021 // for static WEP the keys are not set thru' SetContextReq
8022 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8023 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8024 {
8025 //KeyLength maybe 0 for static WEP
8026 if( pSetKey->keyLength )
8027 {
8028 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8029 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008030 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 break;
8032 }
8033
8034 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
8035 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
8036 }
8037 }
8038 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8039 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8040 {
8041 //KeyLength maybe 0 for static WEP
8042 if( pSetKey->keyLength )
8043 {
8044 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008046 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 break;
8048 }
8049
8050 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8051 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8052 }
8053 }
8054 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8055 {
8056 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008058 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 break;
8060 }
8061 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8062 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8063 }
8064 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8065 {
8066 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008068 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 break;
8070 }
8071 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8072 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8073 }
8074#ifdef FEATURE_WLAN_WAPI
8075 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8076 {
8077 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008079 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 break;
8081 }
8082 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8083 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8084 }
8085#endif /* FEATURE_WLAN_WAPI */
8086#ifdef FEATURE_WLAN_CCX
8087 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8088 {
8089 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008091 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 break;
8093 }
8094 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8095 pSession->ccxCckmInfo.reassoc_req_num=1;
8096 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8097 status = eHAL_STATUS_SUCCESS;
8098 break;
8099 }
8100#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008101
Jeff Johnson295189b2012-06-20 16:38:30 -07008102#ifdef WLAN_FEATURE_11W
8103 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008104 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008106 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008107 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008108 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 break;
8110 }
8111 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008112 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 }
8114#endif
8115 status = eHAL_STATUS_SUCCESS;
8116 pCommand->u.setKeyCmd.roamId = roamId;
8117 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8118 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8119 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8120 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8121 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8122 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8123 //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
8124
8125 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8126 if( !HAL_STATUS_SUCCESS( status ) )
8127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008128 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 }
8130 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 // Free the command if there has been a failure, or it is a
8132 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008133 if ( ( NULL != pCommand ) &&
8134 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008135#ifdef FEATURE_WLAN_CCX
8136 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8137#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008138 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 {
8140 csrReleaseCommandSetKey( pMac, pCommand );
8141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 return( status );
8143}
8144
Jeff Johnson295189b2012-06-20 16:38:30 -07008145eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8146 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8147{
8148 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8149 tSmeCmd *pCommand = NULL;
8150 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 do
8152 {
8153 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008155 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008156 status = eHAL_STATUS_CSR_WRONG_STATE;
8157 break;
8158 }
8159 pCommand = csrGetCommandBuffer(pMac);
8160 if(NULL == pCommand)
8161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008162 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 status = eHAL_STATUS_RESOURCES;
8164 break;
8165 }
8166 pCommand->command = eSmeCommandRemoveKey;
8167 pCommand->sessionId = (tANI_U8)sessionId;
8168 pCommand->u.removeKeyCmd.roamId = roamId;
8169 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8170 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8171 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8172 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8173 {
8174 //in this case, put it to the end of the Q incase there is a set key pending.
8175 fImediate = eANI_BOOLEAN_FALSE;
8176 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008177 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 pRemoveKey->encType, pRemoveKey->keyId,
8179 pCommand->u.removeKeyCmd.peerMac[0],
8180 pCommand->u.removeKeyCmd.peerMac[1],
8181 pCommand->u.removeKeyCmd.peerMac[2],
8182 pCommand->u.removeKeyCmd.peerMac[3],
8183 pCommand->u.removeKeyCmd.peerMac[4],
8184 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8186 if( !HAL_STATUS_SUCCESS( status ) )
8187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008188 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 break;
8190 }
8191 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008192 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8193 {
8194 csrReleaseCommandRemoveKey( pMac, pCommand );
8195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 return (status );
8197}
8198
Jeff Johnson295189b2012-06-20 16:38:30 -07008199eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8200{
8201 eHalStatus status;
8202 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8203 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8204 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8205 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008206#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8207 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8208 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008209 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008210 {
8211 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8212 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8213 {
8214 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8215 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8216 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8217 }
8218 else
8219 {
8220 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8221 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8222 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8223 }
8224 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
lukez3c809222013-05-03 10:23:02 -07008225 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 {
8227 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 //It has to be static WEP here
8229 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8230 {
8231 setKeyEvent.keyId = (v_U8_t)defKeyId;
8232 }
8233 }
8234 else
8235 {
8236 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8237 }
8238 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8239 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8240 }
8241#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 if( csrIsSetKeyAllowed(pMac, sessionId) )
8243 {
8244 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8245 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8246 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8247 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8248 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8249 pCommand->u.setKeyCmd.keyRsc);
8250 }
8251 else
8252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008253 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 //Set this status so the error handling take care of the case.
8255 status = eHAL_STATUS_CSR_WRONG_STATE;
8256 }
8257 if( !HAL_STATUS_SUCCESS(status) )
8258 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008259 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008261#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008262 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 {
8264 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8265 {
8266 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8267 }
8268 else
8269 {
8270 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8271 }
8272 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8273 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8274 }
8275#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 return ( status );
8278}
8279
Jeff Johnson295189b2012-06-20 16:38:30 -07008280eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8281{
8282 eHalStatus status;
8283 tpSirSmeRemoveKeyReq pMsg = NULL;
8284 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8285 tANI_U8 *p;
8286 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008287#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8289 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8291 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8292 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8293 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8294 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8295 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8296 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8297 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8298#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 if( csrIsSetKeyAllowed(pMac, sessionId) )
8300 {
8301 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8302 }
8303 else
8304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008305 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 //Set the error status so error handling kicks in below
8307 status = eHAL_STATUS_CSR_WRONG_STATE;
8308 }
8309 if( HAL_STATUS_SUCCESS( status ) )
8310 {
8311 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8312 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8313 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 pMsg->sessionId = (tANI_U8)sessionId;
8315 pMsg->transactionId = 0;
8316 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8317 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8318 // bssId - copy from session Info
8319 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8320 p += sizeof(tSirMacAddr);
8321 // peerMacAddr
8322 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8323 p += sizeof(tSirMacAddr);
8324 // edType
8325 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8326 p++;
8327 // weptype
8328 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8329 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8330 {
8331 *p = (tANI_U8)eSIR_WEP_STATIC;
8332 }
8333 else
8334 {
8335 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8336 }
8337 p++;
8338 //keyid
8339 *p = pCommand->u.removeKeyCmd.keyId;
8340 p++;
8341 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008342 status = palSendMBMessage(pMac->hHdd, pMsg);
8343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 if( !HAL_STATUS_SUCCESS( status ) )
8345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008346 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008347#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8348 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008349 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8351#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 return ( status );
8355}
8356
Jeff Johnson295189b2012-06-20 16:38:30 -07008357eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8358{
8359 eHalStatus status;
8360
8361 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8362 {
8363 status = eHAL_STATUS_CSR_WRONG_STATE;
8364 }
8365 else
8366 {
8367 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 return ( status );
8370}
8371
Jeff Johnson295189b2012-06-20 16:38:30 -07008372/*
8373 Prepare a filter base on a profile for parsing the scan results.
8374 Upon successful return, caller MUST call csrFreeScanFilter on
8375 pScanFilter when it is done with the filter.
8376*/
8377eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8378 tCsrScanResultFilter *pScanFilter)
8379{
8380 eHalStatus status = eHAL_STATUS_SUCCESS;
8381 tANI_U32 size = 0;
8382 tANI_U8 index = 0;
8383
8384 do
8385 {
8386 if(pProfile->BSSIDs.numOfBSSIDs)
8387 {
8388 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8389 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8390 if(!HAL_STATUS_SUCCESS(status))
8391 {
8392 break;
8393 }
8394 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8395 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8396 }
8397 if(pProfile->SSIDs.numOfSSIDs)
8398 {
8399 if( !CSR_IS_WDS_STA( pProfile ) )
8400 {
8401 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8402 }
8403 else
8404 {
8405 //For WDS station
8406 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8407 pScanFilter->SSIDs.numOfSSIDs = 1;
8408 }
8409 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8410 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8411 if(!HAL_STATUS_SUCCESS(status))
8412 {
8413 break;
8414 }
8415 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8416 }
8417 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8418 {
8419 pScanFilter->ChannelInfo.numOfChannels = 0;
8420 pScanFilter->ChannelInfo.ChannelList = NULL;
8421 }
8422 else if(pProfile->ChannelInfo.numOfChannels)
8423 {
8424 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8425 pScanFilter->ChannelInfo.numOfChannels = 0;
8426 if(HAL_STATUS_SUCCESS(status))
8427 {
8428 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8429 {
8430 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8431 {
8432 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8433 = pProfile->ChannelInfo.ChannelList[index];
8434 pScanFilter->ChannelInfo.numOfChannels++;
8435 }
8436 else
8437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008438 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 }
8441 }
8442 else
8443 {
8444 break;
8445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 }
8447 else
8448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008449 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 status = eHAL_STATUS_FAILURE;
8451 break;
8452 }
8453 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8454 pScanFilter->authType = pProfile->AuthType;
8455 pScanFilter->EncryptionType = pProfile->EncryptionType;
8456 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8457 pScanFilter->BSSType = pProfile->BSSType;
8458 pScanFilter->phyMode = pProfile->phyMode;
8459#ifdef FEATURE_WLAN_WAPI
8460 //check if user asked for WAPI with 11n or auto mode, in that case modify
8461 //the phymode to 11g
8462 if(csrIsProfileWapi(pProfile))
8463 {
8464 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8465 {
8466 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8467 }
8468 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8469 {
8470 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8471 }
8472 if(!pScanFilter->phyMode)
8473 {
8474 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8475 }
8476 }
8477#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 /*Save the WPS info*/
8479 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 if( pProfile->countryCode[0] )
8481 {
8482 //This causes the matching function to use countryCode as one of the criteria.
8483 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8484 WNI_CFG_COUNTRY_CODE_LEN );
8485 }
8486#ifdef WLAN_FEATURE_VOWIFI_11R
8487 if (pProfile->MDID.mdiePresent)
8488 {
8489 pScanFilter->MDID.mdiePresent = 1;
8490 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8491 }
8492#endif
8493
8494 }while(0);
8495
8496 if(!HAL_STATUS_SUCCESS(status))
8497 {
8498 csrFreeScanFilter(pMac, pScanFilter);
8499 }
8500
8501 return(status);
8502}
8503
Jeff Johnson295189b2012-06-20 16:38:30 -07008504tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8505 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8506{
8507 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8508 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 do
8510 {
8511 // Validate the type is ok...
8512 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8513 pCommand = csrGetCommandBuffer( pMac );
8514 if ( !pCommand )
8515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008516 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 break;
8518 }
8519 //Change the substate in case it is waiting for key
8520 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8521 {
8522 csrRoamStopWaitForKeyTimer( pMac );
8523 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8524 }
8525 pCommand->command = eSmeCommandWmStatusChange;
8526 pCommand->sessionId = (tANI_U8)sessionId;
8527 pCommand->u.wmStatusChangeCmd.Type = Type;
8528 if ( eCsrDisassociated == Type )
8529 {
8530 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8531 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8532 }
8533 else
8534 {
8535 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8536 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8537 }
8538 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8539 {
8540 fCommandQueued = eANI_BOOLEAN_TRUE;
8541 }
8542 else
8543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008544 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 csrReleaseCommandWmStatusChange( pMac, pCommand );
8546 }
8547
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8549 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 return( fCommandQueued );
8552}
8553
Jeff Johnson295189b2012-06-20 16:38:30 -07008554static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8555{
8556 v_S7_t rssi = 0;
8557 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8558 if(pGetRssiReq)
8559 {
8560 if(NULL != pGetRssiReq->pVosContext)
8561 {
8562 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8563 }
8564 else
8565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008566 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 return;
8568 }
8569
8570 if(NULL != pGetRssiReq->rssiCallback)
8571 {
8572 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8573 }
8574 else
8575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008576 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 return;
8578 }
8579 }
8580 else
8581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008582 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 }
8584 return;
8585}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308586
8587static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8588{
8589 tANI_S8 snr = 0;
8590 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8591
8592 if (pGetSnrReq)
8593 {
8594 if (VOS_STATUS_SUCCESS !=
8595 WDA_GetSnr(pGetSnrReq->staId, &snr))
8596 {
8597 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8598 return;
8599 }
8600
8601 if (pGetSnrReq->snrCallback)
8602 {
8603 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8604 pGetSnrReq->pDevContext);
8605 }
8606 else
8607 {
8608 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8609 return;
8610 }
8611 }
8612 else
8613 {
8614 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8615 }
8616 return;
8617}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008618#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8619void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8620{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008621 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8622
Jeff Johnson36d483b2013-04-08 11:08:53 -07008623 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008624 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008625 /* Get roam Rssi request is backed up and passed back to the response,
8626 Extract the request message to fetch callback */
8627 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8628 v_S7_t rssi = pRoamRssiRsp->rssi;
8629
8630 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008631 {
8632 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8633 reqBkp->rssiCallback = NULL;
8634 vos_mem_free(reqBkp);
8635 }
8636 else
8637 {
8638 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8639 if (NULL != reqBkp)
8640 {
8641 vos_mem_free(reqBkp);
8642 }
8643 }
8644 }
8645 else
8646 {
8647 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8648 }
8649 return;
8650}
8651#endif
8652
Jeff Johnsone7245742012-09-05 17:12:55 -07008653static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8654{
8655 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8656 if(pTlRssiInd)
8657 {
8658 if(NULL != pTlRssiInd->tlCallback)
8659 {
8660 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008661 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008662 }
8663 else
8664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008665 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008666 }
8667 }
8668 else
8669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008670 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008671 }
8672 return;
8673}
Jeff Johnson295189b2012-06-20 16:38:30 -07008674
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308675eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8676{
8677 tpSirResetAPCapsChange pMsg;
8678 tANI_U16 len;
8679 eHalStatus status = eHAL_STATUS_SUCCESS;
8680
8681 /* Create the message and send to lim */
8682 len = sizeof(tSirResetAPCapsChange);
8683 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8684 if (HAL_STATUS_SUCCESS(status))
8685 {
8686 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8687 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8688 pMsg->length = len;
8689 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8690 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8691 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8692 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8693 status = palSendMBMessage(pMac->hHdd, pMsg);
8694 }
8695 else
8696 {
8697 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8698 }
8699 return status;
8700}
8701
Jeff Johnson295189b2012-06-20 16:38:30 -07008702void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8703{
8704 tSirSmeAssocInd *pAssocInd;
8705 tSirSmeDisassocInd *pDisassocInd;
8706 tSirSmeDeauthInd *pDeauthInd;
8707 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8708 tSirSmeNewBssInfo *pNewBss;
8709 tSmeIbssPeerInd *pIbssPeerInd;
8710 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8711 tSirSmeApNewCaps *pApNewCaps;
8712 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8713 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8714 tCsrRoamInfo *pRoamInfo = NULL;
8715 tCsrRoamInfo roamInfo;
8716 eHalStatus status;
8717 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8718 tCsrRoamSession *pSession = NULL;
8719 tpSirSmeSwitchChannelInd pSwitchChnInd;
8720 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008721 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 pSirMsg->messageType = (pSirMsg->messageType);
8723 pSirMsg->length = (pSirMsg->length);
8724 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 switch( pSirMsg->messageType )
8727 {
8728 case eWNI_SME_ASSOC_IND:
8729 {
8730 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008731 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8733 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8734 if( HAL_STATUS_SUCCESS( status ) )
8735 {
8736 pSession = CSR_GET_SESSION(pMac, sessionId);
8737
Jeff Johnson32d95a32012-09-10 13:15:23 -07008738 if(!pSession)
8739 {
8740 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8741 return;
8742 }
8743
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 pRoamInfo = &roamInfo;
8745
8746 // Required for indicating the frames to upper layer
8747 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8748 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8749
8750 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8751 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8752 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8753 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8754
8755 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8756 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8757 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8758
8759 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8760 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8762 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008763 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8764 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8767 {
8768 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8769 {
8770 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8771 pSession->pConnectBssDesc,
8772 &(pRoamInfo->peerMac),
8773 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8774 pRoamInfo->fAuthRequired = FALSE;
8775 }
8776 else
8777 {
8778 pRoamInfo->fAuthRequired = TRUE;
8779 }
8780 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8781 if (!HAL_STATUS_SUCCESS(status))
8782 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 /* Send Association completion message to PE */
8785 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8786
8787 /* send a message to CSR itself just to avoid the EAPOL frames going
8788 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008789 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8790 {
8791 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8794 {
8795 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8796 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8797 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 }
8800 }
8801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008803 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 // Check if AP dis-associated us because of MIC failure. If so,
8805 // then we need to take action immediately and not wait till the
8806 // the WmStatusChange requests is pushed and processed
8807 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8808 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8809 if( HAL_STATUS_SUCCESS( status ) )
8810 {
8811 // If we are in neighbor preauth done state then on receiving
8812 // disassoc or deauth we dont roam instead we just disassoc
8813 // from current ap and then go to disconnected state
8814 // This happens for CCX and 11r FT connections ONLY.
8815#ifdef WLAN_FEATURE_VOWIFI_11R
8816 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8817 {
8818 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8819 }
8820#endif
8821#ifdef FEATURE_WLAN_CCX
8822 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8823 {
8824 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8825 }
8826#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008827#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308828 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008829 {
8830 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8831 }
8832#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 pSession = CSR_GET_SESSION( pMac, sessionId );
8834
Jeff Johnson32d95a32012-09-10 13:15:23 -07008835 if(!pSession)
8836 {
8837 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8838 return;
8839 }
8840
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 if ( csrIsConnStateInfra( pMac, sessionId ) )
8842 {
8843 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008845#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8846 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8847#endif
8848 csrRoamLinkDown(pMac, sessionId);
8849 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8851 {
8852
8853 pRoamInfo = &roamInfo;
8854
8855 pRoamInfo->statusCode = pDisassocInd->statusCode;
8856 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8857
8858 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8859
8860 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8861 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8862
8863 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008864
8865 /*
8866 * STA/P2P client got disassociated so remove any pending deauth
8867 * commands in sme pending list
8868 */
8869 pCommand.command = eSmeCommandRoam;
8870 pCommand.sessionId = (tANI_U8)sessionId;
8871 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8872 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8873 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 }
8876 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008878 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8880 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8881 if( HAL_STATUS_SUCCESS( status ) )
8882 {
8883 // If we are in neighbor preauth done state then on receiving
8884 // disassoc or deauth we dont roam instead we just disassoc
8885 // from current ap and then go to disconnected state
8886 // This happens for CCX and 11r FT connections ONLY.
8887#ifdef WLAN_FEATURE_VOWIFI_11R
8888 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8889 {
8890 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8891 }
8892#endif
8893#ifdef FEATURE_WLAN_CCX
8894 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8895 {
8896 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8897 }
8898#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008899#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308900 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008901 {
8902 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8903 }
8904#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008905 pSession = CSR_GET_SESSION( pMac, sessionId );
8906
Jeff Johnson32d95a32012-09-10 13:15:23 -07008907 if(!pSession)
8908 {
8909 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8910 return;
8911 }
8912
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 if ( csrIsConnStateInfra( pMac, sessionId ) )
8914 {
8915 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008917#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8918 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8919#endif
8920 csrRoamLinkDown(pMac, sessionId);
8921 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8923 {
8924
8925 pRoamInfo = &roamInfo;
8926
8927 pRoamInfo->statusCode = pDeauthInd->statusCode;
8928 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8929
8930 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8931
8932 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8933 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8934
8935 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 }
8938 break;
8939
8940 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 -08008941 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8943 //Update with the new channel id.
8944 //The channel id is hidden in the statusCode.
8945 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8946 if( HAL_STATUS_SUCCESS( status ) )
8947 {
8948 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008949 if(!pSession)
8950 {
8951 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8952 return;
8953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8955 if(pSession->pConnectBssDesc)
8956 {
8957 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8958 }
8959 }
8960 break;
8961
8962 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008963 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 {
8965 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8966 sessionId = pDeauthRsp->sessionId;
8967 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8968 {
8969 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008970 if(!pSession)
8971 {
8972 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8973 return;
8974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8976 {
8977 pRoamInfo = &roamInfo;
8978 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8979 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8980 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8981 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8982 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8983 }
8984 }
8985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 break;
8987
8988 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008989 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008990 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008991 {
8992 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8993 sessionId = pDisassocRsp->sessionId;
8994 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8995 {
8996 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008997 if(!pSession)
8998 {
8999 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9000 return;
9001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009002 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9003 {
9004 pRoamInfo = &roamInfo;
9005 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9006 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
9007 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9008 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9009 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9010 }
9011 }
9012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009014 case eWNI_SME_MIC_FAILURE_IND:
9015 {
9016 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9017 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9018 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009019
9020 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9021 if( HAL_STATUS_SUCCESS( status ) )
9022 {
9023 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9024 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9025 pRoamInfo = &roamInfo;
9026 if(pMicInd->info.multicast)
9027 {
9028 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9029 }
9030 else
9031 {
9032 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9033 }
9034 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9035 }
9036
Jeff Johnson295189b2012-06-20 16:38:30 -07009037#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9038 {
lukez3c809222013-05-03 10:23:02 -07009039 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009041 if(!pSession)
9042 {
9043 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9044 return;
9045 }
lukez3c809222013-05-03 10:23:02 -07009046
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
9048 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9049 secEvent.encryptionModeMulticast =
9050 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9051 secEvent.encryptionModeUnicast =
9052 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9053 secEvent.authMode =
9054 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9055 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
9056 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9057 }
9058#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Leo Chang9b01ad92013-09-12 17:26:56 -07009059
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 }
9061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9063 {
9064 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9065 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009066 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009067
9068 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9069 if( HAL_STATUS_SUCCESS( status ) )
9070 {
9071 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9072 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9073 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9074 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9075 }
9076 }
9077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009078
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9080 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9081 switch( pStatusChangeMsg->statusChangeCode )
9082 {
9083 case eSIR_SME_IBSS_ACTIVE:
9084 sessionId = csrFindIbssSession( pMac );
9085 if( CSR_SESSION_ID_INVALID != sessionId )
9086 {
9087 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009088 if(!pSession)
9089 {
9090 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9091 return;
9092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9094 if(pSession->pConnectBssDesc)
9095 {
9096 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9097 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9098 pRoamInfo = &roamInfo;
9099 }
9100 else
9101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009102 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 }
9104 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9105 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9106 }
9107 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 case eSIR_SME_IBSS_INACTIVE:
9109 sessionId = csrFindIbssSession( pMac );
9110 if( CSR_SESSION_ID_INVALID != sessionId )
9111 {
9112 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009113 if(!pSession)
9114 {
9115 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9116 return;
9117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009118 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9119 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9120 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9121 }
9122 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9124 sessionId = csrFindIbssSession( pMac );
9125 if( CSR_SESSION_ID_INVALID != sessionId )
9126 {
9127 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009128 if(!pSession)
9129 {
9130 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9131 return;
9132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 // update the connection state information
9134 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009135#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9136 {
9137 vos_log_ibss_pkt_type *pIbssLog;
9138 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9140 if(pIbssLog)
9141 {
9142 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9143 if(pNewBss)
9144 {
9145 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9146 if(pNewBss->ssId.length)
9147 {
9148 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9149 }
9150 pIbssLog->operatingChannel = pNewBss->channelNumber;
9151 }
9152 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9153 {
9154 //***U8 is not enough for beacon interval
9155 pIbssLog->beaconInterval = (v_U8_t)bi;
9156 }
9157 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9158 }
9159 }
9160#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009162
9163 if ((eCSR_ENCRYPT_TYPE_NONE ==
9164 pSession->connectedProfile.EncryptionType ))
9165 {
9166 csrRoamIssueSetContextReq( pMac, sessionId,
9167 pSession->connectedProfile.EncryptionType,
9168 pSession->pConnectBssDesc,
9169 &Broadcastaddr,
9170 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009172 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9173 roamStatus = eCSR_ROAM_IBSS_IND;
9174 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9175 pRoamInfo = &roamInfo;
9176 //This BSSID is th ereal BSSID, let's save it
9177 if(pSession->pConnectBssDesc)
9178 {
9179 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9180 }
9181 // Stop the join IBSS timer in case of join, for
9182 // genuine merge do nothing
9183 if(pSession->ibss_join_pending)
9184 {
9185 pSession->ibss_join_pending = FALSE;
9186 csrRoamStopIbssJoinTimer(pMac, sessionId);
9187 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9188 }
9189 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009190 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 // detection by LIM that the capabilities of the associated AP have changed.
9193 case eSIR_SME_AP_CAPS_CHANGED:
9194 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009195 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9197 if( HAL_STATUS_SUCCESS( status ) )
9198 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009199 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9200 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309201 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009202 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9203 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9204 )
9205 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309206 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9207 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009208 }
9209 else
9210 {
9211 smsLog(pMac, LOGW,
9212 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009213 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009214 pMac->roam.curState[sessionId],
9215 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309216 /* We ignore the caps change event if CSR is not in full connected state.
9217 * Send one event to PE to reset limSentCapsChangeNtf
9218 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9219 * otherwise lim cannot send any CAPS change events to SME */
9220 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 }
9223 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309224
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 default:
9226 roamStatus = eCSR_ROAM_FAILED;
9227 result = eCSR_ROAM_RESULT_NONE;
9228 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 } // end switch on statusChangeCode
9230 if(eCSR_ROAM_RESULT_NONE != result)
9231 {
9232 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9233 }
9234 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 case eWNI_SME_IBSS_NEW_PEER_IND:
9236 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009237#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9238 {
9239 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9241 if(pIbssLog)
9242 {
9243 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9244 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9245 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9246 }
9247 }
9248#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 sessionId = csrFindIbssSession( pMac );
9250 if( CSR_SESSION_ID_INVALID != sessionId )
9251 {
9252 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009253
9254 if(!pSession)
9255 {
9256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9257 return;
9258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9260 if(pSession->pConnectBssDesc)
9261 {
9262 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9263 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9264 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9265 {
9266 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9267 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9268 if(HAL_STATUS_SUCCESS(status))
9269 {
9270 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9271 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9272 roamInfo.nBeaconLength);
9273 }
9274 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9275 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9276 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9277 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9278 pSession->pConnectBssDesc->length);
9279 if(HAL_STATUS_SUCCESS(status))
9280 {
9281 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9282 pSession->pConnectBssDesc->length);
9283 }
9284 if(HAL_STATUS_SUCCESS(status))
9285 {
9286 pRoamInfo = &roamInfo;
9287 }
9288 else
9289 {
9290 if(roamInfo.pbFrames)
9291 {
9292 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9293 }
9294 if(roamInfo.pBssDesc)
9295 {
9296 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9297 }
9298 }
9299 }
9300 else
9301 {
9302 pRoamInfo = &roamInfo;
9303 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009304 if ((eCSR_ENCRYPT_TYPE_NONE ==
9305 pSession->connectedProfile.EncryptionType ))
9306 {
9307 csrRoamIssueSetContextReq( pMac, sessionId,
9308 pSession->connectedProfile.EncryptionType,
9309 pSession->pConnectBssDesc,
9310 &(pIbssPeerInd->peerAddr),
9311 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009313 }
9314 else
9315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009316 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 }
9318 //send up the sec type for the new peer
9319 if (pRoamInfo)
9320 {
9321 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9322 }
9323 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9324 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9325 if(pRoamInfo)
9326 {
9327 if(roamInfo.pbFrames)
9328 {
9329 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9330 }
9331 if(roamInfo.pBssDesc)
9332 {
9333 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9334 }
9335 }
9336 }
9337 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9339 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9340 sessionId = csrFindIbssSession( pMac );
9341 if( CSR_SESSION_ID_INVALID != sessionId )
9342 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009343#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9344 {
9345 vos_log_ibss_pkt_type *pIbssLog;
9346
9347 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9348 if(pIbssLog)
9349 {
9350 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9351 if(pIbssPeerInd)
9352 {
9353 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9354 }
9355 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9356 }
9357 }
9358#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009359 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9361 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9362 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9363 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9364 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9365 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9366 }
9367 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009368 case eWNI_SME_SETCONTEXT_RSP:
9369 {
9370 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9371 tListElem *pEntry;
9372 tSmeCmd *pCommand;
9373
9374 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9375 if ( pEntry )
9376 {
9377 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9378 if ( eSmeCommandSetKey == pCommand->command )
9379 {
9380 sessionId = pCommand->sessionId;
9381 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009382
9383 if(!pSession)
9384 {
9385 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9386 return;
9387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009388
9389#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9390 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9391 {
9392 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9393 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9394 if( pRsp->peerMacAddr[0] & 0x01 )
9395 {
9396 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9397 }
9398 else
9399 {
9400 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9401 }
9402 setKeyEvent.encryptionModeMulticast =
9403 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9404 setKeyEvent.encryptionModeUnicast =
9405 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9406 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9407 setKeyEvent.authMode =
9408 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009409 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 {
9411 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9412 }
9413 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9414 }
9415#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9416 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9417 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009418 csrRoamStopWaitForKeyTimer( pMac );
9419
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 //We are done with authentication, whethere succeed or not
9421 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 //We do it here because this linkup function is not called after association
9423 //when a key needs to be set.
9424 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9425 {
9426 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9427 }
9428 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009429 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 {
9431 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009432 //Make sure we install the GTK before indicating to HDD as authenticated
9433 //This is to prevent broadcast packets go out after PTK and before GTK.
9434 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9435 sizeof(tSirMacAddr) ) )
9436 {
Yathish9f22e662012-12-10 14:21:35 -08009437#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9438 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9439 {
9440 tpSirSetActiveModeSetBncFilterReq pMsg;
9441 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9442 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9443 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9444 pMsg->seesionId = sessionId;
9445 status = palSendMBMessage(pMac->hHdd, pMsg );
9446 }
9447#endif
9448 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009449 }
9450 else
9451 {
9452 result = eCSR_ROAM_RESULT_NONE;
9453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 pRoamInfo = &roamInfo;
9455 }
9456 else
9457 {
9458 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009459 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9461 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9462 }
9463 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9464 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9466 // can go ahead and initiate the TSPEC if any are pending
9467 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009468#ifdef FEATURE_WLAN_CCX
9469 //Send Adjacent AP repot to new AP.
9470 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9471 pSession->isPrevApInfoValid &&
9472 pSession->connectedProfile.isCCXAssoc)
9473 {
9474#ifdef WLAN_FEATURE_VOWIFI
9475 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9476#endif
9477 pSession->isPrevApInfoValid = FALSE;
9478 }
9479#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9481 {
9482 csrReleaseCommandSetKey( pMac, pCommand );
9483 }
9484 }
9485 else
9486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009487 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 }
9489 }
9490 else
9491 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009492 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 smeProcessPendingQueue( pMac );
9495 }
9496 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 case eWNI_SME_REMOVEKEY_RSP:
9498 {
9499 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9500 tListElem *pEntry;
9501 tSmeCmd *pCommand;
9502
9503 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9504 if ( pEntry )
9505 {
9506 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9507 if ( eSmeCommandRemoveKey == pCommand->command )
9508 {
9509 sessionId = pCommand->sessionId;
9510 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009511
9512 if(!pSession)
9513 {
9514 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9515 return;
9516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009517#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9518 {
9519 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9520 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9521 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9522 removeKeyEvent.encryptionModeMulticast =
9523 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9524 removeKeyEvent.encryptionModeUnicast =
9525 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9526 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9527 removeKeyEvent.authMode =
9528 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009529 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 {
9531 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9532 }
9533 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9534 }
9535#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009536 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 {
9538 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9539 result = eCSR_ROAM_RESULT_NONE;
9540 pRoamInfo = &roamInfo;
9541 }
9542 else
9543 {
9544 result = eCSR_ROAM_RESULT_FAILURE;
9545 }
9546 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9547 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9548 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9549 {
9550 csrReleaseCommandRemoveKey( pMac, pCommand );
9551 }
9552 }
9553 else
9554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009555 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 }
9557 }
9558 else
9559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009560 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009562 smeProcessPendingQueue( pMac );
9563 }
9564 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009566 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 csrRoamStatsRspProcessor( pMac, pSirMsg );
9568 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009569#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9570 case eWNI_SME_GET_ROAM_RSSI_RSP:
9571 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9572 csrRoamRssiRspProcessor( pMac, pSirMsg );
9573 break;
9574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009576 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 csrUpdateRssi( pMac, pSirMsg );
9578 break;
9579
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309580 case eWNI_SME_GET_SNR_REQ:
9581 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
9582 csrUpdateSnr(pMac, pSirMsg);
9583 break;
9584
Jeff Johnson295189b2012-06-20 16:38:30 -07009585#ifdef WLAN_FEATURE_VOWIFI_11R
9586 case eWNI_SME_FT_PRE_AUTH_RSP:
9587 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9588 break;
9589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9591 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009592 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 -07009593 sessionId = pSmeMaxAssocInd->sessionId;
9594 roamInfo.sessionId = sessionId;
9595 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9596 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9597 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9598 break;
9599
9600 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009601 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 btampEstablishLogLinkHdlr( pSirMsg );
9603 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009604 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009605 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009606 csrRoamRssiIndHdlr( pMac, pSirMsg );
9607 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009608#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9609 case eWNI_SME_CANDIDATE_FOUND_IND:
9610 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9611 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9612 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009613 case eWNI_SME_HANDOFF_REQ:
9614 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9615 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9616 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009617#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009618
9619 default:
9620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009621 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009622}
9623
Jeff Johnson295189b2012-06-20 16:38:30 -07009624void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9625 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9626{
9627 if(pSession)
9628 {
9629 if(pSession->bRefAssocStartCnt)
9630 {
9631 pSession->bRefAssocStartCnt--;
9632 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9633 //Need to call association_completion because there is an assoc_start pending.
9634 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9635 eCSR_ROAM_ASSOCIATION_COMPLETION,
9636 eCSR_ROAM_RESULT_FAILURE);
9637 }
9638 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9639 }
9640 else
9641 {
9642 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9643 }
9644}
9645
9646
9647eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9648{
9649 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9651 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9652 {
9653 status = csrScanRequestLostLink1( pMac, sessionId );
9654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 return(status);
9656}
9657
Jeff Johnson295189b2012-06-20 16:38:30 -07009658//return a boolean to indicate whether roaming completed or continue.
9659tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9660 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9661{
9662 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9663 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9664 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009666 if(!pSession)
9667 {
9668 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9669 return eANI_BOOLEAN_FALSE;
9670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 //Check whether time is up
9672 if(pSession->fCancelRoaming || fForce ||
9673 ((curTime - pSession->roamingStartTime) > roamTime) ||
9674 eCsrReassocRoaming == pSession->roamingReason ||
9675 eCsrDynamicRoaming == pSession->roamingReason)
9676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009677 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9679 {
9680 //roaming is cancelled, tell HDD to indicate disconnect
9681 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9682 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9683 //to be eSIR_BEACON_MISSED
9684 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9685 {
9686 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9687 }
9688 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9689 {
9690 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9691 }
9692 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9693 {
9694 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9695 }
9696 else
9697 {
9698 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9699 }
9700 }
9701 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9702 pSession->roamingReason = eCsrNotRoaming;
9703 }
9704 else
9705 {
9706 pSession->roamResult = roamResult;
9707 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9708 {
9709 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9710 pSession->roamingReason = eCsrNotRoaming;
9711 }
9712 else
9713 {
9714 fCompleted = eANI_BOOLEAN_FALSE;
9715 }
9716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 return(fCompleted);
9718}
9719
Jeff Johnson295189b2012-06-20 16:38:30 -07009720void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9721{
9722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009723
9724 if(!pSession)
9725 {
9726 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9727 return;
9728 }
9729
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 if(CSR_IS_ROAMING(pSession))
9731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009732 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9734 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9735 {
9736 //No need to do anything in here because the handler takes care of it
9737 }
9738 else
9739 {
9740 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9741 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9742 //Roaming is stopped after here
9743 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9744 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05309745 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 csrRoamStopRoamingTimer(pMac, sessionId);
9747 }
9748 }
9749}
9750
Jeff Johnson295189b2012-06-20 16:38:30 -07009751void csrRoamRoamingTimerHandler(void *pv)
9752{
9753 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9754 tpAniSirGlobal pMac = pInfo->pMac;
9755 tANI_U32 sessionId = pInfo->sessionId;
9756 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009757
9758 if(!pSession)
9759 {
9760 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9761 return;
9762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009763
9764 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9765 {
9766 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9767 {
9768 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9769 pSession->roamingReason = eCsrNotRoaming;
9770 }
9771 }
9772}
9773
Jeff Johnson295189b2012-06-20 16:38:30 -07009774eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9775{
9776 eHalStatus status;
9777 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009778
9779 if(!pSession)
9780 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009781 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009782 return eHAL_STATUS_FAILURE;
9783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009784
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009785 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309787 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009788
9789 return (status);
9790}
9791
Jeff Johnson295189b2012-06-20 16:38:30 -07009792eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9793{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309794 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -07009795}
9796
Jeff Johnson295189b2012-06-20 16:38:30 -07009797void csrRoamWaitForKeyTimeOutHandler(void *pv)
9798{
9799 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9800 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009801 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9802
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009803 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009804 pMac->roam.neighborRoamInfo.neighborRoamState,
9805 pMac->roam.curSubState[pInfo->sessionId]);
9806
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9808 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009809#ifdef FEATURE_WLAN_LFR
9810 if (csrNeighborRoamIsHandoffInProgress(pMac))
9811 {
9812 /*
9813 * Enable heartbeat timer when hand-off is in progress
9814 * and Key Wait timer expired.
9815 */
9816 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009817 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009818 pMac->roam.configParam.HeartbeatThresh24);
9819 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9820 pMac->roam.configParam.HeartbeatThresh24,
9821 NULL, eANI_BOOLEAN_FALSE);
9822 }
9823#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009824 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 //Change the substate so command queue is unblocked.
9826 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009827 if (pSession)
9828 {
9829 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9830 {
9831 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9832 smeProcessPendingQueue(pMac);
9833 }
9834 else
9835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009836 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009837 __func__);
9838 }
9839 }
9840 else
9841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009842 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009844 }
9845
9846}
9847
Jeff Johnson295189b2012-06-20 16:38:30 -07009848eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9849{
9850 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009851#ifdef FEATURE_WLAN_LFR
9852 if (csrNeighborRoamIsHandoffInProgress(pMac))
9853 {
9854 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009855 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009856 __func__,
9857 pMac->roam.neighborRoamInfo.neighborRoamState,
9858 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9859 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9860 }
9861#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009862 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309863 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009864
9865 return (status);
9866}
9867
Jeff Johnson295189b2012-06-20 16:38:30 -07009868eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9869{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009870 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009871 pMac->roam.neighborRoamInfo.neighborRoamState,
9872 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9873#ifdef FEATURE_WLAN_LFR
9874 if (csrNeighborRoamIsHandoffInProgress(pMac))
9875 {
9876 /*
9877 * Enable heartbeat timer when hand-off is in progress
9878 * and Key Wait timer got stopped for some reason
9879 */
9880 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009881 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009882 pMac->roam.configParam.HeartbeatThresh24);
9883 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9884 pMac->roam.configParam.HeartbeatThresh24,
9885 NULL, eANI_BOOLEAN_FALSE);
9886 }
9887#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309888 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07009889}
9890
Jeff Johnson295189b2012-06-20 16:38:30 -07009891void csrRoamIbssJoinTimerHandler(void *pv)
9892{
9893 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9894 tpAniSirGlobal pMac = pInfo->pMac;
9895 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9896 tANI_U32 sessionId = pInfo->sessionId;
9897 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009898
9899 if(!pSession)
9900 {
9901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9902 return;
9903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009904
9905 pSession->ibss_join_pending = FALSE;
9906 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9907 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9908 // Send an IBSS stop request to PE
9909 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009910}
Jeff Johnson295189b2012-06-20 16:38:30 -07009911eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9912{
9913 eHalStatus status;
9914 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009915
9916 if(!pSession)
9917 {
9918 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9919 return eHAL_STATUS_FAILURE;
9920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009921
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009922 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309924 status = vos_timer_start(&pSession->hTimerIbssJoining, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07009925
9926 return (status);
9927}
Jeff Johnson295189b2012-06-20 16:38:30 -07009928eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9929{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05309930 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerIbssJoining));
Jeff Johnson295189b2012-06-20 16:38:30 -07009931}
Jeff Johnson295189b2012-06-20 16:38:30 -07009932void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9933 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9934{
9935 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9936 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009937 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9938 /* To silence the KW tool Null chaeck is added */
9939 if(!pSession)
9940 {
9941 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9942 return;
9943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009944
9945 if(pCommand)
9946 {
9947 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9951 {
9952 //if success, force roaming completion
9953 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9954 }
9955 else
9956 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009957 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009958 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9960 }
9961}
9962
Jeff Johnson295189b2012-06-20 16:38:30 -07009963eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9964{
9965 eHalStatus status = eHAL_STATUS_SUCCESS;
9966 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9967 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9968 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9969 tCsrRoamInfo *pRoamInfo = NULL;
9970 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009971 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009973 /* To silence the KW tool Null chaeck is added */
9974 if(!pSession)
9975 {
9976 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9977 return eHAL_STATUS_FAILURE;
9978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009980 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9982 if ( eWNI_SME_DISASSOC_IND == type )
9983 {
9984 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9985 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9986 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009987 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 }
9989 else if ( eWNI_SME_DEAUTH_IND == type )
9990 {
9991 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9992 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9993 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009994 /* Convert into proper reason code */
9995 pSession->joinFailStatusCode.reasonCode =
9996 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309997 0 : pDeauthIndMsg->reasonCode;
9998 /* cfg layer expects 0 as reason code if
9999 the driver dosent know the reason code
10000 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 }
10002 else
10003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010004 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010006 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 }
10008
10009 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 {
10012 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10013 }
10014
10015 if ( eWNI_SME_DISASSOC_IND == type )
10016 {
10017 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10018 }
10019 else if ( eWNI_SME_DEAUTH_IND == type )
10020 {
10021 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10022 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 if(!HAL_STATUS_SUCCESS(status))
10024 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010025 //If fail to send confirmation to PE, not to trigger roaming
10026 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 }
10028
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010029 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070010030 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10031 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10032 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 if( eWNI_SME_DISASSOC_IND == type)
10034 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010035 //staMacAddr
10036 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10037 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 else if( eWNI_SME_DEAUTH_IND == type )
10040 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010041 //staMacAddr
10042 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10043 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10044 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010045 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010046
10047 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10048 that we are roaming. But if we cannot possibly roam, or if we are unable to
10049 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010050 if(fToRoam)
10051 {
10052 //Only remove the connected BSS in infrastructure mode
10053 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10054 //Not to do anying for lostlink with WDS
10055 if( pMac->roam.configParam.nRoamingTime )
10056 {
10057 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10058 ( eWNI_SME_DEAUTH_IND == type ) ?
10059 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10060 {
10061 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10062 //For IBSS, we need to give some more info to HDD
10063 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10064 {
10065 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10066 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10067 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10068 }
10069 else
10070 {
10071 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10072 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010073 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10075 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10076 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10077 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10078 }
10079 else
10080 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010081 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 fToRoam = eANI_BOOLEAN_FALSE;
10083 }
10084 }
10085 else
10086 {
10087 //We are told not to roam, indicate lostlink
10088 fToRoam = eANI_BOOLEAN_FALSE;
10089 }
10090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010091 if(!fToRoam)
10092 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010093 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010094 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010095 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010096 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10097 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10098 * csrRoamCheckForLinkStatusChange API.
10099 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010100 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10101 }
10102
10103 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 Still enable idle scan for polling in case concurrent sessions are running */
10105 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10106 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010107 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 }
10109 }
10110
10111 return (status);
10112}
10113
Jeff Johnson295189b2012-06-20 16:38:30 -070010114eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10115{
10116 eHalStatus status = eHAL_STATUS_SUCCESS;
10117 tListElem *pEntry = NULL;
10118 tSmeCmd *pCommand = NULL;
10119 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010120
10121 if(!pSession)
10122 {
10123 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10124 return eHAL_STATUS_FAILURE;
10125 }
10126
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010128 //Only remove the connected BSS in infrastructure mode
10129 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10130 if(pMac->roam.configParam.nRoamingTime)
10131 {
10132 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10133 {
10134 //before starting the lost link logic release the roam command for handoff
10135 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10136 if(pEntry)
10137 {
10138 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10139 }
10140 if(pCommand)
10141 {
10142 if (( eSmeCommandRoam == pCommand->command ) &&
10143 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10144 {
10145 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10146 {
10147 csrReleaseCommandRoam( pMac, pCommand );
10148 }
10149 }
10150 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010151 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010152 }
10153 }
10154 else
10155 {
10156 //We are told not to roam, indicate lostlink
10157 status = eHAL_STATUS_FAILURE;
10158 }
10159
10160 return (status);
10161}
Jeff Johnson295189b2012-06-20 16:38:30 -070010162void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10163{
10164 tListElem *pEntry;
10165 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10167 if ( pEntry )
10168 {
10169 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10170 if ( eSmeCommandWmStatusChange == pCommand->command )
10171 {
10172 // Nothing to process in a Lost Link completion.... It just kicks off a
10173 // roaming sequence.
10174 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10175 {
10176 csrReleaseCommandWmStatusChange( pMac, pCommand );
10177 }
10178 else
10179 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010180 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 }
10182
10183 }
10184 else
10185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010186 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010187 }
10188 }
10189 else
10190 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010191 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 smeProcessPendingQueue( pMac );
10194}
10195
Jeff Johnson295189b2012-06-20 16:38:30 -070010196void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10197{
10198 eHalStatus status = eHAL_STATUS_FAILURE;
10199 tSirSmeRsp *pSirSmeMsg;
10200 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010201
10202 if(!pSession)
10203 {
10204 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10205 return;
10206 }
10207
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 switch ( pCommand->u.wmStatusChangeCmd.Type )
10209 {
10210 case eCsrDisassociated:
10211 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10212 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10213 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 case eCsrDeauthenticated:
10215 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10216 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10217 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010219 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 break;
10221 }
10222 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10223 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10224 {
10225 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10226 {
10227 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010228 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 }
10230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10232 // command here since there is nothing else to do.
10233 csrRoamWmStatusChangeComplete( pMac );
10234}
10235
Jeff Johnson295189b2012-06-20 16:38:30 -070010236//This function returns band and mode information.
10237//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10238//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010239static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10240 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010241{
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10243 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10244 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010246
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 //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 -070010248 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10249 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10250 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10251 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 {
10253 switch( pMac->roam.configParam.uCfgDot11Mode )
10254 {
10255 case eCSR_CFG_DOT11_MODE_11A:
10256 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10257 eBand = eCSR_BAND_5G;
10258 break;
10259 case eCSR_CFG_DOT11_MODE_11B:
10260 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10261 eBand = eCSR_BAND_24;
10262 break;
10263 case eCSR_CFG_DOT11_MODE_11G:
10264 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10265 eBand = eCSR_BAND_24;
10266 break;
10267 case eCSR_CFG_DOT11_MODE_11N:
10268 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010269 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10270 break;
10271#ifdef WLAN_FEATURE_11AC
10272 case eCSR_CFG_DOT11_MODE_11AC:
10273 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10274 {
10275 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10276 eBand = eCSR_BAND_5G;
10277 }
10278 else
10279 {
10280 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10281 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10282 }
10283 break;
10284 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10285 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10286 {
10287 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10288 eBand = eCSR_BAND_5G;
10289 }
10290 else
10291 {
10292 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10293 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10294 }
10295 break;
10296#endif
10297 case eCSR_CFG_DOT11_MODE_AUTO:
10298 eBand = pMac->roam.configParam.eBand;
10299 if (eCSR_BAND_24 == eBand)
10300 {
10301 // WiFi tests require IBSS networks to start in 11b mode
10302 // without any change to the default parameter settings
10303 // on the adapter. We use ACU to start an IBSS through
10304 // creation of a startIBSS profile. This startIBSS profile
10305 // has Auto MACProtocol and the adapter property setting
10306 // for dot11Mode is also AUTO. So in this case, let's
10307 // start the IBSS network in 11b mode instead of 11g mode.
10308 // So this is for Auto=profile->MacProtocol && Auto=Global.
10309 // dot11Mode && profile->channel is < 14, then start the IBSS
10310 // in b mode.
10311 //
10312 // Note: we used to have this start as an 11g IBSS for best
10313 // performance... now to specify that the user will have to
10314 // set the do11Mode in the property page to 11g to force it.
10315 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10316 }
10317 else
10318 {
10319#ifdef WLAN_FEATURE_11AC
10320 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10321 {
10322 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10323 eBand = eCSR_BAND_5G;
10324 }
10325 else
10326 {
10327 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10328 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10329 }
10330#else
10331 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10332 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10333#endif
10334 }
10335 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010336 default:
10337 // Global dot11 Mode setting is 11a/b/g.
10338 // use the channel number to determine the Mode setting.
10339 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10340 {
10341 eBand = pMac->roam.configParam.eBand;
10342 if(eCSR_BAND_24 == eBand)
10343 {
10344 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10345 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10346 }
10347 else
10348 {
10349 //prefer 5GHz
10350 eBand = eCSR_BAND_5G;
10351 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10352 }
10353 }
10354 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10355 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010356 // WiFi tests require IBSS networks to start in 11b mode
10357 // without any change to the default parameter settings
10358 // on the adapter. We use ACU to start an IBSS through
10359 // creation of a startIBSS profile. This startIBSS profile
10360 // has Auto MACProtocol and the adapter property setting
10361 // for dot11Mode is also AUTO. So in this case, let's
10362 // start the IBSS network in 11b mode instead of 11g mode.
10363 // So this is for Auto=profile->MacProtocol && Auto=Global.
10364 // dot11Mode && profile->channel is < 14, then start the IBSS
10365 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010367 // Note: we used to have this start as an 11g IBSS for best
10368 // performance... now to specify that the user will have to
10369 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10371 eBand = eCSR_BAND_24;
10372 }
10373 else
10374 {
10375 // else, it's a 5.0GHz channel. Set mode to 11a.
10376 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10377 eBand = eCSR_BAND_5G;
10378 }
10379 break;
10380 }//switch
10381 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10382 else
10383 {
10384 //dot11 mode is set, lets pick the band
10385 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10386 {
10387 // channel is Auto also.
10388 eBand = pMac->roam.configParam.eBand;
10389 if(eCSR_BAND_ALL == eBand)
10390 {
10391 //prefer 5GHz
10392 eBand = eCSR_BAND_5G;
10393 }
10394 }
10395 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10396 {
10397 eBand = eCSR_BAND_24;
10398 }
10399 else
10400 {
10401 eBand = eCSR_BAND_5G;
10402 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 if(pBand)
10405 {
10406 *pBand = eBand;
10407 }
10408
10409 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010410 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10412 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010413
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010414 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10415 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 -070010416 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010417#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010418 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010419#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010420 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10421 {
10422 //We cannot do 11n here
10423 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10424 {
10425 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10426 }
10427 else
10428 {
10429 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10430 }
10431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 return( cfgDot11Mode );
10433}
10434
Jeff Johnson295189b2012-06-20 16:38:30 -070010435eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10436{
10437 eHalStatus status;
10438 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010439
10440 if(!pSession)
10441 {
10442 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10443 return eHAL_STATUS_FAILURE;
10444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010445
10446#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10447 {
10448 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10450 if(pIbssLog)
10451 {
10452 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10453 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10454 }
10455 }
10456#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 pSession->ibss_join_pending = FALSE;
10458 csrRoamStopIbssJoinTimer(pMac, sessionId );
10459 // Set the roaming substate to 'stop Bss request'...
10460 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10461
10462 // attempt to stop the Bss (reason code is ignored...)
10463 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010464 if(!HAL_STATUS_SUCCESS(status))
10465 {
10466 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10467 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 return (status);
10469}
10470
Jeff Johnson295189b2012-06-20 16:38:30 -070010471//pNumChan is a caller allocated space with the sizeof pChannels
10472eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10473{
10474
10475 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10476 (tANI_U8 *)pChannels,
10477 pNumChan));
10478}
10479
Kiran4a17ebe2013-01-31 10:43:43 -080010480tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10481{
10482 tANI_U32 cfgLength = 0;
10483 tANI_U16 cfgId = 0;
10484 tPowerdBm maxTxPwr = 0;
10485 tANI_U8 *pCountryInfo = NULL;
10486 eHalStatus status;
10487 tANI_U8 count = 0;
10488 tANI_U8 firstChannel;
10489 tANI_U8 maxChannels;
10490
10491 if (CSR_IS_CHANNEL_5GHZ(channel))
10492 {
10493 cfgId = WNI_CFG_MAX_TX_POWER_5;
10494 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10495 }
10496 else if (CSR_IS_CHANNEL_24GHZ(channel))
10497 {
10498 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10499 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10500 }
10501 else
10502 return maxTxPwr;
10503
10504 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10505 if (status != eHAL_STATUS_SUCCESS)
10506 {
10507 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10508 FL("%s: palAllocateMemory() failed, status = %d"),
10509 __FUNCTION__, status);
10510 goto error;
10511 }
10512 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10513 if (status != eHAL_STATUS_SUCCESS)
10514 {
10515 goto error;
10516 }
10517 /* Identify the channel and maxtxpower */
10518 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10519 {
10520 firstChannel = pCountryInfo[count++];
10521 maxChannels = pCountryInfo[count++];
10522 maxTxPwr = pCountryInfo[count++];
10523
10524 if ((channel >= firstChannel) &&
10525 (channel < (firstChannel + maxChannels)))
10526 {
10527 break;
10528 }
10529 }
10530
10531error:
10532 if (NULL != pCountryInfo)
10533 palFreeMemory(pMac->hHdd, pCountryInfo);
10534
10535 return maxTxPwr;
10536}
10537
10538
Jeff Johnson295189b2012-06-20 16:38:30 -070010539tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10540{
10541 tANI_BOOLEAN fValid = FALSE;
10542 tANI_U32 idxValidChannels;
10543 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10544
10545 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10546 {
10547 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10548 {
10549 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10550 {
10551 fValid = TRUE;
10552 break;
10553 }
10554 }
10555 }
10556 pMac->roam.numValidChannels = len;
10557 return fValid;
10558}
10559
Jeff Johnson295189b2012-06-20 16:38:30 -070010560tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10561{
10562 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10563 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10565 {
10566 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10567 {
10568 fValid = eANI_BOOLEAN_TRUE;
10569 break;
10570 }
10571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 return (fValid);
10573}
10574
Jeff Johnson295189b2012-06-20 16:38:30 -070010575//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010576 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010577{
Jeff Johnsone7245742012-09-05 17:12:55 -070010578 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010579 tANI_U8 centerChn;
10580 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10582 {
10583 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10584 }
10585 else
10586 {
10587 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10588 }
10589 //Figure what the other side's CB mode
10590 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10591 {
10592 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10593 {
10594 if(pIes->HTInfo.present)
10595 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010596 /* This is called during INFRA STA/CLIENT and should use the merged value of
10597 * supported channel width and recommended tx width as per standard
10598 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010599 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010600 pIes->HTCaps.supportedChannelWidthSet,
10601 pIes->HTInfo.recommendedTxWidthSet,
10602 pIes->HTInfo.secondaryChannelOffset);
10603
10604 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10605 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010606 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010607 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10608 switch (eRet) {
10609 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10610 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10611 break;
10612 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10613 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10614 break;
10615 case PHY_SINGLE_CHANNEL_CENTERED:
10616 default:
10617 centerChn = primaryChn;
10618 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010620 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010622 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010623 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 }
10625 }
10626 }
10627 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 return eRet;
10629}
Jeff Johnson295189b2012-06-20 16:38:30 -070010630tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10631{
10632 tANI_BOOLEAN fFound = FALSE;
10633 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10635 {
10636 if( pCipherList->encryptionType[idx] == encryptionType )
10637 {
10638 fFound = TRUE;
10639 break;
10640 }
10641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010642 return fFound;
10643}
Jeff Johnson295189b2012-06-20 16:38:30 -070010644tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10645{
10646 tANI_BOOLEAN fFound = FALSE;
10647 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010648 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10649 {
10650 if( pAuthList->authType[idx] == authType )
10651 {
10652 fFound = TRUE;
10653 break;
10654 }
10655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 return fFound;
10657}
Jeff Johnson295189b2012-06-20 16:38:30 -070010658tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10659{
10660 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10661 tCsrScanResultFilter *pScanFilter = NULL;
10662 eHalStatus status = eHAL_STATUS_SUCCESS;
10663
10664 if(pProfile1 && pProfile2)
10665 {
10666 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10667 if(HAL_STATUS_SUCCESS(status))
10668 {
10669 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10670 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10671 if(HAL_STATUS_SUCCESS(status))
10672 {
10673 fCheck = eANI_BOOLEAN_FALSE;
10674 do
10675 {
10676 tANI_U32 i;
10677 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10678 {
10679 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10680 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10681 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10682 if ( fCheck ) break;
10683 }
10684 if(!fCheck)
10685 {
10686 break;
10687 }
10688 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10689 || pProfile2->BSSType != pProfile1->BSSType
10690 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10691 )
10692 {
10693 fCheck = eANI_BOOLEAN_FALSE;
10694 break;
10695 }
10696#ifdef WLAN_FEATURE_VOWIFI_11R
10697 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10698 {
10699 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10700 {
10701 fCheck = eANI_BOOLEAN_FALSE;
10702 break;
10703 }
10704 }
10705#endif
10706 //Match found
10707 fCheck = eANI_BOOLEAN_TRUE;
10708 }while(0);
10709 csrFreeScanFilter(pMac, pScanFilter);
10710 }
10711 palFreeMemory(pMac->hHdd, pScanFilter);
10712 }
10713 }
10714
10715 return (fCheck);
10716}
10717
Jeff Johnson295189b2012-06-20 16:38:30 -070010718tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10719{
10720 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10721 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 do
10723 {
10724 //Only check for static WEP
10725 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10726 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10727 {
10728 fCheck = eANI_BOOLEAN_TRUE;
10729 break;
10730 }
10731 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10732 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10733 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10734 {
10735 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10736 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10737 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10738 {
10739 break;
10740 }
10741 }
10742 if( i == CSR_MAX_NUM_KEY)
10743 {
10744 fCheck = eANI_BOOLEAN_TRUE;
10745 }
10746 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010747 return (fCheck);
10748}
10749
Jeff Johnson295189b2012-06-20 16:38:30 -070010750//IBSS
10751
Jeff Johnson295189b2012-06-20 16:38:30 -070010752tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10753{
10754 tANI_U8 channel = 0;
10755 tANI_U32 idx;
10756 tANI_U32 idxValidChannels;
10757 tANI_BOOLEAN fFound = FALSE;
10758 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10759
10760 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10761 {
10762 channel = pMac->roam.configParam.AdHocChannel5G;
10763 if(!csrRoamIsChannelValid(pMac, channel))
10764 {
10765 channel = 0;
10766 }
10767 }
10768 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10769 {
10770 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10771 {
10772 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10773 {
10774 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10775 {
10776 fFound = TRUE;
10777 channel = csrStartIbssChannels50[ idx ];
10778 }
10779 }
10780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10782 if (!fFound)
10783 {
10784 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10785 {
10786 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10787 {
10788 channel = csrStartIbssChannels50[ idx ];
10789 break;
10790 }
10791 }
10792 }
10793 }//if
10794
10795 return( channel );
10796}
10797
Jeff Johnson295189b2012-06-20 16:38:30 -070010798tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10799{
10800 tANI_U8 channel = 1;
10801 tANI_U32 idx;
10802 tANI_U32 idxValidChannels;
10803 tANI_BOOLEAN fFound = FALSE;
10804 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10805
10806 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10807 {
10808 channel = pMac->roam.configParam.AdHocChannel24;
10809 if(!csrRoamIsChannelValid(pMac, channel))
10810 {
10811 channel = 0;
10812 }
10813 }
10814
10815 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10816 {
10817 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10818 {
10819 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10820 {
10821 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10822 {
10823 fFound = TRUE;
10824 channel = csrStartIbssChannels24[ idx ];
10825 }
10826 }
10827 }
10828 }
10829
10830 return( channel );
10831}
10832
Jeff Johnson295189b2012-06-20 16:38:30 -070010833static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10834 tCsrRoamStartBssParams *pParam )
10835{
10836 eCsrCfgDot11Mode cfgDot11Mode;
10837 eCsrBand eBand;
10838 tANI_U8 channel = 0;
10839 tSirNwType nwType;
10840 tANI_U8 operationChannel = 0;
10841
10842 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10843 {
10844 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10845 }
10846
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010848
Jeff Johnson295189b2012-06-20 16:38:30 -070010849 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10850 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10851 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10852 )
10853 {
10854 /* This should never happen */
10855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010856 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 pProfile->csrPersona);
10858 VOS_ASSERT(0);
10859 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 switch( cfgDot11Mode )
10861 {
10862 case eCSR_CFG_DOT11_MODE_11G:
10863 nwType = eSIR_11G_NW_TYPE;
10864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 case eCSR_CFG_DOT11_MODE_11B:
10866 nwType = eSIR_11B_NW_TYPE;
10867 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 case eCSR_CFG_DOT11_MODE_11A:
10869 nwType = eSIR_11A_NW_TYPE;
10870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 default:
10872 case eCSR_CFG_DOT11_MODE_11N:
10873 case eCSR_CFG_DOT11_MODE_TAURUS:
10874 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10875 if(eCSR_BAND_24 == eBand)
10876 {
10877 nwType = eSIR_11G_NW_TYPE;
10878 }
10879 else
10880 {
10881 nwType = eSIR_11A_NW_TYPE;
10882 }
10883 break;
10884 }
10885
10886 pParam->extendedRateSet.numRates = 0;
10887
10888 switch ( nwType )
10889 {
10890 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010891 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 case eSIR_11A_NW_TYPE:
10893
10894 pParam->operationalRateSet.numRates = 8;
10895
10896 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10897 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10898 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10899 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10900 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10901 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10902 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10903 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10904
10905 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10906 {
10907 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10908 if( 0 == channel &&
10909 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10910 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10911 )
10912 {
10913 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10914 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10915 nwType = eSIR_11B_NW_TYPE;
10916 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10917 pParam->operationalRateSet.numRates = 4;
10918 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10919 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10920 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10921 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10922 }
10923 }
10924 else
10925 {
10926 channel = operationChannel;
10927 }
10928 break;
10929
10930 case eSIR_11B_NW_TYPE:
10931 pParam->operationalRateSet.numRates = 4;
10932 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10933 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10934 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10935 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010936 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10937 {
10938 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10939 }
10940 else
10941 {
10942 channel = operationChannel;
10943 }
10944
10945 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010947 /* For P2P Client and P2P GO, disable 11b rates */
10948 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10949 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10950 )
10951 {
10952 pParam->operationalRateSet.numRates = 8;
10953
10954 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10955 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10956 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10957 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10958 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10959 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10960 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10961 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10962 }
10963 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 {
10965 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10967 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10968 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10969 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10970
10971 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10973 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10974 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10975 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10976 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10977 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10978 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10979 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10980 }
10981
10982 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10983 {
10984 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10985 }
10986 else
10987 {
10988 channel = operationChannel;
10989 }
10990
10991 break;
10992 }
10993 pParam->operationChn = channel;
10994 pParam->sirNwType = nwType;
10995}
10996
Jeff Johnson295189b2012-06-20 16:38:30 -070010997static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10998 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10999{
11000
11001 if( pParam )
11002 {
11003 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011004 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011005 pParam->operationChn = pBssDesc->channelId;
11006 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
11007
11008 if( pIes )
11009 {
11010 if(pIes->SuppRates.present)
11011 {
11012 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11013 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011015 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 -070011016 pIes->SuppRates.num_rates);
11017 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11018 }
11019 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11020 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
11021 }
11022 if( pIes->SSID.present )
11023 {
11024 pParam->ssId.length = pIes->SSID.num_ssid;
11025 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
11026 }
11027 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011028 }
11029 else
11030 {
11031 pParam->ssId.length = 0;
11032 pParam->operationalRateSet.numRates = 0;
11033 }
11034 }
11035}
11036
Jeff Johnson295189b2012-06-20 16:38:30 -070011037static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11038{
11039 tANI_U8 MaxRate = 0;
11040 tANI_U32 i;
11041 tANI_U8 *pRate;
11042
11043 pRate = pSirRateSet->rate;
11044 for ( i = 0; i < pSirRateSet->numRates; i++ )
11045 {
11046 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11047 }
11048
11049 // Save the max rate in the connected state information...
11050
11051 // modify LastRates variable as well
11052
11053 return;
11054}
11055
Jeff Johnson295189b2012-06-20 16:38:30 -070011056eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11057 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11058{
11059 eHalStatus status = eHAL_STATUS_SUCCESS;
11060 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011061 // Set the roaming substate to 'Start BSS attempt'...
11062 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011063#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11064 //Need to figure out whether we need to log WDS???
11065 if( CSR_IS_IBSS( pProfile ) )
11066 {
11067 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11069 if(pIbssLog)
11070 {
11071 if(pBssDesc)
11072 {
11073 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
11074 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
11075 }
11076 else
11077 {
11078 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11079 }
11080 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11081 pParam->ssId.length);
11082 if(pProfile->ChannelInfo.numOfChannels == 0)
11083 {
11084 pIbssLog->channelSetting = AUTO_PICK;
11085 }
11086 else
11087 {
11088 pIbssLog->channelSetting = SPECIFIED;
11089 }
11090 pIbssLog->operatingChannel = pParam->operationChn;
11091 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11092 }
11093 }
11094#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11095 //Put RSN information in for Starting BSS
11096 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11097 pParam->pRSNIE = pProfile->pRSNReqIE;
11098
Jeff Johnson295189b2012-06-20 16:38:30 -070011099 pParam->privacy = pProfile->privacy;
11100 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11101 pParam->authType = pProfile->csr80211AuthType;
11102 pParam->beaconInterval = pProfile->beaconInterval;
11103 pParam->dtimPeriod = pProfile->dtimPeriod;
11104 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11105 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11106 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11107 {
11108 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11109 {
11110 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11111 }
11112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 pParam->protEnabled = pProfile->protEnabled;
11114 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11115 pParam->ht_protection = pProfile->cfg_protection;
11116 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011117
Jeff Johnson295189b2012-06-20 16:38:30 -070011118 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11119 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011120 pParam->bssPersona = pProfile->csrPersona;
11121 // When starting an IBSS, start on the channel from the Profile.
11122 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 return (status);
11124}
11125
Jeff Johnson295189b2012-06-20 16:38:30 -070011126static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011127 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011128{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011129 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011130 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011132
11133 if(!pSession)
11134 {
11135 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11136 return;
11137 }
11138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 if( pBssDesc )
11140 {
11141 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11142 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11143 //The following code has to be do after that.
11144 //For WDS station, use selfMac as the self BSSID
11145 if( CSR_IS_WDS_STA( pProfile ) )
11146 {
11147 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11148 }
11149 }
11150 else
11151 {
11152 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 //Use the first SSID
11154 if(pProfile->SSIDs.numOfSSIDs)
11155 {
11156 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11157 }
11158 //For WDS station, use selfMac as the self BSSID
11159 if( CSR_IS_WDS_STA( pProfile ) )
11160 {
11161 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11162 }
11163 //Use the first BSSID
11164 else if( pProfile->BSSIDs.numOfBSSIDs )
11165 {
11166 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11167 }
11168 else
11169 {
11170 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11171 }
11172 }
11173 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 //Set operating channel in pProfile which will be used
11175 //in csrRoamSetBssConfigCfg() to determine channel bonding
11176 //mode and will be configured in CFG later
11177 pProfile->operationChannel = Channel;
11178
11179 if(Channel == 0)
11180 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011181 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011182 }
11183 else
11184 {
11185
11186 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011187 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011188 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011189 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011190 {
11191 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11192 }
11193 else
11194 {
11195 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11196 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011197 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011198 pBssConfig->cbMode = cbMode;
11199 pSession->bssParams.cbMode = cbMode;
11200 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011201 }
11202}
11203
Jeff Johnson295189b2012-06-20 16:38:30 -070011204static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11205 tANI_BOOLEAN *pfSameIbss )
11206{
11207 eHalStatus status = eHAL_STATUS_SUCCESS;
11208 tANI_BOOLEAN fSameIbss = FALSE;
11209
11210 if ( csrIsConnStateIbss( pMac, sessionId ) )
11211 {
11212 // Check if any profile parameter has changed ? If any profile parameter
11213 // has changed then stop old BSS and start a new one with new parameters
11214 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11215 {
11216 fSameIbss = TRUE;
11217 }
11218 else
11219 {
11220 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11221 }
11222 }
11223 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11224 {
11225 // Disassociate from the connected Infrastructure network...
11226 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11227 }
11228 else
11229 {
11230 tBssConfigParam *pBssConfig;
11231
11232 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11233 if(HAL_STATUS_SUCCESS(status))
11234 {
11235 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11236 // there is no Bss description before we start an IBSS so we need to adopt
11237 // all Bss configuration parameters from the Profile.
11238 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11239 if(HAL_STATUS_SUCCESS(status))
11240 {
11241 //save dotMode
11242 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11243 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011244 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011245 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11246 NULL, pBssConfig,
11247 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 palFreeMemory(pMac->hHdd, pBssConfig);
11250 }//Allocate memory
11251 }
11252
11253 if(pfSameIbss)
11254 {
11255 *pfSameIbss = fSameIbss;
11256 }
11257 return( status );
11258}
11259
Jeff Johnson295189b2012-06-20 16:38:30 -070011260static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11261 tSirSmeNewBssInfo *pNewBss )
11262{
11263 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011264
11265 if(!pSession)
11266 {
11267 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11268 return;
11269 }
11270
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 if( pNewBss )
11272 {
11273 // Set the operating channel.
11274 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11275 // move the BSSId from the BSS description into the connected state information.
11276 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11277 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 return;
11280}
11281
Jeff Johnson295189b2012-06-20 16:38:30 -070011282#ifdef FEATURE_WLAN_WAPI
11283eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11284 tANI_U32 numItems )
11285{
11286 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11287 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011288 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011290 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011291 return status;
11292 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011293 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 pSession = CSR_GET_SESSION( pMac, sessionId );
11295 if(numItems <= CSR_MAX_BKID_ALLOWED)
11296 {
11297 status = eHAL_STATUS_SUCCESS;
11298 //numItems may be 0 to clear the cache
11299 pSession->NumBkidCache = (tANI_U16)numItems;
11300 if(numItems && pBKIDCache)
11301 {
11302 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11303 sizeof(tBkidCacheInfo) * numItems );
11304 }
11305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 return (status);
11307}
Jeff Johnson295189b2012-06-20 16:38:30 -070011308eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11309 tBkidCacheInfo *pBkidCache)
11310{
11311 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11312 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011315 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011316 return status;
11317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 pSession = CSR_GET_SESSION( pMac, sessionId );
11319 if(pNum && pBkidCache)
11320 {
11321 if(pSession->NumBkidCache == 0)
11322 {
11323 *pNum = 0;
11324 status = eHAL_STATUS_SUCCESS;
11325 }
11326 else if(*pNum >= pSession->NumBkidCache)
11327 {
11328 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011330 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 -070011331 pSession->NumBkidCache);
11332 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11333 }
11334 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11335 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11336 *pNum = pSession->NumBkidCache;
11337 status = eHAL_STATUS_SUCCESS;
11338 }
11339 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011341}
Jeff Johnson295189b2012-06-20 16:38:30 -070011342tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11343{
11344 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011345}
11346#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011347eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11348 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11349{
11350 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11351 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011352
11353 if(!pSession)
11354 {
11355 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11356 return eHAL_STATUS_FAILURE;
11357 }
11358
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011359 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11361 {
11362#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11363 {
11364 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11365 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11366 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11367 secEvent.encryptionModeMulticast =
11368 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11369 secEvent.encryptionModeUnicast =
11370 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11371 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11372 secEvent.authMode =
11373 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11374 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11375 }
11376#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 status = eHAL_STATUS_SUCCESS;
11378 //numItems may be 0 to clear the cache
11379 pSession->NumPmkidCache = (tANI_U16)numItems;
11380 if(numItems && pPMKIDCache)
11381 {
11382 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11383 sizeof(tPmkidCacheInfo) * numItems );
11384 }
11385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 return (status);
11387}
11388
Jeff Johnson295189b2012-06-20 16:38:30 -070011389tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11390{
11391 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11392}
11393
Jeff Johnson295189b2012-06-20 16:38:30 -070011394eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11395{
11396 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11397 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011398
11399 if(!pSession)
11400 {
11401 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11402 return eHAL_STATUS_FAILURE;
11403 }
11404
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 if(pNum && pPmkidCache)
11406 {
11407 if(pSession->NumPmkidCache == 0)
11408 {
11409 *pNum = 0;
11410 status = eHAL_STATUS_SUCCESS;
11411 }
11412 else if(*pNum >= pSession->NumPmkidCache)
11413 {
11414 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011416 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 -070011417 pSession->NumPmkidCache);
11418 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11419 }
11420 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11421 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11422 *pNum = pSession->NumPmkidCache;
11423 status = eHAL_STATUS_SUCCESS;
11424 }
11425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 return (status);
11427}
11428
Jeff Johnson295189b2012-06-20 16:38:30 -070011429eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11430{
11431 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11432 tANI_U32 len;
11433 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011434
11435 if(!pSession)
11436 {
11437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11438 return eHAL_STATUS_FAILURE;
11439 }
11440
Jeff Johnson295189b2012-06-20 16:38:30 -070011441 if(pLen)
11442 {
11443 len = *pLen;
11444 *pLen = pSession->nWpaRsnReqIeLength;
11445 if(pBuf)
11446 {
11447 if(len >= pSession->nWpaRsnReqIeLength)
11448 {
11449 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11450 }
11451 }
11452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 return (status);
11454}
11455
Jeff Johnson295189b2012-06-20 16:38:30 -070011456eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11457{
11458 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11459 tANI_U32 len;
11460 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011461
11462 if(!pSession)
11463 {
11464 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11465 return eHAL_STATUS_FAILURE;
11466 }
11467
Jeff Johnson295189b2012-06-20 16:38:30 -070011468 if(pLen)
11469 {
11470 len = *pLen;
11471 *pLen = pSession->nWpaRsnRspIeLength;
11472 if(pBuf)
11473 {
11474 if(len >= pSession->nWpaRsnRspIeLength)
11475 {
11476 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11477 }
11478 }
11479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 return (status);
11481}
Jeff Johnson295189b2012-06-20 16:38:30 -070011482#ifdef FEATURE_WLAN_WAPI
11483eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11484{
11485 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11486 tANI_U32 len;
11487 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011488
11489 if(!pSession)
11490 {
11491 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11492 return eHAL_STATUS_FAILURE;
11493 }
11494
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 if(pLen)
11496 {
11497 len = *pLen;
11498 *pLen = pSession->nWapiReqIeLength;
11499 if(pBuf)
11500 {
11501 if(len >= pSession->nWapiReqIeLength)
11502 {
11503 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11504 }
11505 }
11506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 return (status);
11508}
Jeff Johnson295189b2012-06-20 16:38:30 -070011509eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11510{
11511 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11512 tANI_U32 len;
11513 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011514
11515 if(!pSession)
11516 {
11517 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11518 return eHAL_STATUS_FAILURE;
11519 }
11520
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 if(pLen)
11522 {
11523 len = *pLen;
11524 *pLen = pSession->nWapiRspIeLength;
11525 if(pBuf)
11526 {
11527 if(len >= pSession->nWapiRspIeLength)
11528 {
11529 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11530 }
11531 }
11532 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 return (status);
11534}
11535#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011536eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11537{
11538 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11539 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011540
11541 if(!pSession)
11542 {
11543 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11544 return (retStatus);
11545 }
11546
Jeff Johnson295189b2012-06-20 16:38:30 -070011547 if(CSR_IS_ROAMING(pSession))
11548 {
11549 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11550 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11551 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 return (retStatus);
11553}
11554
Jeff Johnson295189b2012-06-20 16:38:30 -070011555//This function remove the connected BSS from te cached scan result
11556eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11557 tCsrRoamConnectedProfile *pConnProfile)
11558{
11559 eHalStatus status = eHAL_STATUS_FAILURE;
11560 tCsrScanResultFilter *pScanFilter = NULL;
11561 tListElem *pEntry;
11562 tCsrScanResult *pResult;
11563 tDot11fBeaconIEs *pIes;
11564 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11566 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11567 {
11568 do
11569 {
11570 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11571 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11572 if(!HAL_STATUS_SUCCESS(status)) break;
11573 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11574 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11575 if(!HAL_STATUS_SUCCESS(status)) break;
11576 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11577 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11578 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11579 {
11580 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11581 if(!HAL_STATUS_SUCCESS(status)) break;
11582 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11583 }
11584 pScanFilter->authType.numEntries = 1;
11585 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11586 pScanFilter->BSSType = pConnProfile->BSSType;
11587 pScanFilter->EncryptionType.numEntries = 1;
11588 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11589 pScanFilter->mcEncryptionType.numEntries = 1;
11590 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11591 //We ignore the channel for now, BSSID should be enough
11592 pScanFilter->ChannelInfo.numOfChannels = 0;
11593 //Also ignore the following fields
11594 pScanFilter->uapsd_mask = 0;
11595 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11596 pScanFilter->countryCode[0] = 0;
11597 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 csrLLLock(&pMac->scan.scanResultList);
11599 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11600 while( pEntry )
11601 {
11602 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11603 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11604 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11605 pScanFilter, NULL, NULL, NULL, &pIes);
11606 //Release the IEs allocated by csrMatchBSS is needed
11607 if( !pResult->Result.pvIes )
11608 {
11609 //need to free the IEs since it is allocated by csrMatchBSS
11610 palFreeMemory(pMac->hHdd, pIes);
11611 }
11612 if(fMatch)
11613 {
11614 //We found the one
11615 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11616 {
11617 //Free the memory
11618 csrFreeScanResultEntry( pMac, pResult );
11619 }
11620 break;
11621 }
11622 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11623 }//while
11624 csrLLUnlock(&pMac->scan.scanResultList);
11625 }while(0);
11626 if(pScanFilter)
11627 {
11628 csrFreeScanFilter(pMac, pScanFilter);
11629 palFreeMemory(pMac->hHdd, pScanFilter);
11630 }
11631 }
11632 return (status);
11633}
11634
Jeff Johnson295189b2012-06-20 16:38:30 -070011635//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011636eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11637{
11638 eHalStatus status = eHAL_STATUS_SUCCESS;
11639 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011640 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11641 {
11642 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11643 {
11644 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11645 {
11646 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011647 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011648 status = eHAL_STATUS_CSR_WRONG_STATE;
11649 break;
11650 }
11651 if( csrIsConnStateInfra( pMac, sessionId ) )
11652 {
11653 if( chnId &&
11654 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011656 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11658 status = eHAL_STATUS_CSR_WRONG_STATE;
11659 break;
11660 }
11661 }
11662 }
11663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 return ( status );
11665}
11666
Jeff Johnson295189b2012-06-20 16:38:30 -070011667static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11668{
11669 eHalStatus status = eHAL_STATUS_SUCCESS;
11670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11671 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011672
11673 if(!pSession)
11674 {
11675 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11676 return eHAL_STATUS_FAILURE;
11677 }
11678
Jeff Johnson295189b2012-06-20 16:38:30 -070011679 if ( csrIsConnStateIbss( pMac, sessionId ) )
11680 {
11681 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11682 }
11683 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11684 {
11685 // Disassociate from the connected Infrastructure network...
11686 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11687 }
11688 else
11689 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11691 //Otherwise we need to add code to handle the
11692 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11693 //send stop_bss to PE, before we can continue.
11694 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11696 /* Assume HDD provide bssid in profile */
11697 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11698 // there is no Bss description before we start an WDS so we need
11699 // to adopt all Bss configuration parameters from the Profile.
11700 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11701 if(HAL_STATUS_SUCCESS(status))
11702 {
11703 //Save profile for late use
11704 csrFreeRoamProfile( pMac, sessionId );
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011705 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 (void **)&pSession->pCurRoamProfile,
11707 sizeof(tCsrRoamProfile))))
11708 {
11709 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11710 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11711 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011713 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011714 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11715 NULL, &bssConfig,
11716 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011717 }
11718 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011719
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 return( status );
11721}
11722
Jeff Johnson295189b2012-06-20 16:38:30 -070011723////////////////////Mail box
11724
Jeff Johnson295189b2012-06-20 16:38:30 -070011725//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11726//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011727static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11728 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070011729 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11730{
11731 tCsrChannelSet channelGroup;
11732 tSirMacCapabilityInfo *pAP_capabilityInfo;
11733 tAniBool fTmp;
11734 tANI_BOOLEAN found = FALSE;
11735 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011736 tANI_S8 pwrLimit = 0;
11737 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11739 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11740 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11741 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 // 802.11h
11743 //We can do this because it is in HOST CPU order for now.
11744 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011745 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11746 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11747 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 fTmp = (tAniBool)pal_cpu_to_be32(1);
11749 }
11750 else
11751 fTmp = (tAniBool)0;
11752
11753 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11754 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11755 pBuf += sizeof(tAniBool);
11756 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011757 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 // This is required for 11k test VoWiFi Ent: Test 2.
11759 // We need the power capabilities for Assoc Req.
11760 // This macro is provided by the halPhyCfg.h. We pick our
11761 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011762 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11763 if (0 != pwrLimit)
11764 {
11765 *pBuf++ = pwrLimit;
11766 }
11767 else
11768 {
11769 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 size = sizeof(pMac->roam.validChannelList);
11772 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11773 {
11774 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11775 for ( i = 0; i < size; i++)
11776 {
11777 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11778
11779 }
11780 }
11781 else
11782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011783 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 *pBuf++ = 0; //tSirSupChnl->numChnl
11785 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 //Check whether it is ok to enter UAPSD
11787#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11788 if( btcIsReadyForUapsd(pMac) )
11789#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11790 {
11791 *pBuf++ = uapsdMask;
11792 }
11793#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11794 else
11795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011796 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 *pBuf++ = 0;
11798 }
11799#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11800
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 // move the entire BssDescription into the join request.
11802 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11803 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11805}
11806
Jeff Johnson295189b2012-06-20 16:38:30 -070011807/*
11808 * The communication between HDD and LIM is thru mailbox (MB).
11809 * Both sides will access the data structure "tSirSmeJoinReq".
11810 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11811 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11812 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11813 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11814 */
11815eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011816 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011817{
11818 eHalStatus status = eHAL_STATUS_SUCCESS;
11819 tSirSmeJoinReq *pMsg;
11820 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011821 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 tANI_U16 msgLen, wTmp, ieLen;
11823 tSirMacRateSet OpRateSet;
11824 tSirMacRateSet ExRateSet;
11825 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11826 tANI_U32 dwTmp;
11827 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011828 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011829
11830 if(!pSession)
11831 {
11832 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11833 return eHAL_STATUS_FAILURE;
11834 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011835 /* To satisfy klockworks */
11836 if (NULL == pBssDescription)
11837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011838 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011839 return eHAL_STATUS_FAILURE;
11840 }
11841
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 do {
11843 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11844 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011845 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011846 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11847 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11848 // IE fields, but the length field in the bssDescription needs to be interpreted to
11849 // determine length of the IE fields.
11850 //
11851 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11852 // add in the length from the bssDescription (then add the size of the 'length' field
11853 // itself because that is NOT included in the length field).
11854 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11855 pBssDescription->length + sizeof( pBssDescription->length ) +
11856 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 -070011857 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11858 if ( !HAL_STATUS_SUCCESS(status) ) break;
11859 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011860 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 pMsg->length = pal_cpu_to_be16(msgLen);
11862 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 // sessionId
11864 *pBuf = (tANI_U8)sessionId;
11865 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011866 // transactionId
11867 *pBuf = 0;
11868 *( pBuf + 1 ) = 0;
11869 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011870 // ssId
11871 if( pIes->SSID.present && pIes->SSID.num_ssid )
11872 {
11873 // ssId len
11874 *pBuf = pIes->SSID.num_ssid;
11875 pBuf++;
11876 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11877 pBuf += pIes->SSID.num_ssid;
11878 }
11879 else
11880 {
11881 *pBuf = 0;
11882 pBuf++;
11883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011884 // selfMacAddr
11885 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11886 pBuf += sizeof(tSirMacAddr);
11887 // bsstype
11888 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11889 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11890 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11891 pBuf += sizeof(tSirBssType);
11892 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011893 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11894 if (pBssDescription->channelId <= 14 &&
11895 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11896 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11897 {
11898 //Need to disable VHT operation in 2.4 GHz band
11899 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11900 }
11901 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 //Persona
11904 *pBuf = (tANI_U8)pProfile->csrPersona;
11905 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011906 //CBMode
11907 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11908 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011909
11910 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011911 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11912
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 // uapsdPerAcBitmask
11914 *pBuf = pProfile->uapsd_mask;
11915 pBuf++;
11916
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011917
11918
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011920 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 {
11922 // OperationalRateSet
11923 if (OpRateSet.numRates) {
11924 *pBuf++ = OpRateSet.numRates;
11925 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11926 pBuf += OpRateSet.numRates;
11927 } else *pBuf++ = 0;
11928 // ExtendedRateSet
11929 if (ExRateSet.numRates) {
11930 *pBuf++ = ExRateSet.numRates;
11931 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11932 pBuf += ExRateSet.numRates;
11933 } else *pBuf++ = 0;
11934 }
11935 else
11936 {
11937 *pBuf++ = 0;
11938 *pBuf++ = 0;
11939 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 // rsnIE
11941 if ( csrIsProfileWpa( pProfile ) )
11942 {
11943 // Insert the Wpa IE into the join request
11944 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11945 (tCsrWpaIe *)( wpaRsnIE ) );
11946 }
11947 else if( csrIsProfileRSN( pProfile ) )
11948 {
11949 // Insert the RSN IE into the join request
11950 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11951 (tCsrRSNIe *)( wpaRsnIE ) );
11952 }
11953#ifdef FEATURE_WLAN_WAPI
11954 else if( csrIsProfileWapi( pProfile ) )
11955 {
11956 // Insert the WAPI IE into the join request
11957 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11958 (tCsrWapiIe *)( wpaRsnIE ) );
11959 }
11960#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011961 else
11962 {
11963 ieLen = 0;
11964 }
11965 //remember the IE for future use
11966 if( ieLen )
11967 {
11968 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11969 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011970 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 -070011971 ieLen = DOT11F_IE_RSN_MAX_LEN;
11972 }
11973#ifdef FEATURE_WLAN_WAPI
11974 if( csrIsProfileWapi( pProfile ) )
11975 {
11976 //Check whether we need to allocate more memory
11977 if(ieLen > pSession->nWapiReqIeLength)
11978 {
11979 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11980 {
11981 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11982 }
11983 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11984 if(!HAL_STATUS_SUCCESS(status)) break;
11985 }
11986 pSession->nWapiReqIeLength = ieLen;
11987 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11988 wTmp = pal_cpu_to_be16( ieLen );
11989 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11990 pBuf += sizeof(tANI_U16);
11991 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11992 pBuf += ieLen;
11993 }
11994 else//should be WPA/WPA2 otherwise
11995#endif /* FEATURE_WLAN_WAPI */
11996 {
11997 //Check whether we need to allocate more memory
11998 if(ieLen > pSession->nWpaRsnReqIeLength)
11999 {
12000 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12001 {
12002 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12003 }
12004 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
12005 if(!HAL_STATUS_SUCCESS(status)) break;
12006 }
12007 pSession->nWpaRsnReqIeLength = ieLen;
12008 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
12009 wTmp = pal_cpu_to_be16( ieLen );
12010 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12011 pBuf += sizeof(tANI_U16);
12012 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12013 pBuf += ieLen;
12014 }
12015 }
12016 else
12017 {
12018 //free whatever old info
12019 pSession->nWpaRsnReqIeLength = 0;
12020 if(pSession->pWpaRsnReqIE)
12021 {
12022 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12023 pSession->pWpaRsnReqIE = NULL;
12024 }
12025#ifdef FEATURE_WLAN_WAPI
12026 pSession->nWapiReqIeLength = 0;
12027 if(pSession->pWapiReqIE)
12028 {
12029 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12030 pSession->pWapiReqIE = NULL;
12031 }
12032#endif /* FEATURE_WLAN_WAPI */
12033 //length is two bytes
12034 *pBuf = 0;
12035 *(pBuf + 1) = 0;
12036 pBuf += 2;
12037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012038#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012039 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012041 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 //length is two bytes
12043 *pBuf = 0;
12044 *(pBuf + 1) = 0;
12045 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012046 }
12047 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012048 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012049 // cckmIE
12050 if( csrIsProfileCCX( pProfile ) )
12051 {
12052 // Insert the CCKM IE into the join request
12053 ieLen = csrConstructCcxCckmIe( pMac,
12054 pSession,
12055 pProfile,
12056 pBssDescription,
12057 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 pSession->nWpaRsnReqIeLength,
12059 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012060 }
12061 else
12062 {
12063 ieLen = 0;
12064 }
12065 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12066 if( ieLen )
12067 {
12068 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12069 wTmp = pal_cpu_to_be16( ieLen );
12070 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12071 pBuf += sizeof(tANI_U16);
12072 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12073 pBuf += ieLen;
12074 }
12075 else
12076 {
12077 //Indicate you have no CCKM IE
12078 //length is two bytes
12079 *pBuf = 0;
12080 *(pBuf + 1) = 0;
12081 pBuf += 2;
12082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 }
12084#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 // addIEScan
12086 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12087 {
12088 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 if(ieLen > pSession->nAddIEScanLength)
12090 {
12091 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12092 {
12093 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12094 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012095 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 (void **)&pSession->pAddIEScan, ieLen);
12097 if(!HAL_STATUS_SUCCESS(status)) break;
12098 }
12099 pSession->nAddIEScanLength = ieLen;
12100 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12101 pProfile->pAddIEScan, ieLen);
12102 wTmp = pal_cpu_to_be16( ieLen );
12103 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12104 pBuf += sizeof(tANI_U16);
12105 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12106 pBuf += ieLen;
12107 }
12108 else
12109 {
12110 pSession->nAddIEScanLength = 0;
12111 if(pSession->pAddIEScan)
12112 {
12113 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12114 pSession->pAddIEScan = NULL;
12115 }
12116 *pBuf = 0;
12117 *(pBuf + 1) = 0;
12118 pBuf += 2;
12119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 // addIEAssoc
12121 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12122 {
12123 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012124 if(ieLen > pSession->nAddIEAssocLength)
12125 {
12126 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12127 {
12128 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12129 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012130 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 (void **)&pSession->pAddIEAssoc, ieLen);
12132 if(!HAL_STATUS_SUCCESS(status)) break;
12133 }
12134 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012135 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 pProfile->pAddIEAssoc, ieLen);
12137 wTmp = pal_cpu_to_be16( ieLen );
12138 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12139 pBuf += sizeof(tANI_U16);
12140 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12141 pBuf += ieLen;
12142 }
12143 else
12144 {
12145 pSession->nAddIEAssocLength = 0;
12146 if(pSession->pAddIEAssoc)
12147 {
12148 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12149 pSession->pAddIEAssoc = NULL;
12150 }
12151 *pBuf = 0;
12152 *(pBuf + 1) = 0;
12153 pBuf += 2;
12154 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012155
12156 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012158 //Unmask any AC in reassoc that is ACM-set
12159 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12160 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012162 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12163 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012164#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012165 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012166#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012167 uapsd_mask &= ~(acm_mask);
12168 }
12169 else
12170 {
12171 uapsd_mask = 0;
12172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 }
12174 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012175
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12177 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012178 pBuf += sizeof(tANI_U32);
12179
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12181 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012182 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012183#ifdef WLAN_FEATURE_11W
12184 //MgmtEncryption
12185 if (pProfile->MFPEnabled)
12186 {
12187 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12188 }
12189 else
12190 {
12191 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12192 }
12193 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12194 pBuf += sizeof(tANI_U32);
12195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012196#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012197 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012198 if (csrIsProfile11r( pProfile )
12199#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012200 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12201 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012202#endif
12203 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012204 {
12205 // is11Rconnection;
12206 dwTmp = pal_cpu_to_be32(TRUE);
12207 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12208 pBuf += sizeof(tAniBool);
12209 }
12210 else
12211 {
12212 // is11Rconnection;
12213 dwTmp = pal_cpu_to_be32(FALSE);
12214 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12215 pBuf += sizeof(tAniBool);
12216 }
12217#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012218#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012219
12220 // isCCXFeatureIniEnabled
12221 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12222 {
12223 dwTmp = pal_cpu_to_be32(TRUE);
12224 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12225 pBuf += sizeof(tAniBool);
12226 }
12227 else
12228 {
12229 dwTmp = pal_cpu_to_be32(FALSE);
12230 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12231 pBuf += sizeof(tAniBool);
12232 }
12233
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012234 /* A profile can not be both CCX and 11R. But an 802.11R AP
12235 * may be advertising support for CCX as well. So if we are
12236 * associating Open or explicitly CCX then we will get CCX.
12237 * If we are associating explictly 11R only then we will get
12238 * 11R.
12239 */
12240 if ((csrIsProfileCCX(pProfile) ||
12241 ((pIes->CCXVersion.present)
12242 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012243 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12244 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12245 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012246#ifdef WLAN_FEATURE_11W
12247 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12248#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012249 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012250 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12251 {
12252 // isCCXconnection;
12253 dwTmp = pal_cpu_to_be32(TRUE);
12254 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12255 pBuf += sizeof(tAniBool);
12256 }
12257 else
12258 {
12259 //isCCXconnection;
12260 dwTmp = pal_cpu_to_be32(FALSE);
12261 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12262 pBuf += sizeof(tAniBool);
12263 }
12264
12265 if (eWNI_SME_JOIN_REQ == messageType)
12266 {
12267 tCCXTspecInfo ccxTspec;
12268 // CCX-Tspec IEs in the ASSOC request is presently not supported
12269 // so nullify the TSPEC parameters
12270 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12271 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12272 pBuf += sizeof(tCCXTspecInfo);
12273 }
12274 else if (eWNI_SME_REASSOC_REQ == messageType)
12275 {
12276 if ((csrIsProfileCCX(pProfile) ||
12277 ((pIes->CCXVersion.present)
12278 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012279 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12280 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12281 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012282#ifdef WLAN_FEATURE_11W
12283 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12284#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012285 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012286 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 {
12288 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 // CCX Tspec information
12290 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12291 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12292 *pBuf = ccxTspec.numTspecs;
12293 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 // Copy the TSPEC information only if present
12295 if (ccxTspec.numTspecs) {
12296 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12297 }
12298 pBuf += sizeof(ccxTspec.tspec);
12299 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012300 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 tCCXTspecInfo ccxTspec;
12303 // CCX-Tspec IEs in the ASSOC request is presently not supported
12304 // so nullify the TSPEC parameters
12305 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12306 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12307 pBuf += sizeof(tCCXTspecInfo);
12308 }
12309 }
12310#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012311#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012313 if (pMac->roam.configParam.isFastTransitionEnabled
12314#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012315 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012316#endif
12317 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012319 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012321 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 }
12323 else
12324 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012325 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012327 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012328 }
12329#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012330#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012331 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012332 {
12333 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012334 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012335 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012336 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012337 }
12338 else
12339 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012340 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012341 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012342 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012343 }
12344#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012345
12346 // txLdpcIniFeatureEnabled
12347 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12348 pBuf++;
12349
Kiran4a17ebe2013-01-31 10:43:43 -080012350 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12351 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12352 {
12353 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12354 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12355 csrApplyPower2Current(pMac);
12356 }
12357
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012358#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012359 // txBFIniFeatureEnabled
12360 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12361 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012362
12363 // txBFCsnValue
12364 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12365 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012366#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012367 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12368 pBuf++;
12369
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012370 //BssDesc
12371 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12372 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012373
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012374 status = palSendMBMessage(pMac->hHdd, pMsg );
12375 if(!HAL_STATUS_SUCCESS(status))
12376 {
12377 break;
12378 }
12379 else
12380 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012381#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012382 if (eWNI_SME_JOIN_REQ == messageType)
12383 {
12384 //Tush-QoS: notify QoS module that join happening
12385 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12386 }
12387 else if (eWNI_SME_REASSOC_REQ == messageType)
12388 {
12389 //Tush-QoS: notify QoS module that reassoc happening
12390 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012392#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012396}
12397
Jeff Johnson295189b2012-06-20 16:38:30 -070012398//
12399eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12400{
12401 eHalStatus status = eHAL_STATUS_SUCCESS;
12402 tSirSmeDisassocReq *pMsg;
12403 tANI_U8 *pBuf;
12404 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12406 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12407 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 do {
12409 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12410 if ( !HAL_STATUS_SUCCESS(status) ) break;
12411 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12412 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12413 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012414 pBuf = &pMsg->sessionId;
12415 // sessionId
12416 *pBuf++ = (tANI_U8)sessionId;
12417 // transactionId
12418 *pBuf = 0;
12419 *( pBuf + 1 ) = 0;
12420 pBuf += sizeof(tANI_U16);
12421
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012422 if ( (pSession->pCurRoamProfile != NULL) &&
12423 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12424 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012425 {
12426 // Set the bssid address before sending the message to LIM
12427 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12428 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 // Set the peer MAC address before sending the message to LIM
12430 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12431 pBuf = pBuf + sizeof ( tSirMacAddr );
12432 }
12433 else
12434 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 // Set the peer MAC address before sending the message to LIM
12436 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12437 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12439 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 if(!HAL_STATUS_SUCCESS(status))
12442 {
12443 palFreeMemory(pMac->hHdd, pMsg);
12444 break;
12445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 // reasonCode
12447 wTmp = pal_cpu_to_be16(reasonCode);
12448 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12449 if(!HAL_STATUS_SUCCESS(status))
12450 {
12451 palFreeMemory(pMac->hHdd, pMsg);
12452 break;
12453 }
12454 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12456 Here we should not send the disassoc over the air to the AP */
12457 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12458#ifdef WLAN_FEATURE_VOWIFI_11R
12459 && csrRoamIs11rAssoc(pMac)
12460#endif
12461 )
12462 {
12463 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12464 }
12465 pBuf += sizeof(tANI_U8);
12466 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 return( status );
12469}
Jeff Johnson295189b2012-06-20 16:38:30 -070012470eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12471{
12472 eHalStatus status = eHAL_STATUS_SUCCESS;
12473 tSirSmeTkipCntrMeasReq *pMsg;
12474 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 do
12476 {
12477 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12478 if ( !HAL_STATUS_SUCCESS(status) ) break;
12479 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12480 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12481 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 pBuf = &pMsg->sessionId;
12483 // sessionId
12484 *pBuf++ = (tANI_U8)sessionId;
12485 // transactionId
12486 *pBuf = 0;
12487 *( pBuf + 1 ) = 0;
12488 pBuf += sizeof(tANI_U16);
12489 // bssid
12490 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12491 pBuf = pBuf + sizeof ( tSirMacAddr );
12492 // bEnable
12493 *pBuf = (tANI_BOOLEAN)bEnable;
12494 if(!HAL_STATUS_SUCCESS(status))
12495 {
12496 palFreeMemory(pMac->hHdd, pMsg);
12497 break;
12498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 return( status );
12502}
Jeff Johnson295189b2012-06-20 16:38:30 -070012503eHalStatus
12504csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12505 VOS_MODULE_ID modId, tSirMacAddr bssId,
12506 void *pUsrContext, void *pfnSapEventCallback,
12507 tANI_U8 *pAssocStasBuf )
12508{
12509 eHalStatus status = eHAL_STATUS_SUCCESS;
12510 tSirSmeGetAssocSTAsReq *pMsg;
12511 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12512 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 do
12514 {
12515 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12516 if (!HAL_STATUS_SUCCESS(status)) break;
12517 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12518 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 pBuf = (tANI_U8 *)&pMsg->bssId;
12520 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 // bssId
12522 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12523 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 // modId
12525 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12526 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12527 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 // pUsrContext
12529 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12530 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12531 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 // pfnSapEventCallback
12533 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12534 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12535 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 // pAssocStasBuf
12537 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12538 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12539 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 status = palSendMBMessage( pMac->hHdd, pMsg );
12542 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 return( status );
12544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012545eHalStatus
12546csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12547 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12548 {
12549 eHalStatus status = eHAL_STATUS_SUCCESS;
12550 tSirSmeGetWPSPBCSessionsReq *pMsg;
12551 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12552 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 do
12554 {
12555 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12556 if (!HAL_STATUS_SUCCESS(status)) break;
12557 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12558 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070012560 VOS_ASSERT(pBuf);
12561
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 // pUsrContext
12564 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12565 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12566 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 // pSapEventCallback
12568 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12569 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12570 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 // bssId
12572 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12573 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 // MAC Address of STA in WPS session
12575 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12576 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 return( status );
12581}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012582
12583eHalStatus
12584csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12585{
12586 tpSirChangeBIParams pMsg;
12587 tANI_U16 len = 0;
12588 eHalStatus status = eHAL_STATUS_SUCCESS;
12589 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12590
12591 if(!pSession)
12592 {
12593 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12594 return eHAL_STATUS_FAILURE;
12595 }
12596
12597 //NO need to update the Beacon Params if update beacon parameter flag is not set
12598 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12599 return eHAL_STATUS_SUCCESS;
12600
12601 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12602
12603 /* Create the message and send to lim */
12604 len = sizeof(tSirChangeBIParams);
12605 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12606 if(HAL_STATUS_SUCCESS(status))
12607 {
12608 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12609 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12610 pMsg->length = len;
12611
12612 // bssId
12613 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012614 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 -080012615 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12616 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12617 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012618 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012619 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12620 status = palSendMBMessage(pMac->hHdd, pMsg);
12621 }
12622 return status;
12623}
12624
Jeff Johnson295189b2012-06-20 16:38:30 -070012625eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12626{
12627 eHalStatus status = eHAL_STATUS_SUCCESS;
12628 tSirSmeDeauthReq *pMsg;
12629 tANI_U8 *pBuf;
12630 tANI_U16 wTmp;
12631 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12632 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12633 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 do {
12635 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12636 if ( !HAL_STATUS_SUCCESS(status) ) break;
12637 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12638 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12639 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12640 //sessionId
12641 pBuf = &pMsg->sessionId;
12642 *pBuf++ = (tANI_U8)sessionId;
12643
12644 //tansactionId
12645 *pBuf = 0;
12646 *(pBuf + 1 ) = 0;
12647 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12651 // Set the BSSID before sending the message to LIM
12652 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12653 pBuf = pBuf + sizeof(tSirMacAddr);
12654 }
12655 else
12656 {
12657 // Set the BSSID before sending the message to LIM
12658 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12659 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 }
12661 if(!HAL_STATUS_SUCCESS(status))
12662 {
12663 palFreeMemory(pMac->hHdd, pMsg);
12664 break;
12665 }
12666 // Set the peer MAC address before sending the message to LIM
12667 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12668 pBuf = pBuf + sizeof(tSirMacAddr);
12669 if(!HAL_STATUS_SUCCESS(status))
12670 {
12671 palFreeMemory(pMac->hHdd, pMsg);
12672 break;
12673 }
12674 wTmp = pal_cpu_to_be16(reasonCode);
12675 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12676 if(!HAL_STATUS_SUCCESS(status))
12677 {
12678 palFreeMemory(pMac->hHdd, pMsg);
12679 break;
12680 }
12681 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 return( status );
12684}
12685
Jeff Johnson295189b2012-06-20 16:38:30 -070012686eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12687{
12688 eHalStatus status = eHAL_STATUS_SUCCESS;
12689 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 do {
12691 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12692 if ( !HAL_STATUS_SUCCESS(status) ) break;
12693 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12694 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12695 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12696 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12697 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12698 if(!HAL_STATUS_SUCCESS(status))
12699 {
12700 palFreeMemory(pMac->hHdd, pMsg);
12701 break;
12702 }
12703//To test reconn
12704 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12705 if(!HAL_STATUS_SUCCESS(status))
12706 {
12707 palFreeMemory(pMac->hHdd, pMsg);
12708 break;
12709 }
12710//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 return( status );
12714}
12715
Jeff Johnson295189b2012-06-20 16:38:30 -070012716eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12717{
12718 eHalStatus status = eHAL_STATUS_SUCCESS;
12719 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 do {
12721 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12722 if ( !HAL_STATUS_SUCCESS(status) ) break;
12723 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12724 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12725 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12726 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12727 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12728 if(!HAL_STATUS_SUCCESS(status))
12729 {
12730 palFreeMemory(pMac->hHdd, pMsg);
12731 break;
12732 }
12733 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12734 if(!HAL_STATUS_SUCCESS(status))
12735 {
12736 palFreeMemory(pMac->hHdd, pMsg);
12737 break;
12738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 return( status );
12742}
Jeff Johnson295189b2012-06-20 16:38:30 -070012743eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12744{
12745 eHalStatus status = eHAL_STATUS_SUCCESS;
12746 tSirSmeAssocCnf *pMsg;
12747 tANI_U8 *pBuf;
12748 tSirResultCodes statusCode;
12749 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 do {
12751 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12752 if ( !HAL_STATUS_SUCCESS(status) ) break;
12753 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12754 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12755 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 pBuf = (tANI_U8 *)&pMsg->statusCode;
12757 if(HAL_STATUS_SUCCESS(Halstatus))
12758 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12759 else
12760 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12761 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12762 pBuf += sizeof(tSirResultCodes);
12763 // bssId
12764 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12765 pBuf += sizeof (tSirMacAddr);
12766 // peerMacAddr
12767 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12768 pBuf += sizeof (tSirMacAddr);
12769 // aid
12770 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12771 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12772 pBuf += sizeof (tANI_U16);
12773 // alternateBssId
12774 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12775 pBuf += sizeof (tSirMacAddr);
12776 // alternateChannelId
12777 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012778 status = palSendMBMessage( pMac->hHdd, pMsg );
12779 if(!HAL_STATUS_SUCCESS(status))
12780 {
12781 //pMsg is freed by palSendMBMessage
12782 break;
12783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012785 return( status );
12786}
Jeff Johnson295189b2012-06-20 16:38:30 -070012787eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12788 tpSirSmeAssocInd pAssocInd,
12789 eHalStatus Halstatus,
12790 tANI_U8 sessionId)
12791{
12792 tSirMsgQ msgQ;
12793 eHalStatus status = eHAL_STATUS_SUCCESS;
12794 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12795 tANI_U8 *pBuf;
12796 tSirResultCodes statusCode;
12797 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012798 do {
12799 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12800 if ( !HAL_STATUS_SUCCESS(status) ) break;
12801 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012802
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12804 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12805
12806 pMsg->sessionId = sessionId;
12807
12808 pBuf = (tANI_U8 *)&pMsg->statusCode;
12809 if(HAL_STATUS_SUCCESS(Halstatus))
12810 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12811 else
12812 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12813 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12814 pBuf += sizeof(tSirResultCodes);
12815 // bssId
12816 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12817 pBuf += sizeof (tSirMacAddr);
12818 // peerMacAddr
12819 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12820 pBuf += sizeof (tSirMacAddr);
12821 // StaId
12822 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12823 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12824 pBuf += sizeof (tANI_U16);
12825 // alternateBssId
12826 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12827 pBuf += sizeof (tSirMacAddr);
12828 // alternateChannelId
12829 *pBuf = 11;
12830 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012831 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 //Wmm
12833 *pBuf = pAssocInd->wmmEnabledSta;
12834 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 //RSN IE
12836 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12837 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 //Additional IE
12839 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12840 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 //reassocReq
12842 *pBuf = pAssocInd->reassocReq;
12843 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12845 msgQ.bodyptr = pMsg;
12846 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 return( status );
12850}
Jeff Johnson295189b2012-06-20 16:38:30 -070012851
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053012852eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12854 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12855 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12856 tANI_U8 *pKeyRsc )
12857{
12858 tSirSmeSetContextReq *pMsg;
12859 tANI_U16 msgLen;
12860 eHalStatus status = eHAL_STATUS_FAILURE;
12861 tAniEdType tmpEdType;
12862 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012863 tANI_U8 *pBuf = NULL;
12864 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12869 // key set. Since we only support upto one key, we always allocate memory for 1 key
12870 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12871 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12872 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12873 ( sizeof( pMsg->keyMaterial.key ) );
12874
12875 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12876 if ( !HAL_STATUS_SUCCESS(status) ) break;
12877 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12878 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12879 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 //sessionId
12881 pBuf = &pMsg->sessionId;
12882 *pBuf = (tANI_U8)sessionId;
12883 pBuf++;
12884 // transactionId
12885 *pBuf = 0;
12886 *(pBuf + 1) = 0;
12887 pBuf += sizeof(tANI_U16);
12888 // peerMacAddr
12889 palCopyMemory( pMac->hHdd, pBuf,
12890 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12891
12892 pBuf += sizeof(tSirMacAddr);
12893
12894 // bssId
12895 palCopyMemory( pMac->hHdd, pBuf,
12896 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12897
12898 pBuf += sizeof(tSirMacAddr);
12899
12900 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12902 // in the tSirKeyMaterial keyMaterial; field).
12903 //
12904 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12905 // shorter than this max size. Is LIM interpreting this ok ?
12906 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 -070012907 // set pMsg->keyMaterial.edType
12908 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12909 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12910 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 // set the pMsg->keyMaterial.numKeys field
12912 *p = numKeys;
12913 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 // set pSirKey->keyId = keyId;
12915 *p = keyId;
12916 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 // set pSirKey->unicast = (tANI_U8)fUnicast;
12918 *p = (tANI_U8)fUnicast;
12919 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012920 // set pSirKey->keyDirection = aniKeyDirection;
12921 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12922 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12923 p += sizeof(tAniKeyDirection);
12924 // pSirKey->keyRsc = ;;
12925 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12926 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 // set pSirKey->paeRole
12928 *p = paeRole; // 0 is Supplicant
12929 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 // set pSirKey->keyLength = keyLength;
12931 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 if ( keyLength && pKey )
12933 {
12934 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12935 if(keyLength == 16)
12936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012937 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 -070012938 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12939 pKey[5], pKey[6], pKey[7], pKey[8],
12940 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12941 }
12942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012943 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 return( status );
12946}
12947
Jeff Johnson295189b2012-06-20 16:38:30 -070012948eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12949 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12950{
12951 eHalStatus status;
12952 tSirSmeStartBssReq *pMsg;
12953 tANI_U8 *pBuf = NULL;
12954 tANI_U8 *wTmpBuf = NULL;
12955 tANI_U16 msgLen, wTmp;
12956 tANI_U32 dwTmp;
12957 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012958 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012961
12962 if(!pSession)
12963 {
12964 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12965 return eHAL_STATUS_FAILURE;
12966 }
12967
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 do {
12969 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12970 pSession->joinFailStatusCode.reasonCode = 0;
12971 msgLen = sizeof(tSirSmeStartBssReq);
12972 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12973 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12975 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012976 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 //sessionId
12979 *pBuf = (tANI_U8)sessionId;
12980 pBuf++;
12981 // transactionId
12982 *pBuf = 0;
12983 *(pBuf + 1) = 0;
12984 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 // bssid
12986 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12987 pBuf += sizeof(tSirMacAddr);
12988 // selfMacAddr
12989 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12990 pBuf += sizeof(tSirMacAddr);
12991 // beaconInterval
12992 if( pBssDesc && pBssDesc->beaconInterval )
12993 {
12994 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 else if(pParam->beaconInterval)
12997 {
12998 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 else
13001 {
13002 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13003 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013004 if(csrIsconcurrentsessionValid (pMac, sessionId,
13005 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013006 == eHAL_STATUS_SUCCESS )
13007 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013008 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013009 pParam->bssPersona);
13010 //Update the beacon Interval
13011 pParam->beaconInterval = wTmp;
13012 }
13013 else
13014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013015 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013016 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070013017 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070013018 return status;
13019 }
13020
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13022 pBuf += sizeof(tANI_U16);
13023 // dot11mode
13024 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13025 pBuf += 1;
13026 // bssType
13027 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
13028 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
13029 pBuf += sizeof(tSirBssType);
13030 // ssId
13031 if( pParam->ssId.length )
13032 {
13033 // ssId len
13034 *pBuf = pParam->ssId.length;
13035 pBuf++;
13036 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
13037 pBuf += pParam->ssId.length;
13038 }
13039 else
13040 {
13041 *pBuf = 0;
13042 pBuf++;
13043 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 // set the channel Id
13045 *pBuf = pParam->operationChn;
13046 pBuf++;
13047 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013048 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
13049 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
13050 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013051
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 // Set privacy
13053 *pBuf = pParam->privacy;
13054 pBuf++;
13055
13056 //Set Uapsd
13057 *pBuf = pParam->ApUapsdEnable;
13058 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 //Set SSID hidden
13060 *pBuf = pParam->ssidHidden;
13061 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13063 pBuf++;
13064
13065 //Ht protection Enable/Disable
13066 *pBuf = (tANI_U8)pParam->protEnabled;
13067 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 //Enable Beacons to Receive for OBSS protection Enable/Disable
13069 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13070 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 //set cfg related to protection
13072 wTmp = pal_cpu_to_be16( pParam->ht_protection );
13073 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13074 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 // Set Auth type
13076 authType = pal_cpu_to_be32(pParam->authType);
13077 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
13078 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 // Set DTIM
13080 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
13081 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
13082 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 // Set wps_state
13084 *pBuf = pParam->wps_state;
13085 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 //Persona
13087 *pBuf = (tANI_U8)pParam->bssPersona;
13088 pBuf++;
13089
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013090 //txLdpcIniFeatureEnabled
13091 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13092 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013093
krunal soni4f087d22013-07-29 16:32:26 -070013094 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013095 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13096 {
13097 status = eHAL_STATUS_INVALID_PARAMETER;
13098 palFreeMemory( pMac->hHdd, pMsg );
13099 break;
13100 }
13101 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
13102 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
13103 pBuf += sizeof(tANI_U16);
13104 if( wTmp )
13105 {
13106 wTmp = pParam->nRSNIELength;
13107 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13108 pBuf += wTmp;
13109 }
13110 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13111 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13112 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13114 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13116 pBuf += pParam->operationalRateSet.numRates ;
13117 *pBuf++ = pParam->extendedRateSet.numRates;
13118 if(0 != pParam->extendedRateSet.numRates)
13119 {
13120 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13121 pBuf += pParam->extendedRateSet.numRates;
13122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13124 pMsg->length = pal_cpu_to_be16(msgLen);
13125
13126 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 return( status );
13129}
13130
Jeff Johnson295189b2012-06-20 16:38:30 -070013131eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13132{
13133 eHalStatus status = eHAL_STATUS_FAILURE;
13134 tSirSmeStopBssReq *pMsg;
13135 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13136 tANI_U8 *pBuf;
13137 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013138
13139 if(!pSession)
13140 {
13141 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13142 return eHAL_STATUS_FAILURE;
13143 }
13144
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 do {
13146 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13147 if ( !HAL_STATUS_SUCCESS(status) ) break;
13148 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13149 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13150 pBuf = &pMsg->sessionId;
13151 //sessionId
13152 *pBuf = (tANI_U8)sessionId;
13153 pBuf++;
13154 // transactionId
13155 *pBuf = 0;
13156 pBuf += sizeof(tANI_U16);
13157 //reason code
13158 *pBuf = 0;
13159 pBuf += sizeof(tSirResultCodes);
13160 // bssid
13161 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13162 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13163 {
13164 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13165 }
13166 else
13167 {
13168 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13169 }
13170 pBuf += sizeof(tSirMacAddr);
13171 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13172 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 status = palSendMBMessage( pMac->hHdd, pMsg );
13174#if 0
13175 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13176 if ( !HAL_STATUS_SUCCESS(status) ) break;
13177 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13178 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13179 pMsg->reasonCode = 0;
13180 // bssid
13181 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13182 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13183 {
13184 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13185 }
13186 else
13187 {
13188 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13189 }
13190 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13191 pMsg->transactionId = 0;
13192 pMsg->sessionId = (tANI_U8)sessionId;
13193 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13194 status = palSendMBMessage( pMac->hHdd, pMsg );
13195#endif
13196 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 return( status );
13198}
13199
Jeff Johnson295189b2012-06-20 16:38:30 -070013200eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13201 tCsrRoamModifyProfileFields *pModProfileFields,
13202 tANI_U32 *pRoamId, v_BOOL_t fForce)
13203{
Jeff Johnson295189b2012-06-20 16:38:30 -070013204 eHalStatus status = eHAL_STATUS_FAILURE;
13205 tANI_U32 roamId = 0;
13206 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 if((csrIsConnStateConnected(pMac, sessionId)) &&
13208 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13209 &pSession->connectedProfile.modifyProfileFields,
13210 sizeof(tCsrRoamModifyProfileFields)))) )
13211 {
13212 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13213 if(pRoamId)
13214 {
13215 *pRoamId = roamId;
13216 }
13217
Jeff Johnson295189b2012-06-20 16:38:30 -070013218 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13219 eCsrSmeIssuedReassocToSameAP, roamId,
13220 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 return status;
13223}
Jeff Johnson295189b2012-06-20 16:38:30 -070013224static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13225{
13226 eHalStatus status = eHAL_STATUS_SUCCESS;
13227 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13229 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13230 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13231 return (status);
13232}
Jeff Johnson295189b2012-06-20 16:38:30 -070013233eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13234{
13235 eHalStatus status = eHAL_STATUS_SUCCESS;
13236 tListElem *pEntry = NULL;
13237 tSmeCmd *pCommand = NULL;
13238 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 do
13240 {
13241 if(pMsg == NULL)
13242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013243 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 status = eHAL_STATUS_FAILURE;
13245 break;
13246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13248 if(pEntry)
13249 {
13250 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13251 if(eSmeCommandAddStaSession == pCommand->command)
13252 {
13253 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013254 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 //Remove this command out of the active list
13258 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13259 {
13260 //Now put this command back on the avilable command list
13261 csrReleaseCommand(pMac, pCommand);
13262 }
13263 smeProcessPendingQueue( pMac );
13264 }
13265 else
13266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013267 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 -070013268 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 status = eHAL_STATUS_FAILURE;
13270 break;
13271 }
13272 }
13273 else
13274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013275 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 -070013276 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 status = eHAL_STATUS_FAILURE;
13278 break;
13279 }
13280 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013282}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013283eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13284 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013285{
13286 tSirSmeAddStaSelfReq *pMsg;
13287 tANI_U16 msgLen;
13288 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013290 msgLen = sizeof(tSirSmeAddStaSelfReq);
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13292 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13295 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 // self station address
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013297 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr,
13298 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13299
13300 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13301
13302 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 pMsg->selfMacAddr[0],
13304 pMsg->selfMacAddr[1],
13305 pMsg->selfMacAddr[2],
13306 pMsg->selfMacAddr[3],
13307 pMsg->selfMacAddr[4],
13308 pMsg->selfMacAddr[5]);
13309 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 return( status );
13312}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013313eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13314 tANI_U32 sessionId,
13315 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013316{
13317 eHalStatus status = eHAL_STATUS_SUCCESS;
13318 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 pCommand = csrGetCommandBuffer(pMac);
13320 if(NULL == pCommand)
13321 {
13322 status = eHAL_STATUS_RESOURCES;
13323 }
13324 else
13325 {
13326 pCommand->command = eSmeCommandAddStaSession;
13327 pCommand->sessionId = (tANI_U8)sessionId;
13328 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013329 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13331 if( !HAL_STATUS_SUCCESS( status ) )
13332 {
13333 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013334 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 }
13336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 return (status);
13338}
Jeff Johnson295189b2012-06-20 16:38:30 -070013339eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13340{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013341 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013342}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013343eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13344 csrRoamCompleteCallback callback,
13345 void *pContext, tANI_U8 *pSelfMacAddr,
13346 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013347{
13348 eHalStatus status = eHAL_STATUS_SUCCESS;
13349 tANI_U32 i;
13350 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 *pbSessionId = CSR_SESSION_ID_INVALID;
13352 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13353 {
13354 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13355 {
13356 pSession = CSR_GET_SESSION( pMac, i );
13357 status = eHAL_STATUS_SUCCESS;
13358 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13359 pSession->sessionId = (tANI_U8)i;
13360 pSession->callback = callback;
13361 pSession->pContext = pContext;
13362 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13363 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013364 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13365 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 &pSession->roamingTimerInfo);
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 Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 break;
13371 }
13372#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013373 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13374 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013376 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013378 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 break;
13380 }
13381#endif
13382 pSession->ibssJoinTimerInfo.pMac = pMac;
13383 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013384 status = vos_timer_init(&pSession->hTimerIbssJoining, VOS_TIMER_TYPE_SW,
13385 csrRoamIbssJoinTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 &pSession->ibssJoinTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013387 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013389 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 break;
13391 }
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013392 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 break;
13394 }
13395 }
13396 if( CSR_ROAM_SESSION_MAX == i )
13397 {
13398 //No session is available
13399 status = eHAL_STATUS_RESOURCES;
13400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 return ( status );
13402}
Jeff Johnson295189b2012-06-20 16:38:30 -070013403eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13404{
13405 eHalStatus status = eHAL_STATUS_SUCCESS;
13406 tListElem *pEntry = NULL;
13407 tSmeCmd *pCommand = NULL;
13408 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 do
13410 {
13411 if(pMsg == NULL)
13412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013413 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 status = eHAL_STATUS_FAILURE;
13415 break;
13416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13418 if(pEntry)
13419 {
13420 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13421 if(eSmeCommandDelStaSession == pCommand->command)
13422 {
13423 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013424 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013425 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 //This session is done.
13427 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 if(pCommand->u.delStaSessionCmd.callback)
13429 {
13430
13431 status = sme_ReleaseGlobalLock( &pMac->sme );
13432 if ( HAL_STATUS_SUCCESS( status ) )
13433 {
13434 pCommand->u.delStaSessionCmd.callback(
13435 pCommand->u.delStaSessionCmd.pContext);
13436 status = sme_AcquireGlobalLock( &pMac->sme );
13437 if (! HAL_STATUS_SUCCESS( status ) )
13438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013439 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 return status;
13441 }
13442 }
13443 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013444 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 }
13446 }
13447
13448 //Remove this command out of the active list
13449 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13450 {
13451 //Now put this command back on the avilable command list
13452 csrReleaseCommand(pMac, pCommand);
13453 }
13454 smeProcessPendingQueue( pMac );
13455 }
13456 else
13457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013458 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 -070013459 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 status = eHAL_STATUS_FAILURE;
13461 break;
13462 }
13463 }
13464 else
13465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013466 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 -070013467 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 status = eHAL_STATUS_FAILURE;
13469 break;
13470 }
13471 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473}
Jeff Johnson295189b2012-06-20 16:38:30 -070013474eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13475{
13476 tSirSmeDelStaSelfReq *pMsg;
13477 tANI_U16 msgLen;
13478 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13481 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13483 if ( !HAL_STATUS_SUCCESS(status) ) break;
13484
13485 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13487 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 // self station address
13489 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 return( status );
13493}
Jeff Johnson295189b2012-06-20 16:38:30 -070013494eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13495 tSirMacAddr sessionMacAddr,
13496 csrRoamSessionCloseCallback callback,
13497 void *pContext)
13498{
13499 eHalStatus status = eHAL_STATUS_SUCCESS;
13500 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 pCommand = csrGetCommandBuffer(pMac);
13502 if(NULL == pCommand)
13503 {
13504 status = eHAL_STATUS_RESOURCES;
13505 }
13506 else
13507 {
13508 pCommand->command = eSmeCommandDelStaSession;
13509 pCommand->sessionId = (tANI_U8)sessionId;
13510 pCommand->u.delStaSessionCmd.callback = callback;
13511 pCommand->u.delStaSessionCmd.pContext = pContext;
13512 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13514 if( !HAL_STATUS_SUCCESS( status ) )
13515 {
13516 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013517 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 }
13519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 return (status);
13521}
Jeff Johnson295189b2012-06-20 16:38:30 -070013522eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13523{
13524 return csrSendMBDelSelfStaReqMsg( pMac,
13525 pCommand->u.delStaSessionCmd.selfMacAddr );
13526}
Jeff Johnson295189b2012-06-20 16:38:30 -070013527static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13528{
13529 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13530 tListElem *pEntry, *pNext;
13531 tSmeCmd *pCommand;
13532 tDblLinkList localList;
13533
13534 vos_mem_zero(&localList, sizeof(tDblLinkList));
13535 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13536 {
13537 smsLog(pMac, LOGE, FL(" failed to open list"));
13538 return;
13539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 csrLLLock(pList);
13541 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13542 while(pEntry != NULL)
13543 {
13544 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13545 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13546 if(pCommand->sessionId == sessionId)
13547 {
13548 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13549 {
13550 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13551 }
13552 }
13553 pEntry = pNext;
13554 }
13555 csrLLUnlock(pList);
13556
13557 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13558 {
13559 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13560 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13561 }
13562 csrLLClose(&localList);
13563}
13564
Jeff Johnson295189b2012-06-20 16:38:30 -070013565void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13566{
13567 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13568 {
13569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 csrRoamStop(pMac, sessionId);
13571 csrFreeConnectBssDesc(pMac, sessionId);
13572 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13573 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013574 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070013575#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013576 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013577#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013578 vos_timer_destroy(&pSession->hTimerIbssJoining);
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053013579 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
13580 if (pMac->fScanOffload)
13581 {
13582 purgeSmeSessionCmdList(pMac, sessionId,
13583 &pMac->sme.smeScanCmdPendingList);
13584 }
13585
Jeff Johnson295189b2012-06-20 16:38:30 -070013586 purgeCsrSessionCmdList(pMac, sessionId);
13587 csrInitSession(pMac, sessionId);
13588 }
13589}
13590
Jeff Johnson295189b2012-06-20 16:38:30 -070013591eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13592 tANI_BOOLEAN fSync,
13593 csrRoamSessionCloseCallback callback,
13594 void *pContext )
13595{
13596 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13598 {
13599 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13600 if(fSync)
13601 {
13602 csrCleanupSession(pMac, sessionId);
13603 }
13604 else
13605 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053013606 purgeSmeSessionCmdList(pMac, sessionId,
13607 &pMac->sme.smeCmdPendingList);
13608 if (pMac->fScanOffload)
13609 {
13610 purgeSmeSessionCmdList(pMac, sessionId,
13611 &pMac->sme.smeScanCmdPendingList);
13612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 purgeCsrSessionCmdList(pMac, sessionId);
13614 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13615 pSession->selfMacAddr, callback, pContext);
13616 }
13617 }
13618 else
13619 {
13620 status = eHAL_STATUS_INVALID_PARAMETER;
13621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 return ( status );
13623}
13624
Jeff Johnson295189b2012-06-20 16:38:30 -070013625static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13626{
13627 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013628
13629 if(!pSession)
13630 {
13631 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13632 return;
13633 }
13634
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13636 pSession->sessionId = CSR_SESSION_ID_INVALID;
13637 pSession->callback = NULL;
13638 pSession->pContext = NULL;
13639 pSession->ibss_join_pending = FALSE;
13640 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13641 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13642 csrFreeRoamProfile( pMac, sessionId );
13643 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13644 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13645 csrFreeConnectBssDesc(pMac, sessionId);
13646 csrScanEnable(pMac);
13647 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13648 if(pSession->pWpaRsnReqIE)
13649 {
13650 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13651 pSession->pWpaRsnReqIE = NULL;
13652 }
13653 pSession->nWpaRsnReqIeLength = 0;
13654 if(pSession->pWpaRsnRspIE)
13655 {
13656 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13657 pSession->pWpaRsnRspIE = NULL;
13658 }
13659 pSession->nWpaRsnRspIeLength = 0;
13660#ifdef FEATURE_WLAN_WAPI
13661 if(pSession->pWapiReqIE)
13662 {
13663 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13664 pSession->pWapiReqIE = NULL;
13665 }
13666 pSession->nWapiReqIeLength = 0;
13667 if(pSession->pWapiRspIE)
13668 {
13669 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13670 pSession->pWapiRspIE = NULL;
13671 }
13672 pSession->nWapiRspIeLength = 0;
13673#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 if(pSession->pAddIEScan)
13675 {
13676 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13677 pSession->pAddIEScan = NULL;
13678 }
13679 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 if(pSession->pAddIEAssoc)
13681 {
13682 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13683 pSession->pAddIEAssoc = NULL;
13684}
13685 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013686}
13687
Jeff Johnson295189b2012-06-20 16:38:30 -070013688eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13689{
13690 eHalStatus status = eHAL_STATUS_FAILURE;
13691 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13693 {
13694 if( CSR_IS_SESSION_VALID( pMac, i ) )
13695 {
13696 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13697 {
13698 //Found it
13699 status = eHAL_STATUS_SUCCESS;
13700 *pSessionId = i;
13701 break;
13702 }
13703 }
13704 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 return( status );
13706}
13707
Jeff Johnson295189b2012-06-20 16:38:30 -070013708//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13709//session because for IBSS, the bssid changes.
13710static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13711{
13712 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13713 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13715 {
13716 if( CSR_IS_SESSION_VALID( pMac, i ) )
13717 {
13718 pSession = CSR_GET_SESSION( pMac, i );
13719 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13720 {
13721 //Found it
13722 nRet = i;
13723 break;
13724 }
13725 }
13726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 return (nRet);
13728}
Jeff Johnson295189b2012-06-20 16:38:30 -070013729static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13730{
13731 /* Update the current BSS info in ho control block based on connected
13732 profile info from pmac global structure */
13733
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013734 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13736 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 /* Check for user misconfig of RSSI trigger threshold */
13738 pMac->roam.configParam.vccRssiThreshold =
13739 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13740 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13741 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 /* Check for user misconfig of UL MAC Loss trigger threshold */
13743 pMac->roam.configParam.vccUlMacLossThreshold =
13744 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13745 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013746#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13747 {
13748 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 /* Indicate the neighbor roal algorithm about the connect indication */
13750 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13751 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13752 }
13753#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013754}
13755
Jeff Johnson295189b2012-06-20 16:38:30 -070013756static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13757{
13758 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013759
13760 if(!pSession)
13761 {
13762 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13763 return;
13764 }
13765
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 //Only to handle the case for Handover on infra link
13767 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13768 {
13769 return;
13770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13772 csrRoamDeregStatisticsReq(pMac);
13773 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13774#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13775 /* Indicate the neighbor roal algorithm about the disconnect indication */
13776 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13777#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013778
13779 //Remove this code once SLM_Sessionization is supported
13780 //BMPS_WORKAROUND_NOT_NEEDED
13781 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013782 csrIsInfraApStarted( pMac ) &&
13783 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013784 {
13785 pMac->roam.configParam.doBMPSWorkaround = 0;
13786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013787}
13788
Jeff Johnson295189b2012-06-20 16:38:30 -070013789void csrRoamTlStatsTimerHandler(void *pv)
13790{
13791 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13792 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13794
Jeff Johnsone7245742012-09-05 17:12:55 -070013795 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13796
Jeff Johnson295189b2012-06-20 16:38:30 -070013797#if 0
13798 // TODO Persession .???
13799 //req TL for stats
13800 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013802 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 }
13804 else
13805 {
13806 //save in SME
13807 csrRoamSaveStatsFromTl(pMac, tlStats);
13808 }
13809#endif
13810 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13811 {
13812 if(pMac->roam.tlStatsReqInfo.periodicity)
13813 {
13814 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013815 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13816 pMac->roam.tlStatsReqInfo.periodicity);
13817 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013819 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 return;
13821 }
13822 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13823 }
13824 }
13825}
Jeff Johnson295189b2012-06-20 16:38:30 -070013826void csrRoamPeStatsTimerHandler(void *pv)
13827{
13828 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13829 eHalStatus status;
13830 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13831 VOS_STATUS vosStatus;
13832 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 pPeStatsReqListEntry->timerRunning = FALSE;
13834 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13835 {
13836 // If we entered here, meaning the timer could not be successfully
13837 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13838
13839 /* Destroy the timer */
13840 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13841 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13842 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013843 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 }
13845
13846 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013847 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 pPeStatsReqListEntry = NULL;
13849 }
13850 else
13851 {
13852 if(!pPeStatsReqListEntry->rspPending)
13853 {
13854 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13855 pPeStatsReqListEntry->staId);
13856 if(!HAL_STATUS_SUCCESS(status))
13857 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013858 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 }
13860 else
13861 {
13862 pPeStatsReqListEntry->rspPending = TRUE;
13863 }
13864 }
13865
13866 //send down a req
13867 if(pPeStatsReqListEntry->periodicity &&
13868 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13869 {
13870 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13871 if(ePMC_FULL_POWER == powerState)
13872 {
13873 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13874 {
13875 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13876 }
13877 }
13878 else
13879 {
13880 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13881 {
13882 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13883 }
13884 }
13885 //start timer
13886 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13887 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013889 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 return;
13891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 pPeStatsReqListEntry->timerRunning = TRUE;
13893
13894 }
13895
13896 }
13897}
Jeff Johnson295189b2012-06-20 16:38:30 -070013898void csrRoamStatsClientTimerHandler(void *pv)
13899{
13900 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13902 {
13903#if 0
13904 // TODO Stats fix for multisession
13905 //start the timer
13906 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13907
13908 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013910 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 }
13912#endif
13913 }
13914#if 0
13915 //send up the stats report
13916 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13917 pStaEntry->staId, pStaEntry->pContext);
13918#endif
13919}
13920
13921
13922
Jeff Johnson295189b2012-06-20 16:38:30 -070013923eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13924{
13925 tAniGetPEStatsReq *pMsg;
13926 eHalStatus status = eHAL_STATUS_SUCCESS;
13927 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13928 if ( !HAL_STATUS_SUCCESS(status) )
13929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013930 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 return status;
13932 }
13933 // need to initiate a stats request to PE
13934 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13935 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13936 pMsg->staId = staId;
13937 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 if(!HAL_STATUS_SUCCESS(status))
13940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013941 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 return status;
13944}
Jeff Johnson295189b2012-06-20 16:38:30 -070013945void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13946{
13947 tAniGetPEStatsRsp *pSmeStatsRsp;
13948 eHalStatus status = eHAL_STATUS_FAILURE;
13949 tListElem *pEntry = NULL;
13950 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13951 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13952 tANI_U32 tempMask = 0;
13953 tANI_U8 counter = 0;
13954 tANI_U8 *pStats = NULL;
13955 tANI_U32 length = 0;
13956 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013957 v_S7_t rssi = 0, snr = 0;
13958 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013959 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13961 if(pSmeStatsRsp->rc)
13962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013963 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 goto post_update;
13965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 tempMask = pSmeStatsRsp->statsMask;
13967 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 /* subtract all statistics from this length, and after processing the entire
13969 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13970 * in this 'stats' message.
13971 */
13972 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 //new stats info from PE, fill up the stats strucutres in PMAC
13974 while(tempMask)
13975 {
13976 if(tempMask & 1)
13977 {
13978 switch(counter)
13979 {
13980 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013981 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13983 pStats, sizeof(tCsrSummaryStatsInfo));
13984 if(!HAL_STATUS_SUCCESS(status))
13985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013986 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 }
13988 pStats += sizeof(tCsrSummaryStatsInfo);
13989 length -= sizeof(tCsrSummaryStatsInfo);
13990 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013992 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13994 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13995 if(!HAL_STATUS_SUCCESS(status))
13996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013997 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 }
13999 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14000 length -= sizeof(tCsrGlobalClassAStatsInfo);
14001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014003 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14005 pStats, sizeof(tCsrGlobalClassBStatsInfo));
14006 if(!HAL_STATUS_SUCCESS(status))
14007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014008 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 }
14010 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14011 length -= sizeof(tCsrGlobalClassBStatsInfo);
14012 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014014 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14016 pStats, sizeof(tCsrGlobalClassCStatsInfo));
14017 if(!HAL_STATUS_SUCCESS(status))
14018 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014019 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 }
14021 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14022 length -= sizeof(tCsrGlobalClassCStatsInfo);
14023 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014025 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14027 {
14028 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14029 pStats, sizeof(tCsrPerStaStatsInfo));
14030 }
14031 else
14032 {
14033 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014034 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 VOS_ASSERT( 0 );
14036 }
14037 if(!HAL_STATUS_SUCCESS(status))
14038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014039 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 }
14041 pStats += sizeof(tCsrPerStaStatsInfo);
14042 length -= sizeof(tCsrPerStaStatsInfo);
14043 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014045 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 }
14048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 tempMask >>=1;
14050 counter++;
14051 }
14052 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14053 if (length != 0)
14054 {
14055 pRssi = (tANI_U32*)pStats;
14056 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014057 pStats += sizeof(tANI_U32);
14058 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 }
14060 else
14061 {
14062 /* If riva is not sending rssi, continue to use the hack */
14063 rssi = RSSI_HACK_BMPS;
14064 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014065
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014067
14068 if (length != 0)
14069 {
14070 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014071 pStats += sizeof(tANI_U32);
14072 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014073 }
14074 else
14075 {
14076 linkCapacity = 0;
14077 }
14078
14079 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014080
14081 if (length != 0)
14082 {
14083 pSnr = (tANI_U32*)pStats;
14084 snr = (v_S7_t)*pSnr;
14085 }
14086 else
14087 {
14088 snr = SNR_HACK_BMPS;
14089 }
14090
14091 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014092post_update:
14093 //make sure to update the pe stats req list
14094 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14095 if(pEntry)
14096 {
14097 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14098 pPeStaEntry->rspPending = FALSE;
14099
14100 }
14101 //check the one timer cases
14102 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14103 if(pEntry)
14104 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014106 if(pTempStaEntry->timerExpired)
14107 {
14108 //send up the stats report
14109 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14110 pTempStaEntry->staId, pTempStaEntry->pContext);
14111 //also remove from the client list
14112 csrRoamRemoveStatListEntry(pMac, pEntry);
14113 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 }
14115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014116}
Jeff Johnson295189b2012-06-20 16:38:30 -070014117tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14118{
14119 tListElem *pEntry = NULL;
14120 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 if(!pEntry)
14123 {
14124 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014125 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 return NULL;
14127 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 while( pEntry )
14129 {
14130 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 if(pTempStaEntry->statsMask == statsMask)
14132 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014133 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 break;
14135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 return pEntry;
14139}
14140
Jeff Johnson295189b2012-06-20 16:38:30 -070014141tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14142 tANI_BOOLEAN update)
14143{
14144 tListElem *pEntry;
14145 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014147 if(!pEntry)
14148 {
14149 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014150 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014151 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 return NULL;
14153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 while( pEntry )
14155 {
14156 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014157 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14158 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014160 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 if(update)
14162 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014163 pTempStaEntry->periodicity = pStaEntry->periodicity;
14164 pTempStaEntry->callback = pStaEntry->callback;
14165 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014166 }
14167 break;
14168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 return pEntry;
14172}
Jeff Johnson295189b2012-06-20 16:38:30 -070014173tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14174{
14175 tListElem *pEntry;
14176 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014178 if(!pEntry)
14179 {
14180 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014181 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014182 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 return NULL;
14184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 while( pEntry )
14186 {
14187 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014190 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 break;
14192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 return pEntry;
14196}
Jeff Johnson295189b2012-06-20 16:38:30 -070014197eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14198 csrRoamLinkQualityIndCallback callback,
14199 void *pContext)
14200{
14201 pMac->roam.linkQualityIndInfo.callback = callback;
14202 pMac->roam.linkQualityIndInfo.context = pContext;
14203 if( NULL == callback )
14204 {
14205 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14206 }
14207 else
14208 {
14209 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014210 /* do we need to invoke the callback to notify client of initial value ?? */
14211 }
14212 return eHAL_STATUS_SUCCESS;
14213}
Jeff Johnson295189b2012-06-20 16:38:30 -070014214void csrRoamVccTrigger(tpAniSirGlobal pMac)
14215{
14216 eCsrRoamLinkQualityInd newVccLinkQuality;
14217 tANI_U32 ul_mac_loss = 0;
14218 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14220 /*-------------------------------------------------------------------------
14221 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 Check for a change in link quality and notify client if necessary
14223 -------------------------------------------------------------------------*/
14224 ul_mac_loss_trigger_threshold =
14225 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014227 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014228 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14230 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014231 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14233 }
14234 else
14235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014236 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14240 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014243 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14245 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014246 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 newVccLinkQuality );
14248
14249 /* we now invoke the callback once to notify client of initial value */
14250 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14251 pMac->roam.linkQualityIndInfo.context );
14252 //event: EVENT_WLAN_VCC
14253 }
14254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 pMac->roam.vccLinkQuality = newVccLinkQuality;
14256
Jeff Johnson295189b2012-06-20 16:38:30 -070014257}
Jeff Johnson295189b2012-06-20 16:38:30 -070014258VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14259 v_U8_t rssiNotification,
14260 void * context)
14261{
14262 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14263 eCsrRoamLinkQualityInd newVccLinkQuality;
14264 // TODO : Session info unavailable
14265 tANI_U32 sessionId = 0;
14266 VOS_STATUS status = VOS_STATUS_SUCCESS;
14267 /*-------------------------------------------------------------------------
14268 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 Check for a change in link quality and notify client if necessary
14270 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014271 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 pMac->roam.configParam.vccRssiThreshold);
14273 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014275 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 return VOS_STATUS_SUCCESS;
14277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014280 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14282 }
14283 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014285 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14287 }
14288 else
14289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014290 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 //Set to this so the code below won't do anything
14292 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014293 VOS_ASSERT(0);
14294 }
14295
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014298 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014299 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014301 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 /* we now invoke the callback once to notify client of initial value */
14304 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14305 pMac->roam.linkQualityIndInfo.context );
14306 //event: EVENT_WLAN_VCC
14307 }
14308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 return status;
14311}
Jeff Johnson295189b2012-06-20 16:38:30 -070014312tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14313 tDblLinkList *pStaList,
14314 tCsrStatsClientReqInfo *pStaEntry)
14315{
14316 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 //if same entity requested for same set of stats with different periodicity &
14319 // callback update it
14320 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14321 {
14322
14323 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14324 if (!HAL_STATUS_SUCCESS(status))
14325 {
14326 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014327 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 return NULL;
14329 }
14330
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 pNewStaEntry->callback = pStaEntry->callback;
14332 pNewStaEntry->pContext = pStaEntry->pContext;
14333 pNewStaEntry->periodicity = pStaEntry->periodicity;
14334 pNewStaEntry->requesterId = pStaEntry->requesterId;
14335 pNewStaEntry->statsMask = pStaEntry->statsMask;
14336 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14337 pNewStaEntry->pMac = pStaEntry->pMac;
14338 pNewStaEntry->staId = pStaEntry->staId;
14339 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14340
14341 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14342 }
14343 return pNewStaEntry;
14344}
14345
Jeff Johnson295189b2012-06-20 16:38:30 -070014346tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14347 tDblLinkList *pStaList,
14348 tCsrPeStatsReqInfo *pStaEntry)
14349{
14350 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14353 if (!HAL_STATUS_SUCCESS(status))
14354 {
14355 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014356 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 return NULL;
14358 }
14359
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14361 pNewStaEntry->numClient = pStaEntry->numClient;
14362 pNewStaEntry->periodicity = pStaEntry->periodicity;
14363 pNewStaEntry->statsMask = pStaEntry->statsMask;
14364 pNewStaEntry->pMac = pStaEntry->pMac;
14365 pNewStaEntry->staId = pStaEntry->staId;
14366 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14367 pNewStaEntry->rspPending = pStaEntry->rspPending;
14368
14369 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 return pNewStaEntry;
14371}
Jeff Johnson295189b2012-06-20 16:38:30 -070014372eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14373 tCsrRssiCallback callback,
14374 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14375{
14376 eHalStatus status = eHAL_STATUS_SUCCESS;
14377 vos_msg_t msg;
14378 tANI_U32 sessionId;
14379
14380 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014381 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14383 if ( !HAL_STATUS_SUCCESS(status) )
14384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014385 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 return status;
14387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14389
14390 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14391 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14392 pMsg->sessionId = sessionId;
14393 pMsg->staId = staId;
14394 pMsg->rssiCallback = callback;
14395 pMsg->pDevContext = pContext;
14396 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 msg.type = eWNI_SME_GET_RSSI_REQ;
14398 msg.bodyptr = pMsg;
14399 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014402 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 palFreeMemory(pMac->hHdd, (void *)pMsg);
14404 status = eHAL_STATUS_FAILURE;
14405 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014406 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014407 return status;
14408}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014409
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014410eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14411 tCsrSnrCallback callback,
14412 tANI_U8 staId, tCsrBssid bssId,
14413 void *pContext)
14414{
14415 eHalStatus status = eHAL_STATUS_SUCCESS;
14416 vos_msg_t msg;
14417 tANI_U32 sessionId;
14418
14419 tAniGetSnrReq *pMsg;
14420
14421 smsLog(pMac, LOG2, FL("called"));
14422
14423 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
14424 if (NULL == pMsg )
14425 {
14426 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
14427 return status;
14428 }
14429
14430 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14431
14432 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
14433 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
14434 pMsg->sessionId = sessionId;
14435 pMsg->staId = staId;
14436 pMsg->snrCallback = callback;
14437 pMsg->pDevContext = pContext;
14438 msg.type = eWNI_SME_GET_SNR_REQ;
14439 msg.bodyptr = pMsg;
14440 msg.reserved = 0;
14441
14442 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14443 {
14444 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
14445 vos_mem_free((v_VOID_t *)pMsg);
14446 status = eHAL_STATUS_FAILURE;
14447 }
14448
14449 smsLog(pMac, LOG2, FL("returned"));
14450 return status;
14451}
14452
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014453#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14454eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14455 tCsrRssiCallback callback,
14456 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14457{
14458 eHalStatus status = eHAL_STATUS_SUCCESS;
14459 tAniGetRssiReq *pMsg;
14460
14461 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14462 if ( !HAL_STATUS_SUCCESS(status) )
14463 {
14464 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14465 return status;
14466 }
14467 // need to initiate a stats request to PE
14468 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14469 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14470 pMsg->staId = staId;
14471 pMsg->rssiCallback = callback;
14472 pMsg->pDevContext = pContext;
14473 pMsg->pVosContext = pVosContext;
14474 status = palSendMBMessage(pMac->hHdd, pMsg );
14475 if(!HAL_STATUS_SUCCESS(status))
14476 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014477 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14478 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014479 status = eHAL_STATUS_FAILURE;
14480 }
14481 return status;
14482}
14483#endif
14484
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053014485/* ---------------------------------------------------------------------------
14486 \fn csrGetTLSTAState
14487 \helper function to get teh TL STA State whenever the function is called.
14488
14489 \param staId - The staID to be passed to the TL
14490 to get the relevant TL STA State
14491 \return the state as tANI_U16
14492 ---------------------------------------------------------------------------*/
14493tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
14494{
14495 WLANTL_STAStateType tlSTAState;
14496 tlSTAState = WLANTL_STA_INIT;
14497
14498 //request TL for STA State
14499 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
14500 {
14501 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
14502 }
14503
14504 return tlSTAState;
14505}
14506
Jeff Johnson295189b2012-06-20 16:38:30 -070014507eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14508 tANI_U32 statsMask,
14509 tCsrStatsCallback callback,
14510 tANI_U32 periodicity, tANI_BOOLEAN cache,
14511 tANI_U8 staId, void *pContext)
14512{
14513 tCsrStatsClientReqInfo staEntry;
14514 tCsrStatsClientReqInfo *pStaEntry = NULL;
14515 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14516 tListElem *pEntry = NULL;
14517 tANI_BOOLEAN found = FALSE;
14518 eHalStatus status = eHAL_STATUS_SUCCESS;
14519 tANI_BOOLEAN insertInClientList = FALSE;
14520 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014521 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014522
14523 if( csrIsAllSessionDisconnected(pMac) )
14524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014525 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 return eHAL_STATUS_FAILURE;
14527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 if((!statsMask) && (!callback))
14529 {
14530 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014531 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 return eHAL_STATUS_FAILURE;
14533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014534 //for the search list method for deregister
14535 staEntry.requesterId = requesterId;
14536 staEntry.statsMask = statsMask;
14537 //requester wants to deregister or just an error
14538 if((statsMask) && (!callback))
14539 {
14540 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14541 if(!pEntry)
14542 {
14543 //msg
14544 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014545 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014546 return eHAL_STATUS_FAILURE;
14547 }
14548 else
14549 {
14550 //clean up & return
14551 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014552 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014553 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014554 pStaEntry->pPeStaEntry->numClient--;
14555 //check if we need to delete the entry from peStatsReqList too
14556 if(!pStaEntry->pPeStaEntry->numClient)
14557 {
14558 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014561
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 //check if we need to stop the tl stats timer too
14563 pMac->roam.tlStatsReqInfo.numClient--;
14564 if(!pMac->roam.tlStatsReqInfo.numClient)
14565 {
14566 if(pMac->roam.tlStatsReqInfo.timerRunning)
14567 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014568 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14569 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014571 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 return eHAL_STATUS_FAILURE;
14573 }
14574 }
14575 pMac->roam.tlStatsReqInfo.periodicity = 0;
14576 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14577 }
14578 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 // Destroy the vos timer...
14580 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14581 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014583 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 csrRoamRemoveStatListEntry(pMac, pEntry);
14586 pStaEntry = NULL;
14587 return eHAL_STATUS_SUCCESS;
14588 }
14589 }
14590
14591 if(cache && !periodicity)
14592 {
14593 //return the cached stats
14594 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14595 }
14596 else
14597 {
14598 //add the request in the client req list
14599 staEntry.callback = callback;
14600 staEntry.pContext = pContext;
14601 staEntry.periodicity = periodicity;
14602 staEntry.pPeStaEntry = NULL;
14603 staEntry.staId = staId;
14604 staEntry.pMac = pMac;
14605 staEntry.timerExpired = FALSE;
14606
14607
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 //if periodic report requested with non cached result from PE/TL
14609 if(periodicity)
14610 {
14611
14612 //if looking for stats from PE
14613 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14614 {
14615
14616 //check if same request made already & waiting for rsp
14617 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14618 periodicity, &found, staId);
14619 if(!pPeStaEntry)
14620 {
14621 //bail out, maxed out on number of req for PE
14622 return eHAL_STATUS_FAILURE;
14623 }
14624 else
14625 {
14626 staEntry.pPeStaEntry = pPeStaEntry;
14627 }
14628
14629 }
14630 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14631 if(statsMask & (1 << eCsrGlobalClassDStats))
14632 {
14633 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014635 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 }
14637 else
14638 {
14639
14640 //update periodicity
14641 if(pMac->roam.tlStatsReqInfo.periodicity)
14642 {
14643 pMac->roam.tlStatsReqInfo.periodicity =
14644 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14645 }
14646 else
14647 {
14648 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14649 }
14650 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14651 {
14652 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14653 }
14654
14655 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14656 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014657 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14658 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014659 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014660 //req TL for class D stats
14661 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014663 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014664 }
14665 else
14666 {
14667 //save in SME
14668 csrRoamSaveStatsFromTl(pMac, pTlStats);
14669 }
14670 vos_mem_free(pTlStats);
14671 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014672 }
14673 else
14674 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014675 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014677
Jeff Johnson295189b2012-06-20 16:38:30 -070014678 if(pMac->roam.tlStatsReqInfo.periodicity)
14679 {
14680 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014681 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14682 pMac->roam.tlStatsReqInfo.periodicity);
14683 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014685 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 return eHAL_STATUS_FAILURE;
14687 }
14688 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14689 }
14690 }
14691 }
14692 pMac->roam.tlStatsReqInfo.numClient++;
14693 }
14694
14695 insertInClientList = TRUE;
14696 }
14697 //if one time report requested with non cached result from PE/TL
14698 else if(!cache && !periodicity)
14699 {
14700 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14701 {
14702 //send down a req
14703 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14704 if(!HAL_STATUS_SUCCESS(status))
14705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014706 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 }
14708 //so that when the stats rsp comes back from PE we respond to upper layer
14709 //right away
14710 staEntry.timerExpired = TRUE;
14711 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 }
14713 if(statsMask & (1 << eCsrGlobalClassDStats))
14714 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014715 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14716 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014718 //req TL for class D stats
14719 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014721 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014722 }
14723 else
14724 {
14725 //save in SME
14726 csrRoamSaveStatsFromTl(pMac, pTlStats);
14727 }
14728 vos_mem_free(pTlStats);
14729 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 }
14731 else
14732 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014733 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014735
14736 }
14737 //if looking for stats from TL only
14738 if(!insertInClientList)
14739 {
14740 //return the stats
14741 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 if(insertInClientList)
14745 {
14746 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14747 if(!pStaEntry)
14748 {
14749 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014750 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 return eHAL_STATUS_FAILURE;
14752 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014753 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 //Init & start timer if needed
14755 if(periodicity)
14756 {
14757 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14758 csrRoamStatsClientTimerHandler, pStaEntry );
14759 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014761 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 return eHAL_STATUS_FAILURE;
14763 }
14764 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14765 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014767 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 return eHAL_STATUS_FAILURE;
14769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 }
14773 return eHAL_STATUS_SUCCESS;
14774}
14775
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014776#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14777
14778static tSirRetStatus
14779csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14780 tANI_U8* pBD,
14781 tANI_U8 type,
14782 tANI_U8 subType,
14783 tSirMacAddr peerAddr,
14784 tSirMacAddr selfMacAddr)
14785{
14786 tSirRetStatus statusCode = eSIR_SUCCESS;
14787 tpSirMacMgmtHdr pMacHdr;
14788
14789 /* Prepare MAC management header */
14790 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14791
14792 /* Prepare FC */
14793 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14794 pMacHdr->fc.type = type;
14795 pMacHdr->fc.subType = subType;
14796
14797 /* Prepare Address 1 */
14798 palCopyMemory( pMac->hHdd,
14799 (tANI_U8 *) pMacHdr->da,
14800 (tANI_U8 *) peerAddr,
14801 sizeof( tSirMacAddr ));
14802
14803 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14804
14805 /* Prepare Address 3 */
14806 palCopyMemory( pMac->hHdd,
14807 (tANI_U8 *) pMacHdr->bssId,
14808 (tANI_U8 *) peerAddr,
14809 sizeof( tSirMacAddr ));
14810 return statusCode;
14811} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14812
14813static tSirRetStatus
14814csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14815 tANI_U8 nChannelNum,
14816 tANI_U32 dot11mode,
14817 tSirMacAddr selfMacAddr,
14818 tANI_U8 *pFrame,
14819 tANI_U16 *pusLen)
14820{
14821 tDot11fProbeRequest pr;
14822 tANI_U32 nStatus, nBytes, nPayload;
14823 tSirRetStatus nSirStatus;
14824 /*Bcast tx*/
14825 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14826 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14827
14828
14829 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14830
14831 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14832
14833 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14834 {
14835 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14836 }
14837
14838
14839 if (IS_DOT11_MODE_HT(dot11mode))
14840 {
14841 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14842 }
14843
14844
14845 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14846 if ( DOT11F_FAILED( nStatus ) )
14847 {
14848 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14849 "Failed to calculate the packed size f"
14850 "or a Probe Request (0x%08x).\n", nStatus );
14851
14852
14853 nPayload = sizeof( tDot11fProbeRequest );
14854 }
14855 else if ( DOT11F_WARNED( nStatus ) )
14856 {
14857 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14858 "There were warnings while calculating"
14859 "the packed size for a Probe Request ("
14860 "0x%08x).\n", nStatus );
14861 }
14862
14863 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14864
14865 /* Prepare outgoing frame*/
14866 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14867
14868
14869 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014870 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014871
14872 if ( eSIR_SUCCESS != nSirStatus )
14873 {
14874 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14875 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14876 nSirStatus );
14877 return nSirStatus;
14878 }
14879
14880
14881 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14882 sizeof( tSirMacMgmtHdr ),
14883 nPayload, &nPayload );
14884 if ( DOT11F_FAILED( nStatus ) )
14885 {
14886 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14887 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14888 return eSIR_FAILURE;
14889 }
14890 else if ( DOT11F_WARNED( nStatus ) )
14891 {
14892 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14893 "There were warnings while packing a Probe Request (0x%08x).\n" );
14894 }
14895
14896 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14897 return eSIR_SUCCESS;
14898}
14899
14900eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14901{
14902 vos_msg_t msg;
14903 tSirRoamOffloadScanReq *pRequestBuf;
14904 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14905 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070014906 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014907 tANI_U8 *ChannelList = NULL;
14908 tANI_U32 sessionId;
14909 eHalStatus status = eHAL_STATUS_SUCCESS;
14910 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070014911 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070014912 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014913 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14914
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070014915 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014916 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014917 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014918 return eHAL_STATUS_FAILURE;
14919 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070014920
14921 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
14922 {
14923 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
14924 return eHAL_STATUS_FAILURE;
14925 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014926 status = csrRoamGetSessionIdFromBSSID(pMac,
14927 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14928 &sessionId);
14929 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14930 * It is important to ensure that the command is passed down to the FW only
14931 * if the Infra Station is in a connected state.A connected station could also be
14932 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14933 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14934 * irrespective of whichever state we are in.*/
14935 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14936 (command != ROAM_SCAN_OFFLOAD_STOP))
14937 {
14938 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14939 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14940 return eHAL_STATUS_FAILURE;
14941 }
14942
14943 if ( !HAL_STATUS_SUCCESS( status ) )
14944 {
14945 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14946 return eHAL_STATUS_FAILURE;
14947 }
14948 pSession = CSR_GET_SESSION( pMac, sessionId );
14949 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14950 if (NULL == pRequestBuf)
14951 {
14952 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14953 return eHAL_STATUS_FAILED_ALLOC;
14954 }
14955
14956 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14957 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14958 * host driver reloads, but Riva still up and running*/
14959 if(command == ROAM_SCAN_OFFLOAD_STOP)
14960 pRequestBuf->RoamScanOffloadEnabled = 0;
14961 else
14962 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14963 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14964 sizeof(tCsrBssid));
14965 pRequestBuf->ConnectedNetwork.ssId.length =
14966 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14967 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14968 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14969 pRequestBuf->ConnectedNetwork.ssId.length);
14970 pRequestBuf->ConnectedNetwork.authentication =
14971 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14972 pRequestBuf->ConnectedNetwork.encryption =
14973 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14974 pRequestBuf->ConnectedNetwork.mcencryption =
14975 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14976 pRequestBuf->LookupThreshold =
14977 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14978 pRequestBuf->RoamRssiDiff =
14979 pMac->roam.configParam.RoamRssiDiff;
14980 pRequestBuf->Command = command;
14981 pRequestBuf->StartScanReason = reason;
14982 pRequestBuf->NeighborScanTimerPeriod =
14983 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14984 pRequestBuf->NeighborRoamScanRefreshPeriod =
14985 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14986 pRequestBuf->NeighborScanChannelMinTime =
14987 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14988 pRequestBuf->NeighborScanChannelMaxTime =
14989 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14990 pRequestBuf->EmptyRefreshScanPeriod =
14991 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14992#ifdef FEATURE_WLAN_CCX
14993 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14994#endif
14995 if (
14996#ifdef FEATURE_WLAN_CCX
14997 ((pNeighborRoamInfo->isCCXAssoc) &&
14998 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14999 eANI_BOOLEAN_FALSE)) ||
15000 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15001#endif // CCX
15002 currChannelListInfo->numOfChannels == 0)
15003 {
15004
15005 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
15006 * Give Preference to INI Channels.*/
15007 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15008 {
15009 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15010 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
15011 {
15012 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15013 {
15014 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15015 }
15016 ChannelList++;
15017 }
15018 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15019 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15020 }
15021 else{
15022 ChannelList = pMac->scan.occupiedChannels.channelList;
15023 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15024 {
15025 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15026 {
15027 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15028 }
15029 ChannelList++;
15030 }
15031 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15032 /* If the profile changes as to what it was earlier, inform the FW through
15033 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15034 * for the earlier profile and try to learn them afresh.*/
15035 if (reason == REASON_FLUSH_CHANNEL_LIST)
15036 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15037 else {
15038 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15039 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15040 else
15041 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15042 }
15043 }
15044 }
15045#ifdef FEATURE_WLAN_CCX
15046 else
15047 {
15048 /* If CCX is enabled, and a neighbor Report is received,then
15049 * Ignore the INI Channels or the Occupied Channel List. Consider
15050 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015051 if (currChannelListInfo->numOfChannels != 0)
15052 {
15053 ChannelList = currChannelListInfo->ChannelList;
15054 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015055 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015056 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15057 {
15058 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15059 }
15060 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015061 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015062 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15063 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15064 }
15065 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015066#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015067 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15068 {
15069 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15070 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15071 }
15072 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15073 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15074 pRequestBuf->ChannelCacheType,
15075 pRequestBuf->ConnectedNetwork.ChannelCount,
15076 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015077 num_channels = 0;
15078 ChannelList = NULL;
15079
15080 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015081 host_channels = sizeof(pMac->roam.validChannelList);
15082 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015083 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015084 ChannelList = pMac->roam.validChannelList;
15085 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015086 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015087 else
15088 {
15089 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15090 "%s:Failed to get the valid channel list", __func__);
15091 return eHAL_STATUS_FAILURE;
15092 }
15093 for(i=0; i<pMac->roam.numValidChannels; i++)
15094 {
15095 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15096 {
15097 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15098 }
15099 ChannelList++;
15100 }
15101 pRequestBuf->ValidChannelCount = num_channels;
15102
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015103 pRequestBuf->MDID.mdiePresent =
15104 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15105 pRequestBuf->MDID.mobilityDomain =
15106 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015107 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15108
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015109 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015110
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015111 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15112 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15113 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15114 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15115 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15116
15117 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15118 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015119 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015120 msg.reserved = 0;
15121 msg.bodyptr = pRequestBuf;
15122 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15123 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15125 vos_mem_free(pRequestBuf);
15126 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015127 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015128 else
15129 {
15130 if (ROAM_SCAN_OFFLOAD_START == command)
15131 bRoamScanOffloadStarted = VOS_TRUE;
15132 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15133 bRoamScanOffloadStarted = VOS_FALSE;
15134 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015135
15136 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15137 return status;
15138}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015139
15140eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15141{
15142 switch(reason)
15143 {
15144 case 0:
15145 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15146 break;
15147 case REASON_OS_REQUESTED_ROAMING_NOW:
15148 csrNeighborRoamProceedWithHandoffReq(pMac);
15149 break;
15150 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015151 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 -070015152 }
15153 return eHAL_STATUS_SUCCESS;
15154}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015155#endif
15156
Jeff Johnson295189b2012-06-20 16:38:30 -070015157tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15158 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15159{
15160 tANI_BOOLEAN found = FALSE;
15161 eHalStatus status = eHAL_STATUS_SUCCESS;
15162 tCsrPeStatsReqInfo staEntry;
15163 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15164 tListElem *pStaEntry = NULL;
15165 VOS_STATUS vosStatus;
15166 tPmcPowerState powerState;
15167 *pFound = FALSE;
15168
15169 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15170 if(pStaEntry)
15171 {
15172 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15173 if(pTempStaEntry->periodicity)
15174 {
15175 pTempStaEntry->periodicity =
15176 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15177 }
15178 else
15179 {
15180 pTempStaEntry->periodicity = periodicity;
15181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 pTempStaEntry->numClient++;
15183 found = TRUE;
15184 }
15185 else
15186 {
15187 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
15188 staEntry.numClient = 1;
15189 staEntry.periodicity = periodicity;
15190 staEntry.pMac = pMac;
15191 staEntry.rspPending = FALSE;
15192 staEntry.staId = staId;
15193 staEntry.statsMask = statsMask;
15194 staEntry.timerRunning = FALSE;
15195 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15196 if(!pTempStaEntry)
15197 {
15198 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015199 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015200 return NULL;
15201 }
15202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015203 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15204 if(ePMC_FULL_POWER == powerState)
15205 {
15206 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15207 {
15208 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15209 }
15210 }
15211 else
15212 {
15213 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15214 {
15215 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15216 }
15217 }
15218 if(!pTempStaEntry->timerRunning)
15219 {
15220 //send down a req in case of one time req, for periodic ones wait for timer to expire
15221 if(!pTempStaEntry->rspPending &&
15222 !pTempStaEntry->periodicity)
15223 {
15224 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15225 if(!HAL_STATUS_SUCCESS(status))
15226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015227 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 }
15229 else
15230 {
15231 pTempStaEntry->rspPending = TRUE;
15232 }
15233 }
15234 if(pTempStaEntry->periodicity)
15235 {
15236 if(!found)
15237 {
15238
15239 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15240 csrRoamPeStatsTimerHandler, pTempStaEntry );
15241 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015243 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 return NULL;
15245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 }
15247 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015248 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015249 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15250 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015252 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 return NULL;
15254 }
15255 pTempStaEntry->timerRunning = TRUE;
15256 }
15257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015258 *pFound = found;
15259 return pTempStaEntry;
15260}
15261
Jeff Johnson295189b2012-06-20 16:38:30 -070015262/*
15263 pStaEntry is no longer invalid upon the return of this function.
15264*/
15265static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15266{
15267 if(pEntry)
15268 {
15269 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15270 {
15271 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015272 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015273 }
15274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015275
15276void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15277{
15278 tListElem *pEntry;
15279 tCsrPeStatsReqInfo *pTempStaEntry;
15280 VOS_STATUS vosStatus;
15281 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015282 if(!pEntry)
15283 {
15284 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015285 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 return;
15287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 while( pEntry )
15289 {
15290 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015293 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 if(pTempStaEntry->timerRunning)
15295 {
15296 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15297 /* If we are not able to stop the timer here, just remove
15298 * the entry from the linked list. Destroy the timer object
15299 * and free the memory in the timer CB
15300 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015301 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 {
15303 /* the timer is successfully stopped */
15304 pTempStaEntry->timerRunning = FALSE;
15305
15306 /* Destroy the timer */
15307 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15308 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015310 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 }
15312 }
15313 else
15314 {
15315 // the timer could not be stopped. Hence destroy and free the
15316 // memory for the PE stat entry in the timer CB.
15317 pTempStaEntry->timerStopFailed = TRUE;
15318 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015320
15321 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15322 {
15323 // Only free the memory if we could stop the timer successfully
15324 if(!pTempStaEntry->timerStopFailed)
15325 {
15326 palFreeMemory(pMac->hHdd, pTempStaEntry);
15327 pTempStaEntry = NULL;
15328 }
15329 break;
15330 }
15331
15332 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15333 }
15334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 return;
15336}
15337
15338
Jeff Johnsone7245742012-09-05 17:12:55 -070015339void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015340{
15341
Jeff Johnsone7245742012-09-05 17:12:55 -070015342 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15343 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15344 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15345 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15346 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15347 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15348 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015350 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15351 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15352 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15353 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15354 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15355 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015357 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15358 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015359
15360}
15361
Jeff Johnson295189b2012-06-20 16:38:30 -070015362void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15363 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15364{
15365 tANI_U8 stats[500];
15366 tANI_U8 *pStats = NULL;
15367 tANI_U32 tempMask = 0;
15368 tANI_U8 counter = 0;
15369 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 if(!callback)
15371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015372 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 return;
15374 }
15375 if(!statsMask)
15376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015377 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 return;
15379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015381 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 while(tempMask)
15383 {
15384 if(tempMask & 1)
15385 {
15386 //new stats info from PE, fill up the stats strucutres in PMAC
15387 switch(counter)
15388 {
15389 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015390 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15392 sizeof(tCsrSummaryStatsInfo));
15393 if(!HAL_STATUS_SUCCESS(status))
15394 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015395 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 }
15397 pStats += sizeof(tCsrSummaryStatsInfo);
15398 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015400 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15402 sizeof(tCsrGlobalClassAStatsInfo));
15403 if(!HAL_STATUS_SUCCESS(status))
15404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015405 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 }
15407 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015410 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15412 sizeof(tCsrGlobalClassBStatsInfo));
15413 if(!HAL_STATUS_SUCCESS(status))
15414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015415 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015416 }
15417 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015420 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15422 sizeof(tCsrGlobalClassCStatsInfo));
15423 if(!HAL_STATUS_SUCCESS(status))
15424 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015425 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 }
15427 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015430 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15432 sizeof(tCsrGlobalClassDStatsInfo));
15433 if(!HAL_STATUS_SUCCESS(status))
15434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015435 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 }
15437 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015439 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015440 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15442 sizeof(tCsrPerStaStatsInfo));
15443 if(!HAL_STATUS_SUCCESS(status))
15444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015445 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 }
15447 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015448 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015450 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015452 }
15453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 tempMask >>=1;
15455 counter++;
15456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015458}
15459
Jeff Johnson295189b2012-06-20 16:38:30 -070015460eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15461{
15462 tListElem *pEntry = NULL;
15463 tListElem *pPrevEntry = NULL;
15464 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15465 eHalStatus status = eHAL_STATUS_SUCCESS;
15466 VOS_STATUS vosStatus;
15467 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015468 if(!pEntry)
15469 {
15470 //list empty
15471 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015472 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015473 return status;
15474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015475 while( pEntry )
15476 {
15477 if(pPrevEntry)
15478 {
15479 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15480 //send up the stats report
15481 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15482 pTempStaEntry->staId, pTempStaEntry->pContext);
15483 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15487 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015488 pTempStaEntry->pPeStaEntry->numClient--;
15489 //check if we need to delete the entry from peStatsReqList too
15490 if(!pTempStaEntry->pPeStaEntry->numClient)
15491 {
15492 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 //check if we need to stop the tl stats timer too
15496 pMac->roam.tlStatsReqInfo.numClient--;
15497 if(!pMac->roam.tlStatsReqInfo.numClient)
15498 {
15499 if(pMac->roam.tlStatsReqInfo.timerRunning)
15500 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015501 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15502 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015504 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 //we will continue
15506 }
15507 }
15508 pMac->roam.tlStatsReqInfo.periodicity = 0;
15509 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 if (pTempStaEntry->periodicity)
15512 {
15513 //While creating StaEntry in csrGetStatistics,
15514 //Initializing and starting timer only when periodicity is set.
15515 //So Stop and Destroy timer only when periodicity is set.
15516
Jeff Johnsone7245742012-09-05 17:12:55 -070015517 vos_timer_stop( &pTempStaEntry->timer );
15518 // Destroy the vos timer...
15519 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15520 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015522 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015524 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015525
Jeff Johnson295189b2012-06-20 16:38:30 -070015526
15527 pPrevEntry = pEntry;
15528 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15529 }
15530 //the last one
15531 if(pPrevEntry)
15532 {
15533 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15534 //send up the stats report
15535 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15536 pTempStaEntry->staId, pTempStaEntry->pContext);
15537 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 return status;
15540
15541}
15542
Jeff Johnson295189b2012-06-20 16:38:30 -070015543eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15544 tRequestFullPowerReason *pReason,
15545 tANI_BOOLEAN *pfNeedPower )
15546{
15547 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15548 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15549 tPmcState pmcState;
15550 eHalStatus status = eHAL_STATUS_SUCCESS;
15551 // TODO : Session info unavailable
15552 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 if( pfNeedPower )
15554 {
15555 *pfNeedPower = eANI_BOOLEAN_FALSE;
15556 }
15557 //We only handle CSR commands
15558 if( !(eSmeCsrCommandMask & pCommand->command) )
15559 {
15560 return eHAL_STATUS_SUCCESS;
15561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015562 //Check PMC state first
15563 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 switch( pmcState )
15565 {
15566 case REQUEST_IMPS:
15567 case IMPS:
15568 if( eSmeCommandScan == pCommand->command )
15569 {
15570 switch( pCommand->u.scanCmd.reason )
15571 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015572#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15573 case eCsrScanGetLfrResult:
15574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015575 case eCsrScanGetResult:
15576 case eCsrScanBGScanAbort:
15577 case eCsrScanBGScanEnable:
15578 case eCsrScanGetScanChnInfo:
15579 //Internal process, no need for full power
15580 fNeedFullPower = eANI_BOOLEAN_FALSE;
15581 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 default:
15583 //Other scans are real scan, ask for power
15584 fNeedFullPower = eANI_BOOLEAN_TRUE;
15585 break;
15586 } //switch
15587 }
15588 else
15589 {
15590 //ask for power for roam and status change
15591 fNeedFullPower = eANI_BOOLEAN_TRUE;
15592 }
15593 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015594 case REQUEST_BMPS:
15595 case BMPS:
15596 case REQUEST_START_UAPSD:
15597 case UAPSD:
15598 //We treat WOWL same as BMPS
15599 case REQUEST_ENTER_WOWL:
15600 case WOWL:
15601 if( eSmeCommandRoam == pCommand->command )
15602 {
15603 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15604 tCsrScanResult *pScanResult;
15605 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 switch ( pCommand->u.roamCmd.roamReason )
15607 {
15608 case eCsrForcedDisassoc:
15609 case eCsrForcedDisassocMICFailure:
15610 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15611 fNeedFullPower = eANI_BOOLEAN_TRUE;
15612 break;
15613 case eCsrSmeIssuedDisassocForHandoff:
15614 case eCsrForcedDeauth:
15615 case eCsrHddIssuedReassocToSameAP:
15616 case eCsrSmeIssuedReassocToSameAP:
15617 fNeedFullPower = eANI_BOOLEAN_TRUE;
15618 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 case eCsrCapsChange:
15620 fNeedFullPower = eANI_BOOLEAN_TRUE;
15621 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 default:
15623 //Check whether the profile is already connected. If so, no need for full power
15624 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15625 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15626 {
15627 //Only need to check the first one
15628 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15629 if( pEntry )
15630 {
15631 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15632#if 0
15633 // TODO : Session Specific info pConnectBssDesc
15634 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15635 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15636 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15637 {
15638 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15639 // with Authenticating first. To force this, stop the current association (Disassociate) and
15640 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15641 // a new Association.
15642 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15643 {
15644 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15645 {
15646 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15647 //No need for full power
15648 //Set the flag so the code later can avoid to do the above
15649 //check again.
15650 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15651 break;
15652 }
15653 }
15654 }
15655#endif
15656 }
15657 }
15658 //If we are here, full power is needed
15659 fNeedFullPower = eANI_BOOLEAN_TRUE;
15660 break;
15661 }
15662 }
15663 else if( eSmeCommandWmStatusChange == pCommand->command )
15664 {
15665 //need full power for all
15666 fNeedFullPower = eANI_BOOLEAN_TRUE;
15667 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15668 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015669#ifdef FEATURE_WLAN_TDLS
15670 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15671 {
15672 //TDLS link is getting established. need full power
15673 fNeedFullPower = eANI_BOOLEAN_TRUE;
15674 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15675 }
15676#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 case REQUEST_STOP_UAPSD:
15679 case REQUEST_EXIT_WOWL:
15680 if( eSmeCommandRoam == pCommand->command )
15681 {
15682 fNeedFullPower = eANI_BOOLEAN_TRUE;
15683 switch ( pCommand->u.roamCmd.roamReason )
15684 {
15685 case eCsrForcedDisassoc:
15686 case eCsrForcedDisassocMICFailure:
15687 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15688 break;
15689 default:
15690 break;
15691 }
15692 }
15693 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015694 case STOPPED:
15695 case REQUEST_STANDBY:
15696 case STANDBY:
15697 case LOW_POWER:
15698 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015699 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 status = eHAL_STATUS_FAILURE;
15701 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015702 case FULL_POWER:
15703 case REQUEST_FULL_POWER:
15704 default:
15705 //No need to ask for full power. This has to be FULL_POWER state
15706 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015707 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015708 if( pReason )
15709 {
15710 *pReason = reason;
15711 }
15712 if( pfNeedPower )
15713 {
15714 *pfNeedPower = fNeedFullPower;
15715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015716 return ( status );
15717}
15718
Jeff Johnson295189b2012-06-20 16:38:30 -070015719static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15720{
15721 eHalStatus status = eHAL_STATUS_SUCCESS;
15722 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15723 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015724 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015725 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15726 {
15727 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015729 return ( status );
15730}
15731
Jeff Johnson295189b2012-06-20 16:38:30 -070015732tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15733{
15734 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015735 if( pCmd )
15736 {
15737 pMac->roam.sPendingCommands++;
15738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015739 return ( pCmd );
15740}
15741
Jeff Johnson295189b2012-06-20 16:38:30 -070015742void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15743{
15744 if (pMac->roam.sPendingCommands > 0)
15745 {
15746 //All command allocated through csrGetCommandBuffer need to
15747 //decrement the pending count when releasing.
15748 pMac->roam.sPendingCommands--;
15749 smeReleaseCommand( pMac, pCommand );
15750 }
15751 else
15752 {
15753 smsLog(pMac, LOGE, FL( "no pending commands"));
15754 VOS_ASSERT(0);
15755 }
15756}
15757
Jeff Johnson295189b2012-06-20 16:38:30 -070015758//Return SUCCESS is the command is queued, failed
15759eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15760{
15761 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015762 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15763 {
15764 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15765 pCommand->u.scanCmd.reason);
15766 return eHAL_STATUS_CSR_WRONG_STATE;
15767 }
15768
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015769 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
15770 {
15771 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
15772 &pCommand->Link, LL_ACCESS_LOCK);
15773 // process the command queue...
15774 smeProcessPendingQueue(pMac);
15775 status = eHAL_STATUS_SUCCESS;
15776 goto end;
15777 }
15778
Jeff Johnson295189b2012-06-20 16:38:30 -070015779 //We can call request full power first before putting the command into pending Q
15780 //because we are holding SME lock at this point.
15781 status = csrRequestFullPower( pMac, pCommand );
15782 if( HAL_STATUS_SUCCESS( status ) )
15783 {
15784 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015785 //make sure roamCmdPendingList is not empty first
15786 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15787 if( fNoCmdPending )
15788 {
15789 smePushCommand( pMac, pCommand, fHighPriority );
15790 }
15791 else
15792 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015793 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070015794 //no list lock is needed since SME lock is held
15795 if( !fHighPriority )
15796 {
15797 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15798 }
15799 else {
15800 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15801 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015803 }
15804 else if( eHAL_STATUS_PMC_PENDING == status )
15805 {
15806 //no list lock is needed since SME lock is held
15807 if( !fHighPriority )
15808 {
15809 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15810 }
15811 else {
15812 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15813 }
15814 //Let caller know the command is queue
15815 status = eHAL_STATUS_SUCCESS;
15816 }
15817 else
15818 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015819 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070015820 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015821 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015822 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053015823end:
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015825}
Jeff Johnson295189b2012-06-20 16:38:30 -070015826eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15827{
15828 eHalStatus status = eHAL_STATUS_SUCCESS;
15829 tSirUpdateAPWPSIEsReq *pMsg;
15830 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15831
15832 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15833 if (NULL == pSession)
15834 {
15835 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15836 return eHAL_STATUS_FAILURE;
15837 }
15838
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 do
15840 {
15841 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15842 if (!HAL_STATUS_SUCCESS(status)) break;
15843 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15844 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15845
15846 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070015847 VOS_ASSERT(pBuf);
15848
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015850 // transactionId
15851 *pBuf = 0;
15852 *( pBuf + 1 ) = 0;
15853 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015854 // bssId
15855 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15856 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015857 //sessionId
15858 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 // APWPSIEs
15860 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15861 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015862 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015865 return ( status );
15866}
Jeff Johnson295189b2012-06-20 16:38:30 -070015867eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15868{
15869 eHalStatus status = eHAL_STATUS_SUCCESS;
15870 tSirUpdateAPWPARSNIEsReq *pMsg;
15871 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015872 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15873 if (NULL == pSession)
15874 {
15875 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15876 return eHAL_STATUS_FAILURE;
15877 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 do
15879 {
15880 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15881 if (!HAL_STATUS_SUCCESS(status)) break;
15882 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15883 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015884 pBuf = (tANI_U8 *)&pMsg->transactionId;
15885 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015886 // transactionId
15887 *pBuf = 0;
15888 *( pBuf + 1 ) = 0;
15889 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070015890 VOS_ASSERT(pBuf);
15891
Jeff Johnson295189b2012-06-20 16:38:30 -070015892 // bssId
15893 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15894 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 // sessionId
15896 *pBuf++ = (tANI_U8)sessionId;
15897
15898 // APWPARSNIEs
15899 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15900 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015901 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015903 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 return ( status );
15905}
Jeff Johnson295189b2012-06-20 16:38:30 -070015906
15907#ifdef WLAN_FEATURE_VOWIFI_11R
15908//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15909eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15910{
15911 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15912 tpSirFTPreAuthReq pftPreAuthReq;
15913 tANI_U16 auth_req_len = 0;
15914 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015915 auth_req_len = sizeof(tSirFTPreAuthReq);
15916 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15917 if (pftPreAuthReq == NULL)
15918 {
15919 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15920 return eHAL_STATUS_RESOURCES;
15921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015922 // Save the SME Session ID here. We need it while processing the preauth response
15923 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015924 vos_mem_zero(pftPreAuthReq, auth_req_len);
15925
15926 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15927 sizeof(pBssDescription->length) + pBssDescription->length);
15928
15929 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15930
15931 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15932
Jeff Johnson295189b2012-06-20 16:38:30 -070015933 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015934 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15935
Jeff Johnson295189b2012-06-20 16:38:30 -070015936#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015937 if (csrRoamIs11rAssoc(pMac) &&
15938 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 {
15940 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15941 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15942 pMac->ft.ftSmeContext.auth_ft_ies_length);
15943 }
15944 else
15945#endif
15946 {
15947 pftPreAuthReq->ft_ies_length = 0;
15948 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015949 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15950 sizeof(pBssDescription->length) + pBssDescription->length);
15951 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015952 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15953}
Jeff Johnson295189b2012-06-20 16:38:30 -070015954/*--------------------------------------------------------------------------
15955 * This will receive and process the FT Pre Auth Rsp from the current
15956 * associated ap.
15957 *
15958 * This will invoke the hdd call back. This is so that hdd can now
15959 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15960 ------------------------------------------------------------------------*/
15961void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15962{
15963 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15964 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015965#ifdef FEATURE_WLAN_LFR
15966 tCsrRoamInfo roamInfo;
15967#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015968
15969#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015970 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015971#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015972#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015973 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015974 if (status != eHAL_STATUS_SUCCESS) {
15975 /*
15976 * Bail out if pre-auth was not even processed.
15977 */
15978 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15979 return;
15980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015981#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015982 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15983 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15984 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015985 // Implies a success
15986 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015987 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15988 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070015989 /* No need to notify qos module if this is a non 11r roam*/
15990 if (csrRoamIs11rAssoc(pMac))
15991 {
15992 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15993 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015994 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15995 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015996 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15997 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 if (eHAL_STATUS_SUCCESS != status)
15999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016000 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 return;
16002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016003 // Save the received response
16004 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16005 if (csrRoamIs11rAssoc(pMac))
16006 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16007 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16008
16009 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016010#ifdef FEATURE_WLAN_LFR
16011 // If Legacy Fast Roaming is enabled, signal the supplicant
16012 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016013 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016014 {
16015 // Save the bssid from the received response
16016 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16017 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16018 }
16019
16020#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016021
16022 // Done with it, init it.
16023 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16024}
16025#endif
16026#ifdef FEATURE_WLAN_BTAMP_UT_RF
16027void csrRoamJoinRetryTimerHandler(void *pv)
16028{
16029 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16030 tpAniSirGlobal pMac = pInfo->pMac;
16031 tANI_U32 sessionId = pInfo->sessionId;
16032 tCsrRoamSession *pSession;
16033
16034 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016036 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016037 pSession = CSR_GET_SESSION( pMac, sessionId );
16038 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16039 {
16040 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016042 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016043 }
16044 }
16045 }
16046}
Jeff Johnson295189b2012-06-20 16:38:30 -070016047eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16048{
16049 eHalStatus status = eHAL_STATUS_FAILURE;
16050 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16051
16052 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16053 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016054 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016055 pSession->maxRetryCount--;
16056 pSession->joinRetryTimerInfo.pMac = pMac;
16057 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016058 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16059 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016061 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016062 }
16063 }
16064 else
16065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016066 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016067 pSession->maxRetryCount);
16068 }
16069
16070 return (status);
16071}
Jeff Johnson295189b2012-06-20 16:38:30 -070016072eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16073{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016074 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016075 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16076 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016077 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016078 }
16079
16080 return eHAL_STATUS_SUCCESS;
16081}
16082#endif
16083
16084
16085/*
16086 pBuf points to the beginning of the message
16087 LIM packs disassoc rsp as below,
16088 messageType - 2 bytes
16089 messageLength - 2 bytes
16090 sessionId - 1 byte
16091 transactionId - 2 bytes (tANI_U16)
16092 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16093 peerMacAddr - 6 bytes
16094 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16095*/
16096static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16097{
16098 if(pBuf && pRsp)
16099 {
16100 pBuf += 4; //skip type and length
16101 pRsp->sessionId = *pBuf++;
16102 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16103 pBuf += 2;
16104 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16105 pBuf += 4;
16106 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16107 }
16108}
16109
Jeff Johnsond13512a2012-07-17 11:42:19 -070016110eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16111{
16112 static uNvTables nvTables;
16113 eHalStatus status = eHAL_STATUS_SUCCESS;
16114 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16115
16116 /* read the country code from NV and use it */
16117 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16118 {
16119 palCopyMemory( pMac->hHdd, pCountry,
16120 nvTables.defaultCountryTable.countryCode,
16121 WNI_CFG_COUNTRY_CODE_LEN );
16122 return status;
16123 }
16124 else
16125 {
16126 palCopyMemory( pMac->hHdd, pCountry,
16127 "XXX",
16128 WNI_CFG_COUNTRY_CODE_LEN );
16129 status = eHAL_STATUS_FAILURE;
16130 return status;
16131 }
16132}
16133
16134eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16135{
16136 palCopyMemory( pMac->hHdd, pCountry,
16137 pMac->scan.countryCode11d,
16138 WNI_CFG_COUNTRY_CODE_LEN );
16139 return eHAL_STATUS_SUCCESS;
16140}
schang86c22c42013-03-13 18:41:24 -070016141
16142eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16143{
16144 tSirSetTxPowerReq *pMsg = NULL;
16145 eHalStatus status = eHAL_STATUS_SUCCESS;
16146 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16147
16148 if (!pSession)
16149 {
16150 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16151 return eHAL_STATUS_FAILURE;
16152 }
16153
16154 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
16155 if (HAL_STATUS_SUCCESS(status))
16156 {
16157 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
16158 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16159 pMsg->length = sizeof(tSirSetTxPowerReq);
16160 pMsg->mwPower = mW;
16161 palCopyMemory( pMac->hHdd,
16162 (tSirMacAddr *)pMsg->bssId,
16163 &pSession->selfMacAddr,
16164 sizeof(tSirMacAddr) );
16165 status = palSendMBMessage(pMac->hHdd, pMsg);
16166 if (!HAL_STATUS_SUCCESS(status))
16167 {
16168 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016169 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016170 }
16171 }
16172 return status;
16173}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016174
16175/* Returns whether a session is in VOS_STA_MODE...or not */
16176tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16177{
16178 tCsrRoamSession *pSession = NULL;
16179 pSession = CSR_GET_SESSION ( pMac, sessionId );
16180 if(!pSession)
16181 {
16182 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16183 return eANI_BOOLEAN_FALSE;
16184 }
16185 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16186 {
16187 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16188 return eANI_BOOLEAN_FALSE;
16189 }
16190 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16191 {
16192 return eANI_BOOLEAN_FALSE;
16193 }
16194 /* There is a possibility that the above check may fail,because
16195 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16196 * when it is connected.So,we may sneak through the above check even
16197 * if we are not a STA mode INFRA station. So, if we sneak through
16198 * the above condition, we can use the following check if we are
16199 * really in STA Mode.*/
16200
16201 if ( NULL != pSession->pCurRoamProfile )
16202 {
16203 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16204 {
16205 return eANI_BOOLEAN_TRUE;
16206 } else {
16207 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16208 return eANI_BOOLEAN_FALSE;
16209 }
16210 }
16211
16212 return eANI_BOOLEAN_FALSE;
16213}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016214
16215#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16216eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16217 tCsrHandoffRequest *pHandoffInfo)
16218{
16219 eHalStatus status = eHAL_STATUS_SUCCESS;
16220 vos_msg_t msg;
16221
16222 tAniHandoffReq *pMsg;
16223 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
16224 if ( !HAL_STATUS_SUCCESS(status) )
16225 {
16226 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
16227 return status;
16228 }
16229 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16230 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16231 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16232 pMsg->channel = pHandoffInfo->channel;
16233 palCopyMemory(pMac->hHdd, pMsg->bssid,
16234 pHandoffInfo->bssid,
16235 6);
16236 msg.type = eWNI_SME_HANDOFF_REQ;
16237 msg.bodyptr = pMsg;
16238 msg.reserved = 0;
16239 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16240 {
16241 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
16242 palFreeMemory(pMac->hHdd, (void *)pMsg);
16243 status = eHAL_STATUS_FAILURE;
16244 }
16245 return status;
16246}
16247#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */