blob: 93b30991601f795109a2616cea652c92fac90b4b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-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#ifdef FEATURE_WLAN_INTEGRATED_SOC
68#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
69#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070070#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
71#include "halPhyApi.h"
72#include "halInternal.h"
73#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070074#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075#include "palApi.h"
76#include "csrInsideApi.h"
77#include "smsDebug.h"
78#include "logDump.h"
79#include "smeQosInternal.h"
80#include "wlan_qct_tl.h"
81#include "smeInside.h"
82#include "vos_diag_core_event.h"
83#include "vos_diag_core_log.h"
84#include "csrApi.h"
85#include "pmc.h"
86#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070087#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
88#include "csrNeighborRoam.h"
89#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Jeff Johnson295189b2012-06-20 16:38:30 -070090#ifdef FEATURE_WLAN_CCX
91#include "csrCcx.h"
92#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define CSR_NUM_IBSS_START_CHANNELS_50 4
94#define CSR_NUM_IBSS_START_CHANNELS_24 3
95#define CSR_DEF_IBSS_START_CHANNEL_50 36
96#define CSR_DEF_IBSS_START_CHANNEL_24 1
97#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
Madan Mohan Koyyalamudi1002ab82012-12-27 17:36:41 -080098#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 -070099#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
100/*---------------------------------------------------------------------------
101 OBIWAN recommends [8 10]% : pick 9%
102---------------------------------------------------------------------------*/
103#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -0700104/*---------------------------------------------------------------------------
105 OBIWAN recommends -85dBm
106---------------------------------------------------------------------------*/
107#define CSR_VCC_RSSI_THRESHOLD 80
108#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
109#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
110#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
111#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700112//We use constatnt 4 here
113//This macro returns true when higher AC parameter is bigger than lower AC for a difference
114//The bigger the number, the less chance of TX
115//It must put lower AC as the first parameter.
116#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700117//Flag to send/do not send disassoc frame over the air
118#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700119#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700120#define MAX_CB_VALUE_IN_INI (2)
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/*--------------------------------------------------------------------------
123 Static Type declarations
124 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800125static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Jeff Johnson295189b2012-06-20 16:38:30 -0700126/*--------------------------------------------------------------------------
127 Type declarations
128 ------------------------------------------------------------------------*/
129#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700130int diagAuthTypeFromCSRType(eCsrAuthType authType)
131{
132 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700133 switch(authType)
134 {
135 case eCSR_AUTH_TYPE_SHARED_KEY:
136 n = AUTH_SHARED;
137 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 case eCSR_AUTH_TYPE_WPA:
139 n = AUTH_WPA_EAP;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_AUTH_TYPE_WPA_PSK:
142 n = AUTH_WPA_PSK;
143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 case eCSR_AUTH_TYPE_RSN:
145 n = AUTH_WPA2_EAP;
146 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700147 case eCSR_AUTH_TYPE_RSN_PSK:
148 n = AUTH_WPA2_PSK;
149 break;
150#ifdef FEATURE_WLAN_WAPI
151 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
152 n = AUTH_WAPI_CERT;
153 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
155 n = AUTH_WAPI_PSK;
156 break;
157#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 default:
159 break;
160 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 return (n);
162}
Jeff Johnson295189b2012-06-20 16:38:30 -0700163int diagEncTypeFromCSRType(eCsrEncryptionType encType)
164{
165 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 switch(encType)
167 {
168 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
169 case eCSR_ENCRYPT_TYPE_WEP40:
170 n = ENC_MODE_WEP40;
171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
173 case eCSR_ENCRYPT_TYPE_WEP104:
174 n = ENC_MODE_WEP104;
175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 case eCSR_ENCRYPT_TYPE_TKIP:
177 n = ENC_MODE_TKIP;
178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 case eCSR_ENCRYPT_TYPE_AES:
180 n = ENC_MODE_AES;
181 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#ifdef FEATURE_WLAN_WAPI
183 case eCSR_ENCRYPT_TYPE_WPI:
184 n = ENC_MODE_SMS4;
185 break;
186#endif /* FEATURE_WLAN_WAPI */
187 default:
188 break;
189 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700190 return (n);
191}
Jeff Johnson295189b2012-06-20 16:38:30 -0700192#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700193static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
194static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700195static void initConfigParam(tpAniSirGlobal pMac);
196static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
197 eCsrRoamCompleteResult Result, void *Context );
198static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
199 tCsrRoamProfile *pProfile,
200 tANI_BOOLEAN *pfSameIbss );
201static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
202static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700203 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
204static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700205eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
206static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
207eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
208eHalStatus csrRoamClose(tpAniSirGlobal pMac);
209void csrRoamMICErrorTimerHandler(void *pv);
210void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
211tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
212
213static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
214static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
215static void csrRoamRoamingTimerHandler(void *pv);
216eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
217eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
218static void csrRoamIbssJoinTimerHandler(void *pv);
219eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
220eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
221static void csrRoamWaitForKeyTimeOutHandler(void *pv);
222
223static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700224static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700225static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
226eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
227 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
228 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
229 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
230 tANI_U8 *pKeyRsc );
231static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
232 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
233 tCsrRoamProfile *pProfile );
234void csrRoamStatisticsTimerHandler(void *pv);
235void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700236static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
237VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
238 v_U8_t rssiNotification,
239 void * context);
240static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
241void csrRoamVccTrigger(tpAniSirGlobal pMac);
242eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
243/*
244 pStaEntry is no longer invalid upon the return of this function.
245*/
246static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700247#ifdef WLAN_SOFTAP_FEATURE
248static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
249#else
250static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, eCsrPhyMode phyModeIn, tANI_U8 operationChn, eCsrBand *pBand );
251#endif
252static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
254 tDblLinkList *pStaList,
255 tCsrStatsClientReqInfo *pStaEntry);
256void csrRoamStatsClientTimerHandler(void *pv);
257tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
258 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
259void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
260 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700261void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700262void csrRoamTlStatsTimerHandler(void *pv);
263void csrRoamPeStatsTimerHandler(void *pv);
264tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
265void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
266tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
267eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
268static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
269static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
270static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
271static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
272 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
273//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
274static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
275void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
276#ifdef FEATURE_WLAN_BTAMP_UT_RF
277void csrRoamJoinRetryTimerHandler(void *pv);
278#endif
279extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700280extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700281static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700282void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700283
284//Initialize global variables
285static void csrRoamInitGlobals(tpAniSirGlobal pMac)
286{
287 if(pMac)
288 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800289 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
290 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 }
292 return;
293}
294
Jeff Johnson295189b2012-06-20 16:38:30 -0700295static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
296{
297 if(pMac)
298 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800299 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 }
301 return;
302}
Jeff Johnson295189b2012-06-20 16:38:30 -0700303eHalStatus csrOpen(tpAniSirGlobal pMac)
304{
305 eHalStatus status = eHAL_STATUS_SUCCESS;
306 static uNvTables nvTables;
307 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 v_REGDOMAIN_t regId;
309 tANI_U32 i;
310
311 do
312 {
313 /* Initialize CSR Roam Globals */
314 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
316 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
317
318 initConfigParam(pMac);
319 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
320 break;
321 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
322 break;
323 pMac->roam.nextRoamId = 1; //Must not be 0
324 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
325 break;
326 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
327 break;
328 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
329 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
331 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
332 {
333 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
334 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
335 status = eHAL_STATUS_SUCCESS;
336 }
337 else
338 {
339 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE\n") );
340 //hardcoded for now
341 pMac->scan.countryCodeDefault[0] = 'U';
342 pMac->scan.countryCodeDefault[1] = 'S';
343 pMac->scan.countryCodeDefault[2] = 'I';
344 //status = eHAL_STATUS_SUCCESS;
345 }
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -0700346 smsLog( pMac, LOG1, FL(" country Code from nvRam %s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 WDA_SetRegDomain(pMac, regId);
349 pMac->scan.domainIdDefault = regId;
350 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
352 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
353 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 }while(0);
355
356 return (status);
357}
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359#ifdef WLAN_SOFTAP_FEATURE
360eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
361{
362 eHalStatus status = eHAL_STATUS_SUCCESS;
363 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
364 v_REGDOMAIN_t regId;
365 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 if(NULL == apCntryCode)
367 {
368 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer\n") );
369 return eHAL_STATUS_FAILURE;
370 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 smsLog( pMac, LOGW, FL(" country Code %s\n"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 /* To get correct Regulatory domain from NV table
373 * 2 character Country code should be used
374 * 3rd charater is optional for indoor/outdoor setting */
375 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700376
377 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
378 {
379 smsLog( pMac, LOGW, FL(" Invalid Country Code Length\n") );
380 return eHAL_STATUS_FAILURE;
381 }
382
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
384 if (status != eHAL_STATUS_SUCCESS)
385 {
386 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s\n"), apCntryCode );
387 return status;
388 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 status = WDA_SetRegDomain(hHal, regId);
390 if (status != eHAL_STATUS_SUCCESS)
391 {
392 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s\n"), apCntryCode );
393 return status;
394 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 pMac->scan.domainIdDefault = regId;
396 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 /* Clear CC field */
398 palFillMemory( pMac->hHdd,
399 pMac->scan.countryCodeDefault,
400 WNI_CFG_COUNTRY_CODE_LEN,
401 0 );
402 /* Copy 2 or 3 bytes country code */
403 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
404 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 /* If 2 bytes country code, 3rd byte must be filled with space */
406 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
407 {
408 palFillMemory( pMac->hHdd,
409 pMac->scan.countryCodeDefault + 2,
410 1,
411 0x20 );
412 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
414 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
415 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 return status;
417}
Jeff Johnson295189b2012-06-20 16:38:30 -0700418eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
419{
420 eHalStatus status = eHAL_STATUS_SUCCESS;
421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
422 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
424 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
426 {
427 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
428 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
429 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
430 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
431 }
432 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
433
434 return status;
435}
436#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700437eHalStatus csrClose(tpAniSirGlobal pMac)
438{
439 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkala277e02b2012-12-21 08:03:42 -0800440
Jeff Johnson295189b2012-06-20 16:38:30 -0700441 csrStop(pMac);
442 csrRoamClose(pMac);
443 csrScanClose(pMac);
444 csrLLClose(&pMac->roam.statsClientReqList);
445 csrLLClose(&pMac->roam.peStatsReqList);
446 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 /* DeInit Globals */
448 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 return (status);
450}
Jeff Johnson295189b2012-06-20 16:38:30 -0700451eHalStatus csrStart(tpAniSirGlobal pMac)
452{
453 eHalStatus status = eHAL_STATUS_SUCCESS;
454 tANI_U32 i;
455
456 do
457 {
458 //save the global vos context
459 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
460 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
461 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
462
463 status = csrRoamStart(pMac);
464 if(!HAL_STATUS_SUCCESS(status)) break;
465 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
466 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
467 if(!HAL_STATUS_SUCCESS(status)) break;
468 pMac->roam.sPendingCommands = 0;
469 csrScanEnable(pMac);
470#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
471 status = csrNeighborRoamInit(pMac);
472#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
473 pMac->roam.tlStatsReqInfo.numClient = 0;
474 pMac->roam.tlStatsReqInfo.periodicity = 0;
475 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
476 //init the link quality indication also
477 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
478 if(!HAL_STATUS_SUCCESS(status))
479 {
480 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk \n");
481 break;
482 }
483 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700484#if defined(ANI_LOGDUMP)
485 csrDumpInit(pMac);
486#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 return (status);
488}
489
Jeff Johnson295189b2012-06-20 16:38:30 -0700490eHalStatus csrStop(tpAniSirGlobal pMac)
491{
492 tANI_U32 sessionId;
493 tANI_U32 i;
494
495 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
496 {
497 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
498 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 csrScanDisable(pMac);
500 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
501 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
503
504#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
505 csrNeighborRoamClose(pMac);
506#endif
507 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 // deregister from PMC since we register during csrStart()
509 // (ignore status since there is nothing we can do if it fails)
510 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 //Reset the domain back to the deault
512 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkala277e02b2012-12-21 08:03:42 -0800513 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514
515 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
516 {
517 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
518 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
519 }
520
521 return (eHAL_STATUS_SUCCESS);
522}
523
Jeff Johnson295189b2012-06-20 16:38:30 -0700524eHalStatus csrReady(tpAniSirGlobal pMac)
525{
526 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 csrScanGetSupportedChannels( pMac );
528 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
529 //use it to init the background scan list
530 csrInitBGScanChannelList(pMac);
531 /* HDD issues the init scan */
532 csrScanStartResultAgingTimer(pMac);
Madan Mohan Koyyalamudi7da2fd72012-12-17 14:44:16 -0800533 /* If the gScanAgingTime is set to '0' then scan results aging timeout
534 based on timer feature is not enabled*/
535 if(0 != pMac->scan.scanResultCfgAgingTime )
536 {
537 csrScanStartResultCfgAgingTimer(pMac);
538 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 //Store the AC weights in TL for later use
540 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 status = csrInitChannelList( pMac );
542 if ( ! HAL_STATUS_SUCCESS( status ) )
543 {
544 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d\n",
545 status );
546 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 return (status);
548}
Jeff Johnson295189b2012-06-20 16:38:30 -0700549void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
550{
551 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
553 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
554}
Jeff Johnson295189b2012-06-20 16:38:30 -0700555void csrSetGlobalCfgs( tpAniSirGlobal pMac )
556{
Jeff Johnsone7245742012-09-05 17:12:55 -0700557
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
559 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
560 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
561 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
562 NULL, eANI_BOOLEAN_FALSE);
563 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700564 /* 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
565 * Once session is established we will use the session related params stored in PE session for CB mode
566 */
567 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700568 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
569
570 //Update the operating mode to configured value during initialization,
571 //So that client can advertise full capabilities in Probe request frame.
572 csrSetDefaultDot11Mode( pMac );
573}
574
Jeff Johnson295189b2012-06-20 16:38:30 -0700575eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
576{
577 eHalStatus status = eHAL_STATUS_SUCCESS;
578 tANI_U32 i;
579 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 do
581 {
582 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
583 {
584 pSession = CSR_GET_SESSION( pMac, i );
585 pSession->roamingTimerInfo.pMac = pMac;
586 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
587 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
589 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
590 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
591 &pMac->roam.WaitForKeyTimerInfo);
592 if(!HAL_STATUS_SUCCESS(status))
593 {
594 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer\n"));
595 break;
596 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
598 if(!HAL_STATUS_SUCCESS(status))
599 {
600 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer\n"));
601 return eHAL_STATUS_FAILURE;
602 }
603 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 return (status);
605}
606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607eHalStatus csrRoamClose(tpAniSirGlobal pMac)
608{
609 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
611 {
612 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
613 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
615 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
617 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 return (eHAL_STATUS_SUCCESS);
619}
620
Jeff Johnson295189b2012-06-20 16:38:30 -0700621eHalStatus csrRoamStart(tpAniSirGlobal pMac)
622{
623 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 return (eHAL_STATUS_SUCCESS);
625}
626
Jeff Johnson295189b2012-06-20 16:38:30 -0700627void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
628{
629 csrRoamStopRoamingTimer(pMac, sessionId);
630 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
631 csrRoamDeregStatisticsReq(pMac);
632}
Jeff Johnson295189b2012-06-20 16:38:30 -0700633eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
634{
635 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdafe1e2882013-02-19 17:41:56 -0800636 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 {
638 status = eHAL_STATUS_SUCCESS;
639 *pState = pMac->roam.roamSession[sessionId].connectState;
640 }
641 return (status);
642}
643
Jeff Johnson295189b2012-06-20 16:38:30 -0700644eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
645{
646 eHalStatus status = eHAL_STATUS_FAILURE;
647 tANI_U32 size = 0;
648 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700649
650 if(!pSession)
651 {
652 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
653 return eHAL_STATUS_FAILURE;
654 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700655
656 if(pProfile)
657 {
658 if(pSession->pConnectBssDesc)
659 {
660 do
661 {
662 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
663 if(size)
664 {
665 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
666 if(HAL_STATUS_SUCCESS(status))
667 {
668 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
669 }
670 else
671 break;
672 }
673 else
674 {
675 pProfile->pBssDesc = NULL;
676 }
677 pProfile->AuthType = pSession->connectedProfile.AuthType;
678 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
679 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
680 pProfile->BSSType = pSession->connectedProfile.BSSType;
681 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
682 pProfile->CBMode = pSession->connectedProfile.CBMode;
683 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
684 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
685#ifdef WLAN_FEATURE_VOWIFI_11R
686 if (pSession->connectedProfile.MDID.mdiePresent)
687 {
688 pProfile->MDID.mdiePresent = 1;
689 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
690 }
691 else
692 {
693 pProfile->MDID.mdiePresent = 0;
694 pProfile->MDID.mobilityDomain = 0;
695 }
696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700697#ifdef FEATURE_WLAN_CCX
698 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
700 {
701 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
702 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
703 pProfile->ccxCckmInfo.reassoc_req_num=
704 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
705 pProfile->ccxCckmInfo.krk_plumbed =
706 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
707 }
708#endif
709 }while(0);
710 }
711 }
712
713 return (status);
714}
715
Jeff Johnson295189b2012-06-20 16:38:30 -0700716eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
717{
718 eHalStatus status = eHAL_STATUS_FAILURE;
719
720 if(csrIsConnStateConnected(pMac, sessionId))
721 {
722 if(pProfile)
723 {
724 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
725 }
726 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 return (status);
728}
Jeff Johnson295189b2012-06-20 16:38:30 -0700729eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
730{
731 eHalStatus status = eHAL_STATUS_SUCCESS;
732
733 if(pProfile->pBssDesc)
734 {
735 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
736 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700737 if(pProfile->pAddIEAssoc)
738 {
739 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
740 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
742 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
743 return (status);
744}
745
Jeff Johnson295189b2012-06-20 16:38:30 -0700746static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
747{
748 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 if( pConnectedInfo->pbFrames )
750 {
751 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
752 pConnectedInfo->pbFrames = NULL;
753 }
754 pConnectedInfo->nBeaconLength = 0;
755 pConnectedInfo->nAssocReqLength = 0;
756 pConnectedInfo->nAssocRspLength = 0;
757 pConnectedInfo->staId = 0;
758#ifdef WLAN_FEATURE_VOWIFI_11R
759 pConnectedInfo->nRICRspLength = 0;
760#endif
761#ifdef FEATURE_WLAN_CCX
762 pConnectedInfo->nTspecIeLength = 0;
763#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 return ( status );
765}
766
Jeff Johnson295189b2012-06-20 16:38:30 -0700767
768
Jeff Johnsone7245742012-09-05 17:12:55 -0700769
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700770void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
771{
772 csrReinitPreauthCmd(pMac, pCommand);
773 csrReleaseCommand( pMac, pCommand );
774}
775
Jeff Johnson295189b2012-06-20 16:38:30 -0700776void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
777{
778 csrReinitRoamCmd(pMac, pCommand);
779 csrReleaseCommand( pMac, pCommand );
780}
781
Jeff Johnson295189b2012-06-20 16:38:30 -0700782void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
783{
784 csrReinitScanCmd(pMac, pCommand);
785 csrReleaseCommand( pMac, pCommand );
786}
787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
789{
790 csrReinitWmStatusChangeCmd(pMac, pCommand);
791 csrReleaseCommand( pMac, pCommand );
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
795{
796 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
797}
798
Jeff Johnson295189b2012-06-20 16:38:30 -0700799void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
800{
801 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
802}
803
Jeff Johnson295189b2012-06-20 16:38:30 -0700804void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
805{
806 csrReinitSetKeyCmd(pMac, pCommand);
807 csrReleaseCommand( pMac, pCommand );
808}
Jeff Johnson295189b2012-06-20 16:38:30 -0700809void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
810{
811 csrReinitRemoveKeyCmd(pMac, pCommand);
812 csrReleaseCommand( pMac, pCommand );
813}
Jeff Johnson295189b2012-06-20 16:38:30 -0700814void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
815{
816
817 if( eSmeCsrCommandMask & pCommand->command )
818 {
819 switch (pCommand->command)
820 {
821 case eSmeCommandScan:
Jeff Johnson3d710ea2012-12-10 14:31:52 -0800822 // We need to inform the requester before dropping the scan command
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700824 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 if (NULL != pCommand->u.scanCmd.callback)
826 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700827 smsLog( pMac, LOGW, "%s callback scan requester\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
829 }
830 csrReleaseCommandScan( pMac, pCommand );
831 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 case eSmeCommandRoam:
833 csrReleaseCommandRoam( pMac, pCommand );
834 break;
835
836 case eSmeCommandWmStatusChange:
837 csrReleaseCommandWmStatusChange( pMac, pCommand );
838 break;
839
840 case eSmeCommandSetKey:
841 csrReleaseCommandSetKey( pMac, pCommand );
842 break;
843
844 case eSmeCommandRemoveKey:
845 csrReleaseCommandRemoveKey( pMac, pCommand );
846 break;
847
848 default:
849 smsLog( pMac, LOGW, " CSR abort standard command %d\n", pCommand->command );
850 csrReleaseCommand( pMac, pCommand );
851 break;
852 }
853 }
854}
855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
857{
858 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]\n", NewSubstate, pMac->roam.curSubState[sessionId]);
859
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 if(pMac->roam.curSubState[sessionId] == NewSubstate)
861 {
862 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700863 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 pMac->roam.curSubState[sessionId] = NewSubstate;
865}
866
Jeff Johnson295189b2012-06-20 16:38:30 -0700867eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
868{
869 eCsrRoamState PreviousState;
870
871 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]\n", NewRoamState, pMac->roam.curState[sessionId]);
872
873 PreviousState = pMac->roam.curState[sessionId];
874
875 if ( NewRoamState != pMac->roam.curState[sessionId] )
876 {
877 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
878 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
879 {
880 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
881 }
882
883 pMac->roam.curState[sessionId] = NewRoamState;
884 }
885 return( PreviousState );
886}
887
Jeff Johnson295189b2012-06-20 16:38:30 -0700888void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
889{
890 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 if(catOffset)
892 {
893 pMac->roam.configParam.bCatRssiOffset = catOffset;
894 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
895 {
896 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
897 }
898 }
899}
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901static void initConfigParam(tpAniSirGlobal pMac)
902{
903 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
905 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
906 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
909 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
910 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
911 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
912 pMac->roam.configParam.HeartbeatThresh24 = 40;
913 pMac->roam.configParam.HeartbeatThresh50 = 40;
914 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
915 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
916 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700917 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 pMac->roam.configParam.RTSThreshold = 2346;
919 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
920 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
921 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
922 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
923 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
924 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
925 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
926 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
927 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
928 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
929 {
930 pMac->roam.configParam.BssPreferValue[i] = i;
931 }
932 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
933 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
934 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
935 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
937 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
938 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
939 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
940 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
941 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700942#ifdef WLAN_AP_STA_CONCURRENCY
943 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
944 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
945 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
946 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
947 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Madan Mohan Koyyalamudi8591f092012-12-17 13:04:30 -0800948 pMac->roam.configParam.nNumChanCombinedConc = CSR_NUM_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700949#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
951 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
952 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
953 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700954#ifdef WLAN_FEATURE_VOWIFI_11R
955 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
956#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700957#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
958 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
959 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
960 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
961 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
962 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
963 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
964 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
965 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
966 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
967 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
968 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
969#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700970#ifdef WLAN_FEATURE_11AC
971 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700973
974 pMac->roam.configParam.addTSWhenACMIsOff = 0;
975 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700976
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700977 //Remove this code once SLM_Sessionization is supported
978 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700979 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700980
Jeff Johnsone7245742012-09-05 17:12:55 -0700981}
Jeff Johnson295189b2012-06-20 16:38:30 -0700982eCsrBand csrGetCurrentBand(tHalHandle hHal)
983{
984 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
985 return pMac->roam.configParam.bandCapability;
986}
Jeff Johnson295189b2012-06-20 16:38:30 -0700987eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
988{
989 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
990 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
992 (eBand == eCSR_BAND_24))
993 {
994 /* DOT11 mode configured to 11a only and received
995 request to change the band to 2.4 GHz */
996 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
997 "failed to set band cfg80211 = %u, band = %u\n",
998 pMac->roam.configParam.uCfgDot11Mode, eBand);
999 return eHAL_STATUS_INVALID_PARAMETER;
1000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1002 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1003 (eBand == eCSR_BAND_5G))
1004 {
1005 /* DOT11 mode configured to 11b/11g only and received
1006 request to change the band to 5 GHz */
1007 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1008 "failed to set band dot11mode = %u, band = %u\n",
1009 pMac->roam.configParam.uCfgDot11Mode, eBand);
1010 return eHAL_STATUS_INVALID_PARAMETER;
1011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1013 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)\n", eBand);
1014 pMac->roam.configParam.eBand = eBand;
1015 pMac->roam.configParam.bandCapability = eBand;
1016 csrScanGetSupportedChannels( pMac );
1017 status = csrInitGetChannels( pMac );
1018 if (eHAL_STATUS_SUCCESS == status)
1019 csrInitChannelList( hHal );
1020 return status;
1021}
Jeff Johnsone7245742012-09-05 17:12:55 -07001022/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1023 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1024 * Ideally we should have kept the ini value and enum value same and representing the same
1025 * cb values as in 11n standard i.e.
1026 * Set to 1 (SCA) if the secondary channel is above the primary channel
1027 * Set to 3 (SCB) if the secondary channel is below the primary channel
1028 * Set to 0 (SCN) if no secondary channel is present
1029 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1030 * 0 - secondary none
1031 * 1 - secondary LOW
1032 * 2 - secondary HIGH
1033 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1034 * The enum values are as follows:
1035 * PHY_SINGLE_CHANNEL_CENTERED = 0
1036 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1037 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1038 */
1039ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1040{
1041
1042 ePhyChanBondState phyCbState;
1043 switch (cbIniValue) {
1044 // secondary none
1045 case 0:
1046 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1047 break;
1048 // secondary LOW
1049 case 1:
1050 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1051 break;
1052 // secondary HIGH
1053 case 2:
1054 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1055 break;
1056#ifdef WLAN_FEATURE_11AC
1057 case 3:
1058 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1059 break;
1060 case 4:
1061 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1062 break;
1063 case 5:
1064 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1065 break;
1066 case 6:
1067 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1068 break;
1069 case 7:
1070 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1071 break;
1072 case 8:
1073 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1074 break;
1075 case 9:
1076 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1077 break;
1078#endif
1079 default:
1080 // If an invalid value is passed, disable CHANNEL BONDING
1081 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1082 break;
1083 }
1084 return phyCbState;
1085}
1086
1087v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1088{
1089
1090 v_U32_t cbIniValue;
1091 switch (phyCbState) {
1092 // secondary none
1093 case PHY_SINGLE_CHANNEL_CENTERED:
1094 cbIniValue = 0;
1095 break;
1096 // secondary LOW
1097 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1098 cbIniValue = 1;
1099 break;
1100 // secondary HIGH
1101 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1102 cbIniValue = 2;
1103 break;
1104#ifdef WLAN_FEATURE_11AC
1105 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1106 cbIniValue = 3;
1107 break;
1108 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1109 cbIniValue = 4;
1110 break;
1111 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1112 cbIniValue = 5;
1113 break;
1114 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1115 cbIniValue = 6;
1116 break;
1117 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1118 cbIniValue = 7;
1119 break;
1120 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1121 cbIniValue = 8;
1122 break;
1123 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1124 cbIniValue = 9;
1125 break;
1126#endif
1127 default:
1128 // return some invalid value
1129 cbIniValue = 10;
1130 break;
1131 }
1132 return cbIniValue;
1133}
Jeff Johnson295189b2012-06-20 16:38:30 -07001134
1135eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1136{
1137 eHalStatus status = eHAL_STATUS_SUCCESS;
1138
1139 if(pParam)
1140 {
1141 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1142 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1143 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1144 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1145 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1146 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1147
1148 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001149 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1150
Jeff Johnsone7245742012-09-05 17:12:55 -07001151 /* channelBondingMode5GHz plays a dual role right now
1152 * 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
1153 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1154 */
1155 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1156 {
1157 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED\n", pParam->channelBondingMode24GHz);
1158 }
1159 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1160 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1161 {
1162 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED\n", pParam->channelBondingMode5GHz);
1163 }
1164 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1166 pMac->roam.configParam.phyMode = pParam->phyMode;
1167 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1168 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1169 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1170 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1171 pMac->roam.configParam.TxRate = pParam->TxRate;
1172 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1173 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1174 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1175 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1176 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 //if HDD passed down non zero values then only update,
1178 //otherwise keep using the defaults
1179 if(pParam->nActiveMaxChnTime)
1180 {
1181 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1182 }
1183 if(pParam->nActiveMinChnTime)
1184 {
1185 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1186 }
1187 if(pParam->nPassiveMaxChnTime)
1188 {
1189 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1190 }
1191 if(pParam->nPassiveMinChnTime)
1192 {
1193 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1194 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001195#ifdef WLAN_AP_STA_CONCURRENCY
1196 if(pParam->nActiveMaxChnTimeConc)
1197 {
1198 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1199 }
1200 if(pParam->nActiveMinChnTimeConc)
1201 {
1202 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1203 }
1204 if(pParam->nPassiveMaxChnTimeConc)
1205 {
1206 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1207 }
1208 if(pParam->nPassiveMinChnTimeConc)
1209 {
1210 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1211 }
1212 if(pParam->nRestTimeConc)
1213 {
1214 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1215 }
Madan Mohan Koyyalamudi8591f092012-12-17 13:04:30 -08001216 if(pParam->nNumChanCombinedConc)
1217 {
1218 pMac->roam.configParam.nNumChanCombinedConc = pParam->nNumChanCombinedConc;
1219 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 //if upper layer wants to disable idle scan altogether set it to 0
1222 if(pParam->impsSleepTime)
1223 {
1224 //Change the unit from second to microsecond
1225 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1227 {
1228 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1229 }
1230 else
1231 {
1232 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1233 }
1234 }
1235 else
1236 {
1237 pMac->roam.configParam.impsSleepTime = 0;
1238 }
1239 pMac->roam.configParam.eBand = pParam->eBand;
1240#ifdef WLAN_SOFTAP_FEATURE
1241 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1242 pMac->roam.configParam.ProprietaryRatesEnabled);
1243#else
1244 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pMac->roam.configParam.phyMode,
1245 pMac->roam.configParam.ProprietaryRatesEnabled);
1246#endif
1247 //if HDD passed down non zero values for age params, then only update,
1248 //otherwise keep using the defaults
1249 if(pParam->nScanResultAgeCount)
1250 {
1251 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001253 if(pParam->scanAgeTimeNCNPS)
1254 {
1255 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001257 if(pParam->scanAgeTimeNCPS)
1258 {
1259 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 if(pParam->scanAgeTimeCNPS)
1262 {
1263 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1264 }
1265 if(pParam->scanAgeTimeCPS)
1266 {
1267 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1268 }
1269
1270 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1271 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1272 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1273 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1274 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1275 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1277 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1279 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1280 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1281 //Assign this before calling CsrInit11dInfo
1282 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 if( csrIs11dSupported( pMac ) )
1284 {
1285 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1286 }
1287 else
1288 {
1289 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1290 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001291
1292 /* Initialize the power + channel information if 11h is enabled.
1293 If 11d is enabled this information has already been initialized */
1294 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1295 {
1296 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1297 }
1298
1299
Jeff Johnson295189b2012-06-20 16:38:30 -07001300#ifdef WLAN_FEATURE_VOWIFI_11R
1301 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1302 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d\n", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
1303#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001304#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001306 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudif4289db2012-12-03 16:45:39 -08001307 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
1308 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d\n",
1309 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudic4c01172012-11-30 14:56:21 -08001310 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Jeff Johnson295189b2012-06-20 16:38:30 -07001311#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001312#ifdef FEATURE_WLAN_LFR
1313 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1314#endif
1315
Jeff Johnson295189b2012-06-20 16:38:30 -07001316#ifdef FEATURE_WLAN_CCX
1317 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1318#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001319#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1320 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1322 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1323 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1324 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1325 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1326 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d\n", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1327 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 {
1329 int i;
1330 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d\n"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1332 {
1333 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1334 }
1335 smsLog( pMac, LOG1, "\n");
1336 }
1337#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1339 pMac->scan.fValidateList = pParam->fValidateList;
1340 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1341 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Madan Mohan Koyyalamudi7da2fd72012-12-17 14:44:16 -08001342 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001344 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1345 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1346 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1347 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1348 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1349 * single session
1350 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001351 //Remove this code once SLM_Sessionization is supported
1352 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001353 pMac->roam.configParam.doBMPSWorkaround = 0;
1354
Jeff Johnsone7245742012-09-05 17:12:55 -07001355#ifdef WLAN_FEATURE_11AC
1356 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -08001357 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchi95934c32013-02-16 18:18:33 -08001358 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001359#endif
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001360 pMac->scan.fIgnore_chan165 = pParam->fIgnore_chan165;
Gopichand Nakkalab7ed0a62013-01-04 11:41:02 -08001361 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 }
1363
1364 return status;
1365}
1366
Jeff Johnson295189b2012-06-20 16:38:30 -07001367eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1368{
1369 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 if(pParam)
1371 {
1372 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1373 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1374 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1375 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1376 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1377 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001378 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1379 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1381 pParam->phyMode = pMac->roam.configParam.phyMode;
1382 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1383 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1384 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1385 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1386 pParam->TxRate = pMac->roam.configParam.TxRate;
1387 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1388 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1389 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1390 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1391 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1393 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1394 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1395 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001396#ifdef WLAN_AP_STA_CONCURRENCY
1397 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1398 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1399 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1400 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1401 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Madan Mohan Koyyalamudi8591f092012-12-17 13:04:30 -08001402 pParam->nNumChanCombinedConc = pMac->roam.configParam.nNumChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 //Change the unit from microsecond to second
1405 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1406 pParam->eBand = pMac->roam.configParam.eBand;
1407 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1408 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1409 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1410 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1411 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1412 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1413 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1414 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1415 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1416 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1417 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1418 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1419 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1421 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1422 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1423 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1425 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1426 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1427 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001428 pParam->fIgnore_chan165= pMac->scan.fIgnore_chan165;
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001430 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001431 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001432 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi441b91b2013-01-20 23:45:53 -08001433 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001434
1435#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1436 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1437#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001438#ifdef WLAN_FEATURE_11AC
1439 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -08001440 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchi95934c32013-02-16 18:18:33 -08001441 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001443
1444 csrSetChannels(pMac, pParam);
1445
1446 status = eHAL_STATUS_SUCCESS;
1447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 return (status);
1449}
1450
Jeff Johnson295189b2012-06-20 16:38:30 -07001451eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1452{
1453 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1454 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1455 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1456 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 do
1458 {
1459 if(eCSR_BAND_24 == eBand)
1460 {
1461 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1462 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1463 }
1464 if(eCSR_BAND_5G == eBand)
1465 {
1466 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1467 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1468 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1469 )
1470 {
1471 break;
1472 }
1473 }
1474 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1475 {
1476 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1477 }
1478 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1479 {
1480 newPhyMode = eCSR_DOT11_MODE_AUTO;
1481 }
1482 else
1483 {
1484 //Check for dual band and higher capability first
1485 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1486 {
1487 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1488 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1489 }
1490 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1491 {
1492 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1493 if(eCSR_BAND_24 == eBand) break;
1494 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1495 eBand = eCSR_BAND_5G;
1496 }
1497 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1498 {
1499 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1500 if(eCSR_BAND_5G == eBand) break;
1501 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1502 eBand = eCSR_BAND_24;
1503 }
1504 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1505 {
1506 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1507 if(eCSR_BAND_5G == eBand) break;
1508 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1509 eBand = eCSR_BAND_24;
1510 }
1511 else if(eCSR_DOT11_MODE_11n & phyMode)
1512 {
1513 newPhyMode = eCSR_DOT11_MODE_11n;
1514 }
1515 else if(eCSR_DOT11_MODE_abg & phyMode)
1516 {
1517 newPhyMode = eCSR_DOT11_MODE_abg;
1518 }
1519 else if(eCSR_DOT11_MODE_11a & phyMode)
1520 {
1521 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1522 {
1523 if(eCSR_BAND_ALL == eBand)
1524 {
1525 newPhyMode = eCSR_DOT11_MODE_abg;
1526 }
1527 else
1528 {
1529 //bad setting
1530 break;
1531 }
1532 }
1533 else
1534 {
1535 newPhyMode = eCSR_DOT11_MODE_11a;
1536 eBand = eCSR_BAND_5G;
1537 }
1538 }
1539 else if(eCSR_DOT11_MODE_11g & phyMode)
1540 {
1541 newPhyMode = eCSR_DOT11_MODE_11g;
1542 eBand = eCSR_BAND_24;
1543 }
1544 else if(eCSR_DOT11_MODE_11b & phyMode)
1545 {
1546 newPhyMode = eCSR_DOT11_MODE_11b;
1547 eBand = eCSR_BAND_24;
1548 }
1549 else
1550 {
1551 //We will never be here
1552 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X\n"), phyMode );
1553 newPhyMode = eCSR_DOT11_MODE_AUTO;
1554 }
1555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 //Done validating
1557 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 //Now we need to check whether a restart is needed.
1559 if(eBand != pMac->roam.configParam.eBand)
1560 {
1561 fRestartNeeded = eANI_BOOLEAN_TRUE;
1562 break;
1563 }
1564 if(newPhyMode != pMac->roam.configParam.phyMode)
1565 {
1566 fRestartNeeded = eANI_BOOLEAN_TRUE;
1567 break;
1568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 if(HAL_STATUS_SUCCESS(status))
1571 {
1572 pMac->roam.configParam.eBand = eBand;
1573 pMac->roam.configParam.phyMode = newPhyMode;
1574 if(pfRestartNeeded)
1575 {
1576 *pfRestartNeeded = fRestartNeeded;
1577 }
1578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 return (status);
1580}
1581
Jeff Johnson295189b2012-06-20 16:38:30 -07001582void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1583{
1584 tANI_U8 Index;
1585 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 // for dual band NICs, don't need to trim the channel list....
1587 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1588 {
1589 // 2.4 GHz band operation requires the channel list to be trimmed to
1590 // the 2.4 GHz channels only...
1591 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1592 {
1593 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1594 Index++ )
1595 {
1596 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1597 {
1598 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1599 cChannels++;
1600 }
1601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1603 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1604 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1605 // only if we need to.
1606 //
1607 // The amount of memory to clear is the number of channesl that we trimmed
1608 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1609
1610 if ( pChannelList->numChannels > cChannels )
1611 {
1612 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1613 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1614
1615 }
1616
1617 pChannelList->numChannels = cChannels;
1618 }
1619 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1620 {
1621 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1622 {
1623 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1624 {
1625 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1626 cChannels++;
1627 }
1628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1630 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1631 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1632 // only if we need to.
1633 //
1634 // The amount of memory to clear is the number of channesl that we trimmed
1635 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1636 if ( pChannelList->numChannels > cChannels )
1637 {
1638 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1639 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1640 }
1641
1642 pChannelList->numChannels = cChannels;
1643 }
1644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001645}
Jeff Johnson295189b2012-06-20 16:38:30 -07001646#ifdef WLAN_SOFTAP_FEATURE
1647#define INFRA_AP_DEFAULT_CHANNEL 6
1648eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1649{
1650 tANI_U8 index= 0;
1651 eHalStatus status = eHAL_STATUS_FAILURE;
1652 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1653 {
1654 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1655 status = eHAL_STATUS_SUCCESS;
1656 break;
1657 }
1658 }
1659 return status;
1660}
1661#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001662eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
1663{
1664 eHalStatus status = eHAL_STATUS_SUCCESS;
1665 tANI_U8 num20MHzChannelsFound = 0;
1666 VOS_STATUS vosStatus;
1667 tANI_U8 Index = 0;
1668 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001669
Jeff Johnson295189b2012-06-20 16:38:30 -07001670
1671 //TODO: this interface changed to include the 40MHz channel list
1672 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
1673 // Read the scan channel list (including the power limit) from EEPROM
1674 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1675 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1676 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1677 {
1678 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1679 status = eHAL_STATUS_FAILURE;
1680 }
1681 else
1682 {
1683 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1684 {
1685 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1686 }
1687 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1688 // Move the channel list to the global data
1689 // structure -- this will be used as the scan list
1690 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1691 {
1692#ifdef FEATURE_WLAN_INTEGRATED_SOC /* Need to fix this while dealing with NV item */
1693 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
1694#else
1695 pMac->scan.base20MHzChannels.channelList[ Index ] = Index + 1;
1696 pMac->scan.defaultPowerTable[Index].chanId = Index + 1;
1697 pMac->scan.defaultPowerTable[Index].pwr = 25;
1698#endif
1699 }
1700 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1701 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
1702 {
1703 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1704 }
1705 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1706 {
1707 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1708 }
1709 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 return (status);
1712}
1713
Jeff Johnson295189b2012-06-20 16:38:30 -07001714eHalStatus csrInitChannelList( tHalHandle hHal )
1715{
1716 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1717 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
1719 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kirand170dcb2013-01-31 10:43:43 -08001720 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
1721 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkala277e02b2012-12-21 08:03:42 -08001723 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001724
1725 return (status);
1726}
Jeff Johnson295189b2012-06-20 16:38:30 -07001727eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
1728 tCsrUpdateConfigParam *pUpdateConfigParam)
1729{
1730 eHalStatus status = eHAL_STATUS_FAILURE;
1731 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
1733 status = CsrInit11dInfo(pMac, ps11dinfo);
1734 return status;
1735}
1736
Jeff Johnson295189b2012-06-20 16:38:30 -07001737static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1738{
1739 eHalStatus status = eHAL_STATUS_FAILURE;
1740 tANI_U8 index;
1741 tANI_U32 count=0;
1742 tSirMacChanInfo *pChanInfo;
1743 tSirMacChanInfo *pChanInfoStart;
1744 tANI_BOOLEAN applyConfig = TRUE;
1745
1746 if(!ps11dinfo)
1747 {
1748 return (status);
1749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
1751 {
1752 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
1753 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
1754 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
1755 if(!HAL_STATUS_SUCCESS(status)) return (status);
1756 }
1757 else
1758 {
1759 //No change
1760 return (eHAL_STATUS_SUCCESS);
1761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 //legacy maintenance
1763 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
1764 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1765 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 //Tush: at csropen get this initialized with default, during csr reset if this
1767 // already set with some value no need initilaize with default again
1768 if(0 == pMac->scan.countryCodeCurrent[0])
1769 {
1770 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
1771 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1772 if(!HAL_STATUS_SUCCESS(status)) return (status);
1773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 // need to add the max power channel list
1775 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1776 {
1777 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1778 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07001779 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1780 {
1781 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1782 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1783 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1784 pChanInfo++;
1785 count++;
1786 }
1787 if(count)
1788 {
1789 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1790 }
1791 palFreeMemory(pMac->hHdd, pChanInfoStart);
1792 }
1793 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
1794 if( HAL_STATUS_SUCCESS(status) )
1795 {
1796 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
1797 {
1798 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
1799 {
1800 applyConfig = FALSE;
1801 }
1802 }
1803
1804 if(TRUE == applyConfig)
1805 {
1806 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkala277e02b2012-12-21 08:03:42 -08001807 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001808 }
1809
1810 }
1811 return (status);
1812}
1813/* Initialize the Channel + Power List in the local cache and in the CFG */
1814eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1815{
1816 tANI_U8 index;
1817 tANI_U32 count=0;
1818 tSirMacChanInfo *pChanInfo;
1819 tSirMacChanInfo *pChanInfoStart;
1820
1821 if(!ps11dinfo || !pMac)
1822 {
1823 return eHAL_STATUS_FAILURE;
1824 }
1825
1826 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1827 {
1828 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1829 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001830
1831 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1832 {
1833 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1834 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1835 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1836 pChanInfo++;
1837 count++;
1838 }
1839 if(count)
1840 {
1841 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1842 }
1843 palFreeMemory(pMac->hHdd, pChanInfoStart);
1844 }
1845
Jeff Johnsone7245742012-09-05 17:12:55 -07001846 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001847}
1848
1849//pCommand may be NULL
1850//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
1851void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
1852{
1853 tListElem *pEntry, *pNextEntry;
1854 tSmeCmd *pDupCommand;
1855 tDblLinkList localList;
1856
1857 vos_mem_zero(&localList, sizeof(tDblLinkList));
1858 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
1859 {
1860 smsLog(pMac, LOGE, FL(" failed to open list"));
1861 return;
1862 }
1863 csrLLLock( &pMac->sme.smeCmdPendingList );
1864 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
1865 while( pEntry )
1866 {
1867 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
1868 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 // Remove the previous command if..
1870 // - the new roam command is for the same RoamReason...
1871 // - the new roam command is a NewProfileList.
1872 // - the new roam command is a Forced Dissoc
1873 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
1874 if (
1875 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
1876 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08001877 /* This peermac check is requried for Softap/GO scenarios
1878 * For STA scenario below OR check will suffice as pCommand will
1879 * always be NULL for STA scenarios
1880 */
1881 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
1883 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
1884 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
1885 ||
1886 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07001887 ( (sessionId == pDupCommand->sessionId) &&
1888 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 ((eCsrForcedDisassoc == eRoamReason) ||
1890 (eCsrHddIssued == eRoamReason))
1891 )
1892 )
1893 {
1894 smsLog(pMac, LOGW, FL(" roamReason = %d\n"), pDupCommand->u.roamCmd.roamReason);
1895 // Remove the 'stale' roam command from the pending list...
1896 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
1897 {
1898 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
1899 }
1900 }
1901 pEntry = pNextEntry;
1902 }
1903 csrLLUnlock( &pMac->sme.smeCmdPendingList );
1904
1905 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
1906 {
1907 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
1908 //Tell caller that the command is cancelled
1909 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
1910 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
1911 csrReleaseCommandRoam(pMac, pDupCommand);
1912 }
1913 csrLLClose(&localList);
1914}
Jeff Johnson295189b2012-06-20 16:38:30 -07001915eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
1916 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
1917{
1918 eHalStatus status = eHAL_STATUS_SUCCESS;
1919#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
1920 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
1921#endif
1922 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
1924 {
1925 pSession = CSR_GET_SESSION( pMac, sessionId );
1926 }
1927 else
1928 {
1929 smsLog(pMac, LOGE, "Session ID:%d is not valid\n", sessionId);
1930 VOS_ASSERT(0);
1931 return eHAL_STATUS_FAILURE;
1932 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
1934 {
1935 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d\n", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
1936 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001937 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
1938 /*
1939 * Decrement bRefAssocStartCnt for FT reassoc failure.
1940 * Reason: For FT reassoc failures, we first call
1941 * csrRoamCallCallback before notifying a failed roam
1942 * completion through csrRoamComplete. The latter in
1943 * turn calls csrRoamProcessResults which tries to
1944 * once again call csrRoamCallCallback if bRefAssocStartCnt
1945 * is non-zero. Since this is redundant for FT reassoc
1946 * failure, decrement bRefAssocStartCnt.
1947 */
1948 pSession->bRefAssocStartCnt--;
1949 }
1950
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 if ( (pSession == NULL) ||
1952 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
1953 {
1954 smsLog(pMac, LOG1, "Session ID is not valid\n");
1955 return eHAL_STATUS_FAILURE;
1956 }
1957
1958 if(NULL != pSession->callback)
1959 {
1960 if( pRoamInfo )
1961 {
1962 pRoamInfo->sessionId = (tANI_U8)sessionId;
1963 }
1964
1965 /* avoid holding the global lock when making the roaming callback , original change came
1966 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
1967 is possible on other OS ports where the callback may need to take locks to protect
1968 HDD state
1969 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
1970 that may actually depend on the lock being held */
1971 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
1972 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
1973 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
1974 }
1975 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
1976 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
1977#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
1978 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
1979 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
1980 {
1981 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
1982 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
1983 if(NULL != pRoamInfo->pBssDesc)
1984 {
1985 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
1986 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
1987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
1989 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
1990 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
1991 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
1992 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
1993 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
1996 {
1997 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
1998 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
1999 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 if(eCSR_ROAM_RESULT_FORCED == u2)
2002 {
2003 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2004 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2005 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2008 {
2009 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2010 connectionStatus.reason = eCSR_REASON_DISASSOC;
2011 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2014 {
2015 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2016 connectionStatus.reason = eCSR_REASON_DEAUTH;
2017 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002019#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2020
2021 return (status);
2022}
Jeff Johnson295189b2012-06-20 16:38:30 -07002023// Returns whether handoff is currently in progress or not
2024tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2025{
2026#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2027 return csrNeighborRoamIsHandoffInProgress(pMac);
2028#else
2029 return eANI_BOOLEAN_FALSE;
2030#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002031}
Jeff Johnson295189b2012-06-20 16:38:30 -07002032eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2033 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2034{
2035 eHalStatus status = eHAL_STATUS_SUCCESS;
2036 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2037 tANI_U16 reasonCode;
2038 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002039
2040 if(!pSession)
2041 {
2042 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2043 return eHAL_STATUS_FAILURE;
2044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002045
2046 //Restore AC weight in case we change it
2047 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2048 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002049 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 -07002050 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2051 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2052 }
2053
2054 if ( fMICFailure )
2055 {
2056 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2057 }
2058 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2059 {
2060 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002061 }
2062 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 {
2064 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002066#ifdef WLAN_FEATURE_VOWIFI_11R
2067 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2068 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2069 {
2070 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2071 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002072 }
2073 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002074#endif
2075 if(pSession->pConnectBssDesc)
2076 {
2077 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2078 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002079
Jeff Johnson295189b2012-06-20 16:38:30 -07002080
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002081 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2082 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2083 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2084
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2086
2087 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2088
2089 if(HAL_STATUS_SUCCESS(status))
2090 {
2091 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002092#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2093 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2094 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2095 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002096 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2098 }
2099#endif
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002100 }
2101 else
2102 {
2103 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2104 }
2105
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 return (status);
2107}
Jeff Johnson295189b2012-06-20 16:38:30 -07002108#ifdef WLAN_SOFTAP_FEATURE
2109
Jeff Johnson295189b2012-06-20 16:38:30 -07002110/* ---------------------------------------------------------------------------
2111 \fn csrRoamIssueDisassociateStaCmd
2112 \brief csr function that HDD calls to disassociate a associated station
2113 \param sessionId - session Id for Soft AP
2114 \param pPeerMacAddr - MAC of associated station to delete
2115 \param reason - reason code, be one of the tSirMacReasonCodes
2116 \return eHalStatus
2117 ---------------------------------------------------------------------------*/
2118eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2119 tANI_U32 sessionId,
2120 tANI_U8 *pPeerMacAddr,
2121 tANI_U32 reason)
2122{
2123 eHalStatus status = eHAL_STATUS_SUCCESS;
2124 tSmeCmd *pCommand;
2125
2126 do
2127 {
2128 pCommand = csrGetCommandBuffer( pMac );
2129 if ( !pCommand )
2130 {
2131 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2132 status = eHAL_STATUS_RESOURCES;
2133 break;
2134 }
2135 pCommand->command = eSmeCommandRoam;
2136 pCommand->sessionId = (tANI_U8)sessionId;
2137 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2138 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2139 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2140 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2141 if( !HAL_STATUS_SUCCESS( status ) )
2142 {
2143 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2144 csrReleaseCommandRoam( pMac, pCommand );
2145 }
2146 }while(0);
2147
2148 return status;
2149}
2150
2151
Jeff Johnson295189b2012-06-20 16:38:30 -07002152/* ---------------------------------------------------------------------------
2153 \fn csrRoamIssueDeauthSta
2154 \brief csr function that HDD calls to delete a associated station
2155 \param sessionId - session Id for Soft AP
2156 \param pPeerMacAddr - MAC of associated station to delete
2157 \param reason - reason code, be one of the tSirMacReasonCodes
2158 \return eHalStatus
2159 ---------------------------------------------------------------------------*/
2160eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2161 tANI_U32 sessionId,
2162 tANI_U8 *pPeerMacAddr,
2163 tANI_U32 reason)
2164{
2165 eHalStatus status = eHAL_STATUS_SUCCESS;
2166 tSmeCmd *pCommand;
2167
2168 do
2169 {
2170 pCommand = csrGetCommandBuffer( pMac );
2171 if ( !pCommand )
2172 {
2173 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2174 status = eHAL_STATUS_RESOURCES;
2175 break;
2176 }
2177 pCommand->command = eSmeCommandRoam;
2178 pCommand->sessionId = (tANI_U8)sessionId;
2179 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2180 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2181 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2182 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2183 if( !HAL_STATUS_SUCCESS( status ) )
2184 {
2185 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2186 csrReleaseCommandRoam( pMac, pCommand );
2187 }
2188 }while(0);
2189
2190 return status;
2191}
Jeff Johnson295189b2012-06-20 16:38:30 -07002192eHalStatus
2193csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2194 tANI_BOOLEAN bEnable )
2195{
2196 eHalStatus status = eHAL_STATUS_FAILURE;
2197 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2198 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 if (!pSession)
2200 {
2201 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found\n");
2202 return (status);
2203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 if (pSession->pConnectBssDesc)
2205 {
2206 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2207 }
2208 else
2209 {
2210 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found\n");
2211 return (status);
2212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d\n",
2214 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2215 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2217 return (status);
2218}
Jeff Johnson295189b2012-06-20 16:38:30 -07002219eHalStatus
2220csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2221 VOS_MODULE_ID modId, void *pUsrContext,
2222 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2223{
2224 eHalStatus status = eHAL_STATUS_SUCCESS;
2225 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 if (!pSession)
2228 {
2229 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found\n");
2230 return (status);
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 if(pSession->pConnectBssDesc)
2233 {
2234 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2235 }
2236 else
2237 {
2238 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found\n");
2239 return (status);
2240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2242 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2243 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2245 return (status);
2246}
Jeff Johnson295189b2012-06-20 16:38:30 -07002247eHalStatus
2248csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2249 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2250{
2251 eHalStatus status = eHAL_STATUS_SUCCESS;
2252 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2253 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2254
2255 if (!pSession)
2256 {
2257 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found\n");
2258 return (status);
2259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 if(pSession->pConnectBssDesc)
2261 {
2262 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2263 }
2264 else
2265 {
2266 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found\n");
2267 return (status);
2268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2270 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2271 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2272
2273 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2274
2275 return (status);
2276}
Jeff Johnson295189b2012-06-20 16:38:30 -07002277#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002278eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2279{
2280 eHalStatus status = eHAL_STATUS_SUCCESS;
2281 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2282 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002283
2284 if (!pSession)
2285 {
2286 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2287 return eHAL_STATUS_FAILURE;
2288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002289
2290 if(pSession->pConnectBssDesc)
2291 {
2292 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
2295 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2296 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2298
Madan Mohan Koyyalamudi64571a62013-01-30 19:59:23 +05302299 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002300 if(!HAL_STATUS_SUCCESS(status))
2301 {
2302 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2303 }
2304
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return (status);
2306}
2307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2309{
2310 eHalStatus status = eHAL_STATUS_SUCCESS;
2311 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2312 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002313
2314 if(!pSession)
2315 {
2316 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2317 return eHAL_STATUS_FAILURE;
2318 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002319
2320 // If no BSS description was found in this connection (happens with start IBSS), then
2321 // nix the BSS description that we keep around for the connected BSS) and get out...
2322 if(NULL == pBssDesc)
2323 {
2324 csrFreeConnectBssDesc(pMac, sessionId);
2325 }
2326 else
2327 {
2328 size = pBssDesc->length + sizeof( pBssDesc->length );
2329 if(NULL != pSession->pConnectBssDesc)
2330 {
2331 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2332 {
2333 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2334 csrFreeConnectBssDesc(pMac, sessionId);
2335 }
2336 }
2337 if(NULL == pSession->pConnectBssDesc)
2338 {
2339 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2340 }
2341 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2342 {
2343 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2344 }
2345 }
2346
2347 return (status);
2348}
2349
Jeff Johnson295189b2012-06-20 16:38:30 -07002350eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2351 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2352 tDot11fBeaconIEs *pIes)
2353{
2354 eHalStatus status = eHAL_STATUS_SUCCESS;
2355 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002356#if defined(VOSS_ENABLED)
2357 VOS_ASSERT( pIes != NULL );
2358#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002359
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 do
2361 {
2362 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2363 //get qos
2364 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2365 //get SSID
2366 if(pIes->SSID.present)
2367 {
2368 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2369 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2370 }
2371 else
2372 pBssConfig->SSID.length = 0;
2373 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2374 {
2375 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard\n");
2376 //Return failed if profile doesn't have an SSID either.
2377 if(pProfile->SSIDs.numOfSSIDs == 0)
2378 {
2379 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID\n");
2380 status = eHAL_STATUS_FAILURE;
2381 break;
2382 }
2383 }
2384 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2385 {
2386 pBssConfig->eBand = eCSR_BAND_5G;
2387 }
2388 else
2389 {
2390 pBssConfig->eBand = eCSR_BAND_24;
2391 }
2392 //phymode
2393 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2394 {
2395 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2396 }
2397 else
2398 {
2399 smsLog(pMac, LOGW, " Can not find match phy mode\n");
2400 //force it
2401 if(eCSR_BAND_24 == pBssConfig->eBand)
2402 {
2403 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2404 }
2405 else
2406 {
2407 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2408 }
2409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 //Qos
2411 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2412 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2413 {
2414 //Joining BSS is not 11n capable and WMM is disabled on client.
2415 //Disable QoS and WMM
2416 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2417 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302418
2419 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302420 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302421 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2422 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2423 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2424 {
2425 //Joining BSS is 11n capable and WMM is disabled on AP.
2426 //Assume all HT AP's are QOS AP's and enable WMM
2427 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2428 }
2429
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 //auth type
2431 switch( pProfile->negotiatedAuthType )
2432 {
2433 default:
2434 case eCSR_AUTH_TYPE_WPA:
2435 case eCSR_AUTH_TYPE_WPA_PSK:
2436 case eCSR_AUTH_TYPE_WPA_NONE:
2437 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2438 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2439 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 case eCSR_AUTH_TYPE_SHARED_KEY:
2441 pBssConfig->authType = eSIR_SHARED_KEY;
2442 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 case eCSR_AUTH_TYPE_AUTOSWITCH:
2444 pBssConfig->authType = eSIR_AUTO_SWITCH;
2445 break;
2446 }
2447 //short slot time
2448 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2449 {
2450 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2451 }
2452 else
2453 {
2454 pBssConfig->uShortSlotTime = 0;
2455 }
2456 if(pBssConfig->BssCap.ibss)
2457 {
2458 //We don't support 11h on IBSS
2459 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2460 }
2461 else
2462 {
2463 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2464 }
2465 //power constraint
2466 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2467 //heartbeat
2468 if ( CSR_IS_11A_BSS( pBssDesc ) )
2469 {
2470 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2471 }
2472 else
2473 {
2474 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2475 }
2476 //Join timeout
2477 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002478 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 if ( pBssDesc->beaconInterval )
2480 {
2481 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002482 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 }
2484 else
2485 {
2486 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2487 }
2488 //validate CB
2489 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2490 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 return (status);
2492}
2493
Jeff Johnson295189b2012-06-20 16:38:30 -07002494static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2495 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2496{
2497 eHalStatus status = eHAL_STATUS_SUCCESS;
2498 tANI_U8 operationChannel = 0;
2499 tANI_U8 qAPisEnabled = FALSE;
2500 //SSID
2501 pBssConfig->SSID.length = 0;
2502 if(pProfile->SSIDs.numOfSSIDs)
2503 {
2504 //only use the first one
2505 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2506 }
2507 else
2508 {
2509 //SSID must present
2510 return eHAL_STATUS_FAILURE;
2511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 //Settomg up the capabilities
2513 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2514 {
2515 pBssConfig->BssCap.ibss = 1;
2516 }
2517 else
2518 {
2519 pBssConfig->BssCap.ess = 1;
2520 }
2521 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2522 {
2523 pBssConfig->BssCap.privacy = 1;
2524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 pBssConfig->eBand = pMac->roam.configParam.eBand;
2526 //phymode
2527 if(pProfile->ChannelInfo.ChannelList)
2528 {
2529 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002531#ifdef WLAN_SOFTAP_FEATURE
2532 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2533 &pBssConfig->eBand);
2534#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel,
2536 &pBssConfig->eBand);
2537#endif
2538 //QOS
2539 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 if ( pBssConfig->BssCap.ess == 1 )
2541 {
2542#ifdef WLAN_SOFTAP_FEATURE
2543 /*For Softap case enable WMM*/
2544 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2545 qAPisEnabled = TRUE;
2546 }
2547 else
2548#endif
2549 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2550 qAPisEnabled = TRUE;
2551 } else {
2552 qAPisEnabled = FALSE;
2553 }
2554 } else {
2555 qAPisEnabled = TRUE;
2556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2558 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2559 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2560 )
2561 {
2562 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2563 } else {
2564 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2565 }
2566
2567 //auth type
Jeff Johnson3d30ed12012-12-10 14:41:22 -08002568 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 {
2570 default:
2571 case eCSR_AUTH_TYPE_WPA:
2572 case eCSR_AUTH_TYPE_WPA_PSK:
2573 case eCSR_AUTH_TYPE_WPA_NONE:
2574 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2575 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2576 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 case eCSR_AUTH_TYPE_SHARED_KEY:
2578 pBssConfig->authType = eSIR_SHARED_KEY;
2579 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 case eCSR_AUTH_TYPE_AUTOSWITCH:
2581 pBssConfig->authType = eSIR_AUTO_SWITCH;
2582 break;
2583 }
2584 //short slot time
2585 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2586 {
2587 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2588 }
2589 else
2590 {
2591 pBssConfig->uShortSlotTime = 0;
2592 }
2593 //power constraint. We don't support 11h on IBSS
2594 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2595 pBssConfig->uPowerLimit = 0;
2596 //heartbeat
2597 if ( eCSR_BAND_5G == pBssConfig->eBand )
2598 {
2599 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2600 }
2601 else
2602 {
2603 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2604 }
2605 //Join timeout
2606 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002607
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 return (status);
2609}
Jeff Johnson295189b2012-06-20 16:38:30 -07002610static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2611{
2612 eHalStatus status = eHAL_STATUS_FAILURE;
2613 tDot11fBeaconIEs *pIes = NULL;
2614
2615 do
2616 {
2617 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2618 {
2619 //err msg
2620 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2621 "csrRoamGetQosInfoFromBss() failed\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 break;
2623 }
2624 //check if the AP is QAP & it supports APSD
2625 if( CSR_IS_QOS_BSS(pIes) )
2626 {
2627 return eHAL_STATUS_SUCCESS;
2628 }
2629 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 return status;
2631}
2632
Jeff Johnson295189b2012-06-20 16:38:30 -07002633void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2634{
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2636 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2637 // See !!Note: below in this function...
2638 tANI_U32 PrivacyEnabled = 0;
2639 tANI_U32 RsnEnabled = 0;
2640 tANI_U32 WepDefaultKeyId = 0;
2641 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2642 tANI_U32 Key0Length = 0;
2643 tANI_U32 Key1Length = 0;
2644 tANI_U32 Key2Length = 0;
2645 tANI_U32 Key3Length = 0;
2646
2647 // Reserve for the biggest key
2648 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2649 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2650 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2651 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2652
2653 switch ( pProfile->negotiatedUCEncryptionType )
2654 {
2655 case eCSR_ENCRYPT_TYPE_NONE:
2656
2657 // for NO encryption, turn off Privacy and Rsn.
2658 PrivacyEnabled = 0;
2659 RsnEnabled = 0;
2660
2661 // WEP key length and Wep Default Key ID don't matter in this case....
2662
2663 // clear out the WEP keys that may be hanging around.
2664 Key0Length = 0;
2665 Key1Length = 0;
2666 Key2Length = 0;
2667 Key3Length = 0;
2668
2669 break;
2670
2671 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2672
2673 // Privacy is ON. NO RSN for Wep40 static key.
2674 PrivacyEnabled = 1;
2675 RsnEnabled = 0;
2676
2677 // Set the Wep default key ID.
2678 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 // Wep key size if 5 bytes (40 bits).
2680 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2681
2682 // set encryption keys in the CFG database or clear those that are not present in this profile.
2683 if ( pProfile->Keys.KeyLength[0] )
2684 {
2685 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2686 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2687 }
2688 else
2689 {
2690 Key0Length = 0;
2691 }
2692
2693 if ( pProfile->Keys.KeyLength[1] )
2694 {
2695 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2696 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2697 }
2698 else
2699 {
2700 Key1Length = 0;
2701 }
2702
2703 if ( pProfile->Keys.KeyLength[2] )
2704 {
2705 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2706 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2707 }
2708 else
2709 {
2710 Key2Length = 0;
2711 }
2712
2713 if ( pProfile->Keys.KeyLength[3] )
2714 {
2715 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2716 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2717 }
2718 else
2719 {
2720 Key3Length = 0;
2721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 break;
2723
2724 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2725
2726 // Privacy is ON. NO RSN for Wep40 static key.
2727 PrivacyEnabled = 1;
2728 RsnEnabled = 0;
2729
2730 // Set the Wep default key ID.
2731 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2732
2733 // Wep key size if 13 bytes (104 bits).
2734 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2735
2736 // set encryption keys in the CFG database or clear those that are not present in this profile.
2737 if ( pProfile->Keys.KeyLength[0] )
2738 {
2739 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2740 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2741 }
2742 else
2743 {
2744 Key0Length = 0;
2745 }
2746
2747 if ( pProfile->Keys.KeyLength[1] )
2748 {
2749 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2750 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2751 }
2752 else
2753 {
2754 Key1Length = 0;
2755 }
2756
2757 if ( pProfile->Keys.KeyLength[2] )
2758 {
2759 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2760 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2761 }
2762 else
2763 {
2764 Key2Length = 0;
2765 }
2766
2767 if ( pProfile->Keys.KeyLength[3] )
2768 {
2769 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2770 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
2771 }
2772 else
2773 {
2774 Key3Length = 0;
2775 }
2776
2777 break;
2778
2779 case eCSR_ENCRYPT_TYPE_WEP40:
2780 case eCSR_ENCRYPT_TYPE_WEP104:
2781 case eCSR_ENCRYPT_TYPE_TKIP:
2782 case eCSR_ENCRYPT_TYPE_AES:
2783#ifdef FEATURE_WLAN_WAPI
2784 case eCSR_ENCRYPT_TYPE_WPI:
2785#endif /* FEATURE_WLAN_WAPI */
2786 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
2787 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
2788 PrivacyEnabled = (0 != fPrivacy);
2789
2790 // turn on RSN enabled for WPA associations
2791 RsnEnabled = 1;
2792
2793 // WEP key length and Wep Default Key ID don't matter in this case....
2794
2795 // clear out the static WEP keys that may be hanging around.
2796 Key0Length = 0;
2797 Key1Length = 0;
2798 Key2Length = 0;
2799 Key3Length = 0;
2800
2801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 default:
2803 PrivacyEnabled = 0;
2804 RsnEnabled = 0;
2805 break;
2806 }
2807
2808 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
2809 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
2810 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
2811 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
2812 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
2813 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
2814 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
2815 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
2816}
2817
Jeff Johnson295189b2012-06-20 16:38:30 -07002818static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
2819{
2820 tANI_U32 len = 0;
2821 if(pSSID->length <= WNI_CFG_SSID_LEN)
2822 {
2823 len = pSSID->length;
2824 }
2825 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
2826}
2827
Jeff Johnson295189b2012-06-20 16:38:30 -07002828eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
2829{
2830 eHalStatus status = eHAL_STATUS_SUCCESS;
2831 tANI_U32 QoSEnabled;
2832 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 // set the CFG enable/disable variables based on the qosType being configured...
2834 switch( qosType )
2835 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
2837 QoSEnabled = FALSE;
2838 WmeEnabled = TRUE;
2839 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
2841 QoSEnabled = FALSE;
2842 WmeEnabled = TRUE;
2843 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
2845 QoSEnabled = FALSE;
2846 WmeEnabled = TRUE;
2847 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 case eCSR_MEDIUM_ACCESS_11e_eDCF:
2849 QoSEnabled = TRUE;
2850 WmeEnabled = FALSE;
2851 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 case eCSR_MEDIUM_ACCESS_11e_HCF:
2853 QoSEnabled = TRUE;
2854 WmeEnabled = FALSE;
2855 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 default:
2857 case eCSR_MEDIUM_ACCESS_DCF:
2858 QoSEnabled = FALSE;
2859 WmeEnabled = FALSE;
2860 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 }
2862 //save the WMM setting for later use
2863 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
2865 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 return (status);
2867}
Jeff Johnson295189b2012-06-20 16:38:30 -07002868static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
2869 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
2870{
2871 eHalStatus status = eHAL_STATUS_FAILURE;
2872 int i;
2873 eCsrCfgDot11Mode cfgDot11Mode;
2874 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
2876 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07002877#if defined(VOSS_ENABLED)
2878 VOS_ASSERT( pIes != NULL );
2879#endif
2880
2881 if( NULL != pIes )
2882 {
2883 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 // Originally, we thought that for 11a networks, the 11a rates are always
2885 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
2886 // appear in the Operational Rate set. Consequently, in either case, we
2887 // would blindly put the rates we support into our Operational Rate set
2888 // (including the basic rates, which we have already verified are
2889 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 // However, it turns out that this is not always the case. Some AP's
2891 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
2892 // too. Now, we're a little more careful:
2893 pDstRate = pOpRateSet->rate;
2894 if(pIes->SuppRates.present)
2895 {
2896 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
2897 {
2898 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
2899 {
2900 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002901 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 }
2903 }
2904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
2906 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
2907 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
2908 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
2909 {
2910 // If there are Extended Rates in the beacon, we will reflect those
2911 // extended rates that we support in out Extended Operational Rate
2912 // set:
2913 pDstRate = pExRateSet->rate;
2914 if(pIes->ExtSuppRates.present)
2915 {
2916 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
2917 {
2918 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
2919 {
2920 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
2921 pExRateSet->numRates++;
2922 }
2923 }
2924 }
2925 }
2926 }//Parsing BSSDesc
2927 else
2928 {
2929 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
2930 }
2931 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
2932 return status;
2933}
2934
2935static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
2936 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
2937{
2938 int i;
2939 tANI_U8 *pDstRate;
2940 eCsrCfgDot11Mode cfgDot11Mode;
2941 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
2942 tANI_U32 OperationalRatesLength = 0;
2943 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
2944 tANI_U32 ExtendedOperationalRatesLength = 0;
2945 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
2946 tANI_U32 ProprietaryOperationalRatesLength = 0;
2947 tANI_U32 PropRatesEnable = 0;
2948 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
2949 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002950#if defined(VOSS_ENABLED)
2951 VOS_ASSERT( pIes != NULL );
2952#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 if( NULL != pIes )
2954 {
2955 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 // Originally, we thought that for 11a networks, the 11a rates are always
2957 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
2958 // appear in the Operational Rate set. Consequently, in either case, we
2959 // would blindly put the rates we support into our Operational Rate set
2960 // (including the basic rates, which we have already verified are
2961 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 // However, it turns out that this is not always the case. Some AP's
2963 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
2964 // too. Now, we're a little more careful:
2965 pDstRate = OperationalRates;
2966 if(pIes->SuppRates.present)
2967 {
2968 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
2969 {
2970 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
2971 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
2972 {
2973 *pDstRate++ = pIes->SuppRates.rates[ i ];
2974 OperationalRatesLength++;
2975 }
2976 }
2977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
2979 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
2980 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
2981 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
2982 {
2983 // If there are Extended Rates in the beacon, we will reflect those
2984 // extended rates that we support in out Extended Operational Rate
2985 // set:
2986 pDstRate = ExtendedOperationalRates;
2987 if(pIes->ExtSuppRates.present)
2988 {
2989 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
2990 {
2991 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
2992 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
2993 {
2994 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
2995 ExtendedOperationalRatesLength++;
2996 }
2997 }
2998 }
2999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 // Enable proprietary MAC features if peer node is Airgo node and STA
3001 // user wants to use them
3002 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3003 {
3004 PropRatesEnable = 1;
3005 }
3006 else
3007 {
3008 PropRatesEnable = 0;
3009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 // For ANI network companions, we need to populate the proprietary rate
3011 // set with any proprietary rates we found in the beacon, only if user
3012 // allows them...
3013 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3014 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3015 {
3016 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3017 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3018 {
3019 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3020 }
3021 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3022 }
3023 else {
3024 // No proprietary modes...
3025 ProprietaryOperationalRatesLength = 0;
3026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 /* Get MCS Rate */
3028 pDstRate = MCSRateIdxSet;
3029 if ( pIes->HTCaps.present )
3030 {
3031 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3032 {
3033 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3034 {
3035 MCSRateLength++;
3036 *pDstRate++ = i;
3037 }
3038 }
3039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 // Set the operational rate set CFG variables...
3041 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3042 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3043 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3044 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3045 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3046 ProprietaryOperationalRates,
3047 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3048 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3049 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3050 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3051 }//Parsing BSSDesc
3052 else
3053 {
3054 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3055 }
3056}
3057
Jeff Johnson295189b2012-06-20 16:38:30 -07003058static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3059 tCsrRoamProfile *pProfile )
3060{
3061 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3062 { 8,
3063 { SIR_MAC_RATE_6,
3064 SIR_MAC_RATE_9,
3065 SIR_MAC_RATE_12,
3066 SIR_MAC_RATE_18,
3067 SIR_MAC_RATE_24,
3068 SIR_MAC_RATE_36,
3069 SIR_MAC_RATE_48,
3070 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3072 { 4,
3073 { SIR_MAC_RATE_1,
3074 SIR_MAC_RATE_2,
3075 SIR_MAC_RATE_5_5,
3076 SIR_MAC_RATE_11 } } };
3077
3078
3079 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3080 { SIR_MAC_RATE_72,
3081 SIR_MAC_RATE_96,
3082 SIR_MAC_RATE_108 } };
3083 eCsrCfgDot11Mode cfgDot11Mode;
3084 eCsrBand eBand;
3085 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3086 tANI_U32 OperationalRatesLength = 0;
3087 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3088 tANI_U32 ExtendedOperationalRatesLength = 0;
3089 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3090 tANI_U32 ProprietaryOperationalRatesLength = 0;
3091 tANI_U32 PropRatesEnable = 0;
3092 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 if(pProfile->ChannelInfo.ChannelList)
3094 {
3095 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003097#ifdef WLAN_SOFTAP_FEATURE
3098 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
3099#else
3100 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel, &eBand );
3101#endif
3102 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3103 // networks, the 11b rates appear in the Operational Rate set. In either case,
3104 // we can blindly put the rates we support into our Operational Rate set
3105 // (including the basic rates, which we have already verified are supported
3106 // earlier in the roaming decision).
3107 if ( eCSR_BAND_5G == eBand )
3108 {
3109 // 11a rates into the Operational Rate Set.
3110 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3111 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3112 palCopyMemory( pMac->hHdd, OperationalRates,
3113 DefaultSupportedRates11a.supportedRateSet.rate,
3114 OperationalRatesLength );
3115
3116 // Nothing in the Extended rate set.
3117 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 // populate proprietary rates if user allows them
3119 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3120 {
3121 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3122 sizeof(*DefaultSupportedPropRates.propRate);
3123 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3124 DefaultSupportedPropRates.propRate,
3125 ProprietaryOperationalRatesLength );
3126 }
3127 else
3128 {
3129 // No proprietary modes
3130 ProprietaryOperationalRatesLength = 0;
3131 }
3132 }
3133 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3134 {
3135 // 11b rates into the Operational Rate Set.
3136 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3137 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3138 palCopyMemory( pMac->hHdd, OperationalRates,
3139 DefaultSupportedRates11b.supportedRateSet.rate,
3140 OperationalRatesLength );
3141 // Nothing in the Extended rate set.
3142 ExtendedOperationalRatesLength = 0;
3143 // No proprietary modes
3144 ProprietaryOperationalRatesLength = 0;
3145 }
3146 else
3147 {
3148 // 11G
3149
3150 // 11b rates into the Operational Rate Set.
3151 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3152 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3153 palCopyMemory( pMac->hHdd, OperationalRates,
3154 DefaultSupportedRates11b.supportedRateSet.rate,
3155 OperationalRatesLength );
3156
3157 // 11a rates go in the Extended rate set.
3158 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3159 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3160 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3161 DefaultSupportedRates11a.supportedRateSet.rate,
3162 ExtendedOperationalRatesLength );
3163
3164 // populate proprietary rates if user allows them
3165 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3166 {
3167 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3168 sizeof(*DefaultSupportedPropRates.propRate);
3169 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3170 DefaultSupportedPropRates.propRate,
3171 ProprietaryOperationalRatesLength );
3172 }
3173 else
3174 {
3175 // No proprietary modes
3176 ProprietaryOperationalRatesLength = 0;
3177 }
3178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3180 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3181 {
3182 PropRatesEnable = 1;
3183 }
3184 else
3185 {
3186 PropRatesEnable = 0;
3187 }
3188
3189 // Set the operational rate set CFG variables...
3190 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3191 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3192 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3193 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3194 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3195 ProprietaryOperationalRates,
3196 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3197 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003198}
Jeff Johnson295189b2012-06-20 16:38:30 -07003199void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3200{
3201 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003202
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3204 tANI_U32 sessionId;
3205 tSmeCmd *pCommand = NULL;
3206
3207 if(NULL == pEntry)
3208 {
3209 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
3210 return;
3211 }
3212 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3213 sessionId = pCommand->sessionId;
3214
3215 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3216 {
3217 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3218 }
3219}
3220
Jeff Johnson295189b2012-06-20 16:38:30 -07003221//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3222tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3223{
3224 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3225 {
3226 return (WNI_CFG_PHY_MODE_11B);
3227 }
3228 else
3229 {
3230 if(eCSR_BAND_24 == band)
3231 return (WNI_CFG_PHY_MODE_11G);
3232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 return (WNI_CFG_PHY_MODE_11A);
3234}
Jeff Johnson295189b2012-06-20 16:38:30 -07003235
Jeff Johnsone7245742012-09-05 17:12:55 -07003236
3237#ifdef WLAN_FEATURE_11AC
3238ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3239{
3240 switch ( aniCBMode )
3241 {
3242 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3243 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3244 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3245 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3246 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3247 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3248 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3249 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3250 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003251 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003252 return PHY_SINGLE_CHANNEL_CENTERED;
3253 }
3254}
3255#endif
3256
Jeff Johnson295189b2012-06-20 16:38:30 -07003257//pIes may be NULL
3258eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3259 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3260 tDot11fBeaconIEs *pIes)
3261{
3262 eHalStatus status = eHAL_STATUS_SUCCESS;
3263 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3264 tANI_U8 channel = 0;
3265 //Make sure we have the domain info for the BSS we try to connect to.
3266 //Do we need to worry about sequence for OSs that are not Windows??
3267 if(pBssDesc)
3268 {
3269 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3270 {
3271 //Make sure the 11d info from this BSSDesc can be applied
3272 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3273 csrApplyCountryInformation( pMac, TRUE );
3274 }
Kirand170dcb2013-01-31 10:43:43 -08003275 if ((csrIs11dSupported (pMac)) && pIes)
3276 {
3277 if (!pIes->Country.present)
3278 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 //Qos
3282 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3283 //SSID
3284 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3285 //fragment threshold
3286 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3287 //RTS threshold
3288 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3289
3290 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3291
3292 //Auth type
3293 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3294 //encryption type
3295 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3296 //short slot time
3297 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003298#ifdef WLAN_SOFTAP_FEATURE
3299 //11d
3300 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3301 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3302 NULL, eANI_BOOLEAN_FALSE);
3303#endif
3304 /*//11h
3305 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3306 */
3307 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3308 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003309
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3311 {
3312 channel = pProfile->operationChannel;
3313 }
3314 else
3315 {
3316 if(pBssDesc)
3317 {
3318 channel = pBssDesc->channelId;
3319 }
3320 }
3321 if(0 != channel)
3322 {
3323 if(CSR_IS_CHANNEL_24GHZ(channel))
3324 {//for now if we are on 2.4 Ghz, CB will be always disabled
3325 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3326 }
3327 else
3328 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003329 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 }
3331 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003332#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003333 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3334 // in function csrConvertCBIniValueToPhyCBState()
3335 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3336 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003337 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003338 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003339 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003340 }
3341 else
3342 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003343 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003344 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003345 }
3346 else
3347#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3349 //Rate
3350 //Fixed Rate
3351 if(pBssDesc)
3352 {
3353 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3354 }
3355 else
3356 {
3357 csrSetCfgRateSetFromProfile(pMac, pProfile);
3358 }
3359 //Make this the last CFG to set. The callback will trigger a join_req
3360 //Join time out
3361 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3362
3363 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 return (status);
3365}
3366
Jeff Johnson295189b2012-06-20 16:38:30 -07003367eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3368 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3369{
3370 eHalStatus status;
3371 tBssConfigParam *pBssConfig;
3372 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003373
3374 if(!pSession)
3375 {
3376 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3377 return eHAL_STATUS_FAILURE;
3378 }
3379
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3381 if(HAL_STATUS_SUCCESS(status))
3382 {
3383 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3384 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3385 if(HAL_STATUS_SUCCESS(status))
3386 {
3387 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003388 /* This will allow to pass cbMode during join req */
3389 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 //For IBSS, we need to prepare some more information
3391 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
3392#ifdef WLAN_SOFTAP_FEATURE
3393 || CSR_IS_INFRA_AP(pProfile)
3394#endif
3395 )
3396 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003397 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 }
3399 // If we are in an IBSS, then stop the IBSS...
3400 ////Not worry about WDS connection for now
3401 if ( csrIsConnStateIbss( pMac, sessionId ) )
3402 {
3403 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3404 }
3405 else
3406 {
3407 // if we are in an Infrastructure association....
3408 if ( csrIsConnStateInfra( pMac, sessionId ) )
3409 {
3410 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3411 // across SSIDs (roaming to a new SSID)... //
3412 //Not worry about WDS connection for now
3413 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3414 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3415 {
3416 // then we need to disassociate from the Infrastructure network...
3417 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3418 }
3419 else
3420 {
3421 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3422 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3423 if ( pBssDesc )
3424 {
3425 // Set parameters for this Bss.
3426 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3427 }
3428 }
3429 }
3430 else
3431 {
3432 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3433 // Nothing to stop.
3434 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
3435#ifdef WLAN_SOFTAP_FEATURE
3436 || CSR_IS_INFRA_AP(pProfile)
3437#endif
3438 )
3439 {
3440 // Set parameters for this Bss.
3441 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3442 }
3443 }
3444 }
3445 }//Success getting BSS config info
3446 palFreeMemory(pMac->hHdd, pBssConfig);
3447 }//Allocate memory
3448
3449 return (status);
3450}
3451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3453 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3454{
3455 eCsrJoinState eRoamState = eCsrContinueRoaming;
3456 eHalStatus status;
3457 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3458 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3459 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003460
3461 if(!pSession)
3462 {
3463 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3464 return (eCsrStopRoaming);
3465 }
3466
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 if( CSR_IS_WDS_STA( pProfile ) )
3468 {
3469 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3470 if( !HAL_STATUS_SUCCESS( status ) )
3471 {
3472 eRoamState = eCsrStopRoaming;
3473 }
3474 }
3475 else
3476 {
3477 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3478 {
3479 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3480 return (eCsrStopRoaming);
3481 }
3482 if ( csrIsInfraBssDesc( pBssDesc ) )
3483 {
3484 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3485 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3486 // have changed and handle the changes (without disturbing the current association).
3487
3488 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3489 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3490 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3491 )
3492 {
3493 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3494 // with Authenticating first. To force this, stop the current association (Disassociate) and
3495 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3496 // a new Association.
3497 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3498 {
3499 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d\n"), pProfile->AuthType, pProfile->EncryptionType);
3500 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3501 {
3502 eRoamState = eCsrReassocToSelfNoCapChange;
3503 }
3504 else
3505 {
3506 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 //The key changes
3508 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3509 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3510 if(HAL_STATUS_SUCCESS(status))
3511 {
3512 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003513 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 //Reapply the config including Keys so reassoc is happening.
3515 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3516 if(!HAL_STATUS_SUCCESS(status))
3517 {
3518 eRoamState = eCsrStopRoaming;
3519 }
3520 }
3521 else
3522 {
3523 eRoamState = eCsrStopRoaming;
3524 }
3525 }//same profile
3526 }
3527 else
3528 {
3529 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3530 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3531 {
3532 smsLog(pMac, LOGW, FL(" fail to issue disassociate\n"));
3533 eRoamState = eCsrStopRoaming;
3534 }
3535 }
3536 }
3537 else
3538 {
3539 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3540 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3541 // work much better.
3542 //
3543 //
3544 // stop the existing network before attempting to join the new network...
3545 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3546 {
3547 eRoamState = eCsrStopRoaming;
3548 }
3549 }
3550 }//Infra
3551 else
3552 {
3553 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3554 {
3555 eRoamState = eCsrStopRoaming;
3556 }
3557 }
3558 if( pIesLocal && !pScanResult->pvIes )
3559 {
3560 palFreeMemory(pMac->hHdd, pIesLocal);
3561 }
3562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 return( eRoamState );
3564}
3565
Jeff Johnson295189b2012-06-20 16:38:30 -07003566eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3567 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3568{
3569 eHalStatus status = eHAL_STATUS_SUCCESS;
3570 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3572 roamInfo.pBssDesc = pBssDesc;
3573 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3574 return (status);
3575}
Jeff Johnson295189b2012-06-20 16:38:30 -07003576//In case no matching BSS is found, use whatever default we can find
3577static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3578{
3579 //Need to get all negotiated types in place first
3580 //auth type
Jeff Johnson3d30ed12012-12-10 14:41:22 -08003581 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 {
3583 default:
3584 case eCSR_AUTH_TYPE_WPA:
3585 case eCSR_AUTH_TYPE_WPA_PSK:
3586 case eCSR_AUTH_TYPE_WPA_NONE:
3587 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3588 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3589 break;
3590
3591 case eCSR_AUTH_TYPE_SHARED_KEY:
3592 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3593 break;
3594
3595 case eCSR_AUTH_TYPE_AUTOSWITCH:
3596 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3597 break;
3598 }
3599 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3600 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3601 //In this case, the multicast encryption needs to follow the uncast ones.
3602 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3603 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3604}
3605
3606static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3607{
3608 eHalStatus status;
3609 tCsrScanResult *pScanResult = NULL;
3610 eCsrJoinState eRoamState = eCsrStopRoaming;
3611 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3612 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3613 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3614#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3615 v_U8_t acm_mask = 0;
3616#endif
3617 tANI_U32 sessionId = pCommand->sessionId;
3618 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3619 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3620 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003621
3622 if(!pSession)
3623 {
3624 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3625 return (eCsrStopRoaming);
3626 }
3627
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 do
3629 {
3630 // Check for Cardbus eject condition, before trying to Roam to any BSS
3631 //***if( !balIsCardPresent(pAdapter) ) break;
3632
3633 if(NULL != pBSSList)
3634 {
3635 // When handling AP's capability change, continue to associate to
3636 // same BSS and make sure pRoamBssEntry is not Null.
3637 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3638 {
3639 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3640 {
3641 //Try the first BSS
3642 pCommand->u.roamCmd.pLastRoamBss = NULL;
3643 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3644 }
3645 else
3646 {
3647 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3648 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3649 {
3650 //Done with all the BSSs
3651 //In this case, will tell HDD the completion
3652 break;
3653 }
3654 else
3655 {
3656 //We need to indicate to HDD that we are done with this one.
3657 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3658 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3659 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3660 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3661 pRoamInfo = &roamInfo;
3662 }
3663 }
3664 while(pCommand->u.roamCmd.pRoamBssEntry)
3665 {
3666 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 /*If concurrency enabled take the concurrent connected channel first. */
3668 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07003669 if (vos_concurrent_sessions_running() &&
3670 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 {
3672 concurrentChannel =
3673 csrGetConcurrentOperationChannel(pMac);
3674 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003675 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 if ((concurrentChannel) &&
3677 (concurrentChannel ==
3678 pScanResult->Result.BssDescriptor.channelId))
3679 {
3680 //make this 0 because we do not want the
3681 //below check to pass as we don't want to
3682 //connect on other channel
3683 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3684 FL("Concurrent channel match =%d"),
3685 concurrentChannel);
3686 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 }
3688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003689
3690 if (!concurrentChannel)
3691 {
3692
3693 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3694 sessionId, &pScanResult->Result.BssDescriptor,
3695 pCommand->u.roamCmd.roamId)))
3696 {
3697 //Ok to roam this
3698 break;
3699 }
3700 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003701 else
3702 {
3703 eRoamState = eCsrStopRoamingDueToConcurrency;
3704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3706 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3707 {
3708 //Done with all the BSSs
3709 fDone = eANI_BOOLEAN_TRUE;
3710 break;
3711 }
3712 }
3713 if(fDone)
3714 {
3715 break;
3716 }
3717 }
3718 }
3719 //We have something to roam, tell HDD when it is infra.
3720 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3721 //For WDS, the indication is eCSR_ROAM_WDS_IND
3722 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3723 {
3724 if(pRoamInfo)
3725 {
3726 pSession->bRefAssocStartCnt--;
3727 //Complete the last association attemp because a new one is about to be tried
3728 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3729 eCSR_ROAM_ASSOCIATION_COMPLETION,
3730 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3731 }
3732 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3733 if(pScanResult)
3734 {
3735 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3737 {
3738 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
3739 fDone = eANI_BOOLEAN_TRUE;
3740 eRoamState = eCsrStopRoaming;
3741 break;
3742 }
3743 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3744 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3745 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3746 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3747 CSR_IS_QOS_BSS(pIesLocal) &&
3748 CSR_IS_UAPSD_BSS(pIesLocal) )
3749 {
3750#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3752 pIesLocal);
3753 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3754#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 }
3756 else
3757 {
3758 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3759 }
3760 if( pIesLocal && !pScanResult->Result.pvIes)
3761 {
3762 palFreeMemory(pMac->hHdd, pIesLocal);
3763 }
3764 }
3765 else
3766 {
3767 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3768 }
3769 roamInfo.pProfile = pProfile;
3770 pSession->bRefAssocStartCnt++;
3771 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3772 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3775 {
3776 // If this is a start IBSS profile, then we need to start the IBSS.
3777 if ( CSR_IS_START_IBSS(pProfile) )
3778 {
3779 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 // Attempt to start this IBSS...
3781 csrRoamAssignDefaultParam( pMac, pCommand );
3782 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
3783 if(HAL_STATUS_SUCCESS(status))
3784 {
3785 if ( fSameIbss )
3786 {
3787 eRoamState = eCsrStartIbssSameIbss;
3788 }
3789 else
3790 {
3791 eRoamState = eCsrContinueRoaming;
3792 }
3793 }
3794 else
3795 {
3796 //it somehow fail need to stop
3797 eRoamState = eCsrStopRoaming;
3798 }
3799 break;
3800 }
3801 else if ( (CSR_IS_WDS_AP(pProfile))
3802#ifdef WLAN_SOFTAP_FEATURE
3803 || (CSR_IS_INFRA_AP(pProfile))
3804#endif
3805 )
3806 {
3807 // Attempt to start this WDS...
3808 csrRoamAssignDefaultParam( pMac, pCommand );
3809 /* For AP WDS, we dont have any BSSDescription */
3810 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
3811 if(HAL_STATUS_SUCCESS(status))
3812 {
3813 eRoamState = eCsrContinueRoaming;
3814 }
3815 else
3816 {
3817 //it somehow fail need to stop
3818 eRoamState = eCsrStopRoaming;
3819 }
3820 }
3821 else
3822 {
3823 //Nothing we can do
3824 smsLog(pMac, LOGW, FL("cannot continue without BSS list\n"));
3825 eRoamState = eCsrStopRoaming;
3826 break;
3827 }
3828 }
3829 else //We have BSS
3830 {
3831 //Need to assign these value because they are used in csrIsSameProfile
3832 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3833 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
3834 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
3835 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
3836 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
3837 {
3838 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3839 {
3840 eRoamState = eCsrStartIbssSameIbss;
3841 break;
3842 }
3843 }
3844 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
3845 {
3846 //trying to connect to the one already connected
3847 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
3848 eRoamState = eCsrReassocToSelfNoCapChange;
3849 break;
3850 }
3851 // Attempt to Join this Bss...
3852 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
3853 break;
3854 }
3855
3856 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
3858 {
3859 //Need to indicate association_completion if association_start has been done
3860 if(pSession->bRefAssocStartCnt > 0)
3861 {
3862 pSession->bRefAssocStartCnt--;
3863 //Complete the last association attemp because a new one is about to be tried
3864 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3865 eCSR_ROAM_ASSOCIATION_COMPLETION,
3866 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3867 }
3868 }
3869
3870 return( eRoamState );
3871}
3872
Jeff Johnson295189b2012-06-20 16:38:30 -07003873static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3874{
3875 eHalStatus status = eHAL_STATUS_SUCCESS;
3876 eCsrJoinState RoamState;
3877 tANI_U32 sessionId = pCommand->sessionId;
3878
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 //***if( hddIsRadioStateOn( pAdapter ) )
3880 {
3881 // Attept to join a Bss...
3882 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07003883
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07003885 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 {
3887 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 // and if connected in Infrastructure mode...
3889 if ( csrIsConnStateInfra(pMac, sessionId) )
3890 {
3891 //... then we need to issue a disassociation
3892 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
3893 if(!HAL_STATUS_SUCCESS(status))
3894 {
3895 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d\n"), status);
3896 //roam command is completed by caller in the failed case
3897 fComplete = eANI_BOOLEAN_TRUE;
3898 }
3899 }
3900 else if( csrIsConnStateIbss(pMac, sessionId) )
3901 {
3902 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3903 if(!HAL_STATUS_SUCCESS(status))
3904 {
3905 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
3906 //roam command is completed by caller in the failed case
3907 fComplete = eANI_BOOLEAN_TRUE;
3908 }
3909 }
3910#ifdef WLAN_SOFTAP_FEATURE
3911 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
3912 {
3913 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3914 if(!HAL_STATUS_SUCCESS(status))
3915 {
3916 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
3917 //roam command is completed by caller in the failed case
3918 fComplete = eANI_BOOLEAN_TRUE;
3919 }
3920 }
3921#endif
3922 else
3923 {
3924 fComplete = eANI_BOOLEAN_TRUE;
3925 }
3926 if(fComplete)
3927 {
3928 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07003929 if(eCsrStopRoamingDueToConcurrency == RoamState)
3930 {
3931 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
3932 }
3933 else
3934 {
3935 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
3936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 }
3938 }
3939 else if ( eCsrReassocToSelfNoCapChange == RoamState )
3940 {
3941 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
3942 }
3943 else if ( eCsrStartIbssSameIbss == RoamState )
3944 {
3945 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
3946 }
3947 }//hddIsRadioStateOn
3948
3949 return status;
3950}
Jeff Johnson295189b2012-06-20 16:38:30 -07003951eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3952{
3953 tANI_U32 sessionId;
3954 tCsrRoamSession *pSession;
3955 tCsrScanResult *pScanResult = NULL;
3956 tSirBssDescription *pBssDesc = NULL;
3957 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 sessionId = pCommand->sessionId;
3959 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003960
3961 if(!pSession)
3962 {
3963 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3964 return eHAL_STATUS_FAILURE;
3965 }
3966
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
3968 {
3969 //the roaming is cancelled. Simply complete the command
3970 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
3971 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
3972 return eHAL_STATUS_FAILURE;
3973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 if (pCommand->u.roamCmd.pRoamBssEntry)
3975 {
3976 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3977 pBssDesc = &pScanResult->Result.BssDescriptor;
3978 }
3979 else
3980 {
3981 //the roaming is cancelled. Simply complete the command
3982 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
3983 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
3984 return eHAL_STATUS_FAILURE;
3985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
3987 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
3988 return status;
3989}
3990
Jeff Johnson295189b2012-06-20 16:38:30 -07003991eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3992{
3993 eHalStatus status = eHAL_STATUS_SUCCESS;
3994 tCsrRoamInfo roamInfo;
3995 tANI_U32 sessionId = pCommand->sessionId;
3996 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003997
3998 if(!pSession)
3999 {
4000 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4001 return eHAL_STATUS_FAILURE;
4002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004003
4004 switch ( pCommand->u.roamCmd.roamReason )
4005 {
4006 case eCsrForcedDisassoc:
4007 csrFreeRoamProfile(pMac, sessionId);
4008 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 case eCsrSmeIssuedDisassocForHandoff:
4011 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4012#if 0 // TODO : Confirm this change
4013 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4014#else
4015 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4016#endif
4017
4018 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 case eCsrForcedDisassocMICFailure:
4020 csrFreeRoamProfile(pMac, sessionId);
4021 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
4022 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 case eCsrForcedDeauth:
4024 csrFreeRoamProfile(pMac, sessionId);
4025 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
4026 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 case eCsrHddIssuedReassocToSameAP:
4028 case eCsrSmeIssuedReassocToSameAP:
4029 {
4030 tDot11fBeaconIEs *pIes = NULL;
4031
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 if( pSession->pConnectBssDesc )
4033 {
4034 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4035 if(!HAL_STATUS_SUCCESS(status) )
4036 {
4037 smsLog(pMac, LOGE, FL(" fail to parse IEs\n"));
4038 }
4039 else
4040 {
4041 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4042 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4043 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4045 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4046 pSession->bRefAssocStartCnt++;
4047 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4048 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4049
4050 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate\n"));
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004051 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4052 &pCommand->u.roamCmd.roamProfile );
4053 if(!HAL_STATUS_SUCCESS(status))
4054 {
4055 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
4056 }
4057
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 palFreeMemory(pMac->hHdd, pIes);
4059 pIes = NULL;
4060 }
4061 }
4062 break;
4063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 case eCsrCapsChange:
4065 smsLog(pMac, LOGE, FL("received eCsrCapsChange \n"));
4066 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4067 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4068 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 case eCsrSmeIssuedFTReassoc:
4070 smsLog(pMac, LOGE, FL("received FT Reassoc Req \n"));
4071 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4072 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004073
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 case eCsrStopBss:
4075 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4076 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4077 break;
4078
4079 case eCsrForcedDisassocSta:
4080 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4081 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4082 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4083 pCommand->u.roamCmd.reason);
4084 break;
4085
4086 case eCsrForcedDeauthSta:
4087 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4088 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4089 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4090 pCommand->u.roamCmd.reason);
4091 break;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004092
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004093 case eCsrPerformPreauth:
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08004094 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004095 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4096 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004097 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004098
4099 default:
4100 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4101
4102 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4103 {
4104 //Remember the roaming profile
4105 csrFreeRoamProfile(pMac, sessionId);
4106 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4107 {
4108 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4109 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4110 }
4111 }
4112
4113 //At this point, original uapsd_mask is saved in pCurRoamProfile
4114 //uapsd_mask in the pCommand may change from this point on.
4115
4116 // Attempt to roam with the new scan results (if we need to..)
4117 status = csrRoam( pMac, pCommand );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004118 if(!HAL_STATUS_SUCCESS(status))
4119 {
4120 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X\n"), status);
4121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 break;
4123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 return (status);
4125}
4126
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004127void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4128{
4129 pCommand->u.roamCmd.pLastRoamBss = NULL;
4130 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4131 //Because u.roamCmd is union and share with scanCmd and StatusChange
4132 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4133}
4134
Jeff Johnson295189b2012-06-20 16:38:30 -07004135void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4136{
4137 if(pCommand->u.roamCmd.fReleaseBssList)
4138 {
4139 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4140 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4141 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4142 }
4143 if(pCommand->u.roamCmd.fReleaseProfile)
4144 {
4145 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4146 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4147 }
4148 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4149 //Because u.roamCmd is union and share with scanCmd and StatusChange
4150 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4151}
4152
Jeff Johnson295189b2012-06-20 16:38:30 -07004153void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4154{
4155 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4156}
Jeff Johnson295189b2012-06-20 16:38:30 -07004157void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4158{
4159 tListElem *pEntry;
4160 tSmeCmd *pCommand;
4161 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004162 smsLog( pMac, LOG2, "Roam Completion ...\n" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4164 if ( pEntry )
4165 {
4166 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 // If the head of the queue is Active and it is a ROAM command, remove
4168 // and put this on the Free queue.
4169 if ( eSmeCommandRoam == pCommand->command )
4170 {
4171 //we need to process the result first before removing it from active list because state changes
4172 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4173 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4174 if( fReleaseCommand )
4175 {
4176 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4177 {
4178 csrReleaseCommandRoam( pMac, pCommand );
4179 }
4180 else
4181 {
4182 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004183 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 }
4185 }
4186 else
4187 {
4188 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004189 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 }
4191 }
4192 else
4193 {
4194 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
4195 }
4196 }
4197 else
4198 {
4199 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
4200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 if( fReleaseCommand )
4202 {
4203 smeProcessPendingQueue( pMac );
4204 }
4205}
4206
Jeff Johnson295189b2012-06-20 16:38:30 -07004207void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4208{
4209 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004210 if(!pSession)
4211 {
4212 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4213 return;
4214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4216 pSession->NumPmkidCandidate = 0;
4217}
Jeff Johnson295189b2012-06-20 16:38:30 -07004218#ifdef FEATURE_WLAN_WAPI
4219void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4220{
4221 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004222 if(!pSession)
4223 {
4224 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4225 return;
4226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4228 pSession->NumBkidCandidate = 0;
4229}
4230#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004231extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4232
Jeff Johnson295189b2012-06-20 16:38:30 -07004233static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4234 tSirBssDescription *pSirBssDesc,
4235 tDot11fBeaconIEs *pIes)
4236{
4237 eHalStatus status = eHAL_STATUS_SUCCESS;
4238 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4239 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004240
4241 if(!pSession)
4242 {
4243 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4244 return eHAL_STATUS_FAILURE;
4245 }
4246
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 if((eCSR_AUTH_TYPE_WPA == authType) ||
4248 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4249 (eCSR_AUTH_TYPE_RSN == authType) ||
4250 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4251#if defined WLAN_FEATURE_VOWIFI_11R
4252 ||
4253 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4254 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4255#endif /* FEATURE_WLAN_WAPI */
4256#ifdef FEATURE_WLAN_WAPI
4257 ||
4258 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4259 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4260#endif /* FEATURE_WLAN_WAPI */
4261 )
4262 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4264 {
4265 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
4266 }
4267 if( pIesLocal )
4268 {
4269 tANI_U32 nIeLen;
4270 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004271 if((eCSR_AUTH_TYPE_RSN == authType) ||
4272#if defined WLAN_FEATURE_VOWIFI_11R
4273 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4274 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4275#endif /* WLAN_FEATURE_VOWIFI_11R */
4276 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4277 {
4278 if(pIesLocal->RSN.present)
4279 {
4280 //Calculate the actual length
4281 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4282 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4283 + 2 //akm_suite_count
4284 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4285 + 2; //reserved
4286 if( pIesLocal->RSN.pmkid_count )
4287 {
4288 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4289 }
4290 //nIeLen doesn't count EID and length fields
4291 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4292 {
4293 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4294 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4295 //copy upto akm_suites
4296 pIeBuf = pSession->pWpaRsnRspIE + 2;
4297 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4298 pIeBuf += 8;
4299 if( pIesLocal->RSN.pwise_cipher_suite_count )
4300 {
4301 //copy pwise_cipher_suites
4302 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4303 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4304 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4305 }
4306 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4307 pIeBuf += 2;
4308 if( pIesLocal->RSN.akm_suite_count )
4309 {
4310 //copy akm_suites
4311 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4312 pIesLocal->RSN.akm_suite_count * 4);
4313 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4314 }
4315 //copy the rest
4316 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4317 pIesLocal->RSN.akm_suite_count * 4,
4318 2 + pIesLocal->RSN.pmkid_count * 4);
4319 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4320 }
4321 }
4322 }
4323 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4324 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4325 {
4326 if(pIesLocal->WPA.present)
4327 {
4328 //Calculate the actual length
4329 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4330 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4331 + 2 //auth_suite_count
4332 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4333 // The WPA capabilities follows the Auth Suite (two octects)--
4334 // this field is optional, and we always "send" zero, so just
4335 // remove it. This is consistent with our assumptions in the
4336 // frames compiler; c.f. bug 15234:
4337 //nIeLen doesn't count EID and length fields
4338 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4339 {
4340 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4341 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4342 pIeBuf = pSession->pWpaRsnRspIE + 2;
4343 //Copy WPA OUI
4344 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4345 pIeBuf += 4;
4346 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4347 pIesLocal->WPA.unicast_cipher_count * 4);
4348 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4349 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4350 pIesLocal->WPA.auth_suite_count * 4);
4351 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4352 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4353 }
4354 }
4355 }
4356#ifdef FEATURE_WLAN_WAPI
4357 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4358 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4359 {
4360 if(pIesLocal->WAPI.present)
4361 {
4362 //Calculate the actual length
4363 nIeLen = 4 //version + akm_suite_count
4364 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4365 + 2 //pwise_cipher_suite_count
4366 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4367 + 6; //gp_cipher_suite + preauth + reserved
4368 if( pIesLocal->WAPI.bkid_count )
4369 {
4370 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4371 }
4372
4373 //nIeLen doesn't count EID and length fields
4374 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4375 {
4376 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4377 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4378 pIeBuf = pSession->pWapiRspIE + 2;
4379 //copy upto akm_suite_count
4380 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4381 pIeBuf += 4;
4382 if( pIesLocal->WAPI.akm_suite_count )
4383 {
4384 //copy akm_suites
4385 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4386 pIesLocal->WAPI.akm_suite_count * 4);
4387 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4388 }
4389 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4390 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4392 {
4393 //copy pwise_cipher_suites
4394 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4395 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4396 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4397 }
4398 //gp_cipher_suite + preauth + reserved + bkid_count
4399 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4400 pIeBuf += 8;
4401 if( pIesLocal->WAPI.bkid_count )
4402 {
4403 //copy akm_suites
4404 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4405 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4406 }
4407 pSession->nWapiRspIeLength = nIeLen + 2;
4408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 }
4410 }
4411#endif /* FEATURE_WLAN_WAPI */
4412 if( !pIes )
4413 {
4414 //locally allocated
4415 palFreeMemory(pMac->hHdd, pIesLocal);
4416 }
4417 }
4418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 return (status);
4420}
4421
Jeff Johnson295189b2012-06-20 16:38:30 -07004422static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4423{
4424 v_U8_t bACWeights[WLANTL_MAX_AC];
4425 v_U8_t paramBk, paramBe, paramVi, paramVo;
4426 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4428 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4429 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4430 //This doesn't address the case where the lower AC needs a real higher weight
4431 if( pIEs->WMMParams.present )
4432 {
4433 //no change to the lowest ones
4434 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4435 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4436 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4437 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4438 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4439 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4440 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4441 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4442 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4443 {
4444 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4445 fWeightChange = VOS_TRUE;
4446 }
4447 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4448 {
4449 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4450 fWeightChange = VOS_TRUE;
4451 }
4452 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4453 {
4454 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4455 fWeightChange = VOS_TRUE;
4456 }
4457 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4458 {
4459 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4460 fWeightChange = VOS_TRUE;
4461 }
4462 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4463 {
4464 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4465 fWeightChange = VOS_TRUE;
4466 }
4467 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4468 {
4469 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4470 fWeightChange = VOS_TRUE;
4471 }
4472 if(fWeightChange)
4473 {
4474 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)\n"), bACWeights[0], bACWeights[1],
4475 bACWeights[2], bACWeights[3]);
4476 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4477 }
4478 }
4479}
Jeff Johnson295189b2012-06-20 16:38:30 -07004480#ifdef WLAN_FEATURE_VOWIFI_11R
4481//Returns whether the current association is a 11r assoc or not
4482tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4483{
4484#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4485 return csrNeighborRoamIs11rAssoc(pMac);
4486#else
4487 return eANI_BOOLEAN_FALSE;
4488#endif
4489}
4490#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004491#ifdef FEATURE_WLAN_CCX
4492//Returns whether the current association is a CCX assoc or not
4493tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4494{
4495#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4496 return csrNeighborRoamIsCCXAssoc(pMac);
4497#else
4498 return eANI_BOOLEAN_FALSE;
4499#endif
4500}
4501#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004502#ifdef FEATURE_WLAN_LFR
4503//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304504tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004505{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304506 tCsrRoamSession *pSession = NULL;
4507
4508 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4509 {
4510 pSession = CSR_GET_SESSION( pMac, sessionId );
4511 if (NULL != pSession->pCurRoamProfile)
4512 {
4513 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4514 {
4515 return eANI_BOOLEAN_FALSE;
4516 }
4517 }
4518 }
4519
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004520 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004521 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004522}
4523#endif
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525//Return true means the command can be release, else not
4526static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4527 eCsrRoamCompleteResult Result, void *Context )
4528{
4529 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4530 tSirBssDescription *pSirBssDesc = NULL;
4531 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4532 tCsrScanResult *pScanResult = NULL;
4533 tCsrRoamInfo roamInfo;
4534 sme_QosAssocInfo assocInfo;
4535 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4536 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4537 tDot11fBeaconIEs *pIes = NULL;
4538 tANI_U32 sessionId = pCommand->sessionId;
4539 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4540 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4541 eRoamCmdStatus roamStatus;
4542 eCsrRoamResult roamResult;
4543 eHalStatus status;
4544 tANI_U32 key_timeout_interval = 0;
4545#ifdef WLAN_SOFTAP_FEATURE
4546 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
4547#endif
4548
Jeff Johnson32d95a32012-09-10 13:15:23 -07004549 if(!pSession)
4550 {
4551 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4552 return eANI_BOOLEAN_FALSE;
4553 }
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 smsLog( pMac, LOG1, FL("Processing ROAM results...\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 switch( Result )
4557 {
4558 case eCsrJoinSuccess:
4559 // reset the IDLE timer
4560 // !!
4561 // !! fall through to the next CASE statement here is intentional !!
4562 // !!
4563 case eCsrReassocSuccess:
4564 if(eCsrReassocSuccess == Result)
4565 {
4566 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4567 }
4568 else
4569 {
4570 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4571 }
4572 // Success Join Response from LIM. Tell NDIS we are connected and save the
4573 // Connected state...
4574 smsLog(pMac, LOGW, FL("receives association indication\n"));
4575 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4576 //always free the memory here
4577 if(pSession->pWpaRsnRspIE)
4578 {
4579 pSession->nWpaRsnRspIeLength = 0;
4580 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4581 pSession->pWpaRsnRspIE = NULL;
4582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004583#ifdef FEATURE_WLAN_WAPI
4584 if(pSession->pWapiRspIE)
4585 {
4586 pSession->nWapiRspIeLength = 0;
4587 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4588 pSession->pWapiRspIE = NULL;
4589 }
4590#endif /* FEATURE_WLAN_WAPI */
4591#ifdef FEATURE_WLAN_BTAMP_UT_RF
4592 //Reset counter so no join retry is needed.
4593 pSession->maxRetryCount = 0;
4594 csrRoamStopJoinRetryTimer(pMac, sessionId);
4595#endif
4596 /* This creates problem since we have not saved the connected profile.
4597 So moving this after saving the profile
4598 */
4599 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4600 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4601 {
4602 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4603 }
4604 else
4605 {
4606 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 //Use the last connected bssdesc for reassoc-ing to the same AP.
4609 //NOTE: What to do when reassoc to a different AP???
4610 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4611 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4612 {
4613 pSirBssDesc = pSession->pConnectBssDesc;
4614 if(pSirBssDesc)
4615 {
4616 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4617 }
4618 }
4619 else
4620 {
4621
4622 if(pCommand->u.roamCmd.pRoamBssEntry)
4623 {
4624 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4625 if(pScanResult != NULL)
4626 {
4627 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4628 //this can be NULL
4629 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4630 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4631 }
4632 }
4633 }
4634 if( pSirBssDesc )
4635 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4638 //Save WPA/RSN IE
4639 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4640#ifdef FEATURE_WLAN_CCX
4641 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4642#endif
4643
4644 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4645 // substate change.
4646 // Moving even save profile above so that below mentioned conditon is also met.
4647 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4648 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4650 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4651 // will be dropped for the security context may not be set properly.
4652 //
4653 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4654 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4655 //
4656 // this reordering was done on titan_prod_usb branch and is being replicated here.
4657 //
4658
4659 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4660 !pProfile->bWPSAssociation)
4661 {
4662 // Issue the set Context request to LIM to establish the Unicast STA context
4663 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4664 pProfile->negotiatedUCEncryptionType,
4665 pSirBssDesc, &(pSirBssDesc->bssId),
4666 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4667 {
4668 smsLog( pMac, LOGE, FL(" Set context for unicast fail\n") );
4669 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4670 }
4671 // Issue the set Context request to LIM to establish the Broadcast STA context
4672 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4673 pSirBssDesc, &BroadcastMac,
4674 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4675 }
4676 else
4677 {
4678 //Need to wait for supplicant authtication
4679 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 //Set the subestate to WaitForKey in case authentiation is needed
4681 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4682
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 if(pProfile->bWPSAssociation)
4684 {
4685 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4686 }
4687 else
4688 {
4689 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4690 }
4691
4692 //Save sessionId in case of timeout
4693 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4694 //This time should be long enough for the rest of the process plus setting key
4695 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4696 {
4697 //Reset our state so nothting is blocked.
4698 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer\n") );
4699 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4700 }
4701 }
4702
4703 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4704 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 if(Context)
4706 {
4707 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4708 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4710 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4711#ifdef WLAN_FEATURE_VOWIFI_11R
4712 len += pJoinRsp->parsedRicRspLen;
4713#endif /* WLAN_FEATURE_VOWIFI_11R */
4714#ifdef FEATURE_WLAN_CCX
4715 len += pJoinRsp->tspecIeLen;
4716#endif
4717 if(len)
4718 {
4719 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4720 (void **)&pSession->connectedInfo.pbFrames, len)))
4721 {
4722 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4723 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4724 {
4725 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4726 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4727 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4728#ifdef WLAN_FEATURE_VOWIFI_11R
4729 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4730#endif /* WLAN_FEATURE_VOWIFI_11R */
4731#ifdef FEATURE_WLAN_CCX
4732 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4733#endif
4734 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4735 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4736 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4737 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4738 }
4739 else
4740 {
4741 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004742 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4744 pSession->connectedInfo.pbFrames = NULL;
4745 }
4746 }
4747 }
4748 if(pCommand->u.roamCmd.fReassoc)
4749 {
4750 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4751 }
4752 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4753 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4754 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4755 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4756 }
4757 else
4758 {
4759 if(pCommand->u.roamCmd.fReassoc)
4760 {
4761 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4762 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4763 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4764 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4765 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4766 }
4767 }
4768#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4769 // Indicate SME-QOS with reassoc success event, only after
4770 // copying the frames
4771 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4772#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 roamInfo.pBssDesc = pSirBssDesc;
4774 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4775 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4776#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4777 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4778#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4779 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07004780#ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
4781 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
4782 //It may be better to let QoS do this????
4783 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
4784 {
4785 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now\n",
4786 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
4787 pmcStartUapsd( pMac, NULL, NULL );
4788 }
4789#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4791 if( pSession->bRefAssocStartCnt > 0 )
4792 {
4793 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004794 //Remove this code once SLM_Sessionization is supported
4795 //BMPS_WORKAROUND_NOT_NEEDED
4796 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07004797 {
4798 pMac->roam.configParam.doBMPSWorkaround = 1;
4799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4801 }
4802
4803 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 // reset the PMKID candidate list
4805 csrResetPMKIDCandidateList( pMac, sessionId );
4806 //Update TL's AC weight base on the current EDCA parameters
4807 //These parameters may change in the course of the connection, that sictuation
4808 //is not taken care here. This change is mainly to address a WIFI WMM test where
4809 //BE has a equal or higher TX priority than VI.
4810 //We only do this for infra link
4811 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
4812 {
4813 csrCheckAndUpdateACWeight(pMac, pIes);
4814 }
4815#ifdef FEATURE_WLAN_WAPI
4816 // reset the BKID candidate list
4817 csrResetBKIDCandidateList( pMac, sessionId );
4818#endif /* FEATURE_WLAN_WAPI */
4819 }
4820 else
4821 {
4822 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc\n");
4823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 csrScanCancelIdleScan(pMac);
4825 //Not to signal link up because keys are yet to be set.
4826 //The linkup function will overwrite the sub-state that we need to keep at this point.
4827 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
4828 {
4829 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
4830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
4832 //enough to let security and DHCP handshake succeed before entry into BMPS
4833 if (pmcShouldBmpsTimerRun(pMac))
4834 {
4835 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
4836 != eHAL_STATUS_SUCCESS)
4837 {
4838 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
4839 }
4840 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
4841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 break;
4843
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 case eCsrStartBssSuccess:
4845 // on the StartBss Response, LIM is returning the Bss Description that we
4846 // are beaconing. Add this Bss Description to our scan results and
4847 // chain the Profile to this Bss Description. On a Start BSS, there was no
4848 // detected Bss description (no partner) so we issued the Start Bss to
4849 // start the Ibss without any Bss description. Lim was kind enough to return
4850 // the Bss Description that we start beaconing for the newly started Ibss.
4851 smsLog(pMac, LOG2, FL("receives start BSS ok indication\n"));
4852 status = eHAL_STATUS_FAILURE;
4853#ifdef WLAN_SOFTAP_FEATURE
4854 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
4855#endif
4856 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4857 if( CSR_IS_IBSS( pProfile ) )
4858 {
4859 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
4860 }
4861#ifdef WLAN_SOFTAP_FEATURE
4862 else if (CSR_IS_INFRA_AP(pProfile))
4863 {
4864 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
4865 }
4866#endif
4867 else
4868 {
4869 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
4870 }
4871 if( !CSR_IS_WDS_STA( pProfile ) )
4872 {
4873 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
4874#ifdef WLAN_SOFTAP_FEATURE
4875 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
4876#else
4877 pSirBssDesc = (tSirBssDescription *)Context;
4878#endif
4879 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
4880 {
4881 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs\n"));
4882 roamInfo.pBssDesc = pSirBssDesc;
4883 //We need to associate_complete it first, becasue Associate_start already indicated.
4884 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4885 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
4886 break;
4887 }
4888#ifdef WLAN_SOFTAP_FEATURE
4889 if (!CSR_IS_INFRA_AP(pProfile))
4890#endif
4891 {
4892 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
4893 }
4894 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
4895 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
4896 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4897 if(pSirBssDesc)
4898 {
4899 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4900 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4901 }
4902 //We are doen with the IEs so free it
4903 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4905 {
4906 vos_log_ibss_pkt_type *pIbssLog;
4907 tANI_U32 bi;
4908
4909 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
4910 if(pIbssLog)
4911 {
4912 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
4913 {
4914 //We start the IBSS (didn't find any matched IBSS out there)
4915 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
4916 }
4917 else
4918 {
4919 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
4920 }
4921 if(pSirBssDesc)
4922 {
4923 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
4924 pIbssLog->operatingChannel = pSirBssDesc->channelId;
4925 }
4926 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
4927 {
4928 //***U8 is not enough for beacon interval
4929 pIbssLog->beaconInterval = (v_U8_t)bi;
4930 }
4931 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
4932 }
4933 }
4934#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4935 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
4936 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07004937#ifdef WLAN_SOFTAP_FEATURE
4938 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
4939 {
4940#else
4941 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ))
4942 {
4943#endif
4944 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
4945 csrRoamIssueSetContextReq( pMac, sessionId,
4946 pProfile->negotiatedMCEncryptionType,
4947 pSirBssDesc, &BroadcastMac,
4948 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4949 }
4950 }
4951 else
4952 {
4953 //Keep the state to eCSR_ROAMING_STATE_JOINING
4954 //Need to send join_req.
4955 if(pCommand->u.roamCmd.pRoamBssEntry)
4956 {
4957 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
4958 {
4959 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4960 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4961 // Set the roaming substate to 'join attempt'...
4962 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowda071f6082013-01-16 13:39:39 -08004963 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 }
4965 }
4966 else
4967 {
4968 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc\n" );
4969 VOS_ASSERT( 0 );
4970 }
4971 }
4972 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
4973 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
4974 //trigger the connection start indication in Vista
4975 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
4976 {
4977 roamStatus = eCSR_ROAM_IBSS_IND;
4978 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
4979 if( CSR_IS_WDS( pProfile ) )
4980 {
4981 roamStatus = eCSR_ROAM_WDS_IND;
4982 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
4983 }
4984#ifdef WLAN_SOFTAP_FEATURE
4985 if( CSR_IS_INFRA_AP( pProfile ) )
4986 {
4987 roamStatus = eCSR_ROAM_INFRA_IND;
4988 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
4989 }
4990#endif
4991
4992 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
4993 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
4994 //trigger the connection start indication in Vista
4995 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4996 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4997 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4998 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
4999 {
5000 //We start the IBSS (didn't find any matched IBSS out there)
5001 roamInfo.pBssDesc = pSirBssDesc;
5002 }
5003#ifdef WLAN_SOFTAP_FEATURE
5004 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
5005#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005006 //Remove this code once SLM_Sessionization is supported
5007 //BMPS_WORKAROUND_NOT_NEEDED
5008 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005009 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005010 {
5011 pMac->roam.configParam.doBMPSWorkaround = 1;
5012 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005013
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5015 }
5016
5017 csrScanCancelIdleScan(pMac);
5018 //Only use this timer for ibss. BAP has its own timer for WDS
5019 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5020 {
5021 //start the join IBSS timer
5022 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5023 pSession->ibss_join_pending = TRUE;
5024 }
5025 if( HAL_STATUS_SUCCESS( status ) )
5026 {
5027 //Already sent join_req for the WDS station
5028 fReleaseCommand = eANI_BOOLEAN_FALSE;
5029 }
5030 else if( CSR_IS_WDS_STA( pProfile ) )
5031 {
5032 //need to send stop BSS because we fail to send join_req
5033 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5034 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5035 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 case eCsrStartBssFailure:
5039#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5040 {
5041 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5043 if(pIbssLog)
5044 {
5045 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5046 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5047 }
5048 }
5049#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 roamStatus = eCSR_ROAM_IBSS_IND;
5051 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5052 if( CSR_IS_WDS( pProfile ) )
5053 {
5054 roamStatus = eCSR_ROAM_WDS_IND;
5055 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5056 }
5057#ifdef WLAN_SOFTAP_FEATURE
5058 if( CSR_IS_INFRA_AP( pProfile ) )
5059 {
5060 roamStatus = eCSR_ROAM_INFRA_IND;
5061 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5062 }
5063#endif
5064 if(Context)
5065 {
5066 pSirBssDesc = (tSirBssDescription *)Context;
5067 }
5068 else
5069 {
5070 pSirBssDesc = NULL;
5071 }
5072 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5073 roamInfo.pBssDesc = pSirBssDesc;
5074 //We need to associate_complete it first, becasue Associate_start already indicated.
5075 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5076 csrSetDefaultDot11Mode( pMac );
5077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 case eCsrSilentlyStopRoaming:
5079 // We are here because we try to start the same IBSS
5080 //No message to PE
5081 // return the roaming state to Joined.
5082 smsLog(pMac, LOGW, FL("receives silently roaming indication\n"));
5083 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5084 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5085 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5086 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5087 if( roamInfo.pBssDesc )
5088 {
5089 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5090 }
5091 //Since there is no change in the current state, simply pass back no result otherwise
5092 //HDD may be mistakenly mark to disconnected state.
5093 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5094 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 case eCsrSilentlyStopRoamingSaveState:
5097 //We are here because we try to connect to the same AP
5098 //No message to PE
5099 smsLog(pMac, LOGW, FL("receives silently stop roaming indication\n"));
5100 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5101
5102 //to aviod resetting the substate to NONE
5103 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5104 //No need to change substate to wai_for_key because there is no state change
5105 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5106 if( roamInfo.pBssDesc )
5107 {
5108 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5111 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5112 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5113 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5114 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5115 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5116 roamInfo.staId = pSession->connectedInfo.staId;
5117 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5118#if defined(VOSS_ENABLED)
5119 VOS_ASSERT( roamInfo.staId != 0 );
5120#endif
5121 pSession->bRefAssocStartCnt--;
5122 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5123 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5124 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5125 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 case eCsrReassocFailure:
5127#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5128 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5129#endif
5130 case eCsrJoinWdsFailure:
5131 smsLog(pMac, LOGW, FL("failed to join WDS\n"));
5132 csrFreeConnectBssDesc(pMac, sessionId);
5133 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5134 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5135 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5136 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5137 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5138 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5139 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5140 eCSR_ROAM_WDS_IND,
5141 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5142 //Need to issue stop_bss
5143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 case eCsrJoinFailure:
5145 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005146 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 default:
5148 {
5149 smsLog(pMac, LOGW, FL("receives no association indication\n"));
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005150 smsLog(pMac, LOG1, FL("Assoc ref count %d\n"),
5151 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5153 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5154 {
5155 //do not free for the other profiles as we need to send down stop BSS later
5156 csrFreeConnectBssDesc(pMac, sessionId);
5157 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5158 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5159 csrSetDefaultDot11Mode( pMac );
5160 }
5161
5162 switch( pCommand->u.roamCmd.roamReason )
5163 {
5164 // If this transition is because of an 802.11 OID, then we transition
5165 // back to INIT state so we sit waiting for more OIDs to be issued and
5166 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005167 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 case eCsrSmeIssuedAssocToSimilarAP:
5169 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005170 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5172 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5173 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5174 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5175 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 /* Defeaturize this later if needed */
5177#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5178 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5179 if (csrRoamIsHandoffInProgress(pMac))
5180 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 /* Should indicate neighbor roam algorithm about the connect failure here */
5182 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005184#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 if(pSession->bRefAssocStartCnt > 0)
5186 {
5187 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005188 if(eCsrJoinFailureDueToConcurrency == Result)
5189 {
5190 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5191 eCSR_ROAM_ASSOCIATION_COMPLETION,
5192 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5193 }
5194 else
5195 {
5196 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 eCSR_ROAM_ASSOCIATION_COMPLETION,
5198 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 }
Gopichand Nakkalad9a00c52012-12-31 16:43:00 -08005201 else
5202 {
5203 /* bRefAssocStartCnt is not incremented when
5204 * eRoamState == eCsrStopRoamingDueToConcurrency
5205 * in csrRoamJoinNextBss API. so handle this in
5206 * else case by sending assoc failure
5207 */
5208 csrRoamCallCallback(pMac, sessionId, NULL,
5209 pCommand->u.scanCmd.roamId,
5210 eCSR_ROAM_ASSOCIATION_FAILURE,
5211 eCSR_ROAM_RESULT_FAILURE);
5212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 smsLog(pMac, LOG1, FL(" roam(reason %d) failed\n"), pCommand->u.roamCmd.roamReason);
5214#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5215 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5216#endif
5217 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5218 csrScanStartIdleScan(pMac);
5219#ifdef FEATURE_WLAN_BTAMP_UT_RF
5220 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5221 //BT activity and not able to recevie WLAN traffic. Retry the join
5222 if( CSR_IS_WDS_STA(pProfile) )
5223 {
5224 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5225 }
5226#endif
5227 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 case eCsrHddIssuedReassocToSameAP:
5229 case eCsrSmeIssuedReassocToSameAP:
5230 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5231
5232 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5233#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5234 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5235#endif
5236 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5237 csrScanStartIdleScan(pMac);
5238 break;
5239 case eCsrForcedDisassoc:
5240 case eCsrForcedDeauth:
5241 case eCsrSmeIssuedIbssJoinFailure:
5242 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5243
5244 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5245 {
5246 // Notify HDD that IBSS join failed
5247 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5248 }
5249 else
5250 {
5251 csrRoamCallCallback(pMac, sessionId, NULL,
5252 pCommand->u.roamCmd.roamId,
5253 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5254 }
5255#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5256 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5257#endif
5258 csrRoamLinkDown(pMac, sessionId);
5259 csrScanStartIdleScan(pMac);
5260 break;
5261 case eCsrForcedIbssLeave:
5262 csrRoamCallCallback(pMac, sessionId, NULL,
5263 pCommand->u.roamCmd.roamId,
5264 eCSR_ROAM_IBSS_LEAVE,
5265 eCSR_ROAM_RESULT_IBSS_STOP);
5266 break;
5267 case eCsrForcedDisassocMICFailure:
5268 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5269
5270 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5271#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5272 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5273#endif
5274 csrScanStartIdleScan(pMac);
5275 break;
5276#ifdef WLAN_SOFTAP_FEATURE
5277 case eCsrStopBss:
5278 csrRoamCallCallback(pMac, sessionId, NULL,
5279 pCommand->u.roamCmd.roamId,
5280 eCSR_ROAM_INFRA_IND,
5281 eCSR_ROAM_RESULT_INFRA_STOPPED);
5282 break;
5283 case eCsrForcedDisassocSta:
5284 case eCsrForcedDeauthSta:
5285 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5286 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5287 {
5288 pSession = CSR_GET_SESSION(pMac, sessionId);
5289 if (!pSession)
5290 break;
5291
5292 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5293 {
5294 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5295 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5296 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5297 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5298 roamInfo.statusCode = eSIR_SME_SUCCESS;
5299 status = csrRoamCallCallback(pMac, sessionId,
5300 &roamInfo, pCommand->u.roamCmd.roamId,
5301 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5302 }
5303 }
5304 break;
5305#endif
5306 case eCsrLostLink1:
5307 // if lost link roam1 failed, then issue lost link Scan2 ...
5308 csrScanRequestLostLink2(pMac, sessionId);
5309 break;
5310 case eCsrLostLink2:
5311 // if lost link roam2 failed, then issue lost link scan3 ...
5312 csrScanRequestLostLink3(pMac, sessionId);
5313 break;
5314 case eCsrLostLink3:
5315 default:
5316 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5317
5318 //We are done with one round of lostlink roaming here
5319 csrScanHandleFailedLostlink3(pMac, sessionId);
5320 break;
5321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 break;
5323 }
5324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 return ( fReleaseCommand );
5326}
5327
Jeff Johnson295189b2012-06-20 16:38:30 -07005328eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5329{
5330 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 return (status);
5332}
5333
Jeff Johnson295189b2012-06-20 16:38:30 -07005334eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5335{
5336 eHalStatus status = eHAL_STATUS_SUCCESS;
5337 tANI_U32 size = 0;
5338
5339 do
5340 {
5341 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5342 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5343 {
5344 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5345 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5346 if(!HAL_STATUS_SUCCESS(status))
5347 {
5348 break;
5349 }
5350 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5351 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5352 }
5353 if(pSrcProfile->SSIDs.numOfSSIDs)
5354 {
5355 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5356 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5357 if(!HAL_STATUS_SUCCESS(status))
5358 {
5359 break;
5360 }
5361 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5362 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5363 }
5364 if(pSrcProfile->nWPAReqIELength)
5365 {
5366 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5367 if(!HAL_STATUS_SUCCESS(status))
5368 {
5369 break;
5370 }
5371 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5372 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5373 }
5374 if(pSrcProfile->nRSNReqIELength)
5375 {
5376 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5377 if(!HAL_STATUS_SUCCESS(status))
5378 {
5379 break;
5380 }
5381 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5382 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5383 }
5384#ifdef FEATURE_WLAN_WAPI
5385 if(pSrcProfile->nWAPIReqIELength)
5386 {
5387 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5388 if(!HAL_STATUS_SUCCESS(status))
5389 {
5390 break;
5391 }
5392 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5393 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5394 }
5395#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 if(pSrcProfile->nAddIEScanLength)
5397 {
5398 status = palAllocateMemory(pMac->hHdd,
5399 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5400 if(!HAL_STATUS_SUCCESS(status))
5401 {
5402 break;
5403 }
5404 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5405 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5406 pSrcProfile->nAddIEScanLength);
5407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 if(pSrcProfile->nAddIEAssocLength)
5409 {
5410 status = palAllocateMemory(pMac->hHdd,
5411 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5412 if(!HAL_STATUS_SUCCESS(status))
5413 {
5414 break;
5415 }
5416 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5417 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5418 pSrcProfile->nAddIEAssocLength);
5419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 if(pSrcProfile->ChannelInfo.ChannelList)
5421 {
5422 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5423 if(!HAL_STATUS_SUCCESS(status))
5424 {
5425 break;
5426 }
5427 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5428 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 pDstProfile->AuthType = pSrcProfile->AuthType;
5431 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5432 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5433 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5434 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5435 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5436 pDstProfile->BSSType = pSrcProfile->BSSType;
5437 pDstProfile->phyMode = pSrcProfile->phyMode;
5438 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5439
5440#ifdef FEATURE_WLAN_WAPI
5441 if(csrIsProfileWapi(pSrcProfile))
5442 {
5443 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5444 {
5445 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5446 }
5447 }
5448#endif /* FEATURE_WLAN_WAPI */
5449 pDstProfile->CBMode = pSrcProfile->CBMode;
5450 /*Save the WPS info*/
5451 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5452 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
5454#ifdef WLAN_SOFTAP_FEATURE
5455 pDstProfile->privacy = pSrcProfile->privacy;
5456 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5457 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5458 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5459 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5460 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5461 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5462 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5463 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5464 pDstProfile->wps_state = pSrcProfile->wps_state;
5465 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
5466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005468#ifdef WLAN_FEATURE_VOWIFI_11R
5469 if (pSrcProfile->MDID.mdiePresent)
5470 {
5471 pDstProfile->MDID.mdiePresent = 1;
5472 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5473 }
5474#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 }while(0);
5476
5477 if(!HAL_STATUS_SUCCESS(status))
5478 {
5479 csrReleaseProfile(pMac, pDstProfile);
5480 pDstProfile = NULL;
5481 }
5482
5483 return (status);
5484}
Jeff Johnson295189b2012-06-20 16:38:30 -07005485eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5486{
5487 eHalStatus status = eHAL_STATUS_SUCCESS;
5488 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5489 do
5490 {
5491 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5492 if(pSrcProfile->bssid)
5493 {
5494 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5495 if(!HAL_STATUS_SUCCESS(status))
5496 {
5497 break;
5498 }
5499 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5500 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5501 }
5502 if(pSrcProfile->SSID.ssId)
5503 {
5504 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5505 if(!HAL_STATUS_SUCCESS(status))
5506 {
5507 break;
5508 }
5509 pDstProfile->SSIDs.numOfSSIDs = 1;
5510 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5511 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5512 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5513 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005514 if(pSrcProfile->nAddIEAssocLength)
5515 {
5516 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5517 if(!HAL_STATUS_SUCCESS(status))
5518 {
5519 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs \n") );
5520 break;
5521 }
5522 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5523 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5524 pSrcProfile->nAddIEAssocLength);
5525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5527 if(!HAL_STATUS_SUCCESS(status))
5528 {
5529 break;
5530 }
5531 pDstProfile->ChannelInfo.numOfChannels = 1;
5532 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 pDstProfile->AuthType.numEntries = 1;
5534 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5535 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5536 pDstProfile->EncryptionType.numEntries = 1;
5537 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5538 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5539 pDstProfile->mcEncryptionType.numEntries = 1;
5540 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5541 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5542 pDstProfile->BSSType = pSrcProfile->BSSType;
5543 pDstProfile->CBMode = pSrcProfile->CBMode;
5544 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5545#ifdef WLAN_FEATURE_VOWIFI_11R
5546 if (pSrcProfile->MDID.mdiePresent)
5547 {
5548 pDstProfile->MDID.mdiePresent = 1;
5549 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5550 }
5551#endif
5552
5553 }while(0);
5554
5555 if(!HAL_STATUS_SUCCESS(status))
5556 {
5557 csrReleaseProfile(pMac, pDstProfile);
5558 pDstProfile = NULL;
5559 }
5560
5561 return (status);
5562}
5563
Jeff Johnson295189b2012-06-20 16:38:30 -07005564eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5565 tScanResultHandle hBSSList,
5566 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5567 tANI_BOOLEAN fClearScan)
5568{
5569 eHalStatus status = eHAL_STATUS_SUCCESS;
5570 tSmeCmd *pCommand;
5571
5572 pCommand = csrGetCommandBuffer(pMac);
5573 if(NULL == pCommand)
5574 {
5575 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5576 status = eHAL_STATUS_RESOURCES;
5577 }
5578 else
5579 {
5580 if( fClearScan )
5581 {
5582 csrScanCancelIdleScan(pMac);
5583 csrScanAbortMacScanNotForConnect(pMac);
5584 }
5585 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5586 if(NULL == pProfile)
5587 {
5588 //We can roam now
5589 //Since pProfile is NULL, we need to build our own profile, set everything to default
5590 //We can only support open and no encryption
5591 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5592 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5593 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5594 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5595 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5596 }
5597 else
5598 {
5599 //make a copy of the profile
5600 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5601 if(HAL_STATUS_SUCCESS(status))
5602 {
5603 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5604 }
5605 }
5606 pCommand->command = eSmeCommandRoam;
5607 pCommand->sessionId = (tANI_U8)sessionId;
5608 pCommand->u.roamCmd.hBSSList = hBSSList;
5609 pCommand->u.roamCmd.roamId = roamId;
5610 pCommand->u.roamCmd.roamReason = reason;
5611 //We need to free the BssList when the command is done
5612 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5613 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5615 FL("CSR PERSONA=%d"),
5616 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5618 if( !HAL_STATUS_SUCCESS( status ) )
5619 {
5620 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5621 csrReleaseCommandRoam( pMac, pCommand );
5622 }
5623 }
5624
5625 return (status);
5626}
Jeff Johnson295189b2012-06-20 16:38:30 -07005627eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5628 tCsrRoamModifyProfileFields *pMmodProfileFields,
5629 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5630{
5631 eHalStatus status = eHAL_STATUS_SUCCESS;
5632 tSmeCmd *pCommand;
5633
5634 pCommand = csrGetCommandBuffer(pMac);
5635 if(NULL == pCommand)
5636 {
5637 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5638 status = eHAL_STATUS_RESOURCES;
5639 }
5640 else
5641 {
5642 csrScanCancelIdleScan(pMac);
5643 csrScanAbortMacScanNotForConnect(pMac);
5644 if(pProfile)
5645 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 //This is likely trying to reassoc to different profile
5647 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5648 //make a copy of the profile
5649 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5650 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 }
5652 else
5653 {
5654 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5655 //how to update WPA/WPA2 info in roamProfile??
5656 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 if(HAL_STATUS_SUCCESS(status))
5659 {
5660 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5661 }
5662 pCommand->command = eSmeCommandRoam;
5663 pCommand->sessionId = (tANI_U8)sessionId;
5664 pCommand->u.roamCmd.roamId = roamId;
5665 pCommand->u.roamCmd.roamReason = reason;
5666 //We need to free the BssList when the command is done
5667 //For reassoc there is no BSS list, so the boolean set to false
5668 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5669 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5670 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5672 if( !HAL_STATUS_SUCCESS( status ) )
5673 {
5674 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5675 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5676 csrReleaseCommandRoam( pMac, pCommand );
5677 }
5678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 return (status);
5680}
5681
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005682eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
5683 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
5684// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5685{
5686 eHalStatus status = eHAL_STATUS_SUCCESS;
5687 tSmeCmd *pCommand;
5688
5689 pCommand = csrGetCommandBuffer(pMac);
5690 if(NULL == pCommand)
5691 {
5692 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5693 status = eHAL_STATUS_RESOURCES;
5694 }
5695 else
5696 {
5697 if(pBssDescription)
5698 {
5699 //copy over the parameters we need later
5700 pCommand->command = eSmeCommandRoam;
5701 pCommand->sessionId = (tANI_U8)sessionId;
5702 pCommand->u.roamCmd.roamReason = reason;
5703 //this is the important parameter
5704 //in this case we are using this field for the "next" BSS
5705 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
5706 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
5707 if( !HAL_STATUS_SUCCESS( status ) )
5708 {
5709 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d\n"), status );
5710 csrReleaseCommandPreauth( pMac, pCommand );
5711 }
5712 }
5713 else
5714 {
5715 //Return failure
5716 status = eHAL_STATUS_RESOURCES;
5717 }
5718 }
5719 return (status);
5720}
5721
5722eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
5723{
5724 tListElem *pEntry;
5725 tSmeCmd *pCommand;
5726 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5727 if ( pEntry )
5728 {
5729 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5730 if ( (eSmeCommandRoam == pCommand->command) &&
5731 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
5732 {
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08005733 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005734 pCommand->command, pCommand->u.roamCmd.roamReason);
5735 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
5736 csrReleaseCommandPreauth( pMac, pCommand );
5737 }
5738 } else {
5739 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d \n"),
5740 pCommand->command, pCommand->u.roamCmd.roamReason);
5741 }
5742 }
5743 else {
5744 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP\n"));
5745 }
5746 smeProcessPendingQueue( pMac );
5747 return eHAL_STATUS_SUCCESS;
5748}
5749
Jeff Johnson295189b2012-06-20 16:38:30 -07005750eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5751 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5752{
5753 eHalStatus status = eHAL_STATUS_FAILURE;
5754 tScanResultHandle hBSSList;
5755 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5757 if(HAL_STATUS_SUCCESS(status))
5758 {
5759 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5760 if(pRoamId)
5761 {
5762 *pRoamId = roamId;
5763 }
5764 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5765 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5766 if(!HAL_STATUS_SUCCESS(status))
5767 {
5768 smsLog(pMac, LOGE, FL("failed to start a join process\n"));
5769 csrScanResultPurge(pMac, hBSSList);
5770 }
5771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 return (status);
5773}
5774
Jeff Johnson295189b2012-06-20 16:38:30 -07005775eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5776 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5777{
5778 eHalStatus status = eHAL_STATUS_SUCCESS;
5779 tScanResultHandle hBSSList;
5780 tCsrScanResultFilter *pScanFilter;
5781 tANI_U32 roamId = 0;
5782 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5783 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 if (NULL == pProfile)
5785 {
5786 smsLog(pMac, LOGP, FL("No profile specified"));
5787 return eHAL_STATUS_FAILURE;
5788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"),
5790 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 if( CSR_IS_WDS( pProfile ) &&
5792 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5793 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005794 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d\n"),
5795 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 return status;
5797 }
5798 csrRoamCancelRoaming(pMac, sessionId);
5799 csrScanRemoveFreshScanCommand(pMac, sessionId);
5800 csrScanCancelIdleScan(pMac);
5801 //Only abort the scan if it is not used for other roam/connect purpose
5802 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005803#ifdef WLAN_SOFTAP_FEATURE
5804 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5805 {
5806 csrScanDisable(pMac);
5807 }
5808#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5810 //Check whether ssid changes
5811 if(csrIsConnStateConnected(pMac, sessionId))
5812 {
5813 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5814 {
5815 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5816 }
5817 }
5818#ifdef FEATURE_WLAN_BTAMP_UT_RF
5819 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
5820#endif
5821 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
5822 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005823 smsLog(pMac, LOG1, FL("is called with BSSList\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
5825 if(pRoamId)
5826 {
5827 roamId = *pRoamId;
5828 }
5829 if(!HAL_STATUS_SUCCESS(status))
5830 {
5831 fCallCallback = eANI_BOOLEAN_TRUE;
5832 }
5833 }
5834 else
5835 {
5836 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5837 if(HAL_STATUS_SUCCESS(status))
5838 {
5839 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5840 //Try to connect to any BSS
5841 if(NULL == pProfile)
5842 {
5843 //No encryption
5844 pScanFilter->EncryptionType.numEntries = 1;
5845 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5846 }//we don't have a profile
5847 else
5848 {
5849 //Here is the profile we need to connect to
5850 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
5851 }//We have a profile
5852 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5853 if(pRoamId)
5854 {
5855 *pRoamId = roamId;
5856 }
5857
5858 if(HAL_STATUS_SUCCESS(status))
5859 {
5860 /*Save the WPS info*/
5861 if(NULL != pProfile)
5862 {
5863 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
5864 }
5865 else
5866 {
5867 pScanFilter->bWPSAssociation = 0;
5868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 do
5870 {
5871 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
5872#ifdef WLAN_SOFTAP_FEATURE
5873 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
5874#endif
5875 )
5876 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005877 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
5879 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5880 if(!HAL_STATUS_SUCCESS(status))
5881 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005882 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 fCallCallback = eANI_BOOLEAN_TRUE;
5884 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005885 else
5886 {
5887 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
5888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 break;
5890 }
5891 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Mohit Khanna23863762012-09-11 17:40:09 -07005892 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d\n", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 if(HAL_STATUS_SUCCESS(status))
5894 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005895 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5896 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5897 if(!HAL_STATUS_SUCCESS(status))
5898 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005899 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 csrScanResultPurge(pMac, hBSSList);
5901 fCallCallback = eANI_BOOLEAN_TRUE;
5902 }
5903 }//Have scan result
5904 else if(NULL != pProfile)
5905 {
5906 //Check whether it is for start ibss
5907 if(CSR_IS_START_IBSS(pProfile))
5908 {
5909 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
5910 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5911 if(!HAL_STATUS_SUCCESS(status))
5912 {
5913 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X\n", status);
5914 fCallCallback = eANI_BOOLEAN_TRUE;
5915 }
5916 }
5917 else
5918 {
5919 //scan for this SSID
5920 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
5921 if(!HAL_STATUS_SUCCESS(status))
5922 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005923 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 fCallCallback = eANI_BOOLEAN_TRUE;
5925 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005926 else
5927 {
5928 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
5929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 }
5931 }
5932 else
5933 {
5934 fCallCallback = eANI_BOOLEAN_TRUE;
5935 }
5936 } while (0);
5937 if(NULL != pProfile)
5938 {
5939 //we need to free memory for filter if profile exists
5940 csrFreeScanFilter(pMac, pScanFilter);
5941 }
5942 }//Got the scan filter from profile
5943
5944 palFreeMemory(pMac->hHdd, pScanFilter);
5945 }//allocated memory for pScanFilter
5946 }//No Bsslist coming in
5947 //tell the caller if we fail to trigger a join request
5948 if( fCallCallback )
5949 {
5950 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
5951 }
5952
5953 return (status);
5954}
Jeff Johnson295189b2012-06-20 16:38:30 -07005955eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5956 tCsrRoamModifyProfileFields modProfileFields,
5957 tANI_U32 *pRoamId)
5958{
5959 eHalStatus status = eHAL_STATUS_SUCCESS;
5960 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
5961 tANI_U32 roamId = 0;
5962 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 if (NULL == pProfile)
5964 {
5965 smsLog(pMac, LOGP, FL("No profile specified"));
5966 return eHAL_STATUS_FAILURE;
5967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
5969 csrRoamCancelRoaming(pMac, sessionId);
5970 csrScanRemoveFreshScanCommand(pMac, sessionId);
5971 csrScanCancelIdleScan(pMac);
5972 csrScanAbortMacScanNotForConnect(pMac);
5973 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 if(csrIsConnStateConnected(pMac, sessionId))
5975 {
5976 if(pProfile)
5977 {
5978 if(pProfile->SSIDs.numOfSSIDs &&
5979 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5980 {
5981 fCallCallback = eANI_BOOLEAN_FALSE;
5982 }
5983 else
5984 {
5985 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile\n"));
5986 }
5987 }
5988 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
5989 &pSession->connectedProfile.modifyProfileFields,
5990 sizeof(tCsrRoamModifyProfileFields)))
5991 {
5992 fCallCallback = eANI_BOOLEAN_FALSE;
5993 }
5994 else
5995 {
5996 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
5997 "in tCsrRoamModifyProfileFields got modified\n"));
5998 }
5999 }
6000 else
6001 {
6002 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc\n"));
6003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 if(!fCallCallback)
6005 {
6006 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6007 if(pRoamId)
6008 {
6009 *pRoamId = roamId;
6010 }
6011
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6013 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 }
6015 else
6016 {
6017 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6018 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 return status;
6021}
Jeff Johnson295189b2012-06-20 16:38:30 -07006022eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6023{
6024 eHalStatus status = eHAL_STATUS_FAILURE;
6025 tScanResultHandle hBSSList = NULL;
6026 tCsrScanResultFilter *pScanFilter = NULL;
6027 tANI_U32 roamId;
6028 tCsrRoamProfile *pProfile = NULL;
6029 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006030
6031 if(!pSession)
6032 {
6033 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6034 return eHAL_STATUS_FAILURE;
6035 }
6036
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 do
6038 {
6039 if(pSession->pCurRoamProfile)
6040 {
6041 csrScanCancelIdleScan(pMac);
6042 csrScanAbortMacScanNotForConnect(pMac);
6043 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6044 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6045 if(!HAL_STATUS_SUCCESS(status))
6046 break;
6047 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6048 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6049 if(!HAL_STATUS_SUCCESS(status))
6050 break;
6051 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6052 if(!HAL_STATUS_SUCCESS(status))
6053 {
6054 break;
6055 }
6056 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6057 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6058 if(!HAL_STATUS_SUCCESS(status))
6059 {
6060 break;
6061 }
6062 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6063 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6064 if(HAL_STATUS_SUCCESS(status))
6065 {
6066 //we want to put the last connected BSS to the very beginning, if possible
6067 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6068 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6069 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6070 if(!HAL_STATUS_SUCCESS(status))
6071 {
6072 csrScanResultPurge(pMac, hBSSList);
6073 break;
6074 }
6075 }
6076 else
6077 {
6078 //Do a scan on this profile
6079 //scan for this SSID only in case the AP suppresses SSID
6080 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6081 if(!HAL_STATUS_SUCCESS(status))
6082 {
6083 break;
6084 }
6085 }
6086 }//We have a profile
6087 else
6088 {
6089 smsLog(pMac, LOGW, FL("cannot find a roaming profile\n"));
6090 break;
6091 }
6092 }while(0);
6093 if(pScanFilter)
6094 {
6095 csrFreeScanFilter(pMac, pScanFilter);
6096 palFreeMemory(pMac->hHdd, pScanFilter);
6097 }
6098 if(NULL != pProfile)
6099 {
6100 csrReleaseProfile(pMac, pProfile);
6101 palFreeMemory(pMac->hHdd, pProfile);
6102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 return (status);
6104}
Jeff Johnson295189b2012-06-20 16:38:30 -07006105eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6106{
6107 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 if(csrIsConnStateConnected(pMac, sessionId))
6109 {
6110 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6111 if(HAL_STATUS_SUCCESS(status))
6112 {
6113 status = csrRoamJoinLastProfile(pMac, sessionId);
6114 }
6115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 return (status);
6117}
6118
Jeff Johnson295189b2012-06-20 16:38:30 -07006119eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6120{
6121 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 smsLog(pMac, LOGW, FL("is called\n"));
6123 csrRoamCancelRoaming(pMac, sessionId);
6124 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6125 if(csrIsConnStateDisconnected(pMac, sessionId))
6126 {
6127 status = csrRoamJoinLastProfile(pMac, sessionId);
6128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 return (status);
6130}
6131
Jeff Johnson295189b2012-06-20 16:38:30 -07006132eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6133{
6134 eHalStatus status = eHAL_STATUS_SUCCESS;
6135 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6136 eCsrRoamSubState NewSubstate;
6137 tANI_U32 sessionId = pCommand->sessionId;
6138
6139 // change state to 'Roaming'...
6140 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6141
6142 if ( csrIsConnStateIbss( pMac, sessionId ) )
6143 {
6144 // If we are in an IBSS, then stop the IBSS...
6145 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6146 fComplete = (!HAL_STATUS_SUCCESS(status));
6147 }
6148 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6149 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07006150 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)\n"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6152 //Restore AC weight in case we change it
6153 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6154 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6155 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6156 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6157 {
6158 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6159 }
6160 if( fDisassoc )
6161 {
6162 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6163 }
6164 else
6165 {
6166 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6167 }
6168 fComplete = (!HAL_STATUS_SUCCESS(status));
6169 }
6170 else if ( csrIsConnStateWds( pMac, sessionId ) )
6171 {
6172 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6173 {
6174 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6175 fComplete = (!HAL_STATUS_SUCCESS(status));
6176 }
6177 //This has to be WDS station
6178 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6179 {
6180
6181 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6182 if( fDisassoc )
6183 {
6184 status = csrRoamIssueDisassociate( pMac, sessionId,
6185 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6186 fComplete = (!HAL_STATUS_SUCCESS(status));
6187 }
6188 }
6189 } else {
6190 // we got a dis-assoc request while not connected to any peer
6191 // just complete the command
6192 fComplete = eANI_BOOLEAN_TRUE;
6193 status = eHAL_STATUS_FAILURE;
6194 }
6195 if(fComplete)
6196 {
6197 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6198 }
6199
6200 if(HAL_STATUS_SUCCESS(status))
6201 {
6202 if ( csrIsConnStateInfra( pMac, sessionId ) )
6203 {
6204 //Set the state to disconnect here
6205 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6206 }
6207 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006208 else
6209 {
6210 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 return (status);
6213}
6214
Jeff Johnson295189b2012-06-20 16:38:30 -07006215/* This is been removed from latest code base */
6216/*
6217static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6218{
6219 eHalStatus status;
6220 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6222 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 return ( status );
6224}
6225*/
6226
Jeff Johnson295189b2012-06-20 16:38:30 -07006227eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6228{
6229 eHalStatus status = eHAL_STATUS_SUCCESS;
6230 tSmeCmd *pCommand;
6231 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 do
6233 {
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08006234 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 pCommand = csrGetCommandBuffer( pMac );
6236 if ( !pCommand )
6237 {
6238 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6239 status = eHAL_STATUS_RESOURCES;
6240 break;
6241 }
6242 //Change the substate in case it is wait-for-key
6243 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6244 {
6245 csrRoamStopWaitForKeyTimer( pMac );
6246 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6247 }
6248 pCommand->command = eSmeCommandRoam;
6249 pCommand->sessionId = (tANI_U8)sessionId;
6250 switch ( reason )
6251 {
6252 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6253 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6254 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 case eCSR_DISCONNECT_REASON_DEAUTH:
6256 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6257 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 case eCSR_DISCONNECT_REASON_HANDOFF:
6259 fHighPriority = eANI_BOOLEAN_TRUE;
6260 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6261 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6263 case eCSR_DISCONNECT_REASON_DISASSOC:
6264 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6265 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6267 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6268 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6270 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6271 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 default:
6273 break;
6274 }
6275 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6276 if( !HAL_STATUS_SUCCESS( status ) )
6277 {
6278 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6279 csrReleaseCommandRoam( pMac, pCommand );
6280 }
6281 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 return( status );
6283}
6284
Jeff Johnson295189b2012-06-20 16:38:30 -07006285eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6286{
6287 eHalStatus status = eHAL_STATUS_SUCCESS;
6288 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 pCommand = csrGetCommandBuffer( pMac );
6290 if ( NULL != pCommand )
6291 {
6292 //Change the substate in case it is wait-for-key
6293 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6294 {
6295 csrRoamStopWaitForKeyTimer( pMac );
6296 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6297 }
6298 pCommand->command = eSmeCommandRoam;
6299 pCommand->sessionId = (tANI_U8)sessionId;
6300 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6301 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6302 if( !HAL_STATUS_SUCCESS( status ) )
6303 {
6304 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6305 csrReleaseCommandRoam( pMac, pCommand );
6306 }
6307 }
6308 else
6309 {
6310 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6311 status = eHAL_STATUS_RESOURCES;
6312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 return ( status );
6314}
6315
Jeff Johnson295189b2012-06-20 16:38:30 -07006316eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6317{
6318 eHalStatus status = eHAL_STATUS_SUCCESS;
6319 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006320
6321 if(!pSession)
6322 {
6323 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6324 return eHAL_STATUS_FAILURE;
6325 }
6326
Jeff Johnson295189b2012-06-20 16:38:30 -07006327#ifdef FEATURE_WLAN_BTAMP_UT_RF
6328 //Stop te retry
6329 pSession->maxRetryCount = 0;
6330 csrRoamStopJoinRetryTimer(pMac, sessionId);
6331#endif
6332 //Not to call cancel roaming here
6333 //Only issue disconnect when necessary
6334 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6335 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6336 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6337
6338 {
6339 smsLog(pMac, LOG2, FL("called\n"));
6340 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 return (status);
6343}
6344
Jeff Johnson295189b2012-06-20 16:38:30 -07006345eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6346{
6347 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006348
6349 if(!pSession)
6350 {
6351 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6352 return eHAL_STATUS_FAILURE;
6353 }
6354
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 csrRoamCancelRoaming(pMac, sessionId);
6356 pSession->ibss_join_pending = FALSE;
6357 csrRoamStopIbssJoinTimer(pMac, sessionId);
6358 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6359
6360 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6361}
6362
Jeff Johnson295189b2012-06-20 16:38:30 -07006363eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6364 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6365{
6366 eHalStatus status = eHAL_STATUS_SUCCESS;
6367 tDot11fBeaconIEs *pIesTemp = pIes;
6368 tANI_U8 index;
6369 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6370 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006371
6372 if(!pSession)
6373 {
6374 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6375 return eHAL_STATUS_FAILURE;
6376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006377
6378 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6379 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6380 pConnectProfile->AuthInfo = pProfile->AuthType;
6381 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6382 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6383 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6384 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6385 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6386 pConnectProfile->BSSType = pProfile->BSSType;
6387 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6388 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006389 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6390
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006392 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6393 if(pProfile->nAddIEAssocLength)
6394 {
6395 status = palAllocateMemory(pMac->hHdd,
6396 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6397 if(!HAL_STATUS_SUCCESS(status))
6398 {
6399 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6400 return eHAL_STATUS_FAILURE;
6401 }
6402 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6403 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6404 pProfile->nAddIEAssocLength);
6405 }
6406
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 //Save bssid
6408 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6409#ifdef WLAN_FEATURE_VOWIFI_11R
6410 if (pSirBssDesc->mdiePresent)
6411 {
6412 pConnectProfile->MDID.mdiePresent = 1;
6413 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6414 }
6415#endif
6416#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006417 if ((csrIsProfileCCX(pProfile) ||
6418 ((pIesTemp->CCXVersion.present)
6419 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6420 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6421 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6422 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
6423 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
6424 && (!(csrIsProfile11r( pProfile )))
6425 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 {
6427 pConnectProfile->isCCXAssoc = 1;
6428 }
6429#endif
6430 //save ssid
6431 if( NULL == pIesTemp )
6432 {
6433 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6434 }
6435 if(HAL_STATUS_SUCCESS(status))
6436 {
6437 if(pIesTemp->SSID.present)
6438 {
6439 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6440 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6441 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6442 }
6443
6444 //Save the bss desc
6445 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306446
6447 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306449 //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 -07006450 pConnectProfile->qap = TRUE;
6451 }
6452 else
6453 {
6454 pConnectProfile->qap = FALSE;
6455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 if ( NULL == pIes )
6457 {
6458 //Free memory if it allocated locally
6459 palFreeMemory(pMac->hHdd, pIesTemp);
6460 }
6461 }
6462 //Save Qos connection
6463 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6464
6465 if(!HAL_STATUS_SUCCESS(status))
6466 {
6467 csrFreeConnectBssDesc(pMac, sessionId);
6468 }
6469 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6470 {
6471 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6472 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6473 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6474 {
6475 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6476 break;
6477 }
6478 pConnectProfile->handoffPermitted = FALSE;
6479 }
6480
6481 return (status);
6482}
6483
Jeff Johnson295189b2012-06-20 16:38:30 -07006484static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6485{
6486 tListElem *pEntry = NULL;
6487 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 //The head of the active list is the request we sent
6489 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6490 if(pEntry)
6491 {
6492 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6495 {
6496 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6497 {
6498#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6499 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6500#endif
6501 }
6502 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6503 }
6504 else
6505 {
6506 tANI_U32 roamId = 0;
6507 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006508 if(!pSession)
6509 {
6510 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6511 return;
6512 }
6513
Jeff Johnson295189b2012-06-20 16:38:30 -07006514
6515 //The head of the active list is the request we sent
6516 //Try to get back the same profile and roam again
6517 if(pCommand)
6518 {
6519 roamId = pCommand->u.roamCmd.roamId;
6520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6522 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
6523 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6524#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6525 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6526 if (csrRoamIsHandoffInProgress(pMac))
6527 {
6528 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6529 /* Should indicate neighbor roam algorithm about the connect failure here */
6530 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6531 }
6532#endif
6533 if (pCommand)
6534 {
6535 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6536 {
6537 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6538 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6539 csrRoamReissueRoamCommand(pMac);
6540 }
6541 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6542 {
6543 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6544 }
6545 else
6546 {
6547 csrRoam(pMac, pCommand);
6548 }
6549 }
6550 else
6551 {
6552 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6553 }
6554 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6555}
6556
Jeff Johnson295189b2012-06-20 16:38:30 -07006557eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6558 tDot11fBeaconIEs *pIes,
6559 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6560{
6561 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
6563 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6564 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6565
6566 // Set the roaming substate to 'join attempt'...
6567 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 // attempt to Join this BSS...
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006569 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 return (status);
6571}
6572
Jeff Johnson295189b2012-06-20 16:38:30 -07006573static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6574 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6575{
6576 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 // Set the roaming substate to 'join attempt'...
6578 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6579
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006580 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006581
6582 // attempt to Join this BSS...
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006583 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006584}
6585
Jeff Johnson295189b2012-06-20 16:38:30 -07006586void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6587{
6588 tListElem *pEntry;
6589 tSmeCmd *pCommand;
6590 tCsrRoamInfo roamInfo;
6591 tANI_U32 sessionId;
6592 tCsrRoamSession *pSession;
6593
6594 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6595 if(pEntry)
6596 {
6597 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6598 if ( eSmeCommandRoam == pCommand->command )
6599 {
6600 sessionId = pCommand->sessionId;
6601 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006602
6603 if(!pSession)
6604 {
6605 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6606 return;
6607 }
6608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 if( pCommand->u.roamCmd.fStopWds )
6610 {
6611 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6612 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6613 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6614 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6615#ifdef WLAN_SOFTAP_FEATURE
6616 if (CSR_IS_WDS(&pSession->connectedProfile)){
6617#endif
6618 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6619 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6620 eCSR_ROAM_WDS_IND,
6621 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
6622#ifdef WLAN_SOFTAP_FEATURE
6623 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6624 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6625 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6626 eCSR_ROAM_INFRA_IND,
6627 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6628 }
6629
6630#endif
6631
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6633 {
6634 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated\n");
6635 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6636 }
6637 }
6638 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6639 {
6640 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated\n");
6641 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6642 }
6643 }
6644 else
6645 {
6646 smsLog(pMac, LOGW, " Command is not roaming after disassociated\n");
6647 }
6648 }
6649 else
6650 {
6651 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available\n");
6652 }
6653}
6654
Jeff Johnson295189b2012-06-20 16:38:30 -07006655tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6656{
6657 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6658 tListElem *pEntry;
6659 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 //alwasy lock active list before locking pending list
6661 csrLLLock( &pMac->sme.smeCmdActiveList );
6662 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6663 if(pEntry)
6664 {
6665 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6666 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6667 {
6668 fRet = eANI_BOOLEAN_TRUE;
6669 }
6670 }
6671 if(eANI_BOOLEAN_FALSE == fRet)
6672 {
6673 csrLLLock(&pMac->sme.smeCmdPendingList);
6674 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6675 while(pEntry)
6676 {
6677 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6678 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6679 {
6680 fRet = eANI_BOOLEAN_TRUE;
6681 break;
6682 }
6683 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6684 }
6685 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6686 }
6687 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 return (fRet);
6689}
6690
Jeff Johnson295189b2012-06-20 16:38:30 -07006691tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6692{
6693 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6694 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6696 {
6697 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6698 {
6699 break;
6700 }
6701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 return ( fRet );
6703}
6704
Jeff Johnson295189b2012-06-20 16:38:30 -07006705tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6706{
6707 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 //alwasy lock active list before locking pending list
6709 csrLLLock( &pMac->sme.smeCmdActiveList );
6710 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6711 if(eANI_BOOLEAN_FALSE == fRet)
6712 {
6713 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6714 }
6715 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 return (fRet);
6717}
6718
Jeff Johnson295189b2012-06-20 16:38:30 -07006719tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6720{
6721 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6722 tListElem *pEntry;
6723 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 //alwasy lock active list before locking pending list
6725 csrLLLock( &pMac->sme.smeCmdActiveList );
6726 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6727 if( pEntry )
6728 {
6729 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6730 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6731 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6732 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6733 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6734 {
6735 fRet = eANI_BOOLEAN_TRUE;
6736 }
6737 }
6738 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 return (fRet);
6740}
Jeff Johnson295189b2012-06-20 16:38:30 -07006741eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6742{
6743 eHalStatus status = eHAL_STATUS_SUCCESS;
6744 tSmeCmd *pCommand = NULL;
6745 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6746 tANI_BOOLEAN fRemoveCmd = FALSE;
6747 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 // Delete the old assoc command. All is setup for reassoc to be serialized
6749 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6750 if ( pEntry )
6751 {
6752 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6753 if ( !pCommand )
6754 {
6755 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6756 return eHAL_STATUS_RESOURCES;
6757 }
6758 if ( eSmeCommandRoam == pCommand->command )
6759 {
6760 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6761 {
6762 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6763 }
6764 else
6765 {
6766 smsLog( pMac, LOGE, FL(" Unexpected active roam command present \n") );
6767 }
6768 if (fRemoveCmd == FALSE)
6769 {
6770 // Implies we did not get the serialized assoc command we
6771 // were expecting
6772 pCommand = NULL;
6773 }
6774 }
6775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 if(NULL == pCommand)
6777 {
6778 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command\n") );
6779 return eHAL_STATUS_RESOURCES;
6780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 do
6782 {
6783 //Change the substate in case it is wait-for-key
6784 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6785 {
6786 csrRoamStopWaitForKeyTimer( pMac );
6787 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6788 }
6789 pCommand->command = eSmeCommandRoam;
6790 pCommand->sessionId = (tANI_U8)sessionId;
6791 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6793 if( !HAL_STATUS_SUCCESS( status ) )
6794 {
6795 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6796 csrReleaseCommandRoam( pMac, pCommand );
6797 }
6798 } while( 0 );
6799
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 return( status );
6801}
6802static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6803{
6804 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6805 tCsrScanResult *pScanResult = NULL;
6806 tSirBssDescription *pBssDesc = NULL;
6807 tSmeCmd *pCommand = NULL;
6808 tANI_U32 sessionId;
6809 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 if(NULL == pEntry)
6811 {
6812 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
6813 return;
6814 }
6815 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6816 sessionId = pCommand->sessionId;
6817 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006818
6819 if(!pSession)
6820 {
6821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6822 return;
6823 }
6824
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
6826 {
6827 //the roaming is cancelled. Simply complete the command
6828 smsLog(pMac, LOGW, FL(" Roam command cancelled\n"));
6829 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
6830 }
6831 else
6832 {
6833 if ( CCM_IS_RESULT_SUCCESS(result) )
6834 {
6835 smsLog(pMac, LOG2, "Cfg sequence complete\n");
6836 // Successfully set the configuration parameters for the new Bss. Attempt to
6837 // join the roaming Bss.
6838 if(pCommand->u.roamCmd.pRoamBssEntry)
6839 {
6840 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
6841 pBssDesc = &pScanResult->Result.BssDescriptor;
6842 }
6843 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
6844 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
6845#ifdef WLAN_SOFTAP_FEATURE
6846 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
6847#endif
6848 )
6849 {
6850 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
6851 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
6852 pBssDesc, pCommand->u.roamCmd.roamId )))
6853 {
6854 smsLog(pMac, LOGW, " CSR start BSS failed\n");
6855 //We need to complete the command
6856 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6857 }
6858 }
6859 else
6860 {
6861 if (!pCommand->u.roamCmd.pRoamBssEntry)
6862 {
6863 smsLog(pMac, LOGW, " pRoamBssEntry is NULL\n");
6864 //We need to complete the command
6865 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
6866 return;
6867 }
6868 // If we are roaming TO an Infrastructure BSS...
6869 VOS_ASSERT(pScanResult != NULL);
6870 if ( csrIsInfraBssDesc( pBssDesc ) )
6871 {
6872 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
6874 {
6875 // ..and currently in an Infrastructure connection....
6876 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
6877 {
6878 // ...and the SSIDs are equal, then we Reassoc.
6879 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
6880 pIesLocal ) )
6881 // ..and currently in an infrastructure connection
6882 {
6883 // then issue a Reassoc.
6884 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
6885 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
6886 &pCommand->u.roamCmd.roamProfile );
6887 }
6888 else
6889 {
6890
6891 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
6892 // previously associated AP.
6893 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
6894 pIesLocal,
6895 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
6896 {
6897 //try something else
6898 csrRoam( pMac, pCommand );
6899 }
6900 }
6901 }
6902 else
6903 {
6904 eHalStatus status = eHAL_STATUS_SUCCESS;
6905
6906 /* We need to come with other way to figure out that this is because of HO in BMP
6907 The below API will be only available for Android as it uses a different HO algorithm */
6908 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
6909 * use join request */
6910#ifdef WLAN_FEATURE_VOWIFI_11R
6911 if (csrRoamIsHandoffInProgress(pMac) &&
6912 csrRoamIs11rAssoc(pMac))
6913 {
6914 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
6915 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
6916 }
6917 else
6918#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006919#ifdef FEATURE_WLAN_CCX
6920 if (csrRoamIsHandoffInProgress(pMac) &&
6921 csrRoamIsCCXAssoc(pMac))
6922 {
6923 // Now serialize the reassoc command.
6924 status = csrRoamIssueReassociateCmd(pMac, sessionId);
6925 }
6926 else
6927#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006928#ifdef FEATURE_WLAN_LFR
6929 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05306930 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006931 {
6932 // Now serialize the reassoc command.
6933 status = csrRoamIssueReassociateCmd(pMac, sessionId);
6934 }
6935 else
6936#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 // else we are not connected and attempting to Join. Issue the
6938 // Join request.
6939 {
6940 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
6941 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
6942 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
6943 }
6944 if(!HAL_STATUS_SUCCESS(status))
6945 {
6946 //try something else
6947 csrRoam( pMac, pCommand );
6948 }
6949 }
6950 if( !pScanResult->Result.pvIes )
6951 {
6952 //Locally allocated
6953 palFreeMemory(pMac->hHdd, pIesLocal);
6954 }
6955 }
6956 }//if ( csrIsInfraBssDesc( pBssDesc ) )
6957 else
6958 {
6959 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description\n"));
6960 }
6961 }//else
6962 }//if ( WNI_CFG_SUCCESS == result )
6963 else
6964 {
6965 // In the event the configuration failed, for infra let the roam processor
6966 //attempt to join something else...
6967 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
6968 {
6969 csrRoam(pMac, pCommand);
6970 }
6971 else
6972 {
6973 //We need to complete the command
6974 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
6975 {
6976 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6977 }
6978 else
6979 {
6980 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6981 }
6982 }
6983 }
6984 }//we have active entry
6985}
6986
Jeff Johnson295189b2012-06-20 16:38:30 -07006987static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
6988{
6989 //No one is sending eWNI_SME_AUTH_REQ to PE.
6990 smsLog(pMac, LOGW, FL("is no-op\n"));
6991 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
6992 {
6993 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful\n" );
6994 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
6995 // join the new one...
6996 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
6998 }
6999 else {
7000 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]\n", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
7001 /***profHandleLostLinkAfterReset(pAdapter);
7002 // In the event the authenticate fails, let the roam processor attempt to join something else...
7003 roamRoam( pAdapter );***/
7004 }
7005}
7006
Jeff Johnson295189b2012-06-20 16:38:30 -07007007static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7008{
7009 eCsrRoamCompleteResult result;
7010 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7011 tCsrRoamInfo roamInfo;
7012 tANI_U32 roamId = 0;
7013
7014 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7015 {
7016 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful\n" );
7017 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 /* Defeaturize this part later if needed */
7019#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7020 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7021 * we need the response contents while processing the result in csrRoamProcessResults() */
7022 if (csrRoamIsHandoffInProgress(pMac))
7023 {
7024 /* Need to dig more on indicating events to SME QoS module */
7025 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7026 csrRoamComplete( pMac, result, pSmeJoinRsp);
7027 }
7028 else
7029#endif
7030 {
7031 csrRoamComplete( pMac, result, NULL );
7032 }
7033 }
7034 /* Should we handle this similar to handling the join failure? Is it ok
7035 * to call csrRoamComplete() with state as CsrJoinFailure */
7036 else
7037 {
7038 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
7039 result = eCsrReassocFailure;
7040#ifdef WLAN_FEATURE_VOWIFI_11R
7041 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7042 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7043 {
7044 // Inform HDD to turn off FT flag in HDD
7045 if (pNeighborRoamInfo)
7046 {
7047 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7048 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7049 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007050 /*
7051 * Since the above callback sends a disconnect
7052 * to HDD, we should clean-up our state
7053 * machine as well to be in sync with the upper
7054 * layers. There is no need to send a disassoc
7055 * since: 1) we will never reassoc to the current
7056 * AP in LFR, and 2) there is no need to issue a
7057 * disassoc to the AP with which we were trying
7058 * to reassoc.
7059 */
7060 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7061 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 }
7063 }
7064#endif
7065 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7066 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7067 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7068 //The disassoc rsp message will remove the command from active list
7069 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7070 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7071 {
7072 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7073 }
7074 }
7075}
7076
Jeff Johnson295189b2012-06-20 16:38:30 -07007077static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7078{
Jeff Johnson295189b2012-06-20 16:38:30 -07007079#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7080 {
7081 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7083 if(pIbssLog)
7084 {
7085 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7086 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7087 {
7088 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7089 }
7090 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7091 }
7092 }
7093#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7095 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7096 {
7097 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7098 }
7099 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7100 {
7101 csrRoamReissueRoamCommand(pMac);
7102 }
7103}
7104
Jeff Johnson295189b2012-06-20 16:38:30 -07007105void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7106{
7107 tSirResultCodes statusCode;
7108#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7109 tScanResultHandle hBSSList;
7110 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7111 eHalStatus status;
7112 tCsrRoamInfo roamInfo;
7113 tCsrScanResultFilter *pScanFilter = NULL;
7114 tANI_U32 roamId = 0;
7115 tCsrRoamProfile *pCurRoamProfile = NULL;
7116 tListElem *pEntry = NULL;
7117 tSmeCmd *pCommand = NULL;
7118#endif
7119 tANI_U32 sessionId;
7120 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007121
Jeff Johnson295189b2012-06-20 16:38:30 -07007122 tSirSmeDisassocRsp SmeDisassocRsp;
7123
7124 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7125 sessionId = SmeDisassocRsp.sessionId;
7126 statusCode = SmeDisassocRsp.statusCode;
7127
7128 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d\n", sessionId);
7129
7130 if ( csrIsConnStateInfra( pMac, sessionId ) )
7131 {
7132 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007135
7136 if(!pSession)
7137 {
7138 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7139 return;
7140 }
7141
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7143 {
7144 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7145 }
7146 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7147 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7148 {
7149 if ( eSIR_SME_SUCCESS == statusCode )
7150 {
7151 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully\n" );
7152 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7153 }
7154 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7157 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007158 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d\n", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007159#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007160 /*
7161 * First ensure if the roam profile is in the scan cache.
7162 * If not, post a reassoc failure and disconnect.
7163 */
7164 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7165 if(HAL_STATUS_SUCCESS(status))
7166 {
7167 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7168 status = csrRoamPrepareFilterFromProfile(pMac,
7169 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7170 if(!HAL_STATUS_SUCCESS(status))
7171 {
7172 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
7173 __func__, status);
7174 goto POST_ROAM_FAILURE;
7175 }
7176 else
7177 {
7178 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7179 if (!HAL_STATUS_SUCCESS(status))
7180 {
7181 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
7182 __func__, status);
7183 goto POST_ROAM_FAILURE;
7184 }
7185 }
7186 }
7187 else
7188 {
7189 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
7190 __func__, status);
7191 goto POST_ROAM_FAILURE;
7192 }
7193
7194 /*
7195 * After ensuring that the roam profile is in the scan result list,
7196 * dequeue the command from the active list.
7197 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7199 if ( pEntry )
7200 {
7201 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007202 /* If the head of the queue is Active and it is a ROAM command, remove
7203 * and put this on the Free queue.
7204 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 if ( eSmeCommandRoam == pCommand->command )
7206 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007207
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007208 /*
7209 * we need to process the result first before removing it from active list
7210 * because state changes still happening insides roamQProcessRoamResults so
7211 * no other roam command should be issued.
7212 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7214 if(pCommand->u.roamCmd.fReleaseProfile)
7215 {
7216 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7217 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 else
7222 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007223 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d\n",
7224 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 }
7226 }
7227 else
7228 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007229 smsLog( pMac, LOGE, "%s: roam command not active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 }
7231 }
7232 else
7233 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007234 smsLog( pMac, LOGE, "%s: NO commands are active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007236
7237 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7239
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007240 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7241 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7242 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007243
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007244 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7245 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007246
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007247 /* Copy the connected profile to apply the same for this connection as well */
7248 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7249 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007251 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7252 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7253 //make sure to put it at the head of the cmd queue
7254 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7255 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7256 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7257
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 if(!HAL_STATUS_SUCCESS(status))
7259 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007260 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
7261 __func__, status);
7262 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 }
7264
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007265 /* Notify sub-modules like QoS etc. that handoff happening */
7266 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
7267 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 csrFreeScanFilter(pMac, pScanFilter);
7269 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007270 return;
7271 }
7272
7273POST_ROAM_FAILURE:
7274 if (pScanFilter)
7275 {
7276 csrFreeScanFilter(pMac, pScanFilter);
7277 palFreeMemory( pMac->hHdd, pScanFilter );
7278 }
7279 if (pCurRoamProfile)
7280 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7281
7282 /* Inform the upper layers that the reassoc failed */
7283 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7284 csrRoamCallCallback(pMac, sessionId,
7285 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7286
7287 /*
7288 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7289 * Upon success, we would re-enter this routine after receiving the disassoc
7290 * response and will fall into the reassoc fail sub-state. And, eventually
7291 * call csrRoamComplete which would remove the roam command from SME active
7292 * queue.
7293 */
7294 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7295 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7296 {
7297 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
7298 __func__, status);
7299 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007301#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007302
Jeff Johnson295189b2012-06-20 16:38:30 -07007303 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7304 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7305 {
7306 // Disassoc due to Reassoc failure falls into this codepath....
7307 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7308 }
7309 else
7310 {
7311 if ( eSIR_SME_SUCCESS == statusCode )
7312 {
7313 // Successfully disassociated from the 'old' Bss...
7314 //
7315 // We get Disassociate response in three conditions.
7316 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7317 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7318 // Infrastructure network.
7319 // - Third is where we are doing an Infra to Infra roam between networks with different
7320 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7321
7322 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully\n" );
7323 }
7324 else
7325 {
7326 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX\n", statusCode );
7327 }
7328 //We are not done yet. Get the data and continue roaming
7329 csrRoamReissueRoamCommand(pMac);
7330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007331}
7332
Jeff Johnson295189b2012-06-20 16:38:30 -07007333static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7334{
7335 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
7337 smsLog(pMac, LOGW, FL("is no-op\n"));
7338 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7339 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7340 {
7341 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7342 }
7343 else
7344 {
7345 if ( eSIR_SME_SUCCESS == statusCode )
7346 {
7347 // Successfully deauth from the 'old' Bss...
7348 //
7349 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully\n" );
7350 }
7351 else
7352 {
7353 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX\n", statusCode );
7354 }
7355 //We are not done yet. Get the data and continue roaming
7356 csrRoamReissueRoamCommand(pMac);
7357 }
7358}
7359
Jeff Johnson295189b2012-06-20 16:38:30 -07007360static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7361{
7362 eCsrRoamCompleteResult result;
7363
7364 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7365 {
7366 smsLog( pMac, LOGW, "SmeStartBssReq Successful\n" );
7367 result = eCsrStartBssSuccess;
7368 }
7369 else
7370 {
7371 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX\n", pSmeStartBssRsp->statusCode );
7372 //Let csrRoamComplete decide what to do
7373 result = eCsrStartBssFailure;
7374 }
7375#ifdef WLAN_SOFTAP_FEATURE
7376 csrRoamComplete( pMac, result, pSmeStartBssRsp);
7377#else
7378 csrRoamComplete( pMac, result, &pSmeStartBssRsp->bssDescription );
7379#endif
7380}
7381
Jeff Johnson295189b2012-06-20 16:38:30 -07007382/*
7383 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7384 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7385 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7386 For the messages where sender allocates memory for specific structures, then it can be
7387 cast accordingly.
7388*/
7389void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7390{
7391 tSirSmeRsp *pSmeRsp;
7392 tSmeIbssPeerInd *pIbssPeerInd;
7393 tCsrRoamInfo roamInfo;
7394 // TODO Session Id need to be acquired in this function
7395 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d\n",
7398 pSmeRsp->messageType, pSmeRsp->messageType,
7399 pMac->roam.curSubState[pSmeRsp->sessionId] );
7400#if defined ANI_PRODUCT_TYPE_AP
7401 pSmeRsp->messageType = pal_be16_to_cpu(pSmeRsp->messageType);
7402 pSmeRsp->length = pal_be16_to_cpu(pSmeRsp->length);
7403 pSmeRsp->statusCode = pal_be32_to_cpu(pSmeRsp->statusCode);
7404#else
7405 pSmeRsp->messageType = (pSmeRsp->messageType);
7406 pSmeRsp->length = (pSmeRsp->length);
7407 pSmeRsp->statusCode = (pSmeRsp->statusCode);
7408#endif
7409 switch (pSmeRsp->messageType)
7410 {
7411
7412 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7413 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7414 {
7415 //We sent a JOIN_REQ
7416 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7417 }
7418 break;
7419
7420 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7421 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7422 {
7423 //We sent a AUTH_REQ
7424 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7425 }
7426 break;
7427
7428 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7429 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7430 {
7431 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7432 }
7433 break;
7434
7435 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7436 {
7437 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7438 }
7439 break;
7440
7441 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7442 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7443 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7444 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7445 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7446 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7447//HO
7448 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7449 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07007450 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d\n"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007451 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7452 }
7453 break;
7454
7455 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7456 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7457 {
7458 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7459 }
7460 break;
7461
7462 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7463 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7464 {
7465 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7466 }
7467 break;
7468
7469 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7470 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7471 {
7472 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7476 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7477 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
7478 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state\n");
7479 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7480 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7481 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7482 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7483 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7484 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7485 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7486 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7487 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 default:
7489 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d\n",
7490 pSmeRsp->messageType, pSmeRsp->messageType,
7491 pMac->roam.curSubState[pSmeRsp->sessionId] );
7492
7493 //If we are connected, check the link status change
7494 if(!csrIsConnStateDisconnected(pMac, sessionId))
7495 {
7496 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7497 }
7498 break;
7499 }
7500}
7501
Jeff Johnson295189b2012-06-20 16:38:30 -07007502void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7503{
7504 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007505 switch (pSirMsg->messageType)
7506 {
7507 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07007508 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 csrRoamStatsRspProcessor( pMac, pSirMsg );
7510 break;
7511#ifdef WLAN_SOFTAP_FEATURE
7512 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7513 {
7514 tCsrRoamSession *pSession;
7515 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7516 tCsrRoamInfo roamInfo;
7517 tCsrRoamInfo *pRoamInfo = NULL;
7518 tANI_U32 sessionId;
7519 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7522 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007523 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7524 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7525 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007526
7527 if(!pSession)
7528 {
7529 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7530 return;
7531 }
7532
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7534 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7536 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7537 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7539 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7541 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007543 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7544 {
7545 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7546 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7547 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7548 }
7549 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7550 {
7551 vos_sleep( 100 );
7552 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7553 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7554 }
7555
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 }
7557 break;
7558#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 default:
7560 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7561 break;
7562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007563}
7564
Jeff Johnson295189b2012-06-20 16:38:30 -07007565eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7566 tSirBssDescription *pBssDescription,
7567 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7568 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7569 tANI_U8 keyId, tANI_U16 keyLength,
7570 tANI_U8 *pKey, tANI_U8 paeRole )
7571{
7572 eHalStatus status = eHAL_STATUS_SUCCESS;
7573 tAniEdType edType;
7574
7575 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7576 {
7577 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7578 }
7579
7580 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7581
7582 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7583 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7584 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7585 addKey )
7586 {
7587 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 setKey.encType = EncryptType;
7589 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7590 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7591 setKey.paeRole = paeRole; //0 for supplicant
7592 setKey.keyId = keyId; // Kye index
7593 setKey.keyLength = keyLength;
7594 if( keyLength )
7595 {
7596 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7597 }
7598 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 return (status);
7601}
7602
Jeff Johnson295189b2012-06-20 16:38:30 -07007603static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7604 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7605{
7606 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7607 tSmeCmd *pCommand = NULL;
7608#ifdef FEATURE_WLAN_CCX
7609 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7610#endif /* FEATURE_WLAN_CCX */
7611
7612 do
7613 {
7614 pCommand = csrGetCommandBuffer(pMac);
7615 if(NULL == pCommand)
7616 {
7617 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7618 status = eHAL_STATUS_RESOURCES;
7619 break;
7620 }
7621 pCommand->command = eSmeCommandSetKey;
7622 pCommand->sessionId = (tANI_U8)sessionId;
7623 // validate the key length, Adjust if too long...
7624 // for static WEP the keys are not set thru' SetContextReq
7625 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7626 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7627 {
7628 //KeyLength maybe 0 for static WEP
7629 if( pSetKey->keyLength )
7630 {
7631 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7632 {
7633 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7634 break;
7635 }
7636
7637 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7638 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7639 }
7640 }
7641 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7642 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7643 {
7644 //KeyLength maybe 0 for static WEP
7645 if( pSetKey->keyLength )
7646 {
7647 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7648 {
7649 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7650 break;
7651 }
7652
7653 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7654 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7655 }
7656 }
7657 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7658 {
7659 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7660 {
7661 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7662 break;
7663 }
7664 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7665 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7666 }
7667 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7668 {
7669 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7670 {
7671 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7672 break;
7673 }
7674 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7675 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7676 }
7677#ifdef FEATURE_WLAN_WAPI
7678 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7679 {
7680 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7681 {
7682 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7683 break;
7684 }
7685 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7686 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7687 }
7688#endif /* FEATURE_WLAN_WAPI */
7689#ifdef FEATURE_WLAN_CCX
7690 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7691 {
7692 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7693 {
7694 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7695 break;
7696 }
7697 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7698 pSession->ccxCckmInfo.reassoc_req_num=1;
7699 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7700 status = eHAL_STATUS_SUCCESS;
7701 break;
7702 }
7703#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07007704
Jeff Johnson295189b2012-06-20 16:38:30 -07007705#ifdef WLAN_FEATURE_11W
7706 //Check for 11w BIP
7707 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7708 {
7709 tANI_U16 count = 0;
7710 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7711 {
7712 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7713 break;
7714 }
7715 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7716 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7717 }
7718#endif
7719 status = eHAL_STATUS_SUCCESS;
7720 pCommand->u.setKeyCmd.roamId = roamId;
7721 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7722 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7723 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7724 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7725 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7726 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7727 //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
7728
7729 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7730 if( !HAL_STATUS_SUCCESS( status ) )
7731 {
7732 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7733 }
7734 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 // Free the command if there has been a failure, or it is a
7736 // "local" operation like the set CCX CCKM KRK key.
7737 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7738#ifdef FEATURE_WLAN_CCX
7739 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7740#endif /* FEATURE_WLAN_CCX */
7741 )
7742 {
7743 csrReleaseCommandSetKey( pMac, pCommand );
7744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 return( status );
7746}
7747
Jeff Johnson295189b2012-06-20 16:38:30 -07007748eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7749 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7750{
7751 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7752 tSmeCmd *pCommand = NULL;
7753 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007754 do
7755 {
7756 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7757 {
7758 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7759 status = eHAL_STATUS_CSR_WRONG_STATE;
7760 break;
7761 }
7762 pCommand = csrGetCommandBuffer(pMac);
7763 if(NULL == pCommand)
7764 {
7765 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7766 status = eHAL_STATUS_RESOURCES;
7767 break;
7768 }
7769 pCommand->command = eSmeCommandRemoveKey;
7770 pCommand->sessionId = (tANI_U8)sessionId;
7771 pCommand->u.removeKeyCmd.roamId = roamId;
7772 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7773 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7774 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7775 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7776 {
7777 //in this case, put it to the end of the Q incase there is a set key pending.
7778 fImediate = eANI_BOOLEAN_FALSE;
7779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
7781 pRemoveKey->encType, pRemoveKey->keyId,
7782 pCommand->u.removeKeyCmd.peerMac[0],
7783 pCommand->u.removeKeyCmd.peerMac[1],
7784 pCommand->u.removeKeyCmd.peerMac[2],
7785 pCommand->u.removeKeyCmd.peerMac[3],
7786 pCommand->u.removeKeyCmd.peerMac[4],
7787 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007788 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7789 if( !HAL_STATUS_SUCCESS( status ) )
7790 {
7791 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7792 break;
7793 }
7794 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7796 {
7797 csrReleaseCommandRemoveKey( pMac, pCommand );
7798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 return (status );
7800}
7801
Jeff Johnson295189b2012-06-20 16:38:30 -07007802eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7803{
7804 eHalStatus status;
7805 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7806 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7807 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7808 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007809#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7811 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7813 {
7814 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7815 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7816 {
7817 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7818 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7819 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7820 }
7821 else
7822 {
7823 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7824 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7825 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7826 }
7827 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7828 if(CSR_IS_ENC_TYPE_STATIC(edType))
7829 {
7830 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 //It has to be static WEP here
7832 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
7833 {
7834 setKeyEvent.keyId = (v_U8_t)defKeyId;
7835 }
7836 }
7837 else
7838 {
7839 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
7840 }
7841 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7842 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7843 }
7844#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 if( csrIsSetKeyAllowed(pMac, sessionId) )
7846 {
7847 status = csrSendMBSetContextReqMsg( pMac, sessionId,
7848 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
7849 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
7850 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
7851 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
7852 pCommand->u.setKeyCmd.keyRsc);
7853 }
7854 else
7855 {
7856 smsLog( pMac, LOGW, FL(" cannot process not connected\n") );
7857 //Set this status so the error handling take care of the case.
7858 status = eHAL_STATUS_CSR_WRONG_STATE;
7859 }
7860 if( !HAL_STATUS_SUCCESS(status) )
7861 {
7862 smsLog( pMac, LOGE, FL(" error status %d\n"), status );
7863 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007864#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7865 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7866 {
7867 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7868 {
7869 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
7870 }
7871 else
7872 {
7873 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
7874 }
7875 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
7876 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7877 }
7878#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 return ( status );
7881}
7882
Jeff Johnson295189b2012-06-20 16:38:30 -07007883eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7884{
7885 eHalStatus status;
7886 tpSirSmeRemoveKeyReq pMsg = NULL;
7887 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
7888 tANI_U8 *p;
7889 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007890#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7891 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7892 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007893 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7894 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
7895 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7896 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7897 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7898 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
7899 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7900 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
7901#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007902 if( csrIsSetKeyAllowed(pMac, sessionId) )
7903 {
7904 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
7905 }
7906 else
7907 {
7908 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7909 //Set the error status so error handling kicks in below
7910 status = eHAL_STATUS_CSR_WRONG_STATE;
7911 }
7912 if( HAL_STATUS_SUCCESS( status ) )
7913 {
7914 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
7915 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
7916 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 pMsg->sessionId = (tANI_U8)sessionId;
7918 pMsg->transactionId = 0;
7919 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
7920 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
7921 // bssId - copy from session Info
7922 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
7923 p += sizeof(tSirMacAddr);
7924 // peerMacAddr
7925 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
7926 p += sizeof(tSirMacAddr);
7927 // edType
7928 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
7929 p++;
7930 // weptype
7931 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
7932 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
7933 {
7934 *p = (tANI_U8)eSIR_WEP_STATIC;
7935 }
7936 else
7937 {
7938 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
7939 }
7940 p++;
7941 //keyid
7942 *p = pCommand->u.removeKeyCmd.keyId;
7943 p++;
7944 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 status = palSendMBMessage(pMac->hHdd, pMsg);
7946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 if( !HAL_STATUS_SUCCESS( status ) )
7948 {
7949 smsLog( pMac, LOGE, FL(" error status \n"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007950#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7951 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07007952 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
7954#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
7956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 return ( status );
7958}
7959
Jeff Johnson295189b2012-06-20 16:38:30 -07007960eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7961{
7962 eHalStatus status;
7963
7964 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7965 {
7966 status = eHAL_STATUS_CSR_WRONG_STATE;
7967 }
7968 else
7969 {
7970 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
7971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 return ( status );
7973}
7974
Jeff Johnson295189b2012-06-20 16:38:30 -07007975/*
7976 Prepare a filter base on a profile for parsing the scan results.
7977 Upon successful return, caller MUST call csrFreeScanFilter on
7978 pScanFilter when it is done with the filter.
7979*/
7980eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
7981 tCsrScanResultFilter *pScanFilter)
7982{
7983 eHalStatus status = eHAL_STATUS_SUCCESS;
7984 tANI_U32 size = 0;
7985 tANI_U8 index = 0;
7986
7987 do
7988 {
7989 if(pProfile->BSSIDs.numOfBSSIDs)
7990 {
7991 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
7992 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
7993 if(!HAL_STATUS_SUCCESS(status))
7994 {
7995 break;
7996 }
7997 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
7998 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
7999 }
8000 if(pProfile->SSIDs.numOfSSIDs)
8001 {
8002 if( !CSR_IS_WDS_STA( pProfile ) )
8003 {
8004 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8005 }
8006 else
8007 {
8008 //For WDS station
8009 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8010 pScanFilter->SSIDs.numOfSSIDs = 1;
8011 }
8012 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8013 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8014 if(!HAL_STATUS_SUCCESS(status))
8015 {
8016 break;
8017 }
8018 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8019 }
8020 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8021 {
8022 pScanFilter->ChannelInfo.numOfChannels = 0;
8023 pScanFilter->ChannelInfo.ChannelList = NULL;
8024 }
8025 else if(pProfile->ChannelInfo.numOfChannels)
8026 {
8027 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8028 pScanFilter->ChannelInfo.numOfChannels = 0;
8029 if(HAL_STATUS_SUCCESS(status))
8030 {
8031 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8032 {
8033 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8034 {
8035 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8036 = pProfile->ChannelInfo.ChannelList[index];
8037 pScanFilter->ChannelInfo.numOfChannels++;
8038 }
8039 else
8040 {
8041 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid\n"), pProfile->ChannelInfo.ChannelList[index]);
8042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 }
8044 }
8045 else
8046 {
8047 break;
8048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 }
8050 else
8051 {
8052 smsLog(pMac, LOGW, FL("Channel list empty\n"));
8053 status = eHAL_STATUS_FAILURE;
8054 break;
8055 }
8056 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8057 pScanFilter->authType = pProfile->AuthType;
8058 pScanFilter->EncryptionType = pProfile->EncryptionType;
8059 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8060 pScanFilter->BSSType = pProfile->BSSType;
8061 pScanFilter->phyMode = pProfile->phyMode;
8062#ifdef FEATURE_WLAN_WAPI
8063 //check if user asked for WAPI with 11n or auto mode, in that case modify
8064 //the phymode to 11g
8065 if(csrIsProfileWapi(pProfile))
8066 {
8067 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8068 {
8069 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8070 }
8071 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8072 {
8073 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8074 }
8075 if(!pScanFilter->phyMode)
8076 {
8077 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8078 }
8079 }
8080#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 /*Save the WPS info*/
8082 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 if( pProfile->countryCode[0] )
8084 {
8085 //This causes the matching function to use countryCode as one of the criteria.
8086 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8087 WNI_CFG_COUNTRY_CODE_LEN );
8088 }
8089#ifdef WLAN_FEATURE_VOWIFI_11R
8090 if (pProfile->MDID.mdiePresent)
8091 {
8092 pScanFilter->MDID.mdiePresent = 1;
8093 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8094 }
8095#endif
8096
8097 }while(0);
8098
8099 if(!HAL_STATUS_SUCCESS(status))
8100 {
8101 csrFreeScanFilter(pMac, pScanFilter);
8102 }
8103
8104 return(status);
8105}
8106
Jeff Johnson295189b2012-06-20 16:38:30 -07008107tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8108 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8109{
8110 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8111 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 do
8113 {
8114 // Validate the type is ok...
8115 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8116 pCommand = csrGetCommandBuffer( pMac );
8117 if ( !pCommand )
8118 {
8119 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
8120 break;
8121 }
8122 //Change the substate in case it is waiting for key
8123 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8124 {
8125 csrRoamStopWaitForKeyTimer( pMac );
8126 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8127 }
8128 pCommand->command = eSmeCommandWmStatusChange;
8129 pCommand->sessionId = (tANI_U8)sessionId;
8130 pCommand->u.wmStatusChangeCmd.Type = Type;
8131 if ( eCsrDisassociated == Type )
8132 {
8133 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8134 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8135 }
8136 else
8137 {
8138 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8139 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8140 }
8141 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8142 {
8143 fCommandQueued = eANI_BOOLEAN_TRUE;
8144 }
8145 else
8146 {
8147 smsLog( pMac, LOGE, FL(" fail to send message \n") );
8148 csrReleaseCommandWmStatusChange( pMac, pCommand );
8149 }
8150
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8152 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 return( fCommandQueued );
8155}
8156
Jeff Johnson295189b2012-06-20 16:38:30 -07008157static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8158{
8159 v_S7_t rssi = 0;
8160 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8161 if(pGetRssiReq)
8162 {
8163 if(NULL != pGetRssiReq->pVosContext)
8164 {
8165 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8166 }
8167 else
8168 {
8169 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL\n"));
8170 return;
8171 }
8172
8173 if(NULL != pGetRssiReq->rssiCallback)
8174 {
8175 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8176 }
8177 else
8178 {
8179 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL\n"));
8180 return;
8181 }
8182 }
8183 else
8184 {
8185 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL\n"));
8186 }
8187 return;
8188}
Jeff Johnsone7245742012-09-05 17:12:55 -07008189static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8190{
8191 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8192 if(pTlRssiInd)
8193 {
8194 if(NULL != pTlRssiInd->tlCallback)
8195 {
8196 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08008197 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008198 }
8199 else
8200 {
8201 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL\n"));
8202 }
8203 }
8204 else
8205 {
8206 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL\n"));
8207 }
8208 return;
8209}
Jeff Johnson295189b2012-06-20 16:38:30 -07008210
8211void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8212{
8213 tSirSmeAssocInd *pAssocInd;
8214 tSirSmeDisassocInd *pDisassocInd;
8215 tSirSmeDeauthInd *pDeauthInd;
8216 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8217 tSirSmeNewBssInfo *pNewBss;
8218 tSmeIbssPeerInd *pIbssPeerInd;
8219 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8220 tSirSmeApNewCaps *pApNewCaps;
8221 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8222 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8223 tCsrRoamInfo *pRoamInfo = NULL;
8224 tCsrRoamInfo roamInfo;
8225 eHalStatus status;
8226 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8227 tCsrRoamSession *pSession = NULL;
8228 tpSirSmeSwitchChannelInd pSwitchChnInd;
8229 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08008230#ifdef WLAN_SOFTAP_FEATURE
8231 tSmeCmd pCommand;
8232#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008233#if defined ANI_PRODUCT_TYPE_AP
8234 pSirMsg->messageType = pal_be16_to_cpu(pSirMsg->messageType);
8235 pSirMsg->length = pal_be16_to_cpu(pSirMsg->length);
8236 pSirMsg->statusCode = pal_be32_to_cpu(pSirMsg->statusCode);
8237#else
8238 pSirMsg->messageType = (pSirMsg->messageType);
8239 pSirMsg->length = (pSirMsg->length);
8240 pSirMsg->statusCode = (pSirMsg->statusCode);
8241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 switch( pSirMsg->messageType )
8244 {
8245 case eWNI_SME_ASSOC_IND:
8246 {
8247 tCsrRoamSession *pSession;
8248 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME\n"));
8249 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8250 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8251 if( HAL_STATUS_SUCCESS( status ) )
8252 {
8253 pSession = CSR_GET_SESSION(pMac, sessionId);
8254
Jeff Johnson32d95a32012-09-10 13:15:23 -07008255 if(!pSession)
8256 {
8257 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8258 return;
8259 }
8260
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 pRoamInfo = &roamInfo;
8262
8263 // Required for indicating the frames to upper layer
8264 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8265 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8266
8267 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8268 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8269 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8270 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8271
8272 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8273 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8274 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8275
8276 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8277 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8279 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
8280#ifdef WLAN_SOFTAP_FEATURE
8281 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8282 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8283#endif
8284 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8285#ifdef WLAN_SOFTAP_FEATURE
8286 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8287 {
8288 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8289 {
8290 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8291 pSession->pConnectBssDesc,
8292 &(pRoamInfo->peerMac),
8293 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8294 pRoamInfo->fAuthRequired = FALSE;
8295 }
8296 else
8297 {
8298 pRoamInfo->fAuthRequired = TRUE;
8299 }
8300 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8301 if (!HAL_STATUS_SUCCESS(status))
8302 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8303 }
8304#endif
8305 /* Send Association completion message to PE */
8306 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8307
8308 /* send a message to CSR itself just to avoid the EAPOL frames going
8309 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8311 {
8312 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8313 }
8314#ifdef WLAN_SOFTAP_FEATURE
8315 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8316 {
8317 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8318 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8319 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8320 }
8321#endif
8322 }
8323 }
8324 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 case eWNI_SME_DISASSOC_IND:
8326 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 // Check if AP dis-associated us because of MIC failure. If so,
8328 // then we need to take action immediately and not wait till the
8329 // the WmStatusChange requests is pushed and processed
8330 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8331 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8332 if( HAL_STATUS_SUCCESS( status ) )
8333 {
8334 // If we are in neighbor preauth done state then on receiving
8335 // disassoc or deauth we dont roam instead we just disassoc
8336 // from current ap and then go to disconnected state
8337 // This happens for CCX and 11r FT connections ONLY.
8338#ifdef WLAN_FEATURE_VOWIFI_11R
8339 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8340 {
8341 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8342 }
8343#endif
8344#ifdef FEATURE_WLAN_CCX
8345 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8346 {
8347 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8348 }
8349#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008350#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308351 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008352 {
8353 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8354 }
8355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 pSession = CSR_GET_SESSION( pMac, sessionId );
8357
Jeff Johnson32d95a32012-09-10 13:15:23 -07008358 if(!pSession)
8359 {
8360 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8361 return;
8362 }
8363
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 if ( csrIsConnStateInfra( pMac, sessionId ) )
8365 {
8366 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008368#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8369 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8370#endif
8371 csrRoamLinkDown(pMac, sessionId);
8372 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
8373#ifdef WLAN_SOFTAP_FEATURE
8374 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8375 {
8376
8377 pRoamInfo = &roamInfo;
8378
8379 pRoamInfo->statusCode = pDisassocInd->statusCode;
8380 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8381
8382 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8383
8384 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8385 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8386
8387 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08008388
8389 /*
8390 * STA/P2P client got disassociated so remove any pending deauth
8391 * commands in sme pending list
8392 */
8393 pCommand.command = eSmeCommandRoam;
8394 pCommand.sessionId = (tANI_U8)sessionId;
8395 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8396 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8397 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 }
8399#endif
8400 }
8401 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 case eWNI_SME_DEAUTH_IND:
8403 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC\n"));
8404 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8405 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8406 if( HAL_STATUS_SUCCESS( status ) )
8407 {
8408 // If we are in neighbor preauth done state then on receiving
8409 // disassoc or deauth we dont roam instead we just disassoc
8410 // from current ap and then go to disconnected state
8411 // This happens for CCX and 11r FT connections ONLY.
8412#ifdef WLAN_FEATURE_VOWIFI_11R
8413 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8414 {
8415 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8416 }
8417#endif
8418#ifdef FEATURE_WLAN_CCX
8419 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8420 {
8421 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8422 }
8423#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008424#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308425 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008426 {
8427 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8428 }
8429#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 pSession = CSR_GET_SESSION( pMac, sessionId );
8431
Jeff Johnson32d95a32012-09-10 13:15:23 -07008432 if(!pSession)
8433 {
8434 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8435 return;
8436 }
8437
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 if ( csrIsConnStateInfra( pMac, sessionId ) )
8439 {
8440 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008442#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8443 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8444#endif
8445 csrRoamLinkDown(pMac, sessionId);
8446 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
8447#ifdef WLAN_SOFTAP_FEATURE
8448 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8449 {
8450
8451 pRoamInfo = &roamInfo;
8452
8453 pRoamInfo->statusCode = pDeauthInd->statusCode;
8454 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8455
8456 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8457
8458 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8459 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8460
8461 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8462 }
8463#endif
8464 }
8465 break;
8466
8467 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
8468 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME\n"));
8469 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8470 //Update with the new channel id.
8471 //The channel id is hidden in the statusCode.
8472 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8473 if( HAL_STATUS_SUCCESS( status ) )
8474 {
8475 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008476 if(!pSession)
8477 {
8478 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8479 return;
8480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8482 if(pSession->pConnectBssDesc)
8483 {
8484 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8485 }
8486 }
8487 break;
8488
8489 case eWNI_SME_DEAUTH_RSP:
8490 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME\n"));
8491#ifdef WLAN_SOFTAP_FEATURE
8492 {
8493 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8494 sessionId = pDeauthRsp->sessionId;
8495 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8496 {
8497 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008498 if(!pSession)
8499 {
8500 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8501 return;
8502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8504 {
8505 pRoamInfo = &roamInfo;
8506 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8507 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8508 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8509 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8510 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8511 }
8512 }
8513 }
8514#endif
8515 break;
8516
8517 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008518 /* session id is invalid here so cant use it to access the array curSubstate as index */
8519 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008520#ifdef WLAN_SOFTAP_FEATURE
8521 {
8522 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8523 sessionId = pDisassocRsp->sessionId;
8524 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8525 {
8526 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008527 if(!pSession)
8528 {
8529 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8530 return;
8531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8533 {
8534 pRoamInfo = &roamInfo;
8535 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8536 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8537 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8538 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8539 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8540 }
8541 }
8542 }
8543#endif
8544 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 case eWNI_SME_MIC_FAILURE_IND:
8546 {
8547 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8548 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8549 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008550#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8551 {
8552 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008553 if(!pSession)
8554 {
8555 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8556 return;
8557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8559 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8560 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8561 secEvent.encryptionModeMulticast =
8562 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8563 secEvent.encryptionModeUnicast =
8564 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8565 secEvent.authMode =
8566 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8567 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8568 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8569 }
8570#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8572 if( HAL_STATUS_SUCCESS( status ) )
8573 {
8574 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8575 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8576 pRoamInfo = &roamInfo;
8577 if(pMicInd->info.multicast)
8578 {
8579 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8580 }
8581 else
8582 {
8583 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8584 }
8585 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8586 }
8587 }
8588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008589#ifdef WLAN_SOFTAP_FEATURE
8590 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8591 {
8592 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8593 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME\n"));
8595
8596 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8597 if( HAL_STATUS_SUCCESS( status ) )
8598 {
8599 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8600 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8601 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8602 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8603 }
8604 }
8605 break;
8606#endif
8607
Jeff Johnson295189b2012-06-20 16:38:30 -07008608 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8609 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8610 switch( pStatusChangeMsg->statusChangeCode )
8611 {
8612 case eSIR_SME_IBSS_ACTIVE:
8613 sessionId = csrFindIbssSession( pMac );
8614 if( CSR_SESSION_ID_INVALID != sessionId )
8615 {
8616 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008617 if(!pSession)
8618 {
8619 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8620 return;
8621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8623 if(pSession->pConnectBssDesc)
8624 {
8625 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8626 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8627 pRoamInfo = &roamInfo;
8628 }
8629 else
8630 {
8631 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8632 }
8633 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8634 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8635 }
8636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 case eSIR_SME_IBSS_INACTIVE:
8638 sessionId = csrFindIbssSession( pMac );
8639 if( CSR_SESSION_ID_INVALID != sessionId )
8640 {
8641 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008642 if(!pSession)
8643 {
8644 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8645 return;
8646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8648 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8649 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8650 }
8651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8653 sessionId = csrFindIbssSession( pMac );
8654 if( CSR_SESSION_ID_INVALID != sessionId )
8655 {
8656 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008657 if(!pSession)
8658 {
8659 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8660 return;
8661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 // update the connection state information
8663 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008664#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8665 {
8666 vos_log_ibss_pkt_type *pIbssLog;
8667 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8669 if(pIbssLog)
8670 {
8671 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8672 if(pNewBss)
8673 {
8674 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8675 if(pNewBss->ssId.length)
8676 {
8677 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8678 }
8679 pIbssLog->operatingChannel = pNewBss->channelNumber;
8680 }
8681 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8682 {
8683 //***U8 is not enough for beacon interval
8684 pIbssLog->beaconInterval = (v_U8_t)bi;
8685 }
8686 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8687 }
8688 }
8689#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8691 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8692 pSession->pConnectBssDesc,
8693 &Broadcastaddr,
8694 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8695 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8696 roamStatus = eCSR_ROAM_IBSS_IND;
8697 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8698 pRoamInfo = &roamInfo;
8699 //This BSSID is th ereal BSSID, let's save it
8700 if(pSession->pConnectBssDesc)
8701 {
8702 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8703 }
8704 // Stop the join IBSS timer in case of join, for
8705 // genuine merge do nothing
8706 if(pSession->ibss_join_pending)
8707 {
8708 pSession->ibss_join_pending = FALSE;
8709 csrRoamStopIbssJoinTimer(pMac, sessionId);
8710 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8711 }
8712 }
8713 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE\n");
8714 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 // detection by LIM that the capabilities of the associated AP have changed.
8716 case eSIR_SME_AP_CAPS_CHANGED:
8717 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
8718 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED\n");
8719 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8720 if( HAL_STATUS_SUCCESS( status ) )
8721 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008722 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8723 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8724 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8725 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8726 )
8727 {
8728 csrScanForCapabilityChange( pMac, pApNewCaps );
8729 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8730 roamStatus = eCSR_ROAM_GEN_INFO;
8731 }
8732 else
8733 {
8734 smsLog(pMac, LOGW,
8735 "Skipping csrScanForCapabilityChange as "
8736 "CSR is in state %d and sub-state %d\n",
8737 pMac->roam.curState[sessionId],
8738 pMac->roam.curSubState[sessionId]);
8739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 }
8741 break;
8742
8743 default:
8744 roamStatus = eCSR_ROAM_FAILED;
8745 result = eCSR_ROAM_RESULT_NONE;
8746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 } // end switch on statusChangeCode
8748 if(eCSR_ROAM_RESULT_NONE != result)
8749 {
8750 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8751 }
8752 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 case eWNI_SME_IBSS_NEW_PEER_IND:
8754 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008755#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8756 {
8757 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8759 if(pIbssLog)
8760 {
8761 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8762 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8763 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8764 }
8765 }
8766#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 sessionId = csrFindIbssSession( pMac );
8768 if( CSR_SESSION_ID_INVALID != sessionId )
8769 {
8770 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008771
8772 if(!pSession)
8773 {
8774 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8775 return;
8776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8778 if(pSession->pConnectBssDesc)
8779 {
8780 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8781 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8782 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8783 {
8784 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8785 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8786 if(HAL_STATUS_SUCCESS(status))
8787 {
8788 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8789 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8790 roamInfo.nBeaconLength);
8791 }
8792 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8793 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8794 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8795 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8796 pSession->pConnectBssDesc->length);
8797 if(HAL_STATUS_SUCCESS(status))
8798 {
8799 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8800 pSession->pConnectBssDesc->length);
8801 }
8802 if(HAL_STATUS_SUCCESS(status))
8803 {
8804 pRoamInfo = &roamInfo;
8805 }
8806 else
8807 {
8808 if(roamInfo.pbFrames)
8809 {
8810 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8811 }
8812 if(roamInfo.pBssDesc)
8813 {
8814 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8815 }
8816 }
8817 }
8818 else
8819 {
8820 pRoamInfo = &roamInfo;
8821 }
8822 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8823 pSession->pConnectBssDesc,
8824 &(pIbssPeerInd->peerAddr),
8825 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8826 }
8827 else
8828 {
8829 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8830 }
8831 //send up the sec type for the new peer
8832 if (pRoamInfo)
8833 {
8834 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8835 }
8836 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
8837 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
8838 if(pRoamInfo)
8839 {
8840 if(roamInfo.pbFrames)
8841 {
8842 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8843 }
8844 if(roamInfo.pBssDesc)
8845 {
8846 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8847 }
8848 }
8849 }
8850 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8852 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
8853 sessionId = csrFindIbssSession( pMac );
8854 if( CSR_SESSION_ID_INVALID != sessionId )
8855 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008856#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8857 {
8858 vos_log_ibss_pkt_type *pIbssLog;
8859
8860 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8861 if(pIbssLog)
8862 {
8863 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
8864 if(pIbssPeerInd)
8865 {
8866 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8867 }
8868 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8869 }
8870 }
8871#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM\n");
8873 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8874 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8875 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8876 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8877 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8878 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8879 }
8880 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 case eWNI_SME_SETCONTEXT_RSP:
8882 {
8883 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
8884 tListElem *pEntry;
8885 tSmeCmd *pCommand;
8886
8887 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8888 if ( pEntry )
8889 {
8890 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8891 if ( eSmeCommandSetKey == pCommand->command )
8892 {
8893 sessionId = pCommand->sessionId;
8894 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008895
8896 if(!pSession)
8897 {
8898 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8899 return;
8900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008901
8902#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8903 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
8904 {
8905 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
8906 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8907 if( pRsp->peerMacAddr[0] & 0x01 )
8908 {
8909 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8910 }
8911 else
8912 {
8913 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8914 }
8915 setKeyEvent.encryptionModeMulticast =
8916 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8917 setKeyEvent.encryptionModeUnicast =
8918 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8919 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8920 setKeyEvent.authMode =
8921 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8922 if( eSIR_SUCCESS != pRsp->statusCode )
8923 {
8924 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8925 }
8926 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8927 }
8928#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8929 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
8930 {
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08008931 csrRoamStopWaitForKeyTimer( pMac );
8932
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 //We are done with authentication, whethere succeed or not
8934 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 //We do it here because this linkup function is not called after association
8936 //when a key needs to be set.
8937 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
8938 {
8939 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
8940 }
8941 }
Jeff Johnson43971f52012-07-17 12:26:56 -07008942 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 {
8944 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07008945 //Make sure we install the GTK before indicating to HDD as authenticated
8946 //This is to prevent broadcast packets go out after PTK and before GTK.
8947 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
8948 sizeof(tSirMacAddr) ) )
8949 {
Yathishd8713192012-12-10 14:21:35 -08008950#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
8951 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
8952 {
8953 tpSirSetActiveModeSetBncFilterReq pMsg;
8954 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
8955 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
8956 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
8957 pMsg->seesionId = sessionId;
8958 status = palSendMBMessage(pMac->hHdd, pMsg );
8959 }
8960#endif
8961 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07008962 }
8963 else
8964 {
8965 result = eCSR_ROAM_RESULT_NONE;
8966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 pRoamInfo = &roamInfo;
8968 }
8969 else
8970 {
8971 result = eCSR_ROAM_RESULT_FAILURE;
8972 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...\n",
8973 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
8974 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
8975 }
8976 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
8977 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
8979 // can go ahead and initiate the TSPEC if any are pending
8980 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008981#ifdef FEATURE_WLAN_CCX
8982 //Send Adjacent AP repot to new AP.
8983 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
8984 pSession->isPrevApInfoValid &&
8985 pSession->connectedProfile.isCCXAssoc)
8986 {
8987#ifdef WLAN_FEATURE_VOWIFI
8988 csrCcxSendAdjacentApRepMsg(pMac, pSession);
8989#endif
8990 pSession->isPrevApInfoValid = FALSE;
8991 }
8992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
8994 {
8995 csrReleaseCommandSetKey( pMac, pCommand );
8996 }
8997 }
8998 else
8999 {
9000 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9001 }
9002 }
9003 else
9004 {
9005 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009007 smeProcessPendingQueue( pMac );
9008 }
9009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 case eWNI_SME_REMOVEKEY_RSP:
9011 {
9012 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9013 tListElem *pEntry;
9014 tSmeCmd *pCommand;
9015
9016 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9017 if ( pEntry )
9018 {
9019 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9020 if ( eSmeCommandRemoveKey == pCommand->command )
9021 {
9022 sessionId = pCommand->sessionId;
9023 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009024
9025 if(!pSession)
9026 {
9027 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9028 return;
9029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009030#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9031 {
9032 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9033 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9034 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9035 removeKeyEvent.encryptionModeMulticast =
9036 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9037 removeKeyEvent.encryptionModeUnicast =
9038 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9039 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9040 removeKeyEvent.authMode =
9041 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9042 if( eSIR_SUCCESS != pRsp->statusCode )
9043 {
9044 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9045 }
9046 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9047 }
9048#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009049 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 {
9051 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9052 result = eCSR_ROAM_RESULT_NONE;
9053 pRoamInfo = &roamInfo;
9054 }
9055 else
9056 {
9057 result = eCSR_ROAM_RESULT_FAILURE;
9058 }
9059 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9060 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9061 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9062 {
9063 csrReleaseCommandRemoveKey( pMac, pCommand );
9064 }
9065 }
9066 else
9067 {
9068 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9069 }
9070 }
9071 else
9072 {
9073 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009075 smeProcessPendingQueue( pMac );
9076 }
9077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07009079 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 csrRoamStatsRspProcessor( pMac, pSirMsg );
9081 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 case eWNI_SME_GET_RSSI_REQ:
Mohit Khanna23863762012-09-11 17:40:09 -07009083 smsLog( pMac, LOG2, FL("GetRssiReq from self\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 csrUpdateRssi( pMac, pSirMsg );
9085 break;
9086
Jeff Johnson295189b2012-06-20 16:38:30 -07009087#ifdef WLAN_FEATURE_VOWIFI_11R
9088 case eWNI_SME_FT_PRE_AUTH_RSP:
9089 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9090 break;
9091#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9093 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
9094 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted\n"));
9095 sessionId = pSmeMaxAssocInd->sessionId;
9096 roamInfo.sessionId = sessionId;
9097 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9098 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9099 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9100 break;
9101
9102 case eWNI_SME_BTAMP_LOG_LINK_IND:
9103 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread\n"));
9104 btampEstablishLogLinkHdlr( pSirMsg );
9105 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009106 case eWNI_SME_RSSI_IND:
9107 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread\n"));
9108 csrRoamRssiIndHdlr( pMac, pSirMsg );
9109 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009110
9111 default:
9112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009113 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009114}
9115
Jeff Johnson295189b2012-06-20 16:38:30 -07009116void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9117 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9118{
9119 if(pSession)
9120 {
9121 if(pSession->bRefAssocStartCnt)
9122 {
9123 pSession->bRefAssocStartCnt--;
9124 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9125 //Need to call association_completion because there is an assoc_start pending.
9126 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9127 eCSR_ROAM_ASSOCIATION_COMPLETION,
9128 eCSR_ROAM_RESULT_FAILURE);
9129 }
9130 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9131 }
9132 else
9133 {
9134 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9135 }
9136}
9137
9138
9139eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9140{
9141 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9143 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9144 {
9145 status = csrScanRequestLostLink1( pMac, sessionId );
9146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 return(status);
9148}
9149
Jeff Johnson295189b2012-06-20 16:38:30 -07009150//return a boolean to indicate whether roaming completed or continue.
9151tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9152 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9153{
9154 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9155 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9156 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9157 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009158 if(!pSession)
9159 {
9160 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9161 return eANI_BOOLEAN_FALSE;
9162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 //Check whether time is up
9164 if(pSession->fCancelRoaming || fForce ||
9165 ((curTime - pSession->roamingStartTime) > roamTime) ||
9166 eCsrReassocRoaming == pSession->roamingReason ||
9167 eCsrDynamicRoaming == pSession->roamingReason)
9168 {
9169 smsLog(pMac, LOGW, FL(" indicates roaming completion\n"));
9170 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9171 {
9172 //roaming is cancelled, tell HDD to indicate disconnect
9173 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9174 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9175 //to be eSIR_BEACON_MISSED
9176 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9177 {
9178 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9179 }
9180 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9181 {
9182 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9183 }
9184 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9185 {
9186 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9187 }
9188 else
9189 {
9190 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9191 }
9192 }
9193 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9194 pSession->roamingReason = eCsrNotRoaming;
9195 }
9196 else
9197 {
9198 pSession->roamResult = roamResult;
9199 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9200 {
9201 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9202 pSession->roamingReason = eCsrNotRoaming;
9203 }
9204 else
9205 {
9206 fCompleted = eANI_BOOLEAN_FALSE;
9207 }
9208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009209 return(fCompleted);
9210}
9211
Jeff Johnson295189b2012-06-20 16:38:30 -07009212void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9213{
9214 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009215
9216 if(!pSession)
9217 {
9218 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9219 return;
9220 }
9221
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 if(CSR_IS_ROAMING(pSession))
9223 {
9224 smsLog(pMac, LOGW, " Cancelling roaming\n");
9225 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9226 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9227 {
9228 //No need to do anything in here because the handler takes care of it
9229 }
9230 else
9231 {
9232 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9233 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9234 //Roaming is stopped after here
9235 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9236 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9237 csrScanAbortMacScan(pMac);
9238 csrRoamStopRoamingTimer(pMac, sessionId);
9239 }
9240 }
9241}
9242
Jeff Johnson295189b2012-06-20 16:38:30 -07009243void csrRoamRoamingTimerHandler(void *pv)
9244{
9245 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9246 tpAniSirGlobal pMac = pInfo->pMac;
9247 tANI_U32 sessionId = pInfo->sessionId;
9248 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009249
9250 if(!pSession)
9251 {
9252 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9253 return;
9254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009255
9256 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9257 {
9258 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9259 {
9260 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9261 pSession->roamingReason = eCsrNotRoaming;
9262 }
9263 }
9264}
9265
Jeff Johnson295189b2012-06-20 16:38:30 -07009266eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9267{
9268 eHalStatus status;
9269 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009270
9271 if(!pSession)
9272 {
9273 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9274 return eHAL_STATUS_FAILURE;
9275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009276
9277 smsLog(pMac, LOG1, " csrScanStartRoamingTimer \n ");
9278 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9279 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9280
9281 return (status);
9282}
9283
Jeff Johnson295189b2012-06-20 16:38:30 -07009284eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9285{
9286 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9287}
9288
Jeff Johnson295189b2012-06-20 16:38:30 -07009289void csrRoamWaitForKeyTimeOutHandler(void *pv)
9290{
9291 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9292 tpAniSirGlobal pMac = pInfo->pMac;
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009293 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9294
9295 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d\n",
9296 pMac->roam.neighborRoamInfo.neighborRoamState,
9297 pMac->roam.curSubState[pInfo->sessionId]);
9298
Jeff Johnson295189b2012-06-20 16:38:30 -07009299 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9300 {
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009301#ifdef FEATURE_WLAN_LFR
9302 if (csrNeighborRoamIsHandoffInProgress(pMac))
9303 {
9304 /*
9305 * Enable heartbeat timer when hand-off is in progress
9306 * and Key Wait timer expired.
9307 */
9308 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
9309 " (nHBCount=%d)\n",
9310 pMac->roam.configParam.HeartbeatThresh24);
9311 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9312 pMac->roam.configParam.HeartbeatThresh24,
9313 NULL, eANI_BOOLEAN_FALSE);
9314 }
9315#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 smsLog(pMac, LOGW, " SME pre-auth state timeout. \n ");
9317 //Change the substate so command queue is unblocked.
9318 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009319 if (pSession)
9320 {
9321 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9322 {
9323 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9324 smeProcessPendingQueue(pMac);
9325 }
9326 else
9327 {
9328 smsLog(pMac, LOGW, "%s: could not post link up\n",
9329 __func__);
9330 }
9331 }
9332 else
9333 {
9334 smsLog(pMac, LOGW, "%s: session not found\n", __func__);
9335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 }
9337
9338}
9339
Jeff Johnson295189b2012-06-20 16:38:30 -07009340eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9341{
9342 eHalStatus status;
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009343#ifdef FEATURE_WLAN_LFR
9344 if (csrNeighborRoamIsHandoffInProgress(pMac))
9345 {
9346 /* Disable heartbeat timer when hand-off is in progress */
9347 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d\n",
9348 __func__,
9349 pMac->roam.neighborRoamInfo.neighborRoamState,
9350 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9351 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9352 }
9353#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer \n ");
9355 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9356
9357 return (status);
9358}
9359
Jeff Johnson295189b2012-06-20 16:38:30 -07009360eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9361{
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009362 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d\n",
9363 pMac->roam.neighborRoamInfo.neighborRoamState,
9364 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9365#ifdef FEATURE_WLAN_LFR
9366 if (csrNeighborRoamIsHandoffInProgress(pMac))
9367 {
9368 /*
9369 * Enable heartbeat timer when hand-off is in progress
9370 * and Key Wait timer got stopped for some reason
9371 */
9372 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
9373 " (nHBCount=%d)\n",
9374 pMac->roam.configParam.HeartbeatThresh24);
9375 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9376 pMac->roam.configParam.HeartbeatThresh24,
9377 NULL, eANI_BOOLEAN_FALSE);
9378 }
9379#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009380 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9381}
9382
Jeff Johnson295189b2012-06-20 16:38:30 -07009383void csrRoamIbssJoinTimerHandler(void *pv)
9384{
9385 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9386 tpAniSirGlobal pMac = pInfo->pMac;
9387 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9388 tANI_U32 sessionId = pInfo->sessionId;
9389 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009390
9391 if(!pSession)
9392 {
9393 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9394 return;
9395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009396
9397 pSession->ibss_join_pending = FALSE;
9398 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9399 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9400 // Send an IBSS stop request to PE
9401 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009402}
Jeff Johnson295189b2012-06-20 16:38:30 -07009403eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9404{
9405 eHalStatus status;
9406 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009407
9408 if(!pSession)
9409 {
9410 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9411 return eHAL_STATUS_FAILURE;
9412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009413
9414 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer \n ");
9415 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9416 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9417
9418 return (status);
9419}
Jeff Johnson295189b2012-06-20 16:38:30 -07009420eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9421{
9422 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9423}
Jeff Johnson295189b2012-06-20 16:38:30 -07009424void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9425 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9426{
9427 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9428 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009429 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9430 /* To silence the KW tool Null chaeck is added */
9431 if(!pSession)
9432 {
9433 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9434 return;
9435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009436
9437 if(pCommand)
9438 {
9439 roamId = pCommand->u.roamCmd.roamId;
9440#if defined(VOSS_ENABLED)
9441 VOS_ASSERT( sessionId == pCommand->sessionId );
9442#endif
9443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9445 {
9446 //if success, force roaming completion
9447 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9448 }
9449 else
9450 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009451 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d\n"), roamResult);
9453 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9454 }
9455}
9456
Jeff Johnson295189b2012-06-20 16:38:30 -07009457eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9458{
9459 eHalStatus status = eHAL_STATUS_SUCCESS;
9460 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9461 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9462 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9463 tCsrRoamInfo *pRoamInfo = NULL;
9464 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009465 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009467 /* To silence the KW tool Null chaeck is added */
9468 if(!pSession)
9469 {
9470 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9471 return eHAL_STATUS_FAILURE;
9472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009474 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9476 if ( eWNI_SME_DISASSOC_IND == type )
9477 {
9478 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9479 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9480 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009481 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 }
9483 else if ( eWNI_SME_DEAUTH_IND == type )
9484 {
9485 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9486 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9487 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009488 /* Convert into proper reason code */
9489 pSession->joinFailStatusCode.reasonCode =
9490 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
9491 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON : pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 }
9493 else
9494 {
9495 smsLog(pMac, LOGW, FL("gets an unknown type (%d)\n"), type);
9496 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009497 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 }
9499
9500 // call profile lost link routine here
9501#ifdef WLAN_SOFTAP_FEATURE
9502 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
9503#endif
9504 {
9505 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9506 }
9507
9508 if ( eWNI_SME_DISASSOC_IND == type )
9509 {
9510 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9511 }
9512 else if ( eWNI_SME_DEAUTH_IND == type )
9513 {
9514 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 if(!HAL_STATUS_SUCCESS(status))
9517 {
9518 //If fail to send confirmation to PE, not to trigger roaming
9519 fToRoam = eANI_BOOLEAN_FALSE;
9520 }
9521
9522 //tell HDD to disconnect
9523 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9524 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9525 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9526#ifdef WLAN_SOFTAP_FEATURE
9527 if( eWNI_SME_DISASSOC_IND == type)
9528 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009529 //staMacAddr
9530 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9531 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 else if( eWNI_SME_DEAUTH_IND == type )
9534 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009535 //staMacAddr
9536 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9537 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009539#endif
9540 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)\n"), roamInfo.staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 if(fToRoam)
9542 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009543 //Tell HDD about the lost link
9544 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 //Only remove the connected BSS in infrastructure mode
9546 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9547 //Not to do anying for lostlink with WDS
9548 if( pMac->roam.configParam.nRoamingTime )
9549 {
9550 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9551 ( eWNI_SME_DEAUTH_IND == type ) ?
9552 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9553 {
9554 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9555 //For IBSS, we need to give some more info to HDD
9556 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9557 {
9558 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9559 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9560 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9561 }
9562 else
9563 {
9564 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9565 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009566 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9568 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9569 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9570 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9571 }
9572 else
9573 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009574 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 fToRoam = eANI_BOOLEAN_FALSE;
9576 }
9577 }
9578 else
9579 {
9580 //We are told not to roam, indicate lostlink
9581 fToRoam = eANI_BOOLEAN_FALSE;
9582 }
9583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 if(!fToRoam)
9585 {
9586 if( eWNI_SME_DISASSOC_IND == type)
9587 {
9588 //staMacAddr
9589 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9590 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9591 }
9592 else if( eWNI_SME_DEAUTH_IND == type )
9593 {
9594 //staMacAddr
9595 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9596 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9597 }
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009598 //Tell HDD about the lost link
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08009599#ifdef WLAN_SOFTAP_FEATURE
9600 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
9601#endif
9602 {
9603 /* Dont call csrRoamCallCallback for GO/SoftAp case as this indication
9604 * was alredy given as part of eWNI_SME_DISASSOC_IND msg handling in
9605 * csrRoamCheckForLinkStatusChange API.
9606 */
9607 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9608 }
9609
9610 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 Still enable idle scan for polling in case concurrent sessions are running */
9612 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9613 {
9614 csrScanStartIdleScan(pMac);
9615 }
9616 }
9617
9618 return (status);
9619}
9620
Jeff Johnson295189b2012-06-20 16:38:30 -07009621eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9622{
9623 eHalStatus status = eHAL_STATUS_SUCCESS;
9624 tListElem *pEntry = NULL;
9625 tSmeCmd *pCommand = NULL;
9626 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009627
9628 if(!pSession)
9629 {
9630 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9631 return eHAL_STATUS_FAILURE;
9632 }
9633
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 //Only remove the connected BSS in infrastructure mode
9636 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9637 if(pMac->roam.configParam.nRoamingTime)
9638 {
9639 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9640 {
9641 //before starting the lost link logic release the roam command for handoff
9642 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9643 if(pEntry)
9644 {
9645 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9646 }
9647 if(pCommand)
9648 {
9649 if (( eSmeCommandRoam == pCommand->command ) &&
9650 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9651 {
9652 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9653 {
9654 csrReleaseCommandRoam( pMac, pCommand );
9655 }
9656 }
9657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 smsLog( pMac, LOGW, "Lost link roaming started ...\n");
9659 }
9660 }
9661 else
9662 {
9663 //We are told not to roam, indicate lostlink
9664 status = eHAL_STATUS_FAILURE;
9665 }
9666
9667 return (status);
9668}
Jeff Johnson295189b2012-06-20 16:38:30 -07009669void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9670{
9671 tListElem *pEntry;
9672 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9674 if ( pEntry )
9675 {
9676 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9677 if ( eSmeCommandWmStatusChange == pCommand->command )
9678 {
9679 // Nothing to process in a Lost Link completion.... It just kicks off a
9680 // roaming sequence.
9681 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9682 {
9683 csrReleaseCommandWmStatusChange( pMac, pCommand );
9684 }
9685 else
9686 {
9687 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command\n");
9688 }
9689
9690 }
9691 else
9692 {
9693 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...\n" );
9694 }
9695 }
9696 else
9697 {
9698 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...\n" );
9699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 smeProcessPendingQueue( pMac );
9701}
9702
Jeff Johnson295189b2012-06-20 16:38:30 -07009703void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9704{
9705 eHalStatus status = eHAL_STATUS_FAILURE;
9706 tSirSmeRsp *pSirSmeMsg;
9707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009708
9709 if(!pSession)
9710 {
9711 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9712 return;
9713 }
9714
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 switch ( pCommand->u.wmStatusChangeCmd.Type )
9716 {
9717 case eCsrDisassociated:
9718 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9719 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9720 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 case eCsrDeauthenticated:
9722 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9723 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 default:
9726 smsLog(pMac, LOGW, FL("gets an unknown command %d\n"), pCommand->u.wmStatusChangeCmd.Type);
9727 break;
9728 }
9729 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9730 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9731 {
9732 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9733 {
9734 //This is not good
9735 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command\n"));
9736 }
9737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009738 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9739 // command here since there is nothing else to do.
9740 csrRoamWmStatusChangeComplete( pMac );
9741}
9742
Jeff Johnson295189b2012-06-20 16:38:30 -07009743//This function returns band and mode information.
9744//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9745//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
9746#ifdef WLAN_SOFTAP_FEATURE
9747static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9748 tANI_U8 operationChn, eCsrBand *pBand )
9749#else
9750static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, eCsrPhyMode phyModeIn,
9751 tANI_U8 operationChn, eCsrBand *pBand )
9752#endif
9753{
Jeff Johnson295189b2012-06-20 16:38:30 -07009754#ifdef WLAN_SOFTAP_FEATURE
9755 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9756 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9757 pMac->roam.configParam.ProprietaryRatesEnabled);
9758#else
9759 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(phyModeIn,
9760 pMac->roam.configParam.ProprietaryRatesEnabled);
9761#endif
9762 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009763
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 //If the global setting for dot11Mode is set to auto/abg, we overwrite the setting in the profile.
9765#ifdef WLAN_SOFTAP_FEATURE
9766 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9767 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9768 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9769 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
9770#else
9771 if( (eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9772 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode) ||
9773 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009774#endif
9775 {
9776 switch( pMac->roam.configParam.uCfgDot11Mode )
9777 {
9778 case eCSR_CFG_DOT11_MODE_11A:
9779 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9780 eBand = eCSR_BAND_5G;
9781 break;
9782 case eCSR_CFG_DOT11_MODE_11B:
9783 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9784 eBand = eCSR_BAND_24;
9785 break;
9786 case eCSR_CFG_DOT11_MODE_11G:
9787 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9788 eBand = eCSR_BAND_24;
9789 break;
9790 case eCSR_CFG_DOT11_MODE_11N:
9791 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9792 eBand = eCSR_BAND_24;
9793 break;
9794 //case eCSR_CFG_DOT11_MODE_BEST:
9795 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9796 // eBand = eCSR_BAND_24;
9797 // break;
9798 default:
9799 // Global dot11 Mode setting is 11a/b/g.
9800 // use the channel number to determine the Mode setting.
9801 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9802 {
9803 eBand = pMac->roam.configParam.eBand;
9804 if(eCSR_BAND_24 == eBand)
9805 {
9806 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9807 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9808 }
9809 else
9810 {
9811 //prefer 5GHz
9812 eBand = eCSR_BAND_5G;
9813 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9814 }
9815 }
9816 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9817 {
9818 // channel is a 2.4GHz channel. Set mode to 11g.
9819 //
9820 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9821 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9822 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9823 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9824 // the IBSS network in 11b mode instead of 11g mode.
9825 //
9826 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9827 // then start the IBSS in b mode.
9828 //
9829 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9830 // the user will have to set the do11Mode in the property page to 11g to force it.
9831 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9832 eBand = eCSR_BAND_24;
9833 }
9834 else
9835 {
9836 // else, it's a 5.0GHz channel. Set mode to 11a.
9837 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9838 eBand = eCSR_BAND_5G;
9839 }
9840 break;
9841 }//switch
9842 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9843 else
9844 {
9845 //dot11 mode is set, lets pick the band
9846 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9847 {
9848 // channel is Auto also.
9849 eBand = pMac->roam.configParam.eBand;
9850 if(eCSR_BAND_ALL == eBand)
9851 {
9852 //prefer 5GHz
9853 eBand = eCSR_BAND_5G;
9854 }
9855 }
9856 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9857 {
9858 eBand = eCSR_BAND_24;
9859 }
9860 else
9861 {
9862 eBand = eCSR_BAND_5G;
9863 }
9864 }
9865 if(pBand)
9866 {
9867 *pBand = eBand;
9868 }
9869
9870 if (operationChn == 14){
9871 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode \n"));
9872 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9873 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009874
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -08009875 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
9876 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 -07009877 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009878#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009879 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009880#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009881 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
9882 {
9883 //We cannot do 11n here
9884 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9885 {
9886 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9887 }
9888 else
9889 {
9890 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9891 }
9892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 return( cfgDot11Mode );
9894}
9895
Jeff Johnson295189b2012-06-20 16:38:30 -07009896eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
9897{
9898 eHalStatus status;
9899 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009900
9901 if(!pSession)
9902 {
9903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9904 return eHAL_STATUS_FAILURE;
9905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009906
9907#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9908 {
9909 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9911 if(pIbssLog)
9912 {
9913 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
9914 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9915 }
9916 }
9917#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 pSession->ibss_join_pending = FALSE;
9919 csrRoamStopIbssJoinTimer(pMac, sessionId );
9920 // Set the roaming substate to 'stop Bss request'...
9921 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
9922
9923 // attempt to stop the Bss (reason code is ignored...)
9924 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08009925 if(!HAL_STATUS_SUCCESS(status))
9926 {
9927 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
9928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 return (status);
9930}
9931
Jeff Johnson295189b2012-06-20 16:38:30 -07009932//pNumChan is a caller allocated space with the sizeof pChannels
9933eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
9934{
9935
9936 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
9937 (tANI_U8 *)pChannels,
9938 pNumChan));
9939}
9940
Kirand170dcb2013-01-31 10:43:43 -08009941tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
9942{
9943 tANI_U32 cfgLength = 0;
9944 tANI_U16 cfgId = 0;
9945 tPowerdBm maxTxPwr = 0;
9946 tANI_U8 *pCountryInfo = NULL;
9947 eHalStatus status;
9948 tANI_U8 count = 0;
9949 tANI_U8 firstChannel;
9950 tANI_U8 maxChannels;
9951
9952 if (CSR_IS_CHANNEL_5GHZ(channel))
9953 {
9954 cfgId = WNI_CFG_MAX_TX_POWER_5;
9955 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
9956 }
9957 else if (CSR_IS_CHANNEL_24GHZ(channel))
9958 {
9959 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
9960 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
9961 }
9962 else
9963 return maxTxPwr;
9964
9965 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
9966 if (status != eHAL_STATUS_SUCCESS)
9967 {
9968 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9969 FL("%s: palAllocateMemory() failed, status = %d"),
9970 __FUNCTION__, status);
9971 goto error;
9972 }
9973 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
9974 if (status != eHAL_STATUS_SUCCESS)
9975 {
9976 goto error;
9977 }
9978 /* Identify the channel and maxtxpower */
9979 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
9980 {
9981 firstChannel = pCountryInfo[count++];
9982 maxChannels = pCountryInfo[count++];
9983 maxTxPwr = pCountryInfo[count++];
9984
9985 if ((channel >= firstChannel) &&
9986 (channel < (firstChannel + maxChannels)))
9987 {
9988 break;
9989 }
9990 }
9991
9992error:
9993 if (NULL != pCountryInfo)
9994 palFreeMemory(pMac->hHdd, pCountryInfo);
9995
9996 return maxTxPwr;
9997}
9998
9999
Jeff Johnson295189b2012-06-20 16:38:30 -070010000tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10001{
10002 tANI_BOOLEAN fValid = FALSE;
10003 tANI_U32 idxValidChannels;
10004 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10005
10006 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10007 {
10008 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10009 {
10010 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10011 {
10012 fValid = TRUE;
10013 break;
10014 }
10015 }
10016 }
10017 pMac->roam.numValidChannels = len;
10018 return fValid;
10019}
10020
Jeff Johnson295189b2012-06-20 16:38:30 -070010021tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10022{
10023 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10024 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10026 {
10027 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10028 {
10029 fValid = eANI_BOOLEAN_TRUE;
10030 break;
10031 }
10032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 return (fValid);
10034}
10035
Jeff Johnson295189b2012-06-20 16:38:30 -070010036//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010037 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010038{
Jeff Johnsone7245742012-09-05 17:12:55 -070010039 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 tANI_U8 centerChn;
10041 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10043 {
10044 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10045 }
10046 else
10047 {
10048 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10049 }
10050 //Figure what the other side's CB mode
10051 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10052 {
10053 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10054 {
10055 if(pIes->HTInfo.present)
10056 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010057 /* This is called during INFRA STA/CLIENT and should use the merged value of
10058 * supported channel width and recommended tx width as per standard
10059 */
10060 smsLog(pMac, LOG1, "scws %u rtws %u sco %u\n",
10061 pIes->HTCaps.supportedChannelWidthSet,
10062 pIes->HTInfo.recommendedTxWidthSet,
10063 pIes->HTInfo.secondaryChannelOffset);
10064
10065 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10066 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010068 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10069 switch (eRet) {
10070 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10071 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10072 break;
10073 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10074 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10075 break;
10076 case PHY_SINGLE_CHANNEL_CENTERED:
10077 default:
10078 centerChn = primaryChn;
10079 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010081 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010083 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode\n", centerChn);
10084 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 }
10086 }
10087 }
10088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 return eRet;
10090}
Jeff Johnson295189b2012-06-20 16:38:30 -070010091tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10092{
10093 tANI_BOOLEAN fFound = FALSE;
10094 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010095 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10096 {
10097 if( pCipherList->encryptionType[idx] == encryptionType )
10098 {
10099 fFound = TRUE;
10100 break;
10101 }
10102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 return fFound;
10104}
Jeff Johnson295189b2012-06-20 16:38:30 -070010105tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10106{
10107 tANI_BOOLEAN fFound = FALSE;
10108 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10110 {
10111 if( pAuthList->authType[idx] == authType )
10112 {
10113 fFound = TRUE;
10114 break;
10115 }
10116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 return fFound;
10118}
Jeff Johnson295189b2012-06-20 16:38:30 -070010119tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10120{
10121 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10122 tCsrScanResultFilter *pScanFilter = NULL;
10123 eHalStatus status = eHAL_STATUS_SUCCESS;
10124
10125 if(pProfile1 && pProfile2)
10126 {
10127 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10128 if(HAL_STATUS_SUCCESS(status))
10129 {
10130 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10131 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10132 if(HAL_STATUS_SUCCESS(status))
10133 {
10134 fCheck = eANI_BOOLEAN_FALSE;
10135 do
10136 {
10137 tANI_U32 i;
10138 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10139 {
10140 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10141 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10142 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10143 if ( fCheck ) break;
10144 }
10145 if(!fCheck)
10146 {
10147 break;
10148 }
10149 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10150 || pProfile2->BSSType != pProfile1->BSSType
10151 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10152 )
10153 {
10154 fCheck = eANI_BOOLEAN_FALSE;
10155 break;
10156 }
10157#ifdef WLAN_FEATURE_VOWIFI_11R
10158 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10159 {
10160 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10161 {
10162 fCheck = eANI_BOOLEAN_FALSE;
10163 break;
10164 }
10165 }
10166#endif
10167 //Match found
10168 fCheck = eANI_BOOLEAN_TRUE;
10169 }while(0);
10170 csrFreeScanFilter(pMac, pScanFilter);
10171 }
10172 palFreeMemory(pMac->hHdd, pScanFilter);
10173 }
10174 }
10175
10176 return (fCheck);
10177}
10178
Jeff Johnson295189b2012-06-20 16:38:30 -070010179tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10180{
10181 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10182 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 do
10184 {
10185 //Only check for static WEP
10186 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10187 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10188 {
10189 fCheck = eANI_BOOLEAN_TRUE;
10190 break;
10191 }
10192 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10193 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10194 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10195 {
10196 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10197 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10198 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10199 {
10200 break;
10201 }
10202 }
10203 if( i == CSR_MAX_NUM_KEY)
10204 {
10205 fCheck = eANI_BOOLEAN_TRUE;
10206 }
10207 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 return (fCheck);
10209}
10210
Jeff Johnson295189b2012-06-20 16:38:30 -070010211//IBSS
10212
Jeff Johnson295189b2012-06-20 16:38:30 -070010213tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10214{
10215 tANI_U8 channel = 0;
10216 tANI_U32 idx;
10217 tANI_U32 idxValidChannels;
10218 tANI_BOOLEAN fFound = FALSE;
10219 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10220
10221 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10222 {
10223 channel = pMac->roam.configParam.AdHocChannel5G;
10224 if(!csrRoamIsChannelValid(pMac, channel))
10225 {
10226 channel = 0;
10227 }
10228 }
10229 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10230 {
10231 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10232 {
10233 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10234 {
10235 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10236 {
10237 fFound = TRUE;
10238 channel = csrStartIbssChannels50[ idx ];
10239 }
10240 }
10241 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10243 if (!fFound)
10244 {
10245 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10246 {
10247 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10248 {
10249 channel = csrStartIbssChannels50[ idx ];
10250 break;
10251 }
10252 }
10253 }
10254 }//if
10255
10256 return( channel );
10257}
10258
Jeff Johnson295189b2012-06-20 16:38:30 -070010259tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10260{
10261 tANI_U8 channel = 1;
10262 tANI_U32 idx;
10263 tANI_U32 idxValidChannels;
10264 tANI_BOOLEAN fFound = FALSE;
10265 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10266
10267 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10268 {
10269 channel = pMac->roam.configParam.AdHocChannel24;
10270 if(!csrRoamIsChannelValid(pMac, channel))
10271 {
10272 channel = 0;
10273 }
10274 }
10275
10276 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10277 {
10278 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10279 {
10280 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10281 {
10282 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10283 {
10284 fFound = TRUE;
10285 channel = csrStartIbssChannels24[ idx ];
10286 }
10287 }
10288 }
10289 }
10290
10291 return( channel );
10292}
10293
Jeff Johnson295189b2012-06-20 16:38:30 -070010294static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10295 tCsrRoamStartBssParams *pParam )
10296{
10297 eCsrCfgDot11Mode cfgDot11Mode;
10298 eCsrBand eBand;
10299 tANI_U8 channel = 0;
10300 tSirNwType nwType;
10301 tANI_U8 operationChannel = 0;
10302
10303 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10304 {
10305 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10306 }
10307
10308#ifdef WLAN_SOFTAP_FEATURE
10309 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
10310#else
10311 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel, &eBand );
10312#endif
10313
10314#ifdef WLAN_FEATURE_P2P
10315 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10316 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10317 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10318 )
10319 {
10320 /* This should never happen */
10321 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
10322 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B\n"),
10323 pProfile->csrPersona);
10324 VOS_ASSERT(0);
10325 }
10326#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010327 switch( cfgDot11Mode )
10328 {
10329 case eCSR_CFG_DOT11_MODE_11G:
10330 nwType = eSIR_11G_NW_TYPE;
10331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 case eCSR_CFG_DOT11_MODE_11B:
10333 nwType = eSIR_11B_NW_TYPE;
10334 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 case eCSR_CFG_DOT11_MODE_11A:
10336 nwType = eSIR_11A_NW_TYPE;
10337 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 default:
10339 case eCSR_CFG_DOT11_MODE_11N:
10340 case eCSR_CFG_DOT11_MODE_TAURUS:
10341 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10342 if(eCSR_BAND_24 == eBand)
10343 {
10344 nwType = eSIR_11G_NW_TYPE;
10345 }
10346 else
10347 {
10348 nwType = eSIR_11A_NW_TYPE;
10349 }
10350 break;
10351 }
10352
10353 pParam->extendedRateSet.numRates = 0;
10354
10355 switch ( nwType )
10356 {
10357 default:
10358 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)\n"), nwType);
10359 case eSIR_11A_NW_TYPE:
10360
10361 pParam->operationalRateSet.numRates = 8;
10362
10363 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10364 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10365 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10366 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10367 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10368 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10369 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10370 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10371
10372 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10373 {
10374 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10375 if( 0 == channel &&
10376 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10377 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10378 )
10379 {
10380 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10381 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10382 nwType = eSIR_11B_NW_TYPE;
10383 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10384 pParam->operationalRateSet.numRates = 4;
10385 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10386 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10387 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10388 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10389 }
10390 }
10391 else
10392 {
10393 channel = operationChannel;
10394 }
10395 break;
10396
10397 case eSIR_11B_NW_TYPE:
10398 pParam->operationalRateSet.numRates = 4;
10399 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10400 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10401 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10402 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10404 {
10405 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10406 }
10407 else
10408 {
10409 channel = operationChannel;
10410 }
10411
10412 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 case eSIR_11G_NW_TYPE:
10414#ifdef WLAN_FEATURE_P2P
10415 /* For P2P Client and P2P GO, disable 11b rates */
10416 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10417 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10418 )
10419 {
10420 pParam->operationalRateSet.numRates = 8;
10421
10422 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10423 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10424 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10425 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10426 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10427 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10428 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10429 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10430 }
10431 else
10432#endif
10433 {
10434 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010435 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10436 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10437 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10438 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10439
10440 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010441 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10442 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10443 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10444 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10445 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10446 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10447 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10448 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10449 }
10450
10451 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10452 {
10453 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10454 }
10455 else
10456 {
10457 channel = operationChannel;
10458 }
10459
10460 break;
10461 }
10462 pParam->operationChn = channel;
10463 pParam->sirNwType = nwType;
10464}
10465
Jeff Johnson295189b2012-06-20 16:38:30 -070010466static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10467 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10468{
10469
10470 if( pParam )
10471 {
10472 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010473 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 pParam->operationChn = pBssDesc->channelId;
10475 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10476
10477 if( pIes )
10478 {
10479 if(pIes->SuppRates.present)
10480 {
10481 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10482 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10483 {
10484 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX\n"),
10485 pIes->SuppRates.num_rates);
10486 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10487 }
10488 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10489 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10490 }
10491 if( pIes->SSID.present )
10492 {
10493 pParam->ssId.length = pIes->SSID.num_ssid;
10494 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10495 }
10496 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 }
10498 else
10499 {
10500 pParam->ssId.length = 0;
10501 pParam->operationalRateSet.numRates = 0;
10502 }
10503 }
10504}
10505
Jeff Johnson295189b2012-06-20 16:38:30 -070010506static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10507{
10508 tANI_U8 MaxRate = 0;
10509 tANI_U32 i;
10510 tANI_U8 *pRate;
10511
10512 pRate = pSirRateSet->rate;
10513 for ( i = 0; i < pSirRateSet->numRates; i++ )
10514 {
10515 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10516 }
10517
10518 // Save the max rate in the connected state information...
10519
10520 // modify LastRates variable as well
10521
10522 return;
10523}
10524
Jeff Johnson295189b2012-06-20 16:38:30 -070010525//this function finds a valid secondary channel for channel bonding with "channel".
10526//Param: channel -- primary channel, caller must validate it
10527// cbChoice -- CB directory
10528//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10529static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10530{
10531 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 switch (cbChoice)
10533 {
10534 case eCSR_CB_OFF:
10535 chnUp = 0;
10536 chnDown = 0;
10537 break;
10538 case eCSR_CB_DOWN:
10539 chnUp = 0;
10540 chnDown = channel - CSR_CB_CHANNEL_GAP;
10541 break;
10542 case eCSR_CB_UP:
10543 chnUp = channel + CSR_CB_CHANNEL_GAP;
10544 chnDown = 0;
10545 break;
10546 case eCSR_CB_AUTO:
10547 //consider every other value means auto
10548 default:
10549 chnUp = channel + CSR_CB_CHANNEL_GAP;
10550 chnDown = channel - CSR_CB_CHANNEL_GAP;
10551 break;
10552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 //if CB_UP or auto, try channel up first
10554 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10555 {
10556 //found a valid up channel for channel bonding
10557 //check whether the center channel is valid
10558 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10559 {
10560 chnRet = chnUp;
10561 }
10562 }
10563 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10564 {
10565 //found a valid down channel for channel bonding
10566 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10567 {
10568 chnRet = chnDown;
10569 }
10570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 return chnRet;
10572}
10573
Jeff Johnson295189b2012-06-20 16:38:30 -070010574eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10575 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10576{
10577 eHalStatus status = eHAL_STATUS_SUCCESS;
10578 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010579 // Set the roaming substate to 'Start BSS attempt'...
10580 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010581#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10582 //Need to figure out whether we need to log WDS???
10583 if( CSR_IS_IBSS( pProfile ) )
10584 {
10585 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10587 if(pIbssLog)
10588 {
10589 if(pBssDesc)
10590 {
10591 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10592 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10593 }
10594 else
10595 {
10596 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10597 }
10598 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10599 pParam->ssId.length);
10600 if(pProfile->ChannelInfo.numOfChannels == 0)
10601 {
10602 pIbssLog->channelSetting = AUTO_PICK;
10603 }
10604 else
10605 {
10606 pIbssLog->channelSetting = SPECIFIED;
10607 }
10608 pIbssLog->operatingChannel = pParam->operationChn;
10609 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10610 }
10611 }
10612#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10613 //Put RSN information in for Starting BSS
10614 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10615 pParam->pRSNIE = pProfile->pRSNReqIE;
10616
Jeff Johnson295189b2012-06-20 16:38:30 -070010617#ifdef WLAN_SOFTAP_FEATURE
10618 pParam->privacy = pProfile->privacy;
10619 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10620 pParam->authType = pProfile->csr80211AuthType;
10621 pParam->beaconInterval = pProfile->beaconInterval;
10622 pParam->dtimPeriod = pProfile->dtimPeriod;
10623 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10624 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10625 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10626 {
10627 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10628 {
10629 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10630 }
10631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 pParam->protEnabled = pProfile->protEnabled;
10633 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10634 pParam->ht_protection = pProfile->cfg_protection;
10635 pParam->wps_state = pProfile->wps_state;
10636#endif
10637
Jeff Johnson295189b2012-06-20 16:38:30 -070010638#ifdef WLAN_SOFTAP_FEATURE
10639 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10640 &eBand);
10641#else
10642 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile->operationChannel,
10643 &eBand);
10644#endif
10645 pParam->bssPersona = pProfile->csrPersona;
10646 // When starting an IBSS, start on the channel from the Profile.
10647 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010648 return (status);
10649}
10650
Jeff Johnson295189b2012-06-20 16:38:30 -070010651static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010652 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010653{
10654 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010655 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 eCsrCBChoice cbChoice;
10657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010658
10659 if(!pSession)
10660 {
10661 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10662 return;
10663 }
10664
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 if( pBssDesc )
10666 {
10667 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10668 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10669 //The following code has to be do after that.
10670 //For WDS station, use selfMac as the self BSSID
10671 if( CSR_IS_WDS_STA( pProfile ) )
10672 {
10673 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10674 }
10675 }
10676 else
10677 {
10678 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 //Use the first SSID
10680 if(pProfile->SSIDs.numOfSSIDs)
10681 {
10682 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10683 }
10684 //For WDS station, use selfMac as the self BSSID
10685 if( CSR_IS_WDS_STA( pProfile ) )
10686 {
10687 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10688 }
10689 //Use the first BSSID
10690 else if( pProfile->BSSIDs.numOfBSSIDs )
10691 {
10692 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10693 }
10694 else
10695 {
10696 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10697 }
10698 }
10699 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010700 //Set operating channel in pProfile which will be used
10701 //in csrRoamSetBssConfigCfg() to determine channel bonding
10702 //mode and will be configured in CFG later
10703 pProfile->operationChannel = Channel;
10704
10705 if(Channel == 0)
10706 {
10707 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS\n");
10708 }
10709 else
10710 {
10711
10712 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010713 if (CSR_IS_INFRA_AP(pProfile))
10714 {
10715 if(CSR_IS_CHANNEL_24GHZ(Channel))
10716 {
10717 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10718 }
10719 else
10720 {
10721 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10722 }
10723 smsLog(pMac, LOG1, "##softap cbMode %d\n", cbMode);
10724 pBssConfig->cbMode = cbMode;
10725 pSession->bssParams.cbMode = cbMode;
10726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010727
10728 if( CSR_IS_START_IBSS( pProfile ) )
10729 {
10730 //TBH: channel bonding is not supported for Libra
10731 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10732 {
10733 Channel = pProfile->ChannelInfo.ChannelList[0];
10734 cbChoice = pProfile->CBMode;
10735 }
10736 else {
10737 cbChoice = pMac->roam.configParam.cbChoice;
10738 }
10739 pSession->bssParams.operationChn = Channel;
10740 //make sure channel is valid
10741 if(!csrRoamIsChannelValid(pMac, Channel))
10742 {
10743 //set Channel to 0 to let lim know this is invalid
10744 //We still send this request down to lim even though we know the channel is wrong because
10745 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10746 Channel = 0;
10747 pSession->bssParams.operationChn = 0;
10748 }
10749 else {
10750 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 if(CSR_IS_CHANNEL_24GHZ(Channel))
10752 {
10753 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10754 }
10755 else
10756 {
10757 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10758 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 //now we have a valid channel
10760 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10761 {
10762 //let's pick a secondard channel
10763 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 if(SecondChn > Channel)
10765 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010766 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 }
10768 else if(SecondChn && SecondChn < Channel)
10769 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010770 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 }
10772 else
10773 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010774 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 }
10776 pSession->bssParams.cbMode = cbMode;
10777 }
10778 else
10779 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010780 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 }
10782 }
10783 }
10784 }
10785}
10786
Jeff Johnson295189b2012-06-20 16:38:30 -070010787static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10788 tANI_BOOLEAN *pfSameIbss )
10789{
10790 eHalStatus status = eHAL_STATUS_SUCCESS;
10791 tANI_BOOLEAN fSameIbss = FALSE;
10792
10793 if ( csrIsConnStateIbss( pMac, sessionId ) )
10794 {
10795 // Check if any profile parameter has changed ? If any profile parameter
10796 // has changed then stop old BSS and start a new one with new parameters
10797 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10798 {
10799 fSameIbss = TRUE;
10800 }
10801 else
10802 {
10803 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10804 }
10805 }
10806 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10807 {
10808 // Disassociate from the connected Infrastructure network...
10809 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10810 }
10811 else
10812 {
10813 tBssConfigParam *pBssConfig;
10814
10815 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10816 if(HAL_STATUS_SUCCESS(status))
10817 {
10818 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10819 // there is no Bss description before we start an IBSS so we need to adopt
10820 // all Bss configuration parameters from the Profile.
10821 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10822 if(HAL_STATUS_SUCCESS(status))
10823 {
10824 //save dotMode
10825 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10826 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010827 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10829 }
10830
10831 palFreeMemory(pMac->hHdd, pBssConfig);
10832 }//Allocate memory
10833 }
10834
10835 if(pfSameIbss)
10836 {
10837 *pfSameIbss = fSameIbss;
10838 }
10839 return( status );
10840}
10841
Jeff Johnson295189b2012-06-20 16:38:30 -070010842static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10843 tSirSmeNewBssInfo *pNewBss )
10844{
10845 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010846
10847 if(!pSession)
10848 {
10849 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10850 return;
10851 }
10852
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 if( pNewBss )
10854 {
10855 // Set the operating channel.
10856 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10857 // move the BSSId from the BSS description into the connected state information.
10858 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10859 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10860 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010861 return;
10862}
10863
Jeff Johnson295189b2012-06-20 16:38:30 -070010864#ifdef FEATURE_WLAN_WAPI
10865eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10866 tANI_U32 numItems )
10867{
10868 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10869 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010870 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10871 {
10872 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10873 return status;
10874 }
10875 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d\n", numItems);
10876 pSession = CSR_GET_SESSION( pMac, sessionId );
10877 if(numItems <= CSR_MAX_BKID_ALLOWED)
10878 {
10879 status = eHAL_STATUS_SUCCESS;
10880 //numItems may be 0 to clear the cache
10881 pSession->NumBkidCache = (tANI_U16)numItems;
10882 if(numItems && pBKIDCache)
10883 {
10884 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
10885 sizeof(tBkidCacheInfo) * numItems );
10886 }
10887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010888 return (status);
10889}
Jeff Johnson295189b2012-06-20 16:38:30 -070010890eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
10891 tBkidCacheInfo *pBkidCache)
10892{
10893 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10894 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10896 {
10897 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10898 return status;
10899 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 pSession = CSR_GET_SESSION( pMac, sessionId );
10901 if(pNum && pBkidCache)
10902 {
10903 if(pSession->NumBkidCache == 0)
10904 {
10905 *pNum = 0;
10906 status = eHAL_STATUS_SUCCESS;
10907 }
10908 else if(*pNum >= pSession->NumBkidCache)
10909 {
10910 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
10911 {
10912 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10913 pSession->NumBkidCache);
10914 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
10915 }
10916 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
10917 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
10918 *pNum = pSession->NumBkidCache;
10919 status = eHAL_STATUS_SUCCESS;
10920 }
10921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010923}
Jeff Johnson295189b2012-06-20 16:38:30 -070010924tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10925{
10926 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070010927}
10928#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070010929eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
10930 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
10931{
10932 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10933 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010934
10935 if(!pSession)
10936 {
10937 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10938 return eHAL_STATUS_FAILURE;
10939 }
10940
Jeff Johnson295189b2012-06-20 16:38:30 -070010941 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d\n", numItems);
10942 if(numItems <= CSR_MAX_PMKID_ALLOWED)
10943 {
10944#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10945 {
10946 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
10947 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
10948 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
10949 secEvent.encryptionModeMulticast =
10950 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10951 secEvent.encryptionModeUnicast =
10952 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10953 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
10954 secEvent.authMode =
10955 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
10956 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10957 }
10958#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 status = eHAL_STATUS_SUCCESS;
10960 //numItems may be 0 to clear the cache
10961 pSession->NumPmkidCache = (tANI_U16)numItems;
10962 if(numItems && pPMKIDCache)
10963 {
10964 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
10965 sizeof(tPmkidCacheInfo) * numItems );
10966 }
10967 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010968 return (status);
10969}
10970
Jeff Johnson295189b2012-06-20 16:38:30 -070010971tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10972{
10973 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
10974}
10975
Jeff Johnson295189b2012-06-20 16:38:30 -070010976eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
10977{
10978 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10979 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010980
10981 if(!pSession)
10982 {
10983 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10984 return eHAL_STATUS_FAILURE;
10985 }
10986
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 if(pNum && pPmkidCache)
10988 {
10989 if(pSession->NumPmkidCache == 0)
10990 {
10991 *pNum = 0;
10992 status = eHAL_STATUS_SUCCESS;
10993 }
10994 else if(*pNum >= pSession->NumPmkidCache)
10995 {
10996 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
10997 {
10998 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10999 pSession->NumPmkidCache);
11000 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11001 }
11002 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11003 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11004 *pNum = pSession->NumPmkidCache;
11005 status = eHAL_STATUS_SUCCESS;
11006 }
11007 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 return (status);
11009}
11010
Jeff Johnson295189b2012-06-20 16:38:30 -070011011eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11012{
11013 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11014 tANI_U32 len;
11015 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011016
11017 if(!pSession)
11018 {
11019 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11020 return eHAL_STATUS_FAILURE;
11021 }
11022
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 if(pLen)
11024 {
11025 len = *pLen;
11026 *pLen = pSession->nWpaRsnReqIeLength;
11027 if(pBuf)
11028 {
11029 if(len >= pSession->nWpaRsnReqIeLength)
11030 {
11031 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11032 }
11033 }
11034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 return (status);
11036}
11037
Jeff Johnson295189b2012-06-20 16:38:30 -070011038eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11039{
11040 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11041 tANI_U32 len;
11042 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011043
11044 if(!pSession)
11045 {
11046 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11047 return eHAL_STATUS_FAILURE;
11048 }
11049
Jeff Johnson295189b2012-06-20 16:38:30 -070011050 if(pLen)
11051 {
11052 len = *pLen;
11053 *pLen = pSession->nWpaRsnRspIeLength;
11054 if(pBuf)
11055 {
11056 if(len >= pSession->nWpaRsnRspIeLength)
11057 {
11058 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11059 }
11060 }
11061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 return (status);
11063}
Jeff Johnson295189b2012-06-20 16:38:30 -070011064#ifdef FEATURE_WLAN_WAPI
11065eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11066{
11067 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11068 tANI_U32 len;
11069 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011070
11071 if(!pSession)
11072 {
11073 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11074 return eHAL_STATUS_FAILURE;
11075 }
11076
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 if(pLen)
11078 {
11079 len = *pLen;
11080 *pLen = pSession->nWapiReqIeLength;
11081 if(pBuf)
11082 {
11083 if(len >= pSession->nWapiReqIeLength)
11084 {
11085 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11086 }
11087 }
11088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011089 return (status);
11090}
Jeff Johnson295189b2012-06-20 16:38:30 -070011091eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11092{
11093 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11094 tANI_U32 len;
11095 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011096
11097 if(!pSession)
11098 {
11099 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11100 return eHAL_STATUS_FAILURE;
11101 }
11102
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 if(pLen)
11104 {
11105 len = *pLen;
11106 *pLen = pSession->nWapiRspIeLength;
11107 if(pBuf)
11108 {
11109 if(len >= pSession->nWapiRspIeLength)
11110 {
11111 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11112 }
11113 }
11114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 return (status);
11116}
11117#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011118eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11119{
11120 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11121 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011122
11123 if(!pSession)
11124 {
11125 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11126 return (retStatus);
11127 }
11128
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 if(CSR_IS_ROAMING(pSession))
11130 {
11131 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11132 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 return (retStatus);
11135}
11136
Jeff Johnson295189b2012-06-20 16:38:30 -070011137//This function remove the connected BSS from te cached scan result
11138eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11139 tCsrRoamConnectedProfile *pConnProfile)
11140{
11141 eHalStatus status = eHAL_STATUS_FAILURE;
11142 tCsrScanResultFilter *pScanFilter = NULL;
11143 tListElem *pEntry;
11144 tCsrScanResult *pResult;
11145 tDot11fBeaconIEs *pIes;
11146 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011147 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11148 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11149 {
11150 do
11151 {
11152 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11153 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11154 if(!HAL_STATUS_SUCCESS(status)) break;
11155 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11156 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11157 if(!HAL_STATUS_SUCCESS(status)) break;
11158 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11159 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11160 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11161 {
11162 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11163 if(!HAL_STATUS_SUCCESS(status)) break;
11164 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11165 }
11166 pScanFilter->authType.numEntries = 1;
11167 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11168 pScanFilter->BSSType = pConnProfile->BSSType;
11169 pScanFilter->EncryptionType.numEntries = 1;
11170 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11171 pScanFilter->mcEncryptionType.numEntries = 1;
11172 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11173 //We ignore the channel for now, BSSID should be enough
11174 pScanFilter->ChannelInfo.numOfChannels = 0;
11175 //Also ignore the following fields
11176 pScanFilter->uapsd_mask = 0;
11177 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11178 pScanFilter->countryCode[0] = 0;
11179 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 csrLLLock(&pMac->scan.scanResultList);
11181 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11182 while( pEntry )
11183 {
11184 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11185 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11186 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11187 pScanFilter, NULL, NULL, NULL, &pIes);
11188 //Release the IEs allocated by csrMatchBSS is needed
11189 if( !pResult->Result.pvIes )
11190 {
11191 //need to free the IEs since it is allocated by csrMatchBSS
11192 palFreeMemory(pMac->hHdd, pIes);
11193 }
11194 if(fMatch)
11195 {
11196 //We found the one
11197 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11198 {
11199 //Free the memory
11200 csrFreeScanResultEntry( pMac, pResult );
11201 }
11202 break;
11203 }
11204 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11205 }//while
11206 csrLLUnlock(&pMac->scan.scanResultList);
11207 }while(0);
11208 if(pScanFilter)
11209 {
11210 csrFreeScanFilter(pMac, pScanFilter);
11211 palFreeMemory(pMac->hHdd, pScanFilter);
11212 }
11213 }
11214 return (status);
11215}
11216
Jeff Johnson295189b2012-06-20 16:38:30 -070011217//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011218eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11219{
11220 eHalStatus status = eHAL_STATUS_SUCCESS;
11221 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11223 {
11224 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11225 {
11226 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11227 {
11228 //co-exist with IBSS or BT-AMP is not supported
11229 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d\n", sessionId );
11230 status = eHAL_STATUS_CSR_WRONG_STATE;
11231 break;
11232 }
11233 if( csrIsConnStateInfra( pMac, sessionId ) )
11234 {
11235 if( chnId &&
11236 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11237 {
11238 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)\n",
11239 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11240 status = eHAL_STATUS_CSR_WRONG_STATE;
11241 break;
11242 }
11243 }
11244 }
11245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 return ( status );
11247}
11248
Jeff Johnson295189b2012-06-20 16:38:30 -070011249static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11250{
11251 eHalStatus status = eHAL_STATUS_SUCCESS;
11252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11253 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011254
11255 if(!pSession)
11256 {
11257 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11258 return eHAL_STATUS_FAILURE;
11259 }
11260
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 if ( csrIsConnStateIbss( pMac, sessionId ) )
11262 {
11263 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11264 }
11265 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11266 {
11267 // Disassociate from the connected Infrastructure network...
11268 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11269 }
11270 else
11271 {
11272#if defined(VOSS_ENABLED)
11273 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11274 //Otherwise we need to add code to handle the
11275 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11276 //send stop_bss to PE, before we can continue.
11277 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
11278#endif
11279 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11280 /* Assume HDD provide bssid in profile */
11281 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11282 // there is no Bss description before we start an WDS so we need
11283 // to adopt all Bss configuration parameters from the Profile.
11284 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11285 if(HAL_STATUS_SUCCESS(status))
11286 {
11287 //Save profile for late use
11288 csrFreeRoamProfile( pMac, sessionId );
11289 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11290 (void **)&pSession->pCurRoamProfile,
11291 sizeof(tCsrRoamProfile))))
11292 {
11293 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11294 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011297 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011298 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11299 }
11300 }
11301
11302 return( status );
11303}
11304
Jeff Johnson295189b2012-06-20 16:38:30 -070011305////////////////////Mail box
11306
Jeff Johnson295189b2012-06-20 16:38:30 -070011307//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11308//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11309static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11310 tSirBssDescription *pBssDescription,
11311 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11312{
11313 tCsrChannelSet channelGroup;
11314 tSirMacCapabilityInfo *pAP_capabilityInfo;
11315 tAniBool fTmp;
11316 tANI_BOOLEAN found = FALSE;
11317 tANI_U32 size = 0;
Kirand170dcb2013-01-31 10:43:43 -080011318 tANI_S8 pwrLimit = 0;
11319 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11321 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11322 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11323 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 // 802.11h
11325 //We can do this because it is in HOST CPU order for now.
11326 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kirand170dcb2013-01-31 10:43:43 -080011327 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11328 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11329 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 fTmp = (tAniBool)pal_cpu_to_be32(1);
11331 }
11332 else
11333 fTmp = (tAniBool)0;
11334
11335 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11336 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11337 pBuf += sizeof(tAniBool);
11338 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kirand170dcb2013-01-31 10:43:43 -080011339 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 // This is required for 11k test VoWiFi Ent: Test 2.
11341 // We need the power capabilities for Assoc Req.
11342 // This macro is provided by the halPhyCfg.h. We pick our
11343 // max and min capability by the halPhy provided macros
Kirand170dcb2013-01-31 10:43:43 -080011344 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11345 if (0 != pwrLimit)
11346 {
11347 *pBuf++ = pwrLimit;
11348 }
11349 else
11350 {
11351 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011353 size = sizeof(pMac->roam.validChannelList);
11354 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11355 {
11356 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11357 for ( i = 0; i < size; i++)
11358 {
11359 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11360
11361 }
11362 }
11363 else
11364 {
11365 smsLog(pMac, LOGE, FL("can not find any valid channel\n"));
11366 *pBuf++ = 0; //tSirSupChnl->numChnl
11367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 //Check whether it is ok to enter UAPSD
11369#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11370 if( btcIsReadyForUapsd(pMac) )
11371#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11372 {
11373 *pBuf++ = uapsdMask;
11374 }
11375#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11376 else
11377 {
11378 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)\n"), uapsdMask);
11379 *pBuf++ = 0;
11380 }
11381#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11382
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 // move the entire BssDescription into the join request.
11384 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11385 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11387}
11388
Jeff Johnson295189b2012-06-20 16:38:30 -070011389/*
11390 * The communication between HDD and LIM is thru mailbox (MB).
11391 * Both sides will access the data structure "tSirSmeJoinReq".
11392 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11393 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11394 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11395 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11396 */
11397eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011398 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011399{
11400 eHalStatus status = eHAL_STATUS_SUCCESS;
11401 tSirSmeJoinReq *pMsg;
11402 tANI_U8 *pBuf;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011403 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 tANI_U16 msgLen, wTmp, ieLen;
11405 tSirMacRateSet OpRateSet;
11406 tSirMacRateSet ExRateSet;
11407 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11408 tANI_U32 dwTmp;
11409 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011410
11411 if(!pSession)
11412 {
11413 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11414 return eHAL_STATUS_FAILURE;
11415 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011416 /* To satisfy klockworks */
11417 if (NULL == pBssDescription)
11418 {
11419 smsLog(pMac, LOGE, FL(" pBssDescription is NULL\n"));
11420 return eHAL_STATUS_FAILURE;
11421 }
11422
Jeff Johnson295189b2012-06-20 16:38:30 -070011423 do {
11424 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11425 pSession->joinFailStatusCode.reasonCode = 0;
11426 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11427 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11428 // IE fields, but the length field in the bssDescription needs to be interpreted to
11429 // determine length of the IE fields.
11430 //
11431 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11432 // add in the length from the bssDescription (then add the size of the 'length' field
11433 // itself because that is NOT included in the length field).
11434 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11435 pBssDescription->length + sizeof( pBssDescription->length ) +
11436 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 -070011437 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11438 if ( !HAL_STATUS_SUCCESS(status) ) break;
11439 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011440 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011441 pMsg->length = pal_cpu_to_be16(msgLen);
11442 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011443 // sessionId
11444 *pBuf = (tANI_U8)sessionId;
11445 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 // transactionId
11447 *pBuf = 0;
11448 *( pBuf + 1 ) = 0;
11449 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 // ssId
11451 if( pIes->SSID.present && pIes->SSID.num_ssid )
11452 {
11453 // ssId len
11454 *pBuf = pIes->SSID.num_ssid;
11455 pBuf++;
11456 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11457 pBuf += pIes->SSID.num_ssid;
11458 }
11459 else
11460 {
11461 *pBuf = 0;
11462 pBuf++;
11463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 // selfMacAddr
11465 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11466 pBuf += sizeof(tSirMacAddr);
11467 // bsstype
11468 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11469 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11470 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11471 pBuf += sizeof(tSirBssType);
11472 // dot11mode
11473 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11474 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 //Persona
11476 *pBuf = (tANI_U8)pProfile->csrPersona;
11477 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011478 //CBMode
11479 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11480 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011481
11482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011483 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11484
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 // uapsdPerAcBitmask
11486 *pBuf = pProfile->uapsd_mask;
11487 pBuf++;
11488
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011489
11490
11491#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
Jeff Johnson295189b2012-06-20 16:38:30 -070011492#endif /*(WNI_POLARIS_FW_PACKAGE == ADVANCED)*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011494 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 {
11496 // OperationalRateSet
11497 if (OpRateSet.numRates) {
11498 *pBuf++ = OpRateSet.numRates;
11499 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11500 pBuf += OpRateSet.numRates;
11501 } else *pBuf++ = 0;
11502 // ExtendedRateSet
11503 if (ExRateSet.numRates) {
11504 *pBuf++ = ExRateSet.numRates;
11505 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11506 pBuf += ExRateSet.numRates;
11507 } else *pBuf++ = 0;
11508 }
11509 else
11510 {
11511 *pBuf++ = 0;
11512 *pBuf++ = 0;
11513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 // rsnIE
11515 if ( csrIsProfileWpa( pProfile ) )
11516 {
11517 // Insert the Wpa IE into the join request
11518 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11519 (tCsrWpaIe *)( wpaRsnIE ) );
11520 }
11521 else if( csrIsProfileRSN( pProfile ) )
11522 {
11523 // Insert the RSN IE into the join request
11524 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11525 (tCsrRSNIe *)( wpaRsnIE ) );
11526 }
11527#ifdef FEATURE_WLAN_WAPI
11528 else if( csrIsProfileWapi( pProfile ) )
11529 {
11530 // Insert the WAPI IE into the join request
11531 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11532 (tCsrWapiIe *)( wpaRsnIE ) );
11533 }
11534#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 else
11536 {
11537 ieLen = 0;
11538 }
11539 //remember the IE for future use
11540 if( ieLen )
11541 {
11542 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11543 {
11544 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d\n"), ieLen, DOT11F_IE_RSN_MAX_LEN);
11545 ieLen = DOT11F_IE_RSN_MAX_LEN;
11546 }
11547#ifdef FEATURE_WLAN_WAPI
11548 if( csrIsProfileWapi( pProfile ) )
11549 {
11550 //Check whether we need to allocate more memory
11551 if(ieLen > pSession->nWapiReqIeLength)
11552 {
11553 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11554 {
11555 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11556 }
11557 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11558 if(!HAL_STATUS_SUCCESS(status)) break;
11559 }
11560 pSession->nWapiReqIeLength = ieLen;
11561 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11562 wTmp = pal_cpu_to_be16( ieLen );
11563 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11564 pBuf += sizeof(tANI_U16);
11565 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11566 pBuf += ieLen;
11567 }
11568 else//should be WPA/WPA2 otherwise
11569#endif /* FEATURE_WLAN_WAPI */
11570 {
11571 //Check whether we need to allocate more memory
11572 if(ieLen > pSession->nWpaRsnReqIeLength)
11573 {
11574 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11575 {
11576 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11577 }
11578 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11579 if(!HAL_STATUS_SUCCESS(status)) break;
11580 }
11581 pSession->nWpaRsnReqIeLength = ieLen;
11582 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11583 wTmp = pal_cpu_to_be16( ieLen );
11584 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11585 pBuf += sizeof(tANI_U16);
11586 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11587 pBuf += ieLen;
11588 }
11589 }
11590 else
11591 {
11592 //free whatever old info
11593 pSession->nWpaRsnReqIeLength = 0;
11594 if(pSession->pWpaRsnReqIE)
11595 {
11596 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11597 pSession->pWpaRsnReqIE = NULL;
11598 }
11599#ifdef FEATURE_WLAN_WAPI
11600 pSession->nWapiReqIeLength = 0;
11601 if(pSession->pWapiReqIE)
11602 {
11603 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11604 pSession->pWapiReqIE = NULL;
11605 }
11606#endif /* FEATURE_WLAN_WAPI */
11607 //length is two bytes
11608 *pBuf = 0;
11609 *(pBuf + 1) = 0;
11610 pBuf += 2;
11611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011612#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011613 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011615 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 //length is two bytes
11617 *pBuf = 0;
11618 *(pBuf + 1) = 0;
11619 pBuf += 2;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011620 }
11621 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011622 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011623 // cckmIE
11624 if( csrIsProfileCCX( pProfile ) )
11625 {
11626 // Insert the CCKM IE into the join request
11627 ieLen = csrConstructCcxCckmIe( pMac,
11628 pSession,
11629 pProfile,
11630 pBssDescription,
11631 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 pSession->nWpaRsnReqIeLength,
11633 (void *)( wpaRsnIE ) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011634 }
11635 else
11636 {
11637 ieLen = 0;
11638 }
11639 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11640 if( ieLen )
11641 {
11642 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11643 wTmp = pal_cpu_to_be16( ieLen );
11644 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11645 pBuf += sizeof(tANI_U16);
11646 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11647 pBuf += ieLen;
11648 }
11649 else
11650 {
11651 //Indicate you have no CCKM IE
11652 //length is two bytes
11653 *pBuf = 0;
11654 *(pBuf + 1) = 0;
11655 pBuf += 2;
11656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 }
11658#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011659 // addIEScan
11660 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11661 {
11662 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011663 if(ieLen > pSession->nAddIEScanLength)
11664 {
11665 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11666 {
11667 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11668 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011669 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 (void **)&pSession->pAddIEScan, ieLen);
11671 if(!HAL_STATUS_SUCCESS(status)) break;
11672 }
11673 pSession->nAddIEScanLength = ieLen;
11674 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11675 pProfile->pAddIEScan, ieLen);
11676 wTmp = pal_cpu_to_be16( ieLen );
11677 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11678 pBuf += sizeof(tANI_U16);
11679 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11680 pBuf += ieLen;
11681 }
11682 else
11683 {
11684 pSession->nAddIEScanLength = 0;
11685 if(pSession->pAddIEScan)
11686 {
11687 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11688 pSession->pAddIEScan = NULL;
11689 }
11690 *pBuf = 0;
11691 *(pBuf + 1) = 0;
11692 pBuf += 2;
11693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 // addIEAssoc
11695 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11696 {
11697 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 if(ieLen > pSession->nAddIEAssocLength)
11699 {
11700 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11701 {
11702 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11703 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011704 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 (void **)&pSession->pAddIEAssoc, ieLen);
11706 if(!HAL_STATUS_SUCCESS(status)) break;
11707 }
11708 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011709 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 pProfile->pAddIEAssoc, ieLen);
11711 wTmp = pal_cpu_to_be16( ieLen );
11712 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11713 pBuf += sizeof(tANI_U16);
11714 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11715 pBuf += ieLen;
11716 }
11717 else
11718 {
11719 pSession->nAddIEAssocLength = 0;
11720 if(pSession->pAddIEAssoc)
11721 {
11722 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11723 pSession->pAddIEAssoc = NULL;
11724 }
11725 *pBuf = 0;
11726 *(pBuf + 1) = 0;
11727 pBuf += 2;
11728 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011729
11730 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011731 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011732 //Unmask any AC in reassoc that is ACM-set
11733 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11734 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011735 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011736 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11737 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011738#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011739 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011740#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011741 uapsd_mask &= ~(acm_mask);
11742 }
11743 else
11744 {
11745 uapsd_mask = 0;
11746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 }
11748 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011749
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11751 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011752 pBuf += sizeof(tANI_U32);
11753
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11755 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011756 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011757#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011758 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
11759 if (csrIsProfile11r( pProfile ) )
11760 {
11761 // is11Rconnection;
11762 dwTmp = pal_cpu_to_be32(TRUE);
11763 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11764 pBuf += sizeof(tAniBool);
11765 }
11766 else
11767 {
11768 // is11Rconnection;
11769 dwTmp = pal_cpu_to_be32(FALSE);
11770 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11771 pBuf += sizeof(tAniBool);
11772 }
11773#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011774#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011775 /* A profile can not be both CCX and 11R. But an 802.11R AP
11776 * may be advertising support for CCX as well. So if we are
11777 * associating Open or explicitly CCX then we will get CCX.
11778 * If we are associating explictly 11R only then we will get
11779 * 11R.
11780 */
11781 if ((csrIsProfileCCX(pProfile) ||
11782 ((pIes->CCXVersion.present)
11783 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011784 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11785 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11786 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011787 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11788 && (!(csrIsProfile11r( pProfile )))
11789 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11790 {
11791 // isCCXconnection;
11792 dwTmp = pal_cpu_to_be32(TRUE);
11793 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11794 pBuf += sizeof(tAniBool);
11795 }
11796 else
11797 {
11798 //isCCXconnection;
11799 dwTmp = pal_cpu_to_be32(FALSE);
11800 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11801 pBuf += sizeof(tAniBool);
11802 }
11803
11804 if (eWNI_SME_JOIN_REQ == messageType)
11805 {
11806 tCCXTspecInfo ccxTspec;
11807 // CCX-Tspec IEs in the ASSOC request is presently not supported
11808 // so nullify the TSPEC parameters
11809 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11810 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11811 pBuf += sizeof(tCCXTspecInfo);
11812 }
11813 else if (eWNI_SME_REASSOC_REQ == messageType)
11814 {
11815 if ((csrIsProfileCCX(pProfile) ||
11816 ((pIes->CCXVersion.present)
11817 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011818 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11819 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11820 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011821 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11822 && (!(csrIsProfile11r( pProfile )))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011823 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 {
11825 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 // CCX Tspec information
11827 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11828 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11829 *pBuf = ccxTspec.numTspecs;
11830 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 // Copy the TSPEC information only if present
11832 if (ccxTspec.numTspecs) {
11833 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11834 }
11835 pBuf += sizeof(ccxTspec.tspec);
11836 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011837 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 tCCXTspecInfo ccxTspec;
11840 // CCX-Tspec IEs in the ASSOC request is presently not supported
11841 // so nullify the TSPEC parameters
11842 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11843 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11844 pBuf += sizeof(tCCXTspecInfo);
11845 }
11846 }
11847#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011848#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011850 if (pMac->roam.configParam.isFastTransitionEnabled
11851#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011852 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011853#endif
11854 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011856 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011858 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 }
11860 else
11861 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011862 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011864 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 }
11866#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070011867#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011868 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070011869 {
11870 //legacy fast roaming enabled
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011871 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011872 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011873 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011874 }
11875 else
11876 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011877 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011878 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011879 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011880 }
11881#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011882
11883 // txLdpcIniFeatureEnabled
11884 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
11885 pBuf++;
11886
Kirand170dcb2013-01-31 10:43:43 -080011887 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
11888 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
11889 {
11890 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
11891 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
11892 csrApplyPower2Current(pMac);
11893 }
11894
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -080011895#ifdef WLAN_FEATURE_11AC
Kirand170dcb2013-01-31 10:43:43 -080011896 // txBFIniFeatureEnabled
11897 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
11898 pBuf++;
Shailender Karmuchi95934c32013-02-16 18:18:33 -080011899
11900 // txBFCsnValue
11901 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
11902 pBuf++;
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -080011903#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011904 //BssDesc
11905 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
11906 (tANI_U8)pProfile->uapsd_mask);
11907 status = palSendMBMessage(pMac->hHdd, pMsg );
11908 if(!HAL_STATUS_SUCCESS(status))
11909 {
11910 break;
11911 }
11912 else
11913 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011914#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011915 if (eWNI_SME_JOIN_REQ == messageType)
11916 {
11917 //Tush-QoS: notify QoS module that join happening
11918 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
11919 }
11920 else if (eWNI_SME_REASSOC_REQ == messageType)
11921 {
11922 //Tush-QoS: notify QoS module that reassoc happening
11923 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
11924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011925#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070011929}
11930
Jeff Johnson295189b2012-06-20 16:38:30 -070011931//
11932eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
11933{
11934 eHalStatus status = eHAL_STATUS_SUCCESS;
11935 tSirSmeDisassocReq *pMsg;
11936 tANI_U8 *pBuf;
11937 tANI_U16 wTmp;
11938#ifdef WLAN_SOFTAP_FEATURE
11939 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11940 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
11941 return eHAL_STATUS_FAILURE;
11942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 do {
11944 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
11945 if ( !HAL_STATUS_SUCCESS(status) ) break;
11946 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
11947 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
11948 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 pBuf = &pMsg->sessionId;
11950 // sessionId
11951 *pBuf++ = (tANI_U8)sessionId;
11952 // transactionId
11953 *pBuf = 0;
11954 *( pBuf + 1 ) = 0;
11955 pBuf += sizeof(tANI_U16);
11956
11957#ifdef WLAN_SOFTAP_FEATURE
11958 if ( (pSession->pCurRoamProfile != NULL ) &&
11959 ( reasonCode == eSIR_MAC_UNSPEC_FAILURE_REASON ) &&
11960 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) || (CSR_IS_WDS_AP(pSession->pCurRoamProfile))))
11961 {
11962 // Set the bssid address before sending the message to LIM
11963 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
11964 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 // Set the peer MAC address before sending the message to LIM
11966 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
11967 pBuf = pBuf + sizeof ( tSirMacAddr );
11968 }
11969 else
11970 {
11971#endif
11972 // Set the peer MAC address before sending the message to LIM
11973 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
11974 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
11976 pBuf = pBuf + sizeof ( tSirMacAddr );
11977#ifdef WLAN_SOFTAP_FEATURE
11978 }
11979#endif
11980 if(!HAL_STATUS_SUCCESS(status))
11981 {
11982 palFreeMemory(pMac->hHdd, pMsg);
11983 break;
11984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 // reasonCode
11986 wTmp = pal_cpu_to_be16(reasonCode);
11987 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11988 if(!HAL_STATUS_SUCCESS(status))
11989 {
11990 palFreeMemory(pMac->hHdd, pMsg);
11991 break;
11992 }
11993 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
11995 Here we should not send the disassoc over the air to the AP */
11996 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
11997#ifdef WLAN_FEATURE_VOWIFI_11R
11998 && csrRoamIs11rAssoc(pMac)
11999#endif
12000 )
12001 {
12002 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12003 }
12004 pBuf += sizeof(tANI_U8);
12005 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012006 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 return( status );
12008}
Jeff Johnson295189b2012-06-20 16:38:30 -070012009#ifdef WLAN_SOFTAP_FEATURE
12010eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12011{
12012 eHalStatus status = eHAL_STATUS_SUCCESS;
12013 tSirSmeTkipCntrMeasReq *pMsg;
12014 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 do
12016 {
12017 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12018 if ( !HAL_STATUS_SUCCESS(status) ) break;
12019 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12020 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12021 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012022 pBuf = &pMsg->sessionId;
12023 // sessionId
12024 *pBuf++ = (tANI_U8)sessionId;
12025 // transactionId
12026 *pBuf = 0;
12027 *( pBuf + 1 ) = 0;
12028 pBuf += sizeof(tANI_U16);
12029 // bssid
12030 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12031 pBuf = pBuf + sizeof ( tSirMacAddr );
12032 // bEnable
12033 *pBuf = (tANI_BOOLEAN)bEnable;
12034 if(!HAL_STATUS_SUCCESS(status))
12035 {
12036 palFreeMemory(pMac->hHdd, pMsg);
12037 break;
12038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012041 return( status );
12042}
Jeff Johnson295189b2012-06-20 16:38:30 -070012043eHalStatus
12044csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12045 VOS_MODULE_ID modId, tSirMacAddr bssId,
12046 void *pUsrContext, void *pfnSapEventCallback,
12047 tANI_U8 *pAssocStasBuf )
12048{
12049 eHalStatus status = eHAL_STATUS_SUCCESS;
12050 tSirSmeGetAssocSTAsReq *pMsg;
12051 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12052 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 do
12054 {
12055 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12056 if (!HAL_STATUS_SUCCESS(status)) break;
12057 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12058 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012059 pBuf = (tANI_U8 *)&pMsg->bssId;
12060 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 // bssId
12062 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12063 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 // modId
12065 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12066 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12067 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 // pUsrContext
12069 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12070 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12071 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 // pfnSapEventCallback
12073 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12074 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12075 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 // pAssocStasBuf
12077 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12078 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12079 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012081 status = palSendMBMessage( pMac->hHdd, pMsg );
12082 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012083 return( status );
12084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012085eHalStatus
12086csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12087 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12088 {
12089 eHalStatus status = eHAL_STATUS_SUCCESS;
12090 tSirSmeGetWPSPBCSessionsReq *pMsg;
12091 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12092 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 do
12094 {
12095 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12096 if (!HAL_STATUS_SUCCESS(status)) break;
12097 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12098 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12100 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 // pUsrContext
12102 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12103 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12104 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012105 // pSapEventCallback
12106 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12107 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12108 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 // bssId
12110 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12111 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 // MAC Address of STA in WPS session
12113 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12114 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012117 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 return( status );
12119}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012120
12121eHalStatus
12122csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12123{
12124 tpSirChangeBIParams pMsg;
12125 tANI_U16 len = 0;
12126 eHalStatus status = eHAL_STATUS_SUCCESS;
12127 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12128
12129 if(!pSession)
12130 {
12131 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12132 return eHAL_STATUS_FAILURE;
12133 }
12134
12135 //NO need to update the Beacon Params if update beacon parameter flag is not set
12136 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12137 return eHAL_STATUS_SUCCESS;
12138
12139 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12140
12141 /* Create the message and send to lim */
12142 len = sizeof(tSirChangeBIParams);
12143 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12144 if(HAL_STATUS_SUCCESS(status))
12145 {
12146 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12147 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12148 pMsg->length = len;
12149
12150 // bssId
12151 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
12152 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
12153 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12154 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12155 pMsg->sessionId = sessionId;
12156 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d\n"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
12157 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12158 status = palSendMBMessage(pMac->hHdd, pMsg);
12159 }
12160 return status;
12161}
12162
Jeff Johnson295189b2012-06-20 16:38:30 -070012163#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012164eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12165{
12166 eHalStatus status = eHAL_STATUS_SUCCESS;
12167 tSirSmeDeauthReq *pMsg;
12168 tANI_U8 *pBuf;
12169 tANI_U16 wTmp;
12170 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12171 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12172 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 do {
12174 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12175 if ( !HAL_STATUS_SUCCESS(status) ) break;
12176 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12177 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12178 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12179 //sessionId
12180 pBuf = &pMsg->sessionId;
12181 *pBuf++ = (tANI_U8)sessionId;
12182
12183 //tansactionId
12184 *pBuf = 0;
12185 *(pBuf + 1 ) = 0;
12186 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 if ((pSession->pCurRoamProfile != NULL) && (
12188#ifdef WLAN_SOFTAP_FEATURE
12189 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12190#endif
12191 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12192 // Set the BSSID before sending the message to LIM
12193 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12194 pBuf = pBuf + sizeof(tSirMacAddr);
12195 }
12196 else
12197 {
12198 // Set the BSSID before sending the message to LIM
12199 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12200 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 }
12202 if(!HAL_STATUS_SUCCESS(status))
12203 {
12204 palFreeMemory(pMac->hHdd, pMsg);
12205 break;
12206 }
12207 // Set the peer MAC address before sending the message to LIM
12208 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12209 pBuf = pBuf + sizeof(tSirMacAddr);
12210 if(!HAL_STATUS_SUCCESS(status))
12211 {
12212 palFreeMemory(pMac->hHdd, pMsg);
12213 break;
12214 }
12215 wTmp = pal_cpu_to_be16(reasonCode);
12216 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12217 if(!HAL_STATUS_SUCCESS(status))
12218 {
12219 palFreeMemory(pMac->hHdd, pMsg);
12220 break;
12221 }
12222 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 return( status );
12225}
12226
Jeff Johnson295189b2012-06-20 16:38:30 -070012227eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12228{
12229 eHalStatus status = eHAL_STATUS_SUCCESS;
12230 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 do {
12232 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12233 if ( !HAL_STATUS_SUCCESS(status) ) break;
12234 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12235 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12236 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12237 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12238 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12239 if(!HAL_STATUS_SUCCESS(status))
12240 {
12241 palFreeMemory(pMac->hHdd, pMsg);
12242 break;
12243 }
12244//To test reconn
12245 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12246 if(!HAL_STATUS_SUCCESS(status))
12247 {
12248 palFreeMemory(pMac->hHdd, pMsg);
12249 break;
12250 }
12251//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012252 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012253 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 return( status );
12255}
12256
Jeff Johnson295189b2012-06-20 16:38:30 -070012257eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12258{
12259 eHalStatus status = eHAL_STATUS_SUCCESS;
12260 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 do {
12262 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12263 if ( !HAL_STATUS_SUCCESS(status) ) break;
12264 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12265 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12266 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12267 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12268 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12269 if(!HAL_STATUS_SUCCESS(status))
12270 {
12271 palFreeMemory(pMac->hHdd, pMsg);
12272 break;
12273 }
12274 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12275 if(!HAL_STATUS_SUCCESS(status))
12276 {
12277 palFreeMemory(pMac->hHdd, pMsg);
12278 break;
12279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012281 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012282 return( status );
12283}
Jeff Johnson295189b2012-06-20 16:38:30 -070012284eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12285{
12286 eHalStatus status = eHAL_STATUS_SUCCESS;
12287 tSirSmeAssocCnf *pMsg;
12288 tANI_U8 *pBuf;
12289 tSirResultCodes statusCode;
12290 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 do {
12292 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12293 if ( !HAL_STATUS_SUCCESS(status) ) break;
12294 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12295 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12296 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 pBuf = (tANI_U8 *)&pMsg->statusCode;
12298 if(HAL_STATUS_SUCCESS(Halstatus))
12299 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12300 else
12301 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12302 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12303 pBuf += sizeof(tSirResultCodes);
12304 // bssId
12305 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12306 pBuf += sizeof (tSirMacAddr);
12307 // peerMacAddr
12308 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12309 pBuf += sizeof (tSirMacAddr);
12310 // aid
12311 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12312 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12313 pBuf += sizeof (tANI_U16);
12314 // alternateBssId
12315 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12316 pBuf += sizeof (tSirMacAddr);
12317 // alternateChannelId
12318 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012319 status = palSendMBMessage( pMac->hHdd, pMsg );
12320 if(!HAL_STATUS_SUCCESS(status))
12321 {
12322 //pMsg is freed by palSendMBMessage
12323 break;
12324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 return( status );
12327}
Jeff Johnson295189b2012-06-20 16:38:30 -070012328#ifdef WLAN_SOFTAP_FEATURE
12329eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12330 tpSirSmeAssocInd pAssocInd,
12331 eHalStatus Halstatus,
12332 tANI_U8 sessionId)
12333{
12334 tSirMsgQ msgQ;
12335 eHalStatus status = eHAL_STATUS_SUCCESS;
12336 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12337 tANI_U8 *pBuf;
12338 tSirResultCodes statusCode;
12339 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 do {
12341 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12342 if ( !HAL_STATUS_SUCCESS(status) ) break;
12343 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012344
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12346 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12347
12348 pMsg->sessionId = sessionId;
12349
12350 pBuf = (tANI_U8 *)&pMsg->statusCode;
12351 if(HAL_STATUS_SUCCESS(Halstatus))
12352 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12353 else
12354 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12355 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12356 pBuf += sizeof(tSirResultCodes);
12357 // bssId
12358 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12359 pBuf += sizeof (tSirMacAddr);
12360 // peerMacAddr
12361 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12362 pBuf += sizeof (tSirMacAddr);
12363 // StaId
12364 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12365 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12366 pBuf += sizeof (tANI_U16);
12367 // alternateBssId
12368 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12369 pBuf += sizeof (tSirMacAddr);
12370 // alternateChannelId
12371 *pBuf = 11;
12372 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12374 //Wmm
12375 *pBuf = pAssocInd->wmmEnabledSta;
12376 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 //RSN IE
12378 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12379 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 //Additional IE
12381 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12382 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 //reassocReq
12384 *pBuf = pAssocInd->reassocReq;
12385 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12387 msgQ.bodyptr = pMsg;
12388 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012389 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 return( status );
12392}
12393#endif
12394
Jeff Johnson295189b2012-06-20 16:38:30 -070012395eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12396 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12397 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12398 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12399 tANI_U8 *pKeyRsc )
12400{
12401 tSirSmeSetContextReq *pMsg;
12402 tANI_U16 msgLen;
12403 eHalStatus status = eHAL_STATUS_FAILURE;
12404 tAniEdType tmpEdType;
12405 tAniKeyDirection tmpDirection;
12406 tANI_U8 *pBuf;
12407 tANI_U8 *p;
12408 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012411 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12412 // key set. Since we only support upto one key, we always allocate memory for 1 key
12413 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12414 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12415 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12416 ( sizeof( pMsg->keyMaterial.key ) );
12417
12418 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12419 if ( !HAL_STATUS_SUCCESS(status) ) break;
12420 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12421 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12422 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 //sessionId
12424 pBuf = &pMsg->sessionId;
12425 *pBuf = (tANI_U8)sessionId;
12426 pBuf++;
12427 // transactionId
12428 *pBuf = 0;
12429 *(pBuf + 1) = 0;
12430 pBuf += sizeof(tANI_U16);
12431 // peerMacAddr
12432 palCopyMemory( pMac->hHdd, pBuf,
12433 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12434
12435 pBuf += sizeof(tSirMacAddr);
12436
12437 // bssId
12438 palCopyMemory( pMac->hHdd, pBuf,
12439 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12440
12441 pBuf += sizeof(tSirMacAddr);
12442
12443 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12445 // in the tSirKeyMaterial keyMaterial; field).
12446 //
12447 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12448 // shorter than this max size. Is LIM interpreting this ok ?
12449 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 -070012450 // set pMsg->keyMaterial.edType
12451 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12452 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12453 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 // set the pMsg->keyMaterial.numKeys field
12455 *p = numKeys;
12456 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 // set pSirKey->keyId = keyId;
12458 *p = keyId;
12459 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 // set pSirKey->unicast = (tANI_U8)fUnicast;
12461 *p = (tANI_U8)fUnicast;
12462 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 // set pSirKey->keyDirection = aniKeyDirection;
12464 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12465 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12466 p += sizeof(tAniKeyDirection);
12467 // pSirKey->keyRsc = ;;
12468 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12469 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 // set pSirKey->paeRole
12471 *p = paeRole; // 0 is Supplicant
12472 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 // set pSirKey->keyLength = keyLength;
12474 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 if ( keyLength && pKey )
12476 {
12477 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12478 if(keyLength == 16)
12479 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012480 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\n",
Jeff Johnson295189b2012-06-20 16:38:30 -070012481 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12482 pKey[5], pKey[6], pKey[7], pKey[8],
12483 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12484 }
12485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 return( status );
12489}
12490
Jeff Johnson295189b2012-06-20 16:38:30 -070012491eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12492 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12493{
12494 eHalStatus status;
12495 tSirSmeStartBssReq *pMsg;
12496 tANI_U8 *pBuf = NULL;
12497 tANI_U8 *wTmpBuf = NULL;
12498 tANI_U16 msgLen, wTmp;
12499 tANI_U32 dwTmp;
12500 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012501 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012502#ifdef WLAN_SOFTAP_FEATURE
12503 tANI_U32 authType;
12504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012506
12507 if(!pSession)
12508 {
12509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12510 return eHAL_STATUS_FAILURE;
12511 }
12512
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 do {
12514 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12515 pSession->joinFailStatusCode.reasonCode = 0;
12516 msgLen = sizeof(tSirSmeStartBssReq);
12517 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12518 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12520 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 //sessionId
12524 *pBuf = (tANI_U8)sessionId;
12525 pBuf++;
12526 // transactionId
12527 *pBuf = 0;
12528 *(pBuf + 1) = 0;
12529 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 // bssid
12531 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12532 pBuf += sizeof(tSirMacAddr);
12533 // selfMacAddr
12534 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12535 pBuf += sizeof(tSirMacAddr);
12536 // beaconInterval
12537 if( pBssDesc && pBssDesc->beaconInterval )
12538 {
12539 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12540 }
12541#ifdef WLAN_SOFTAP_FEATURE
12542 else if(pParam->beaconInterval)
12543 {
12544 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12545 }
12546#endif
12547 else
12548 {
12549 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12550 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012551 if(csrIsconcurrentsessionValid (pMac, sessionId,
12552 pParam->bssPersona)
12553 == eHAL_STATUS_SUCCESS )
12554 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012555 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012556 pParam->bssPersona);
12557 //Update the beacon Interval
12558 pParam->beaconInterval = wTmp;
12559 }
12560 else
12561 {
12562 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***\n"));
12563 status = eHAL_STATUS_FAILURE;
12564 return status;
12565 }
12566
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12568 pBuf += sizeof(tANI_U16);
12569 // dot11mode
12570 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12571 pBuf += 1;
12572 // bssType
12573 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12574 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12575 pBuf += sizeof(tSirBssType);
12576 // ssId
12577 if( pParam->ssId.length )
12578 {
12579 // ssId len
12580 *pBuf = pParam->ssId.length;
12581 pBuf++;
12582 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12583 pBuf += pParam->ssId.length;
12584 }
12585 else
12586 {
12587 *pBuf = 0;
12588 pBuf++;
12589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 // set the channel Id
12591 *pBuf = pParam->operationChn;
12592 pBuf++;
12593 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012594 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12595 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12596 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012597
12598#ifdef WLAN_SOFTAP_FEATURE
12599 // Set privacy
12600 *pBuf = pParam->privacy;
12601 pBuf++;
12602
12603 //Set Uapsd
12604 *pBuf = pParam->ApUapsdEnable;
12605 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 //Set SSID hidden
12607 *pBuf = pParam->ssidHidden;
12608 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12610 pBuf++;
12611
12612 //Ht protection Enable/Disable
12613 *pBuf = (tANI_U8)pParam->protEnabled;
12614 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 //Enable Beacons to Receive for OBSS protection Enable/Disable
12616 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12617 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 //set cfg related to protection
12619 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12620 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12621 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012622 // Set Auth type
12623 authType = pal_cpu_to_be32(pParam->authType);
12624 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12625 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 // Set DTIM
12627 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12628 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12629 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 // Set wps_state
12631 *pBuf = pParam->wps_state;
12632 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012633#endif
12634 //Persona
12635 *pBuf = (tANI_U8)pParam->bssPersona;
12636 pBuf++;
12637
Gopichand Nakkalab7ed0a62013-01-04 11:41:02 -080012638 //txLdpcIniFeatureEnabled
12639 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12640 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012641
Jeff Johnson295189b2012-06-20 16:38:30 -070012642
12643 // set RSN IE
12644 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12645 {
12646 status = eHAL_STATUS_INVALID_PARAMETER;
12647 palFreeMemory( pMac->hHdd, pMsg );
12648 break;
12649 }
12650 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12651 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12652 pBuf += sizeof(tANI_U16);
12653 if( wTmp )
12654 {
12655 wTmp = pParam->nRSNIELength;
12656 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12657 pBuf += wTmp;
12658 }
12659 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12660 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12661 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12663 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12665 pBuf += pParam->operationalRateSet.numRates ;
12666 *pBuf++ = pParam->extendedRateSet.numRates;
12667 if(0 != pParam->extendedRateSet.numRates)
12668 {
12669 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12670 pBuf += pParam->extendedRateSet.numRates;
12671 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12673 pMsg->length = pal_cpu_to_be16(msgLen);
12674
12675 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 return( status );
12678}
12679
Jeff Johnson295189b2012-06-20 16:38:30 -070012680eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12681{
12682 eHalStatus status = eHAL_STATUS_FAILURE;
12683 tSirSmeStopBssReq *pMsg;
12684 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12685 tANI_U8 *pBuf;
12686 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012687
12688 if(!pSession)
12689 {
12690 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12691 return eHAL_STATUS_FAILURE;
12692 }
12693
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 do {
12695 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12696 if ( !HAL_STATUS_SUCCESS(status) ) break;
12697 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12698 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12699 pBuf = &pMsg->sessionId;
12700 //sessionId
12701 *pBuf = (tANI_U8)sessionId;
12702 pBuf++;
12703 // transactionId
12704 *pBuf = 0;
12705 pBuf += sizeof(tANI_U16);
12706 //reason code
12707 *pBuf = 0;
12708 pBuf += sizeof(tSirResultCodes);
12709 // bssid
12710 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12711 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12712 {
12713 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12714 }
12715 else
12716 {
12717 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12718 }
12719 pBuf += sizeof(tSirMacAddr);
12720 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12721 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 status = palSendMBMessage( pMac->hHdd, pMsg );
12723#if 0
12724 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12725 if ( !HAL_STATUS_SUCCESS(status) ) break;
12726 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12727 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12728 pMsg->reasonCode = 0;
12729 // bssid
12730 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12731 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12732 {
12733 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12734 }
12735 else
12736 {
12737 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12738 }
12739 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12740 pMsg->transactionId = 0;
12741 pMsg->sessionId = (tANI_U8)sessionId;
12742 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12743 status = palSendMBMessage( pMac->hHdd, pMsg );
12744#endif
12745 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012746 return( status );
12747}
12748
Jeff Johnson295189b2012-06-20 16:38:30 -070012749eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12750 tCsrRoamModifyProfileFields *pModProfileFields,
12751 tANI_U32 *pRoamId, v_BOOL_t fForce)
12752{
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 eHalStatus status = eHAL_STATUS_FAILURE;
12754 tANI_U32 roamId = 0;
12755 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 if((csrIsConnStateConnected(pMac, sessionId)) &&
12757 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12758 &pSession->connectedProfile.modifyProfileFields,
12759 sizeof(tCsrRoamModifyProfileFields)))) )
12760 {
12761 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12762 if(pRoamId)
12763 {
12764 *pRoamId = roamId;
12765 }
12766
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12768 eCsrSmeIssuedReassocToSameAP, roamId,
12769 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 return status;
12772}
Jeff Johnson295189b2012-06-20 16:38:30 -070012773static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12774{
12775 eHalStatus status = eHAL_STATUS_SUCCESS;
12776 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12778 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12779 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12780 return (status);
12781}
Jeff Johnson295189b2012-06-20 16:38:30 -070012782eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12783{
12784 eHalStatus status = eHAL_STATUS_SUCCESS;
12785 tListElem *pEntry = NULL;
12786 tSmeCmd *pCommand = NULL;
12787 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 do
12789 {
12790 if(pMsg == NULL)
12791 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012792 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 status = eHAL_STATUS_FAILURE;
12794 break;
12795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12797 if(pEntry)
12798 {
12799 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12800 if(eSmeCommandAddStaSession == pCommand->command)
12801 {
12802 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
12803 smsLog( pMac, LOG1, "Add Sta rsp status = %d\n", pRsp->status );
12804 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012806 //Remove this command out of the active list
12807 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12808 {
12809 //Now put this command back on the avilable command list
12810 csrReleaseCommand(pMac, pCommand);
12811 }
12812 smeProcessPendingQueue( pMac );
12813 }
12814 else
12815 {
12816 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012817 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012818 status = eHAL_STATUS_FAILURE;
12819 break;
12820 }
12821 }
12822 else
12823 {
12824 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012825 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 status = eHAL_STATUS_FAILURE;
12827 break;
12828 }
12829 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012831}
Jeff Johnson295189b2012-06-20 16:38:30 -070012832eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12833{
12834 tSirSmeAddStaSelfReq *pMsg;
12835 tANI_U16 msgLen;
12836 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12839 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12841 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12844 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 // self station address
12846 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012847 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 pMsg->selfMacAddr[0],
12849 pMsg->selfMacAddr[1],
12850 pMsg->selfMacAddr[2],
12851 pMsg->selfMacAddr[3],
12852 pMsg->selfMacAddr[4],
12853 pMsg->selfMacAddr[5]);
12854 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 return( status );
12857}
Jeff Johnson295189b2012-06-20 16:38:30 -070012858eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12859{
12860 eHalStatus status = eHAL_STATUS_SUCCESS;
12861 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 pCommand = csrGetCommandBuffer(pMac);
12863 if(NULL == pCommand)
12864 {
12865 status = eHAL_STATUS_RESOURCES;
12866 }
12867 else
12868 {
12869 pCommand->command = eSmeCommandAddStaSession;
12870 pCommand->sessionId = (tANI_U8)sessionId;
12871 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12873 if( !HAL_STATUS_SUCCESS( status ) )
12874 {
12875 //Should be panic??
12876 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12877 }
12878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 return (status);
12880}
Jeff Johnson295189b2012-06-20 16:38:30 -070012881eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12882{
12883 return csrSendMBAddSelfStaReqMsg( pMac,
12884 pCommand->u.addStaSessionCmd.selfMacAddr );
12885}
Jeff Johnson295189b2012-06-20 16:38:30 -070012886eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12887 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12888{
12889 eHalStatus status = eHAL_STATUS_SUCCESS;
12890 tANI_U32 i;
12891 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 *pbSessionId = CSR_SESSION_ID_INVALID;
12893 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
12894 {
12895 if( !CSR_IS_SESSION_VALID( pMac, i ) )
12896 {
12897 pSession = CSR_GET_SESSION( pMac, i );
12898 status = eHAL_STATUS_SUCCESS;
12899 pSession->sessionActive = eANI_BOOLEAN_TRUE;
12900 pSession->sessionId = (tANI_U8)i;
12901 pSession->callback = callback;
12902 pSession->pContext = pContext;
12903 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
12904 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
12906 &pSession->roamingTimerInfo);
12907 if(!HAL_STATUS_SUCCESS(status))
12908 {
12909 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer\n"));
12910 break;
12911 }
12912#ifdef FEATURE_WLAN_BTAMP_UT_RF
12913 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
12914 &pSession->joinRetryTimerInfo);
12915 if(!HAL_STATUS_SUCCESS(status))
12916 {
12917 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer\n"));
12918 break;
12919 }
12920#endif
12921 pSession->ibssJoinTimerInfo.pMac = pMac;
12922 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
12924 &pSession->ibssJoinTimerInfo);
12925 if(!HAL_STATUS_SUCCESS(status))
12926 {
12927 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer\n"));
12928 break;
12929 }
12930 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
12931 break;
12932 }
12933 }
12934 if( CSR_ROAM_SESSION_MAX == i )
12935 {
12936 //No session is available
12937 status = eHAL_STATUS_RESOURCES;
12938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 return ( status );
12940}
Jeff Johnson295189b2012-06-20 16:38:30 -070012941eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12942{
12943 eHalStatus status = eHAL_STATUS_SUCCESS;
12944 tListElem *pEntry = NULL;
12945 tSmeCmd *pCommand = NULL;
12946 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 do
12948 {
12949 if(pMsg == NULL)
12950 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012951 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 status = eHAL_STATUS_FAILURE;
12953 break;
12954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12956 if(pEntry)
12957 {
12958 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12959 if(eSmeCommandDelStaSession == pCommand->command)
12960 {
12961 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012962 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
12963 smsLog( pMac, LOG1, "Del Sta rsp status = %d\n", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 //This session is done.
12965 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 if(pCommand->u.delStaSessionCmd.callback)
12967 {
12968
12969 status = sme_ReleaseGlobalLock( &pMac->sme );
12970 if ( HAL_STATUS_SUCCESS( status ) )
12971 {
12972 pCommand->u.delStaSessionCmd.callback(
12973 pCommand->u.delStaSessionCmd.pContext);
12974 status = sme_AcquireGlobalLock( &pMac->sme );
12975 if (! HAL_STATUS_SUCCESS( status ) )
12976 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012977 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 return status;
12979 }
12980 }
12981 else {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012982 smsLog(pMac, LOGE, "%s: Failed to Release Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 }
12984 }
12985
12986 //Remove this command out of the active list
12987 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12988 {
12989 //Now put this command back on the avilable command list
12990 csrReleaseCommand(pMac, pCommand);
12991 }
12992 smeProcessPendingQueue( pMac );
12993 }
12994 else
12995 {
12996 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012997 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 status = eHAL_STATUS_FAILURE;
12999 break;
13000 }
13001 }
13002 else
13003 {
13004 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013005 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 status = eHAL_STATUS_FAILURE;
13007 break;
13008 }
13009 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013011}
Jeff Johnson295189b2012-06-20 16:38:30 -070013012eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13013{
13014 tSirSmeDelStaSelfReq *pMsg;
13015 tANI_U16 msgLen;
13016 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13019 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13021 if ( !HAL_STATUS_SUCCESS(status) ) break;
13022
13023 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13025 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 // self station address
13027 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013029 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 return( status );
13031}
Jeff Johnson295189b2012-06-20 16:38:30 -070013032eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13033 tSirMacAddr sessionMacAddr,
13034 csrRoamSessionCloseCallback callback,
13035 void *pContext)
13036{
13037 eHalStatus status = eHAL_STATUS_SUCCESS;
13038 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 pCommand = csrGetCommandBuffer(pMac);
13040 if(NULL == pCommand)
13041 {
13042 status = eHAL_STATUS_RESOURCES;
13043 }
13044 else
13045 {
13046 pCommand->command = eSmeCommandDelStaSession;
13047 pCommand->sessionId = (tANI_U8)sessionId;
13048 pCommand->u.delStaSessionCmd.callback = callback;
13049 pCommand->u.delStaSessionCmd.pContext = pContext;
13050 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13052 if( !HAL_STATUS_SUCCESS( status ) )
13053 {
13054 //Should be panic??
13055 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
13056 }
13057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 return (status);
13059}
Jeff Johnson295189b2012-06-20 16:38:30 -070013060eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13061{
13062 return csrSendMBDelSelfStaReqMsg( pMac,
13063 pCommand->u.delStaSessionCmd.selfMacAddr );
13064}
Jeff Johnson295189b2012-06-20 16:38:30 -070013065static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13066{
13067 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13068 tListElem *pEntry, *pNext;
13069 tSmeCmd *pCommand;
13070 tDblLinkList localList;
13071
13072 vos_mem_zero(&localList, sizeof(tDblLinkList));
13073 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13074 {
13075 smsLog(pMac, LOGE, FL(" failed to open list"));
13076 return;
13077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 csrLLLock(pList);
13079 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13080 while(pEntry != NULL)
13081 {
13082 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13083 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13084 if(pCommand->sessionId == sessionId)
13085 {
13086 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13087 {
13088 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13089 }
13090 }
13091 pEntry = pNext;
13092 }
13093 csrLLUnlock(pList);
13094
13095 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13096 {
13097 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13098 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13099 }
13100 csrLLClose(&localList);
13101}
13102
Jeff Johnson295189b2012-06-20 16:38:30 -070013103void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13104{
13105 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13106 {
13107 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 csrRoamStop(pMac, sessionId);
13109 csrFreeConnectBssDesc(pMac, sessionId);
13110 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13111 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13112 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13113#ifdef FEATURE_WLAN_BTAMP_UT_RF
13114 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13115#endif
13116 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13117 purgeSmeSessionCmdList(pMac, sessionId);
13118 purgeCsrSessionCmdList(pMac, sessionId);
13119 csrInitSession(pMac, sessionId);
13120 }
13121}
13122
Jeff Johnson295189b2012-06-20 16:38:30 -070013123eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13124 tANI_BOOLEAN fSync,
13125 csrRoamSessionCloseCallback callback,
13126 void *pContext )
13127{
13128 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13130 {
13131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13132 if(fSync)
13133 {
13134 csrCleanupSession(pMac, sessionId);
13135 }
13136 else
13137 {
13138 purgeSmeSessionCmdList(pMac, sessionId);
13139 purgeCsrSessionCmdList(pMac, sessionId);
13140 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13141 pSession->selfMacAddr, callback, pContext);
13142 }
13143 }
13144 else
13145 {
13146 status = eHAL_STATUS_INVALID_PARAMETER;
13147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 return ( status );
13149}
13150
Jeff Johnson295189b2012-06-20 16:38:30 -070013151static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13152{
13153 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013154
13155 if(!pSession)
13156 {
13157 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13158 return;
13159 }
13160
Jeff Johnson295189b2012-06-20 16:38:30 -070013161 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13162 pSession->sessionId = CSR_SESSION_ID_INVALID;
13163 pSession->callback = NULL;
13164 pSession->pContext = NULL;
13165 pSession->ibss_join_pending = FALSE;
13166 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13167 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13168 csrFreeRoamProfile( pMac, sessionId );
13169 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13170 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13171 csrFreeConnectBssDesc(pMac, sessionId);
13172 csrScanEnable(pMac);
13173 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13174 if(pSession->pWpaRsnReqIE)
13175 {
13176 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13177 pSession->pWpaRsnReqIE = NULL;
13178 }
13179 pSession->nWpaRsnReqIeLength = 0;
13180 if(pSession->pWpaRsnRspIE)
13181 {
13182 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13183 pSession->pWpaRsnRspIE = NULL;
13184 }
13185 pSession->nWpaRsnRspIeLength = 0;
13186#ifdef FEATURE_WLAN_WAPI
13187 if(pSession->pWapiReqIE)
13188 {
13189 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13190 pSession->pWapiReqIE = NULL;
13191 }
13192 pSession->nWapiReqIeLength = 0;
13193 if(pSession->pWapiRspIE)
13194 {
13195 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13196 pSession->pWapiRspIE = NULL;
13197 }
13198 pSession->nWapiRspIeLength = 0;
13199#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 if(pSession->pAddIEScan)
13201 {
13202 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13203 pSession->pAddIEScan = NULL;
13204 }
13205 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 if(pSession->pAddIEAssoc)
13207 {
13208 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13209 pSession->pAddIEAssoc = NULL;
13210}
13211 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013212}
13213
Jeff Johnson295189b2012-06-20 16:38:30 -070013214eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13215{
13216 eHalStatus status = eHAL_STATUS_FAILURE;
13217 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013218 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13219 {
13220 if( CSR_IS_SESSION_VALID( pMac, i ) )
13221 {
13222 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13223 {
13224 //Found it
13225 status = eHAL_STATUS_SUCCESS;
13226 *pSessionId = i;
13227 break;
13228 }
13229 }
13230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 return( status );
13232}
13233
Jeff Johnson295189b2012-06-20 16:38:30 -070013234//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13235//session because for IBSS, the bssid changes.
13236static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13237{
13238 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13239 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13241 {
13242 if( CSR_IS_SESSION_VALID( pMac, i ) )
13243 {
13244 pSession = CSR_GET_SESSION( pMac, i );
13245 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13246 {
13247 //Found it
13248 nRet = i;
13249 break;
13250 }
13251 }
13252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 return (nRet);
13254}
Jeff Johnson295189b2012-06-20 16:38:30 -070013255static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13256{
13257 /* Update the current BSS info in ho control block based on connected
13258 profile info from pmac global structure */
13259
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x\n",
13261 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13262 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 /* Check for user misconfig of RSSI trigger threshold */
13264 pMac->roam.configParam.vccRssiThreshold =
13265 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13266 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13267 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 /* Check for user misconfig of UL MAC Loss trigger threshold */
13269 pMac->roam.configParam.vccUlMacLossThreshold =
13270 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13271 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013272#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13273 {
13274 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 /* Indicate the neighbor roal algorithm about the connect indication */
13276 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13277 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13278 }
13279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013280}
13281
Jeff Johnson295189b2012-06-20 16:38:30 -070013282static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13283{
13284 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013285
13286 if(!pSession)
13287 {
13288 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13289 return;
13290 }
13291
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 //Only to handle the case for Handover on infra link
13293 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13294 {
13295 return;
13296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13298 csrRoamDeregStatisticsReq(pMac);
13299 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13300#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13301 /* Indicate the neighbor roal algorithm about the disconnect indication */
13302 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13303#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013304
13305 //Remove this code once SLM_Sessionization is supported
13306 //BMPS_WORKAROUND_NOT_NEEDED
13307 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013308 csrIsInfraApStarted( pMac ) &&
13309 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013310 {
13311 pMac->roam.configParam.doBMPSWorkaround = 0;
13312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013313}
13314
Jeff Johnson295189b2012-06-20 16:38:30 -070013315void csrRoamTlStatsTimerHandler(void *pv)
13316{
13317 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13318 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13320
Jeff Johnsone7245742012-09-05 17:12:55 -070013321 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13322
Jeff Johnson295189b2012-06-20 16:38:30 -070013323#if 0
13324 // TODO Persession .???
13325 //req TL for stats
13326 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13327 {
13328 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL\n"));
13329 }
13330 else
13331 {
13332 //save in SME
13333 csrRoamSaveStatsFromTl(pMac, tlStats);
13334 }
13335#endif
13336 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13337 {
13338 if(pMac->roam.tlStatsReqInfo.periodicity)
13339 {
13340 //start timer
13341 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13342 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13343 if(!HAL_STATUS_SUCCESS(status))
13344 {
13345 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer\n"));
13346 return;
13347 }
13348 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13349 }
13350 }
13351}
Jeff Johnson295189b2012-06-20 16:38:30 -070013352void csrRoamPeStatsTimerHandler(void *pv)
13353{
13354 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13355 eHalStatus status;
13356 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13357 VOS_STATUS vosStatus;
13358 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 pPeStatsReqListEntry->timerRunning = FALSE;
13360 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13361 {
13362 // If we entered here, meaning the timer could not be successfully
13363 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13364
13365 /* Destroy the timer */
13366 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13367 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13368 {
13369 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer\n"));
13370 }
13371
13372 // Free the entry
13373 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13374 pPeStatsReqListEntry = NULL;
13375 }
13376 else
13377 {
13378 if(!pPeStatsReqListEntry->rspPending)
13379 {
13380 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13381 pPeStatsReqListEntry->staId);
13382 if(!HAL_STATUS_SUCCESS(status))
13383 {
13384 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE\n"));
13385 }
13386 else
13387 {
13388 pPeStatsReqListEntry->rspPending = TRUE;
13389 }
13390 }
13391
13392 //send down a req
13393 if(pPeStatsReqListEntry->periodicity &&
13394 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13395 {
13396 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13397 if(ePMC_FULL_POWER == powerState)
13398 {
13399 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13400 {
13401 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13402 }
13403 }
13404 else
13405 {
13406 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13407 {
13408 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13409 }
13410 }
13411 //start timer
13412 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13413 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13414 {
13415 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer\n"));
13416 return;
13417 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 pPeStatsReqListEntry->timerRunning = TRUE;
13419
13420 }
13421
13422 }
13423}
Jeff Johnson295189b2012-06-20 16:38:30 -070013424void csrRoamStatsClientTimerHandler(void *pv)
13425{
13426 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13428 {
13429#if 0
13430 // TODO Stats fix for multisession
13431 //start the timer
13432 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13433
13434 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13435 {
13436 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 }
13438#endif
13439 }
13440#if 0
13441 //send up the stats report
13442 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13443 pStaEntry->staId, pStaEntry->pContext);
13444#endif
13445}
13446
13447
13448
Jeff Johnson295189b2012-06-20 16:38:30 -070013449eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13450{
13451 tAniGetPEStatsReq *pMsg;
13452 eHalStatus status = eHAL_STATUS_SUCCESS;
13453 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13454 if ( !HAL_STATUS_SUCCESS(status) )
13455 {
13456 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req \n");
13457 return status;
13458 }
13459 // need to initiate a stats request to PE
13460 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13461 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13462 pMsg->staId = staId;
13463 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 if(!HAL_STATUS_SUCCESS(status))
13466 {
13467 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req \n");
13468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 return status;
13470}
Jeff Johnson295189b2012-06-20 16:38:30 -070013471void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13472{
13473 tAniGetPEStatsRsp *pSmeStatsRsp;
13474 eHalStatus status = eHAL_STATUS_FAILURE;
13475 tListElem *pEntry = NULL;
13476 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13477 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13478 tANI_U32 tempMask = 0;
13479 tANI_U8 counter = 0;
13480 tANI_U8 *pStats = NULL;
13481 tANI_U32 length = 0;
13482 v_PVOID_t pvosGCtx;
13483 v_S7_t rssi = 0;
13484 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13486 if(pSmeStatsRsp->rc)
13487 {
13488 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure\n"));
13489 goto post_update;
13490 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 tempMask = pSmeStatsRsp->statsMask;
13492 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 /* subtract all statistics from this length, and after processing the entire
13494 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13495 * in this 'stats' message.
13496 */
13497 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 //new stats info from PE, fill up the stats strucutres in PMAC
13499 while(tempMask)
13500 {
13501 if(tempMask & 1)
13502 {
13503 switch(counter)
13504 {
13505 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013506 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013507 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13508 pStats, sizeof(tCsrSummaryStatsInfo));
13509 if(!HAL_STATUS_SUCCESS(status))
13510 {
13511 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats\n"));
13512 }
13513 pStats += sizeof(tCsrSummaryStatsInfo);
13514 length -= sizeof(tCsrSummaryStatsInfo);
13515 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013517 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13519 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13520 if(!HAL_STATUS_SUCCESS(status))
13521 {
13522 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats\n"));
13523 }
13524 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13525 length -= sizeof(tCsrGlobalClassAStatsInfo);
13526 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013528 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13530 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13531 if(!HAL_STATUS_SUCCESS(status))
13532 {
13533 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats\n"));
13534 }
13535 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13536 length -= sizeof(tCsrGlobalClassBStatsInfo);
13537 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013539 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13541 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13542 if(!HAL_STATUS_SUCCESS(status))
13543 {
13544 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats\n"));
13545 }
13546 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13547 length -= sizeof(tCsrGlobalClassCStatsInfo);
13548 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013550 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13552 {
13553 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13554 pStats, sizeof(tCsrPerStaStatsInfo));
13555 }
13556 else
13557 {
13558 status = eHAL_STATUS_FAILURE;
13559 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d\n"), pSmeStatsRsp->staId);
13560 VOS_ASSERT( 0 );
13561 }
13562 if(!HAL_STATUS_SUCCESS(status))
13563 {
13564 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats\n"));
13565 }
13566 pStats += sizeof(tCsrPerStaStatsInfo);
13567 length -= sizeof(tCsrPerStaStatsInfo);
13568 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 default:
13570 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type\n"));
13571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 }
13573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 tempMask >>=1;
13575 counter++;
13576 }
13577 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13578 if (length != 0)
13579 {
13580 pRssi = (tANI_U32*)pStats;
13581 rssi = (v_S7_t)*pRssi;
13582 }
13583 else
13584 {
13585 /* If riva is not sending rssi, continue to use the hack */
13586 rssi = RSSI_HACK_BMPS;
13587 }
13588 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013589post_update:
13590 //make sure to update the pe stats req list
13591 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13592 if(pEntry)
13593 {
13594 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13595 pPeStaEntry->rspPending = FALSE;
13596
13597 }
13598 //check the one timer cases
13599 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13600 if(pEntry)
13601 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 if(pTempStaEntry->timerExpired)
13604 {
13605 //send up the stats report
13606 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13607 pTempStaEntry->staId, pTempStaEntry->pContext);
13608 //also remove from the client list
13609 csrRoamRemoveStatListEntry(pMac, pEntry);
13610 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 }
13612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013613}
Jeff Johnson295189b2012-06-20 16:38:30 -070013614tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13615{
13616 tListElem *pEntry = NULL;
13617 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 if(!pEntry)
13620 {
13621 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013622 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 return NULL;
13624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 while( pEntry )
13626 {
13627 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 if(pTempStaEntry->statsMask == statsMask)
13629 {
Mohit Khanna23863762012-09-11 17:40:09 -070013630 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 break;
13632 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 return pEntry;
13636}
13637
Jeff Johnson295189b2012-06-20 16:38:30 -070013638tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13639 tANI_BOOLEAN update)
13640{
13641 tListElem *pEntry;
13642 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 if(!pEntry)
13645 {
13646 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013647 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 "upper layer client(s)\n");
13649 return NULL;
13650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 while( pEntry )
13652 {
13653 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13655 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13656 {
Mohit Khanna23863762012-09-11 17:40:09 -070013657 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 if(update)
13659 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013660 pTempStaEntry->periodicity = pStaEntry->periodicity;
13661 pTempStaEntry->callback = pStaEntry->callback;
13662 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 }
13664 break;
13665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 return pEntry;
13669}
Jeff Johnson295189b2012-06-20 16:38:30 -070013670tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13671{
13672 tListElem *pEntry;
13673 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 if(!pEntry)
13676 {
13677 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013678 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 "upper layer client(s)\n");
13680 return NULL;
13681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 while( pEntry )
13683 {
13684 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13686 {
Mohit Khanna23863762012-09-11 17:40:09 -070013687 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 break;
13689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 return pEntry;
13693}
Jeff Johnson295189b2012-06-20 16:38:30 -070013694eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13695 csrRoamLinkQualityIndCallback callback,
13696 void *pContext)
13697{
13698 pMac->roam.linkQualityIndInfo.callback = callback;
13699 pMac->roam.linkQualityIndInfo.context = pContext;
13700 if( NULL == callback )
13701 {
13702 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13703 }
13704 else
13705 {
13706 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 /* do we need to invoke the callback to notify client of initial value ?? */
13708 }
13709 return eHAL_STATUS_SUCCESS;
13710}
Jeff Johnson295189b2012-06-20 16:38:30 -070013711void csrRoamVccTrigger(tpAniSirGlobal pMac)
13712{
13713 eCsrRoamLinkQualityInd newVccLinkQuality;
13714 tANI_U32 ul_mac_loss = 0;
13715 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13717 /*-------------------------------------------------------------------------
13718 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 Check for a change in link quality and notify client if necessary
13720 -------------------------------------------------------------------------*/
13721 ul_mac_loss_trigger_threshold =
13722 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d\n",
13725 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13727 {
13728 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR \n");
13729 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13730 }
13731 else
13732 {
13733 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD\n");
13734 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13737 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13739 {
13740 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary\n");
13741 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13742 {
13743 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d\n",
13744 newVccLinkQuality );
13745
13746 /* we now invoke the callback once to notify client of initial value */
13747 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13748 pMac->roam.linkQualityIndInfo.context );
13749 //event: EVENT_WLAN_VCC
13750 }
13751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 pMac->roam.vccLinkQuality = newVccLinkQuality;
13753
Jeff Johnson295189b2012-06-20 16:38:30 -070013754}
Jeff Johnson295189b2012-06-20 16:38:30 -070013755VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13756 v_U8_t rssiNotification,
13757 void * context)
13758{
13759 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13760 eCsrRoamLinkQualityInd newVccLinkQuality;
13761 // TODO : Session info unavailable
13762 tANI_U32 sessionId = 0;
13763 VOS_STATUS status = VOS_STATUS_SUCCESS;
13764 /*-------------------------------------------------------------------------
13765 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 Check for a change in link quality and notify client if necessary
13767 -------------------------------------------------------------------------*/
13768 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d\n",
13769 pMac->roam.configParam.vccRssiThreshold);
13770 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13771 {
13772 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected\n");
13773 return VOS_STATUS_SUCCESS;
13774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13776 {
13777 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR\n");
13778 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13779 }
13780 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13781 {
13782 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD \n");
13783 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13784 }
13785 else
13786 {
13787 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d\n", rssiNotification);
13788 //Set to this so the code below won't do anything
13789 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 VOS_ASSERT(0);
13791 }
13792
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13794 {
13795 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary\n");
13796 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13797 {
13798 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d\n",
13799 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 /* we now invoke the callback once to notify client of initial value */
13801 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13802 pMac->roam.linkQualityIndInfo.context );
13803 //event: EVENT_WLAN_VCC
13804 }
13805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 return status;
13808}
Jeff Johnson295189b2012-06-20 16:38:30 -070013809tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13810 tDblLinkList *pStaList,
13811 tCsrStatsClientReqInfo *pStaEntry)
13812{
13813 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 //if same entity requested for same set of stats with different periodicity &
13816 // callback update it
13817 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13818 {
13819
13820 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13821 if (!HAL_STATUS_SUCCESS(status))
13822 {
13823 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
13824 "entry\n");
13825 return NULL;
13826 }
13827
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 pNewStaEntry->callback = pStaEntry->callback;
13829 pNewStaEntry->pContext = pStaEntry->pContext;
13830 pNewStaEntry->periodicity = pStaEntry->periodicity;
13831 pNewStaEntry->requesterId = pStaEntry->requesterId;
13832 pNewStaEntry->statsMask = pStaEntry->statsMask;
13833 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13834 pNewStaEntry->pMac = pStaEntry->pMac;
13835 pNewStaEntry->staId = pStaEntry->staId;
13836 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13837
13838 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13839 }
13840 return pNewStaEntry;
13841}
13842
Jeff Johnson295189b2012-06-20 16:38:30 -070013843tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13844 tDblLinkList *pStaList,
13845 tCsrPeStatsReqInfo *pStaEntry)
13846{
13847 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13850 if (!HAL_STATUS_SUCCESS(status))
13851 {
13852 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
13853 "entry\n");
13854 return NULL;
13855 }
13856
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13858 pNewStaEntry->numClient = pStaEntry->numClient;
13859 pNewStaEntry->periodicity = pStaEntry->periodicity;
13860 pNewStaEntry->statsMask = pStaEntry->statsMask;
13861 pNewStaEntry->pMac = pStaEntry->pMac;
13862 pNewStaEntry->staId = pStaEntry->staId;
13863 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13864 pNewStaEntry->rspPending = pStaEntry->rspPending;
13865
13866 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 return pNewStaEntry;
13868}
Jeff Johnson295189b2012-06-20 16:38:30 -070013869eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13870 tCsrRssiCallback callback,
13871 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13872{
13873 eHalStatus status = eHAL_STATUS_SUCCESS;
13874 vos_msg_t msg;
13875 tANI_U32 sessionId;
13876
13877 tAniGetRssiReq *pMsg;
13878 smsLog(pMac, LOG2, FL("called"));
13879 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13880 if ( !HAL_STATUS_SUCCESS(status) )
13881 {
13882 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req \n");
13883 return status;
13884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13886
13887 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13888 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13889 pMsg->sessionId = sessionId;
13890 pMsg->staId = staId;
13891 pMsg->rssiCallback = callback;
13892 pMsg->pDevContext = pContext;
13893 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 msg.type = eWNI_SME_GET_RSSI_REQ;
13895 msg.bodyptr = pMsg;
13896 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
13898 {
13899 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self \n");
13900 palFreeMemory(pMac->hHdd, (void *)pMsg);
13901 status = eHAL_STATUS_FAILURE;
13902 }
13903 smsLog(pMac, LOG2, FL("returned"));
13904 return status;
13905}
Jeff Johnson295189b2012-06-20 16:38:30 -070013906eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
13907 tANI_U32 statsMask,
13908 tCsrStatsCallback callback,
13909 tANI_U32 periodicity, tANI_BOOLEAN cache,
13910 tANI_U8 staId, void *pContext)
13911{
13912 tCsrStatsClientReqInfo staEntry;
13913 tCsrStatsClientReqInfo *pStaEntry = NULL;
13914 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13915 tListElem *pEntry = NULL;
13916 tANI_BOOLEAN found = FALSE;
13917 eHalStatus status = eHAL_STATUS_SUCCESS;
13918 tANI_BOOLEAN insertInClientList = FALSE;
13919 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070013920 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070013921
13922 if( csrIsAllSessionDisconnected(pMac) )
13923 {
13924 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected\n", pMac->roam.curState);
13925 return eHAL_STATUS_FAILURE;
13926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 if((!statsMask) && (!callback))
13928 {
13929 //msg
13930 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request\n");
13931 return eHAL_STATUS_FAILURE;
13932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 //for the search list method for deregister
13934 staEntry.requesterId = requesterId;
13935 staEntry.statsMask = statsMask;
13936 //requester wants to deregister or just an error
13937 if((statsMask) && (!callback))
13938 {
13939 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
13940 if(!pEntry)
13941 {
13942 //msg
13943 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
13944 "find any existing request in statsClientReqList\n");
13945 return eHAL_STATUS_FAILURE;
13946 }
13947 else
13948 {
13949 //clean up & return
13950 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070013951 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013953 pStaEntry->pPeStaEntry->numClient--;
13954 //check if we need to delete the entry from peStatsReqList too
13955 if(!pStaEntry->pPeStaEntry->numClient)
13956 {
13957 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
13958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070013960
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 //check if we need to stop the tl stats timer too
13962 pMac->roam.tlStatsReqInfo.numClient--;
13963 if(!pMac->roam.tlStatsReqInfo.numClient)
13964 {
13965 if(pMac->roam.tlStatsReqInfo.timerRunning)
13966 {
13967 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
13968 if(!HAL_STATUS_SUCCESS(status))
13969 {
13970 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer\n"));
13971 return eHAL_STATUS_FAILURE;
13972 }
13973 }
13974 pMac->roam.tlStatsReqInfo.periodicity = 0;
13975 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13976 }
13977 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 // Destroy the vos timer...
13979 vosStatus = vos_timer_destroy( &pStaEntry->timer );
13980 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13981 {
13982 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer\n"));
13983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 csrRoamRemoveStatListEntry(pMac, pEntry);
13985 pStaEntry = NULL;
13986 return eHAL_STATUS_SUCCESS;
13987 }
13988 }
13989
13990 if(cache && !periodicity)
13991 {
13992 //return the cached stats
13993 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
13994 }
13995 else
13996 {
13997 //add the request in the client req list
13998 staEntry.callback = callback;
13999 staEntry.pContext = pContext;
14000 staEntry.periodicity = periodicity;
14001 staEntry.pPeStaEntry = NULL;
14002 staEntry.staId = staId;
14003 staEntry.pMac = pMac;
14004 staEntry.timerExpired = FALSE;
14005
14006
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 //if periodic report requested with non cached result from PE/TL
14008 if(periodicity)
14009 {
14010
14011 //if looking for stats from PE
14012 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14013 {
14014
14015 //check if same request made already & waiting for rsp
14016 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14017 periodicity, &found, staId);
14018 if(!pPeStaEntry)
14019 {
14020 //bail out, maxed out on number of req for PE
14021 return eHAL_STATUS_FAILURE;
14022 }
14023 else
14024 {
14025 staEntry.pPeStaEntry = pPeStaEntry;
14026 }
14027
14028 }
14029 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14030 if(statsMask & (1 << eCsrGlobalClassDStats))
14031 {
14032 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14033 {
14034 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL\n"));
14035 }
14036 else
14037 {
14038
14039 //update periodicity
14040 if(pMac->roam.tlStatsReqInfo.periodicity)
14041 {
14042 pMac->roam.tlStatsReqInfo.periodicity =
14043 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14044 }
14045 else
14046 {
14047 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14048 }
14049 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14050 {
14051 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14052 }
14053
14054 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14055 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014056 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14057 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014058 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014059 //req TL for class D stats
14060 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14061 {
14062 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14063 }
14064 else
14065 {
14066 //save in SME
14067 csrRoamSaveStatsFromTl(pMac, pTlStats);
14068 }
14069 vos_mem_free(pTlStats);
14070 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 }
14072 else
14073 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014074 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014076
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 if(pMac->roam.tlStatsReqInfo.periodicity)
14078 {
14079 //start timer
14080 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14081 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14082 if(!HAL_STATUS_SUCCESS(status))
14083 {
14084 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer\n"));
14085 return eHAL_STATUS_FAILURE;
14086 }
14087 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14088 }
14089 }
14090 }
14091 pMac->roam.tlStatsReqInfo.numClient++;
14092 }
14093
14094 insertInClientList = TRUE;
14095 }
14096 //if one time report requested with non cached result from PE/TL
14097 else if(!cache && !periodicity)
14098 {
14099 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14100 {
14101 //send down a req
14102 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14103 if(!HAL_STATUS_SUCCESS(status))
14104 {
14105 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE\n"));
14106 }
14107 //so that when the stats rsp comes back from PE we respond to upper layer
14108 //right away
14109 staEntry.timerExpired = TRUE;
14110 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 }
14112 if(statsMask & (1 << eCsrGlobalClassDStats))
14113 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014114 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14115 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014117 //req TL for class D stats
14118 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14119 {
14120 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14121 }
14122 else
14123 {
14124 //save in SME
14125 csrRoamSaveStatsFromTl(pMac, pTlStats);
14126 }
14127 vos_mem_free(pTlStats);
14128 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 }
14130 else
14131 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014132 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014134
14135 }
14136 //if looking for stats from TL only
14137 if(!insertInClientList)
14138 {
14139 //return the stats
14140 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 if(insertInClientList)
14144 {
14145 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14146 if(!pStaEntry)
14147 {
14148 //msg
14149 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList\n");
14150 return eHAL_STATUS_FAILURE;
14151 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014152 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 //Init & start timer if needed
14154 if(periodicity)
14155 {
14156 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14157 csrRoamStatsClientTimerHandler, pStaEntry );
14158 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14159 {
14160 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer\n"));
14161 return eHAL_STATUS_FAILURE;
14162 }
14163 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14164 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14165 {
14166 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
14167 return eHAL_STATUS_FAILURE;
14168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 }
14172 return eHAL_STATUS_SUCCESS;
14173}
14174
Jeff Johnson295189b2012-06-20 16:38:30 -070014175tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14176 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14177{
14178 tANI_BOOLEAN found = FALSE;
14179 eHalStatus status = eHAL_STATUS_SUCCESS;
14180 tCsrPeStatsReqInfo staEntry;
14181 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14182 tListElem *pStaEntry = NULL;
14183 VOS_STATUS vosStatus;
14184 tPmcPowerState powerState;
14185 *pFound = FALSE;
14186
14187 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14188 if(pStaEntry)
14189 {
14190 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14191 if(pTempStaEntry->periodicity)
14192 {
14193 pTempStaEntry->periodicity =
14194 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14195 }
14196 else
14197 {
14198 pTempStaEntry->periodicity = periodicity;
14199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014200 pTempStaEntry->numClient++;
14201 found = TRUE;
14202 }
14203 else
14204 {
14205 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14206 staEntry.numClient = 1;
14207 staEntry.periodicity = periodicity;
14208 staEntry.pMac = pMac;
14209 staEntry.rspPending = FALSE;
14210 staEntry.staId = staId;
14211 staEntry.statsMask = statsMask;
14212 staEntry.timerRunning = FALSE;
14213 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14214 if(!pTempStaEntry)
14215 {
14216 //msg
14217 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList\n");
14218 return NULL;
14219 }
14220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14222 if(ePMC_FULL_POWER == powerState)
14223 {
14224 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14225 {
14226 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14227 }
14228 }
14229 else
14230 {
14231 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14232 {
14233 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14234 }
14235 }
14236 if(!pTempStaEntry->timerRunning)
14237 {
14238 //send down a req in case of one time req, for periodic ones wait for timer to expire
14239 if(!pTempStaEntry->rspPending &&
14240 !pTempStaEntry->periodicity)
14241 {
14242 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14243 if(!HAL_STATUS_SUCCESS(status))
14244 {
14245 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE\n"));
14246 }
14247 else
14248 {
14249 pTempStaEntry->rspPending = TRUE;
14250 }
14251 }
14252 if(pTempStaEntry->periodicity)
14253 {
14254 if(!found)
14255 {
14256
14257 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14258 csrRoamPeStatsTimerHandler, pTempStaEntry );
14259 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14260 {
14261 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer\n"));
14262 return NULL;
14263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 }
14265 //start timer
14266 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d\n", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014267 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14268 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14269 {
14270 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer\n"));
14271 return NULL;
14272 }
14273 pTempStaEntry->timerRunning = TRUE;
14274 }
14275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 *pFound = found;
14277 return pTempStaEntry;
14278}
14279
Jeff Johnson295189b2012-06-20 16:38:30 -070014280/*
14281 pStaEntry is no longer invalid upon the return of this function.
14282*/
14283static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14284{
14285 if(pEntry)
14286 {
14287 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14288 {
14289 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 }
14292 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014293
14294void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14295{
14296 tListElem *pEntry;
14297 tCsrPeStatsReqInfo *pTempStaEntry;
14298 VOS_STATUS vosStatus;
14299 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 if(!pEntry)
14301 {
14302 //list empty
14303 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE\n");
14304 return;
14305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 while( pEntry )
14307 {
14308 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14310 {
14311 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found\n");
14312 if(pTempStaEntry->timerRunning)
14313 {
14314 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14315 /* If we are not able to stop the timer here, just remove
14316 * the entry from the linked list. Destroy the timer object
14317 * and free the memory in the timer CB
14318 */
14319 if( vosStatus == VOS_STATUS_SUCCESS )
14320 {
14321 /* the timer is successfully stopped */
14322 pTempStaEntry->timerRunning = FALSE;
14323
14324 /* Destroy the timer */
14325 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14326 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14327 {
14328 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer\n"));
14329 }
14330 }
14331 else
14332 {
14333 // the timer could not be stopped. Hence destroy and free the
14334 // memory for the PE stat entry in the timer CB.
14335 pTempStaEntry->timerStopFailed = TRUE;
14336 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014338
14339 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14340 {
14341 // Only free the memory if we could stop the timer successfully
14342 if(!pTempStaEntry->timerStopFailed)
14343 {
14344 palFreeMemory(pMac->hHdd, pTempStaEntry);
14345 pTempStaEntry = NULL;
14346 }
14347 break;
14348 }
14349
14350 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14351 }
14352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014353 return;
14354}
14355
14356
Jeff Johnsone7245742012-09-05 17:12:55 -070014357void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014358{
14359
Jeff Johnsone7245742012-09-05 17:12:55 -070014360 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14361 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14362 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14363 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14364 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14365 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14366 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014368 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14369 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14370 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14371 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14372 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14373 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014374 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014375 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14376 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014377
14378}
14379
Jeff Johnson295189b2012-06-20 16:38:30 -070014380void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14381 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14382{
14383 tANI_U8 stats[500];
14384 tANI_U8 *pStats = NULL;
14385 tANI_U32 tempMask = 0;
14386 tANI_U8 counter = 0;
14387 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 if(!callback)
14389 {
14390 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL\n"));
14391 return;
14392 }
14393 if(!statsMask)
14394 {
14395 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0\n"));
14396 return;
14397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 while(tempMask)
14401 {
14402 if(tempMask & 1)
14403 {
14404 //new stats info from PE, fill up the stats strucutres in PMAC
14405 switch(counter)
14406 {
14407 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014408 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14410 sizeof(tCsrSummaryStatsInfo));
14411 if(!HAL_STATUS_SUCCESS(status))
14412 {
14413 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats\n"));
14414 }
14415 pStats += sizeof(tCsrSummaryStatsInfo);
14416 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014418 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014419 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14420 sizeof(tCsrGlobalClassAStatsInfo));
14421 if(!HAL_STATUS_SUCCESS(status))
14422 {
14423 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats\n"));
14424 }
14425 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014427 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014428 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014429 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14430 sizeof(tCsrGlobalClassBStatsInfo));
14431 if(!HAL_STATUS_SUCCESS(status))
14432 {
14433 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats\n"));
14434 }
14435 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014438 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014439 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14440 sizeof(tCsrGlobalClassCStatsInfo));
14441 if(!HAL_STATUS_SUCCESS(status))
14442 {
14443 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats\n"));
14444 }
14445 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 case eCsrGlobalClassDStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014448 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014449 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14450 sizeof(tCsrGlobalClassDStatsInfo));
14451 if(!HAL_STATUS_SUCCESS(status))
14452 {
14453 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats\n"));
14454 }
14455 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014458 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14460 sizeof(tCsrPerStaStatsInfo));
14461 if(!HAL_STATUS_SUCCESS(status))
14462 {
14463 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats\n"));
14464 }
14465 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014467 default:
14468 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type\n"));
14469 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 }
14471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014472 tempMask >>=1;
14473 counter++;
14474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014476}
14477
Jeff Johnson295189b2012-06-20 16:38:30 -070014478eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14479{
14480 tListElem *pEntry = NULL;
14481 tListElem *pPrevEntry = NULL;
14482 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14483 eHalStatus status = eHAL_STATUS_SUCCESS;
14484 VOS_STATUS vosStatus;
14485 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 if(!pEntry)
14487 {
14488 //list empty
14489 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
14490 "upper layer client(s)\n");
14491 return status;
14492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 while( pEntry )
14494 {
14495 if(pPrevEntry)
14496 {
14497 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14498 //send up the stats report
14499 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14500 pTempStaEntry->staId, pTempStaEntry->pContext);
14501 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014503 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014504 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14505 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014506 pTempStaEntry->pPeStaEntry->numClient--;
14507 //check if we need to delete the entry from peStatsReqList too
14508 if(!pTempStaEntry->pPeStaEntry->numClient)
14509 {
14510 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 //check if we need to stop the tl stats timer too
14514 pMac->roam.tlStatsReqInfo.numClient--;
14515 if(!pMac->roam.tlStatsReqInfo.numClient)
14516 {
14517 if(pMac->roam.tlStatsReqInfo.timerRunning)
14518 {
14519 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14520 if(!HAL_STATUS_SUCCESS(status))
14521 {
14522 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer\n"));
14523 //we will continue
14524 }
14525 }
14526 pMac->roam.tlStatsReqInfo.periodicity = 0;
14527 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 if (pTempStaEntry->periodicity)
14530 {
14531 //While creating StaEntry in csrGetStatistics,
14532 //Initializing and starting timer only when periodicity is set.
14533 //So Stop and Destroy timer only when periodicity is set.
14534
Jeff Johnsone7245742012-09-05 17:12:55 -070014535 vos_timer_stop( &pTempStaEntry->timer );
14536 // Destroy the vos timer...
14537 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14538 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14539 {
14540 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer\n"));
14541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014542 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014543
Jeff Johnson295189b2012-06-20 16:38:30 -070014544
14545 pPrevEntry = pEntry;
14546 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14547 }
14548 //the last one
14549 if(pPrevEntry)
14550 {
14551 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14552 //send up the stats report
14553 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14554 pTempStaEntry->staId, pTempStaEntry->pContext);
14555 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014557 return status;
14558
14559}
14560
Jeff Johnson295189b2012-06-20 16:38:30 -070014561eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14562 tRequestFullPowerReason *pReason,
14563 tANI_BOOLEAN *pfNeedPower )
14564{
14565 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14566 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14567 tPmcState pmcState;
14568 eHalStatus status = eHAL_STATUS_SUCCESS;
14569 // TODO : Session info unavailable
14570 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 if( pfNeedPower )
14572 {
14573 *pfNeedPower = eANI_BOOLEAN_FALSE;
14574 }
14575 //We only handle CSR commands
14576 if( !(eSmeCsrCommandMask & pCommand->command) )
14577 {
14578 return eHAL_STATUS_SUCCESS;
14579 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 //Check PMC state first
14581 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014582 switch( pmcState )
14583 {
14584 case REQUEST_IMPS:
14585 case IMPS:
14586 if( eSmeCommandScan == pCommand->command )
14587 {
14588 switch( pCommand->u.scanCmd.reason )
14589 {
14590 case eCsrScanGetResult:
14591 case eCsrScanBGScanAbort:
14592 case eCsrScanBGScanEnable:
14593 case eCsrScanGetScanChnInfo:
14594 //Internal process, no need for full power
14595 fNeedFullPower = eANI_BOOLEAN_FALSE;
14596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 default:
14598 //Other scans are real scan, ask for power
14599 fNeedFullPower = eANI_BOOLEAN_TRUE;
14600 break;
14601 } //switch
14602 }
14603 else
14604 {
14605 //ask for power for roam and status change
14606 fNeedFullPower = eANI_BOOLEAN_TRUE;
14607 }
14608 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 case REQUEST_BMPS:
14610 case BMPS:
14611 case REQUEST_START_UAPSD:
14612 case UAPSD:
14613 //We treat WOWL same as BMPS
14614 case REQUEST_ENTER_WOWL:
14615 case WOWL:
14616 if( eSmeCommandRoam == pCommand->command )
14617 {
14618 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14619 tCsrScanResult *pScanResult;
14620 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014621 switch ( pCommand->u.roamCmd.roamReason )
14622 {
14623 case eCsrForcedDisassoc:
14624 case eCsrForcedDisassocMICFailure:
14625 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14626 fNeedFullPower = eANI_BOOLEAN_TRUE;
14627 break;
14628 case eCsrSmeIssuedDisassocForHandoff:
14629 case eCsrForcedDeauth:
14630 case eCsrHddIssuedReassocToSameAP:
14631 case eCsrSmeIssuedReassocToSameAP:
14632 fNeedFullPower = eANI_BOOLEAN_TRUE;
14633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014634 case eCsrCapsChange:
14635 fNeedFullPower = eANI_BOOLEAN_TRUE;
14636 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014637 default:
14638 //Check whether the profile is already connected. If so, no need for full power
14639 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14640 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14641 {
14642 //Only need to check the first one
14643 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14644 if( pEntry )
14645 {
14646 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14647#if 0
14648 // TODO : Session Specific info pConnectBssDesc
14649 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14650 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14651 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14652 {
14653 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14654 // with Authenticating first. To force this, stop the current association (Disassociate) and
14655 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14656 // a new Association.
14657 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14658 {
14659 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14660 {
14661 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14662 //No need for full power
14663 //Set the flag so the code later can avoid to do the above
14664 //check again.
14665 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14666 break;
14667 }
14668 }
14669 }
14670#endif
14671 }
14672 }
14673 //If we are here, full power is needed
14674 fNeedFullPower = eANI_BOOLEAN_TRUE;
14675 break;
14676 }
14677 }
14678 else if( eSmeCommandWmStatusChange == pCommand->command )
14679 {
14680 //need full power for all
14681 fNeedFullPower = eANI_BOOLEAN_TRUE;
14682 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14683 }
Mohit Khannac0b992f2012-12-04 15:08:18 -080014684#ifdef FEATURE_WLAN_TDLS
14685 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14686 {
14687 //TDLS link is getting established. need full power
14688 fNeedFullPower = eANI_BOOLEAN_TRUE;
14689 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14690 }
14691#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014692 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014693 case REQUEST_STOP_UAPSD:
14694 case REQUEST_EXIT_WOWL:
14695 if( eSmeCommandRoam == pCommand->command )
14696 {
14697 fNeedFullPower = eANI_BOOLEAN_TRUE;
14698 switch ( pCommand->u.roamCmd.roamReason )
14699 {
14700 case eCsrForcedDisassoc:
14701 case eCsrForcedDisassocMICFailure:
14702 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14703 break;
14704 default:
14705 break;
14706 }
14707 }
14708 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 case STOPPED:
14710 case REQUEST_STANDBY:
14711 case STANDBY:
14712 case LOW_POWER:
14713 //We are not supposed to do anything
14714 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d\n" ), pmcState );
14715 status = eHAL_STATUS_FAILURE;
14716 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 case FULL_POWER:
14718 case REQUEST_FULL_POWER:
14719 default:
14720 //No need to ask for full power. This has to be FULL_POWER state
14721 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 if( pReason )
14724 {
14725 *pReason = reason;
14726 }
14727 if( pfNeedPower )
14728 {
14729 *pfNeedPower = fNeedFullPower;
14730 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014731 return ( status );
14732}
14733
Jeff Johnson295189b2012-06-20 16:38:30 -070014734static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14735{
14736 eHalStatus status = eHAL_STATUS_SUCCESS;
14737 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14738 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014740 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14741 {
14742 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 return ( status );
14745}
14746
Jeff Johnson295189b2012-06-20 16:38:30 -070014747tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14748{
14749 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 if( pCmd )
14751 {
14752 pMac->roam.sPendingCommands++;
14753 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 return ( pCmd );
14755}
14756
Jeff Johnson295189b2012-06-20 16:38:30 -070014757void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14758{
14759 if (pMac->roam.sPendingCommands > 0)
14760 {
14761 //All command allocated through csrGetCommandBuffer need to
14762 //decrement the pending count when releasing.
14763 pMac->roam.sPendingCommands--;
14764 smeReleaseCommand( pMac, pCommand );
14765 }
14766 else
14767 {
14768 smsLog(pMac, LOGE, FL( "no pending commands"));
14769 VOS_ASSERT(0);
14770 }
14771}
14772
Jeff Johnson295189b2012-06-20 16:38:30 -070014773//Return SUCCESS is the command is queued, failed
14774eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14775{
14776 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14778 {
14779 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14780 pCommand->u.scanCmd.reason);
14781 return eHAL_STATUS_CSR_WRONG_STATE;
14782 }
14783
14784 //We can call request full power first before putting the command into pending Q
14785 //because we are holding SME lock at this point.
14786 status = csrRequestFullPower( pMac, pCommand );
14787 if( HAL_STATUS_SUCCESS( status ) )
14788 {
14789 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 //make sure roamCmdPendingList is not empty first
14791 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14792 if( fNoCmdPending )
14793 {
14794 smePushCommand( pMac, pCommand, fHighPriority );
14795 }
14796 else
14797 {
14798 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14799 //no list lock is needed since SME lock is held
14800 if( !fHighPriority )
14801 {
14802 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14803 }
14804 else {
14805 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14806 }
14807 }
14808 }
14809 else if( eHAL_STATUS_PMC_PENDING == status )
14810 {
14811 //no list lock is needed since SME lock is held
14812 if( !fHighPriority )
14813 {
14814 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14815 }
14816 else {
14817 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14818 }
14819 //Let caller know the command is queue
14820 status = eHAL_STATUS_SUCCESS;
14821 }
14822 else
14823 {
14824 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14825 //release the command.
14826 smsLog( pMac, LOGE, FL( " cannot queue command %d\n" ), pCommand->command );
14827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014828 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014829}
Jeff Johnson295189b2012-06-20 16:38:30 -070014830#ifdef WLAN_SOFTAP_FEATURE
14831eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14832{
14833 eHalStatus status = eHAL_STATUS_SUCCESS;
14834 tSirUpdateAPWPSIEsReq *pMsg;
14835 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14836
14837 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14838 if (NULL == pSession)
14839 {
14840 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14841 return eHAL_STATUS_FAILURE;
14842 }
14843
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 do
14845 {
14846 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14847 if (!HAL_STATUS_SUCCESS(status)) break;
14848 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14849 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14850
14851 pBuf = (tANI_U8 *)&pMsg->transactionId;
14852 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 // transactionId
14854 *pBuf = 0;
14855 *( pBuf + 1 ) = 0;
14856 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 // bssId
14858 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14859 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 //sessionId
14861 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 // APWPSIEs
14863 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
14864 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 return ( status );
14869}
Jeff Johnson295189b2012-06-20 16:38:30 -070014870eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
14871{
14872 eHalStatus status = eHAL_STATUS_SUCCESS;
14873 tSirUpdateAPWPARSNIEsReq *pMsg;
14874 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14876 if (NULL == pSession)
14877 {
14878 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14879 return eHAL_STATUS_FAILURE;
14880 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 do
14882 {
14883 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
14884 if (!HAL_STATUS_SUCCESS(status)) break;
14885 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
14886 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014887 pBuf = (tANI_U8 *)&pMsg->transactionId;
14888 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 // transactionId
14890 *pBuf = 0;
14891 *( pBuf + 1 ) = 0;
14892 pBuf += sizeof(tANI_U16);
14893
14894 // bssId
14895 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14896 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 // sessionId
14898 *pBuf++ = (tANI_U8)sessionId;
14899
14900 // APWPARSNIEs
14901 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
14902 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014903 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 return ( status );
14907}
Jeff Johnson295189b2012-06-20 16:38:30 -070014908#endif //#ifdef WLAN_SOFTAP_FEATURE
14909
14910#ifdef WLAN_FEATURE_VOWIFI_11R
14911//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
14912eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
14913{
14914 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14915 tpSirFTPreAuthReq pftPreAuthReq;
14916 tANI_U16 auth_req_len = 0;
14917 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014918 auth_req_len = sizeof(tSirFTPreAuthReq);
14919 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
14920 if (pftPreAuthReq == NULL)
14921 {
14922 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
14923 return eHAL_STATUS_RESOURCES;
14924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 // Save the SME Session ID here. We need it while processing the preauth response
14926 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 vos_mem_zero(pftPreAuthReq, auth_req_len);
14928
14929 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
14930 sizeof(pBssDescription->length) + pBssDescription->length);
14931
14932 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
14933
14934 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
14935
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
14938
Jeff Johnson295189b2012-06-20 16:38:30 -070014939#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080014940 if (csrRoamIs11rAssoc(pMac) &&
14941 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 {
14943 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
14944 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
14945 pMac->ft.ftSmeContext.auth_ft_ies_length);
14946 }
14947 else
14948#endif
14949 {
14950 pftPreAuthReq->ft_ies_length = 0;
14951 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070014952 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
14953 sizeof(pBssDescription->length) + pBssDescription->length);
14954 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
14956}
Jeff Johnson295189b2012-06-20 16:38:30 -070014957/*--------------------------------------------------------------------------
14958 * This will receive and process the FT Pre Auth Rsp from the current
14959 * associated ap.
14960 *
14961 * This will invoke the hdd call back. This is so that hdd can now
14962 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
14963 ------------------------------------------------------------------------*/
14964void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
14965{
14966 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14967 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014968#ifdef FEATURE_WLAN_LFR
14969 tCsrRoamInfo roamInfo;
14970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014971
14972#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppa40b3c142013-02-20 07:24:43 -080014973 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070014974#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070014975#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppa40b3c142013-02-20 07:24:43 -080014976 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070014977 if (status != eHAL_STATUS_SUCCESS) {
14978 /*
14979 * Bail out if pre-auth was not even processed.
14980 */
14981 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
14982 return;
14983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 /* The below function calls/timers should be invoked only if the pre-auth is successful */
14986 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
14987 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 // Implies a success
14989 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
14991 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
14992 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
14994 * actual transition from the current to handoff AP is triggered */
14995 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
14996 60 * PAL_TIMER_TO_MS_UNIT,
14997 eANI_BOOLEAN_FALSE);
14998 if (eHAL_STATUS_SUCCESS != status)
14999 {
15000 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d\n"), status);
15001 return;
15002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 // Save the received response
15004 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15005 if (csrRoamIs11rAssoc(pMac))
15006 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15007 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15008
15009 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015010#ifdef FEATURE_WLAN_LFR
15011 // If Legacy Fast Roaming is enabled, signal the supplicant
15012 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015013 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015014 {
15015 // Save the bssid from the received response
15016 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15017 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15018 }
15019
15020#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015021
15022 // Done with it, init it.
15023 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15024}
15025#endif
15026#ifdef FEATURE_WLAN_BTAMP_UT_RF
15027void csrRoamJoinRetryTimerHandler(void *pv)
15028{
15029 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15030 tpAniSirGlobal pMac = pInfo->pMac;
15031 tANI_U32 sessionId = pInfo->sessionId;
15032 tCsrRoamSession *pSession;
15033
15034 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15035 {
15036 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d\n" ), sessionId );
15037 pSession = CSR_GET_SESSION( pMac, sessionId );
15038 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15039 {
15040 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15041 {
15042 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile\n" ) );
15043 }
15044 }
15045 }
15046}
Jeff Johnson295189b2012-06-20 16:38:30 -070015047eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15048{
15049 eHalStatus status = eHAL_STATUS_FAILURE;
15050 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15051
15052 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15053 {
15054 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left\n "), sessionId, pSession->maxRetryCount);
15055 pSession->maxRetryCount--;
15056 pSession->joinRetryTimerInfo.pMac = pMac;
15057 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15058 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15059 if(!HAL_STATUS_SUCCESS(status))
15060 {
15061 smsLog(pMac, LOGE, FL(" fail to start timer status %s \n "), status);
15062 }
15063 }
15064 else
15065 {
15066 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)\n "),
15067 pSession->maxRetryCount);
15068 }
15069
15070 return (status);
15071}
Jeff Johnson295189b2012-06-20 16:38:30 -070015072eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15073{
15074 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer \n ");
15075 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15076 {
15077 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15078 }
15079
15080 return eHAL_STATUS_SUCCESS;
15081}
15082#endif
15083
15084
15085/*
15086 pBuf points to the beginning of the message
15087 LIM packs disassoc rsp as below,
15088 messageType - 2 bytes
15089 messageLength - 2 bytes
15090 sessionId - 1 byte
15091 transactionId - 2 bytes (tANI_U16)
15092 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15093 peerMacAddr - 6 bytes
15094 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15095*/
15096static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15097{
15098 if(pBuf && pRsp)
15099 {
15100 pBuf += 4; //skip type and length
15101 pRsp->sessionId = *pBuf++;
15102 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15103 pBuf += 2;
15104 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15105 pBuf += 4;
15106 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15107 }
15108}
15109
Jeff Johnsond13512a2012-07-17 11:42:19 -070015110eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15111{
15112 static uNvTables nvTables;
15113 eHalStatus status = eHAL_STATUS_SUCCESS;
15114 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15115
15116 /* read the country code from NV and use it */
15117 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15118 {
15119 palCopyMemory( pMac->hHdd, pCountry,
15120 nvTables.defaultCountryTable.countryCode,
15121 WNI_CFG_COUNTRY_CODE_LEN );
15122 return status;
15123 }
15124 else
15125 {
15126 palCopyMemory( pMac->hHdd, pCountry,
15127 "XXX",
15128 WNI_CFG_COUNTRY_CODE_LEN );
15129 status = eHAL_STATUS_FAILURE;
15130 return status;
15131 }
15132}
15133
15134eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15135{
15136 palCopyMemory( pMac->hHdd, pCountry,
15137 pMac->scan.countryCode11d,
15138 WNI_CFG_COUNTRY_CODE_LEN );
15139 return eHAL_STATUS_SUCCESS;
15140}