blob: 37ea85251769e700e127f405607206ef00a9dca1 [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;
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 if( pState )
637 {
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;
Jeff Johnsone7245742012-09-05 17:12:55 -07001358#endif
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001359 pMac->scan.fIgnore_chan165 = pParam->fIgnore_chan165;
Gopichand Nakkalab7ed0a62013-01-04 11:41:02 -08001360 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 }
1362
1363 return status;
1364}
1365
Jeff Johnson295189b2012-06-20 16:38:30 -07001366eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1367{
1368 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001369 if(pParam)
1370 {
1371 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1372 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1373 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1374 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1375 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1376 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001377 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1378 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1380 pParam->phyMode = pMac->roam.configParam.phyMode;
1381 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1382 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1383 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1384 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1385 pParam->TxRate = pMac->roam.configParam.TxRate;
1386 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1387 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1388 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1389 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1390 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1392 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1393 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1394 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001395#ifdef WLAN_AP_STA_CONCURRENCY
1396 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1397 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1398 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1399 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1400 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Madan Mohan Koyyalamudi8591f092012-12-17 13:04:30 -08001401 pParam->nNumChanCombinedConc = pMac->roam.configParam.nNumChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 //Change the unit from microsecond to second
1404 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1405 pParam->eBand = pMac->roam.configParam.eBand;
1406 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1407 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1408 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1409 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1410 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1411 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1412 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1413 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1414 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1415 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1416 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1417 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1418 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1420 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1421 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1422 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1424 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1425 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1426 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001427 pParam->fIgnore_chan165= pMac->scan.fIgnore_chan165;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001429 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001430 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001431 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi441b91b2013-01-20 23:45:53 -08001432 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1435 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1436#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001437#ifdef WLAN_FEATURE_11AC
1438 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -08001439 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Jeff Johnsone7245742012-09-05 17:12:55 -07001440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001441
1442 csrSetChannels(pMac, pParam);
1443
1444 status = eHAL_STATUS_SUCCESS;
1445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 return (status);
1447}
1448
Jeff Johnson295189b2012-06-20 16:38:30 -07001449eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1450{
1451 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1452 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1453 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1454 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 do
1456 {
1457 if(eCSR_BAND_24 == eBand)
1458 {
1459 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1460 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1461 }
1462 if(eCSR_BAND_5G == eBand)
1463 {
1464 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1465 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1466 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1467 )
1468 {
1469 break;
1470 }
1471 }
1472 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1473 {
1474 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1475 }
1476 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1477 {
1478 newPhyMode = eCSR_DOT11_MODE_AUTO;
1479 }
1480 else
1481 {
1482 //Check for dual band and higher capability first
1483 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1484 {
1485 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1486 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1487 }
1488 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1489 {
1490 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1491 if(eCSR_BAND_24 == eBand) break;
1492 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1493 eBand = eCSR_BAND_5G;
1494 }
1495 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1496 {
1497 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1498 if(eCSR_BAND_5G == eBand) break;
1499 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1500 eBand = eCSR_BAND_24;
1501 }
1502 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1503 {
1504 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1505 if(eCSR_BAND_5G == eBand) break;
1506 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1507 eBand = eCSR_BAND_24;
1508 }
1509 else if(eCSR_DOT11_MODE_11n & phyMode)
1510 {
1511 newPhyMode = eCSR_DOT11_MODE_11n;
1512 }
1513 else if(eCSR_DOT11_MODE_abg & phyMode)
1514 {
1515 newPhyMode = eCSR_DOT11_MODE_abg;
1516 }
1517 else if(eCSR_DOT11_MODE_11a & phyMode)
1518 {
1519 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1520 {
1521 if(eCSR_BAND_ALL == eBand)
1522 {
1523 newPhyMode = eCSR_DOT11_MODE_abg;
1524 }
1525 else
1526 {
1527 //bad setting
1528 break;
1529 }
1530 }
1531 else
1532 {
1533 newPhyMode = eCSR_DOT11_MODE_11a;
1534 eBand = eCSR_BAND_5G;
1535 }
1536 }
1537 else if(eCSR_DOT11_MODE_11g & phyMode)
1538 {
1539 newPhyMode = eCSR_DOT11_MODE_11g;
1540 eBand = eCSR_BAND_24;
1541 }
1542 else if(eCSR_DOT11_MODE_11b & phyMode)
1543 {
1544 newPhyMode = eCSR_DOT11_MODE_11b;
1545 eBand = eCSR_BAND_24;
1546 }
1547 else
1548 {
1549 //We will never be here
1550 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X\n"), phyMode );
1551 newPhyMode = eCSR_DOT11_MODE_AUTO;
1552 }
1553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 //Done validating
1555 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 //Now we need to check whether a restart is needed.
1557 if(eBand != pMac->roam.configParam.eBand)
1558 {
1559 fRestartNeeded = eANI_BOOLEAN_TRUE;
1560 break;
1561 }
1562 if(newPhyMode != pMac->roam.configParam.phyMode)
1563 {
1564 fRestartNeeded = eANI_BOOLEAN_TRUE;
1565 break;
1566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 if(HAL_STATUS_SUCCESS(status))
1569 {
1570 pMac->roam.configParam.eBand = eBand;
1571 pMac->roam.configParam.phyMode = newPhyMode;
1572 if(pfRestartNeeded)
1573 {
1574 *pfRestartNeeded = fRestartNeeded;
1575 }
1576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 return (status);
1578}
1579
Jeff Johnson295189b2012-06-20 16:38:30 -07001580void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1581{
1582 tANI_U8 Index;
1583 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 // for dual band NICs, don't need to trim the channel list....
1585 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1586 {
1587 // 2.4 GHz band operation requires the channel list to be trimmed to
1588 // the 2.4 GHz channels only...
1589 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1590 {
1591 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1592 Index++ )
1593 {
1594 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1595 {
1596 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1597 cChannels++;
1598 }
1599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1601 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1602 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1603 // only if we need to.
1604 //
1605 // The amount of memory to clear is the number of channesl that we trimmed
1606 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1607
1608 if ( pChannelList->numChannels > cChannels )
1609 {
1610 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1611 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1612
1613 }
1614
1615 pChannelList->numChannels = cChannels;
1616 }
1617 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1618 {
1619 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1620 {
1621 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1622 {
1623 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1624 cChannels++;
1625 }
1626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1628 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1629 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1630 // only if we need to.
1631 //
1632 // The amount of memory to clear is the number of channesl that we trimmed
1633 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1634 if ( pChannelList->numChannels > cChannels )
1635 {
1636 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1637 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1638 }
1639
1640 pChannelList->numChannels = cChannels;
1641 }
1642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001643}
Jeff Johnson295189b2012-06-20 16:38:30 -07001644#ifdef WLAN_SOFTAP_FEATURE
1645#define INFRA_AP_DEFAULT_CHANNEL 6
1646eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1647{
1648 tANI_U8 index= 0;
1649 eHalStatus status = eHAL_STATUS_FAILURE;
1650 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1651 {
1652 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1653 status = eHAL_STATUS_SUCCESS;
1654 break;
1655 }
1656 }
1657 return status;
1658}
1659#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001660eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
1661{
1662 eHalStatus status = eHAL_STATUS_SUCCESS;
1663 tANI_U8 num20MHzChannelsFound = 0;
1664 VOS_STATUS vosStatus;
1665 tANI_U8 Index = 0;
1666 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001667
Jeff Johnson295189b2012-06-20 16:38:30 -07001668
1669 //TODO: this interface changed to include the 40MHz channel list
1670 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
1671 // Read the scan channel list (including the power limit) from EEPROM
1672 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1673 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1674 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1675 {
1676 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1677 status = eHAL_STATUS_FAILURE;
1678 }
1679 else
1680 {
1681 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1682 {
1683 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1684 }
1685 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1686 // Move the channel list to the global data
1687 // structure -- this will be used as the scan list
1688 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1689 {
1690#ifdef FEATURE_WLAN_INTEGRATED_SOC /* Need to fix this while dealing with NV item */
1691 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
1692#else
1693 pMac->scan.base20MHzChannels.channelList[ Index ] = Index + 1;
1694 pMac->scan.defaultPowerTable[Index].chanId = Index + 1;
1695 pMac->scan.defaultPowerTable[Index].pwr = 25;
1696#endif
1697 }
1698 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1699 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
1700 {
1701 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1702 }
1703 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1704 {
1705 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1706 }
1707 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 return (status);
1710}
1711
Jeff Johnson295189b2012-06-20 16:38:30 -07001712eHalStatus csrInitChannelList( tHalHandle hHal )
1713{
1714 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1715 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
1717 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kirand170dcb2013-01-31 10:43:43 -08001718 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
1719 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001720 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkala277e02b2012-12-21 08:03:42 -08001721 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001722
1723 return (status);
1724}
Jeff Johnson295189b2012-06-20 16:38:30 -07001725eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
1726 tCsrUpdateConfigParam *pUpdateConfigParam)
1727{
1728 eHalStatus status = eHAL_STATUS_FAILURE;
1729 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
1731 status = CsrInit11dInfo(pMac, ps11dinfo);
1732 return status;
1733}
1734
Jeff Johnson295189b2012-06-20 16:38:30 -07001735static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1736{
1737 eHalStatus status = eHAL_STATUS_FAILURE;
1738 tANI_U8 index;
1739 tANI_U32 count=0;
1740 tSirMacChanInfo *pChanInfo;
1741 tSirMacChanInfo *pChanInfoStart;
1742 tANI_BOOLEAN applyConfig = TRUE;
1743
1744 if(!ps11dinfo)
1745 {
1746 return (status);
1747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
1749 {
1750 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
1751 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
1752 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
1753 if(!HAL_STATUS_SUCCESS(status)) return (status);
1754 }
1755 else
1756 {
1757 //No change
1758 return (eHAL_STATUS_SUCCESS);
1759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 //legacy maintenance
1761 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
1762 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1763 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 //Tush: at csropen get this initialized with default, during csr reset if this
1765 // already set with some value no need initilaize with default again
1766 if(0 == pMac->scan.countryCodeCurrent[0])
1767 {
1768 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
1769 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1770 if(!HAL_STATUS_SUCCESS(status)) return (status);
1771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 // need to add the max power channel list
1773 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1774 {
1775 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1776 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07001777 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1778 {
1779 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1780 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1781 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1782 pChanInfo++;
1783 count++;
1784 }
1785 if(count)
1786 {
1787 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1788 }
1789 palFreeMemory(pMac->hHdd, pChanInfoStart);
1790 }
1791 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
1792 if( HAL_STATUS_SUCCESS(status) )
1793 {
1794 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
1795 {
1796 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
1797 {
1798 applyConfig = FALSE;
1799 }
1800 }
1801
1802 if(TRUE == applyConfig)
1803 {
1804 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkala277e02b2012-12-21 08:03:42 -08001805 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001806 }
1807
1808 }
1809 return (status);
1810}
1811/* Initialize the Channel + Power List in the local cache and in the CFG */
1812eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1813{
1814 tANI_U8 index;
1815 tANI_U32 count=0;
1816 tSirMacChanInfo *pChanInfo;
1817 tSirMacChanInfo *pChanInfoStart;
1818
1819 if(!ps11dinfo || !pMac)
1820 {
1821 return eHAL_STATUS_FAILURE;
1822 }
1823
1824 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1825 {
1826 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1827 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001828
1829 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1830 {
1831 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1832 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1833 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1834 pChanInfo++;
1835 count++;
1836 }
1837 if(count)
1838 {
1839 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1840 }
1841 palFreeMemory(pMac->hHdd, pChanInfoStart);
1842 }
1843
Jeff Johnsone7245742012-09-05 17:12:55 -07001844 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001845}
1846
1847//pCommand may be NULL
1848//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
1849void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
1850{
1851 tListElem *pEntry, *pNextEntry;
1852 tSmeCmd *pDupCommand;
1853 tDblLinkList localList;
1854
1855 vos_mem_zero(&localList, sizeof(tDblLinkList));
1856 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
1857 {
1858 smsLog(pMac, LOGE, FL(" failed to open list"));
1859 return;
1860 }
1861 csrLLLock( &pMac->sme.smeCmdPendingList );
1862 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
1863 while( pEntry )
1864 {
1865 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
1866 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 // Remove the previous command if..
1868 // - the new roam command is for the same RoamReason...
1869 // - the new roam command is a NewProfileList.
1870 // - the new roam command is a Forced Dissoc
1871 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
1872 if (
1873 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
1874 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08001875 /* This peermac check is requried for Softap/GO scenarios
1876 * For STA scenario below OR check will suffice as pCommand will
1877 * always be NULL for STA scenarios
1878 */
1879 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
1881 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
1882 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
1883 ||
1884 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07001885 ( (sessionId == pDupCommand->sessionId) &&
1886 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 ((eCsrForcedDisassoc == eRoamReason) ||
1888 (eCsrHddIssued == eRoamReason))
1889 )
1890 )
1891 {
1892 smsLog(pMac, LOGW, FL(" roamReason = %d\n"), pDupCommand->u.roamCmd.roamReason);
1893 // Remove the 'stale' roam command from the pending list...
1894 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
1895 {
1896 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
1897 }
1898 }
1899 pEntry = pNextEntry;
1900 }
1901 csrLLUnlock( &pMac->sme.smeCmdPendingList );
1902
1903 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
1904 {
1905 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
1906 //Tell caller that the command is cancelled
1907 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
1908 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
1909 csrReleaseCommandRoam(pMac, pDupCommand);
1910 }
1911 csrLLClose(&localList);
1912}
Jeff Johnson295189b2012-06-20 16:38:30 -07001913eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
1914 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
1915{
1916 eHalStatus status = eHAL_STATUS_SUCCESS;
1917#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
1918 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
1919#endif
1920 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
1922 {
1923 pSession = CSR_GET_SESSION( pMac, sessionId );
1924 }
1925 else
1926 {
1927 smsLog(pMac, LOGE, "Session ID:%d is not valid\n", sessionId);
1928 VOS_ASSERT(0);
1929 return eHAL_STATUS_FAILURE;
1930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
1932 {
1933 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d\n", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
1934 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001935 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
1936 /*
1937 * Decrement bRefAssocStartCnt for FT reassoc failure.
1938 * Reason: For FT reassoc failures, we first call
1939 * csrRoamCallCallback before notifying a failed roam
1940 * completion through csrRoamComplete. The latter in
1941 * turn calls csrRoamProcessResults which tries to
1942 * once again call csrRoamCallCallback if bRefAssocStartCnt
1943 * is non-zero. Since this is redundant for FT reassoc
1944 * failure, decrement bRefAssocStartCnt.
1945 */
1946 pSession->bRefAssocStartCnt--;
1947 }
1948
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 if ( (pSession == NULL) ||
1950 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
1951 {
1952 smsLog(pMac, LOG1, "Session ID is not valid\n");
1953 return eHAL_STATUS_FAILURE;
1954 }
1955
1956 if(NULL != pSession->callback)
1957 {
1958 if( pRoamInfo )
1959 {
1960 pRoamInfo->sessionId = (tANI_U8)sessionId;
1961 }
1962
1963 /* avoid holding the global lock when making the roaming callback , original change came
1964 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
1965 is possible on other OS ports where the callback may need to take locks to protect
1966 HDD state
1967 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
1968 that may actually depend on the lock being held */
1969 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
1970 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
1971 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
1972 }
1973 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
1974 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
1975#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
1976 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
1977 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
1978 {
1979 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
1980 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
1981 if(NULL != pRoamInfo->pBssDesc)
1982 {
1983 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
1984 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
1985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
1987 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
1988 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
1989 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
1990 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
1991 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
1994 {
1995 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
1996 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
1997 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 if(eCSR_ROAM_RESULT_FORCED == u2)
2000 {
2001 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2002 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2003 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2006 {
2007 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2008 connectionStatus.reason = eCSR_REASON_DISASSOC;
2009 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2012 {
2013 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2014 connectionStatus.reason = eCSR_REASON_DEAUTH;
2015 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002017#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2018
2019 return (status);
2020}
Jeff Johnson295189b2012-06-20 16:38:30 -07002021// Returns whether handoff is currently in progress or not
2022tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2023{
2024#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2025 return csrNeighborRoamIsHandoffInProgress(pMac);
2026#else
2027 return eANI_BOOLEAN_FALSE;
2028#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002029}
Jeff Johnson295189b2012-06-20 16:38:30 -07002030eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2031 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2032{
2033 eHalStatus status = eHAL_STATUS_SUCCESS;
2034 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2035 tANI_U16 reasonCode;
2036 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002037
2038 if(!pSession)
2039 {
2040 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2041 return eHAL_STATUS_FAILURE;
2042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002043
2044 //Restore AC weight in case we change it
2045 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2046 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002047 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 -07002048 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2049 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2050 }
2051
2052 if ( fMICFailure )
2053 {
2054 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2055 }
2056 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2057 {
2058 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002059 }
2060 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 {
2062 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002064#ifdef WLAN_FEATURE_VOWIFI_11R
2065 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2066 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2067 {
2068 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2069 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002070 }
2071 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002072#endif
2073 if(pSession->pConnectBssDesc)
2074 {
2075 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2076 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002077
Jeff Johnson295189b2012-06-20 16:38:30 -07002078
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002079 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2080 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2081 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2082
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2084
2085 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2086
2087 if(HAL_STATUS_SUCCESS(status))
2088 {
2089 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2091 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2092 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2093 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002094 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2096 }
2097#endif
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002098 }
2099 else
2100 {
2101 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2102 }
2103
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 return (status);
2105}
Jeff Johnson295189b2012-06-20 16:38:30 -07002106#ifdef WLAN_SOFTAP_FEATURE
2107
Jeff Johnson295189b2012-06-20 16:38:30 -07002108/* ---------------------------------------------------------------------------
2109 \fn csrRoamIssueDisassociateStaCmd
2110 \brief csr function that HDD calls to disassociate a associated station
2111 \param sessionId - session Id for Soft AP
2112 \param pPeerMacAddr - MAC of associated station to delete
2113 \param reason - reason code, be one of the tSirMacReasonCodes
2114 \return eHalStatus
2115 ---------------------------------------------------------------------------*/
2116eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2117 tANI_U32 sessionId,
2118 tANI_U8 *pPeerMacAddr,
2119 tANI_U32 reason)
2120{
2121 eHalStatus status = eHAL_STATUS_SUCCESS;
2122 tSmeCmd *pCommand;
2123
2124 do
2125 {
2126 pCommand = csrGetCommandBuffer( pMac );
2127 if ( !pCommand )
2128 {
2129 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2130 status = eHAL_STATUS_RESOURCES;
2131 break;
2132 }
2133 pCommand->command = eSmeCommandRoam;
2134 pCommand->sessionId = (tANI_U8)sessionId;
2135 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2136 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2137 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2138 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2139 if( !HAL_STATUS_SUCCESS( status ) )
2140 {
2141 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2142 csrReleaseCommandRoam( pMac, pCommand );
2143 }
2144 }while(0);
2145
2146 return status;
2147}
2148
2149
Jeff Johnson295189b2012-06-20 16:38:30 -07002150/* ---------------------------------------------------------------------------
2151 \fn csrRoamIssueDeauthSta
2152 \brief csr function that HDD calls to delete a associated station
2153 \param sessionId - session Id for Soft AP
2154 \param pPeerMacAddr - MAC of associated station to delete
2155 \param reason - reason code, be one of the tSirMacReasonCodes
2156 \return eHalStatus
2157 ---------------------------------------------------------------------------*/
2158eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2159 tANI_U32 sessionId,
2160 tANI_U8 *pPeerMacAddr,
2161 tANI_U32 reason)
2162{
2163 eHalStatus status = eHAL_STATUS_SUCCESS;
2164 tSmeCmd *pCommand;
2165
2166 do
2167 {
2168 pCommand = csrGetCommandBuffer( pMac );
2169 if ( !pCommand )
2170 {
2171 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2172 status = eHAL_STATUS_RESOURCES;
2173 break;
2174 }
2175 pCommand->command = eSmeCommandRoam;
2176 pCommand->sessionId = (tANI_U8)sessionId;
2177 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2178 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2179 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2180 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2181 if( !HAL_STATUS_SUCCESS( status ) )
2182 {
2183 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2184 csrReleaseCommandRoam( pMac, pCommand );
2185 }
2186 }while(0);
2187
2188 return status;
2189}
Jeff Johnson295189b2012-06-20 16:38:30 -07002190eHalStatus
2191csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2192 tANI_BOOLEAN bEnable )
2193{
2194 eHalStatus status = eHAL_STATUS_FAILURE;
2195 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2196 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 if (!pSession)
2198 {
2199 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found\n");
2200 return (status);
2201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 if (pSession->pConnectBssDesc)
2203 {
2204 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2205 }
2206 else
2207 {
2208 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found\n");
2209 return (status);
2210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d\n",
2212 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2213 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2215 return (status);
2216}
Jeff Johnson295189b2012-06-20 16:38:30 -07002217eHalStatus
2218csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2219 VOS_MODULE_ID modId, void *pUsrContext,
2220 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2221{
2222 eHalStatus status = eHAL_STATUS_SUCCESS;
2223 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2224 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 if (!pSession)
2226 {
2227 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found\n");
2228 return (status);
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 if(pSession->pConnectBssDesc)
2231 {
2232 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2233 }
2234 else
2235 {
2236 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found\n");
2237 return (status);
2238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2240 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2241 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2243 return (status);
2244}
Jeff Johnson295189b2012-06-20 16:38:30 -07002245eHalStatus
2246csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2247 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2248{
2249 eHalStatus status = eHAL_STATUS_SUCCESS;
2250 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2251 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2252
2253 if (!pSession)
2254 {
2255 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found\n");
2256 return (status);
2257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 if(pSession->pConnectBssDesc)
2259 {
2260 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2261 }
2262 else
2263 {
2264 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found\n");
2265 return (status);
2266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2268 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2269 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2270
2271 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2272
2273 return (status);
2274}
Jeff Johnson295189b2012-06-20 16:38:30 -07002275#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002276eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2277{
2278 eHalStatus status = eHAL_STATUS_SUCCESS;
2279 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2280 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002281
2282 if (!pSession)
2283 {
2284 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2285 return eHAL_STATUS_FAILURE;
2286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002287
2288 if(pSession->pConnectBssDesc)
2289 {
2290 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
2293 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2294 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2296
Madan Mohan Koyyalamudi64571a62013-01-30 19:59:23 +05302297 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08002298 if(!HAL_STATUS_SUCCESS(status))
2299 {
2300 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2301 }
2302
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 return (status);
2304}
2305
Jeff Johnson295189b2012-06-20 16:38:30 -07002306eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2307{
2308 eHalStatus status = eHAL_STATUS_SUCCESS;
2309 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2310 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002311
2312 if(!pSession)
2313 {
2314 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2315 return eHAL_STATUS_FAILURE;
2316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002317
2318 // If no BSS description was found in this connection (happens with start IBSS), then
2319 // nix the BSS description that we keep around for the connected BSS) and get out...
2320 if(NULL == pBssDesc)
2321 {
2322 csrFreeConnectBssDesc(pMac, sessionId);
2323 }
2324 else
2325 {
2326 size = pBssDesc->length + sizeof( pBssDesc->length );
2327 if(NULL != pSession->pConnectBssDesc)
2328 {
2329 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2330 {
2331 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2332 csrFreeConnectBssDesc(pMac, sessionId);
2333 }
2334 }
2335 if(NULL == pSession->pConnectBssDesc)
2336 {
2337 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2338 }
2339 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2340 {
2341 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2342 }
2343 }
2344
2345 return (status);
2346}
2347
Jeff Johnson295189b2012-06-20 16:38:30 -07002348eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2349 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2350 tDot11fBeaconIEs *pIes)
2351{
2352 eHalStatus status = eHAL_STATUS_SUCCESS;
2353 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002354#if defined(VOSS_ENABLED)
2355 VOS_ASSERT( pIes != NULL );
2356#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002357
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 do
2359 {
2360 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2361 //get qos
2362 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2363 //get SSID
2364 if(pIes->SSID.present)
2365 {
2366 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2367 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2368 }
2369 else
2370 pBssConfig->SSID.length = 0;
2371 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2372 {
2373 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard\n");
2374 //Return failed if profile doesn't have an SSID either.
2375 if(pProfile->SSIDs.numOfSSIDs == 0)
2376 {
2377 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID\n");
2378 status = eHAL_STATUS_FAILURE;
2379 break;
2380 }
2381 }
2382 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2383 {
2384 pBssConfig->eBand = eCSR_BAND_5G;
2385 }
2386 else
2387 {
2388 pBssConfig->eBand = eCSR_BAND_24;
2389 }
2390 //phymode
2391 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2392 {
2393 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2394 }
2395 else
2396 {
2397 smsLog(pMac, LOGW, " Can not find match phy mode\n");
2398 //force it
2399 if(eCSR_BAND_24 == pBssConfig->eBand)
2400 {
2401 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2402 }
2403 else
2404 {
2405 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2406 }
2407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 //Qos
2409 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2410 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2411 {
2412 //Joining BSS is not 11n capable and WMM is disabled on client.
2413 //Disable QoS and WMM
2414 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2415 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302416
2417 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302418 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302419 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2420 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2421 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2422 {
2423 //Joining BSS is 11n capable and WMM is disabled on AP.
2424 //Assume all HT AP's are QOS AP's and enable WMM
2425 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2426 }
2427
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 //auth type
2429 switch( pProfile->negotiatedAuthType )
2430 {
2431 default:
2432 case eCSR_AUTH_TYPE_WPA:
2433 case eCSR_AUTH_TYPE_WPA_PSK:
2434 case eCSR_AUTH_TYPE_WPA_NONE:
2435 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2436 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 case eCSR_AUTH_TYPE_SHARED_KEY:
2439 pBssConfig->authType = eSIR_SHARED_KEY;
2440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 case eCSR_AUTH_TYPE_AUTOSWITCH:
2442 pBssConfig->authType = eSIR_AUTO_SWITCH;
2443 break;
2444 }
2445 //short slot time
2446 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2447 {
2448 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2449 }
2450 else
2451 {
2452 pBssConfig->uShortSlotTime = 0;
2453 }
2454 if(pBssConfig->BssCap.ibss)
2455 {
2456 //We don't support 11h on IBSS
2457 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2458 }
2459 else
2460 {
2461 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2462 }
2463 //power constraint
2464 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2465 //heartbeat
2466 if ( CSR_IS_11A_BSS( pBssDesc ) )
2467 {
2468 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2469 }
2470 else
2471 {
2472 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2473 }
2474 //Join timeout
2475 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002476 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 if ( pBssDesc->beaconInterval )
2478 {
2479 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002480 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 }
2482 else
2483 {
2484 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2485 }
2486 //validate CB
2487 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2488 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 return (status);
2490}
2491
Jeff Johnson295189b2012-06-20 16:38:30 -07002492static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2493 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2494{
2495 eHalStatus status = eHAL_STATUS_SUCCESS;
2496 tANI_U8 operationChannel = 0;
2497 tANI_U8 qAPisEnabled = FALSE;
2498 //SSID
2499 pBssConfig->SSID.length = 0;
2500 if(pProfile->SSIDs.numOfSSIDs)
2501 {
2502 //only use the first one
2503 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2504 }
2505 else
2506 {
2507 //SSID must present
2508 return eHAL_STATUS_FAILURE;
2509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 //Settomg up the capabilities
2511 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2512 {
2513 pBssConfig->BssCap.ibss = 1;
2514 }
2515 else
2516 {
2517 pBssConfig->BssCap.ess = 1;
2518 }
2519 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2520 {
2521 pBssConfig->BssCap.privacy = 1;
2522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 pBssConfig->eBand = pMac->roam.configParam.eBand;
2524 //phymode
2525 if(pProfile->ChannelInfo.ChannelList)
2526 {
2527 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002529#ifdef WLAN_SOFTAP_FEATURE
2530 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2531 &pBssConfig->eBand);
2532#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel,
2534 &pBssConfig->eBand);
2535#endif
2536 //QOS
2537 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 if ( pBssConfig->BssCap.ess == 1 )
2539 {
2540#ifdef WLAN_SOFTAP_FEATURE
2541 /*For Softap case enable WMM*/
2542 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2543 qAPisEnabled = TRUE;
2544 }
2545 else
2546#endif
2547 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2548 qAPisEnabled = TRUE;
2549 } else {
2550 qAPisEnabled = FALSE;
2551 }
2552 } else {
2553 qAPisEnabled = TRUE;
2554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2556 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2557 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2558 )
2559 {
2560 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2561 } else {
2562 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2563 }
2564
2565 //auth type
Jeff Johnson3d30ed12012-12-10 14:41:22 -08002566 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 {
2568 default:
2569 case eCSR_AUTH_TYPE_WPA:
2570 case eCSR_AUTH_TYPE_WPA_PSK:
2571 case eCSR_AUTH_TYPE_WPA_NONE:
2572 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2573 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2574 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 case eCSR_AUTH_TYPE_SHARED_KEY:
2576 pBssConfig->authType = eSIR_SHARED_KEY;
2577 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 case eCSR_AUTH_TYPE_AUTOSWITCH:
2579 pBssConfig->authType = eSIR_AUTO_SWITCH;
2580 break;
2581 }
2582 //short slot time
2583 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2584 {
2585 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2586 }
2587 else
2588 {
2589 pBssConfig->uShortSlotTime = 0;
2590 }
2591 //power constraint. We don't support 11h on IBSS
2592 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2593 pBssConfig->uPowerLimit = 0;
2594 //heartbeat
2595 if ( eCSR_BAND_5G == pBssConfig->eBand )
2596 {
2597 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2598 }
2599 else
2600 {
2601 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2602 }
2603 //Join timeout
2604 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002605
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 return (status);
2607}
Jeff Johnson295189b2012-06-20 16:38:30 -07002608static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2609{
2610 eHalStatus status = eHAL_STATUS_FAILURE;
2611 tDot11fBeaconIEs *pIes = NULL;
2612
2613 do
2614 {
2615 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2616 {
2617 //err msg
2618 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2619 "csrRoamGetQosInfoFromBss() failed\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 break;
2621 }
2622 //check if the AP is QAP & it supports APSD
2623 if( CSR_IS_QOS_BSS(pIes) )
2624 {
2625 return eHAL_STATUS_SUCCESS;
2626 }
2627 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 return status;
2629}
2630
Jeff Johnson295189b2012-06-20 16:38:30 -07002631void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2632{
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2634 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2635 // See !!Note: below in this function...
2636 tANI_U32 PrivacyEnabled = 0;
2637 tANI_U32 RsnEnabled = 0;
2638 tANI_U32 WepDefaultKeyId = 0;
2639 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2640 tANI_U32 Key0Length = 0;
2641 tANI_U32 Key1Length = 0;
2642 tANI_U32 Key2Length = 0;
2643 tANI_U32 Key3Length = 0;
2644
2645 // Reserve for the biggest key
2646 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2647 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2648 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2649 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2650
2651 switch ( pProfile->negotiatedUCEncryptionType )
2652 {
2653 case eCSR_ENCRYPT_TYPE_NONE:
2654
2655 // for NO encryption, turn off Privacy and Rsn.
2656 PrivacyEnabled = 0;
2657 RsnEnabled = 0;
2658
2659 // WEP key length and Wep Default Key ID don't matter in this case....
2660
2661 // clear out the WEP keys that may be hanging around.
2662 Key0Length = 0;
2663 Key1Length = 0;
2664 Key2Length = 0;
2665 Key3Length = 0;
2666
2667 break;
2668
2669 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2670
2671 // Privacy is ON. NO RSN for Wep40 static key.
2672 PrivacyEnabled = 1;
2673 RsnEnabled = 0;
2674
2675 // Set the Wep default key ID.
2676 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 // Wep key size if 5 bytes (40 bits).
2678 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2679
2680 // set encryption keys in the CFG database or clear those that are not present in this profile.
2681 if ( pProfile->Keys.KeyLength[0] )
2682 {
2683 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2684 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2685 }
2686 else
2687 {
2688 Key0Length = 0;
2689 }
2690
2691 if ( pProfile->Keys.KeyLength[1] )
2692 {
2693 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2694 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2695 }
2696 else
2697 {
2698 Key1Length = 0;
2699 }
2700
2701 if ( pProfile->Keys.KeyLength[2] )
2702 {
2703 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2704 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2705 }
2706 else
2707 {
2708 Key2Length = 0;
2709 }
2710
2711 if ( pProfile->Keys.KeyLength[3] )
2712 {
2713 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2714 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2715 }
2716 else
2717 {
2718 Key3Length = 0;
2719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 break;
2721
2722 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2723
2724 // Privacy is ON. NO RSN for Wep40 static key.
2725 PrivacyEnabled = 1;
2726 RsnEnabled = 0;
2727
2728 // Set the Wep default key ID.
2729 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2730
2731 // Wep key size if 13 bytes (104 bits).
2732 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2733
2734 // set encryption keys in the CFG database or clear those that are not present in this profile.
2735 if ( pProfile->Keys.KeyLength[0] )
2736 {
2737 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2738 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2739 }
2740 else
2741 {
2742 Key0Length = 0;
2743 }
2744
2745 if ( pProfile->Keys.KeyLength[1] )
2746 {
2747 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2748 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2749 }
2750 else
2751 {
2752 Key1Length = 0;
2753 }
2754
2755 if ( pProfile->Keys.KeyLength[2] )
2756 {
2757 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2758 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2759 }
2760 else
2761 {
2762 Key2Length = 0;
2763 }
2764
2765 if ( pProfile->Keys.KeyLength[3] )
2766 {
2767 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2768 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
2769 }
2770 else
2771 {
2772 Key3Length = 0;
2773 }
2774
2775 break;
2776
2777 case eCSR_ENCRYPT_TYPE_WEP40:
2778 case eCSR_ENCRYPT_TYPE_WEP104:
2779 case eCSR_ENCRYPT_TYPE_TKIP:
2780 case eCSR_ENCRYPT_TYPE_AES:
2781#ifdef FEATURE_WLAN_WAPI
2782 case eCSR_ENCRYPT_TYPE_WPI:
2783#endif /* FEATURE_WLAN_WAPI */
2784 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
2785 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
2786 PrivacyEnabled = (0 != fPrivacy);
2787
2788 // turn on RSN enabled for WPA associations
2789 RsnEnabled = 1;
2790
2791 // WEP key length and Wep Default Key ID don't matter in this case....
2792
2793 // clear out the static WEP keys that may be hanging around.
2794 Key0Length = 0;
2795 Key1Length = 0;
2796 Key2Length = 0;
2797 Key3Length = 0;
2798
2799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 default:
2801 PrivacyEnabled = 0;
2802 RsnEnabled = 0;
2803 break;
2804 }
2805
2806 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
2807 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
2808 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
2809 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
2810 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
2811 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
2812 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
2813 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
2814}
2815
Jeff Johnson295189b2012-06-20 16:38:30 -07002816static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
2817{
2818 tANI_U32 len = 0;
2819 if(pSSID->length <= WNI_CFG_SSID_LEN)
2820 {
2821 len = pSSID->length;
2822 }
2823 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
2824}
2825
Jeff Johnson295189b2012-06-20 16:38:30 -07002826eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
2827{
2828 eHalStatus status = eHAL_STATUS_SUCCESS;
2829 tANI_U32 QoSEnabled;
2830 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 // set the CFG enable/disable variables based on the qosType being configured...
2832 switch( qosType )
2833 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
2835 QoSEnabled = FALSE;
2836 WmeEnabled = TRUE;
2837 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
2839 QoSEnabled = FALSE;
2840 WmeEnabled = TRUE;
2841 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
2843 QoSEnabled = FALSE;
2844 WmeEnabled = TRUE;
2845 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 case eCSR_MEDIUM_ACCESS_11e_eDCF:
2847 QoSEnabled = TRUE;
2848 WmeEnabled = FALSE;
2849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 case eCSR_MEDIUM_ACCESS_11e_HCF:
2851 QoSEnabled = TRUE;
2852 WmeEnabled = FALSE;
2853 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 default:
2855 case eCSR_MEDIUM_ACCESS_DCF:
2856 QoSEnabled = FALSE;
2857 WmeEnabled = FALSE;
2858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 }
2860 //save the WMM setting for later use
2861 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
2863 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 return (status);
2865}
Jeff Johnson295189b2012-06-20 16:38:30 -07002866static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
2867 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
2868{
2869 eHalStatus status = eHAL_STATUS_FAILURE;
2870 int i;
2871 eCsrCfgDot11Mode cfgDot11Mode;
2872 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
2874 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07002875#if defined(VOSS_ENABLED)
2876 VOS_ASSERT( pIes != NULL );
2877#endif
2878
2879 if( NULL != pIes )
2880 {
2881 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 // Originally, we thought that for 11a networks, the 11a rates are always
2883 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
2884 // appear in the Operational Rate set. Consequently, in either case, we
2885 // would blindly put the rates we support into our Operational Rate set
2886 // (including the basic rates, which we have already verified are
2887 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 // However, it turns out that this is not always the case. Some AP's
2889 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
2890 // too. Now, we're a little more careful:
2891 pDstRate = pOpRateSet->rate;
2892 if(pIes->SuppRates.present)
2893 {
2894 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
2895 {
2896 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
2897 {
2898 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002899 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 }
2901 }
2902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
2904 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
2905 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
2906 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
2907 {
2908 // If there are Extended Rates in the beacon, we will reflect those
2909 // extended rates that we support in out Extended Operational Rate
2910 // set:
2911 pDstRate = pExRateSet->rate;
2912 if(pIes->ExtSuppRates.present)
2913 {
2914 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
2915 {
2916 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
2917 {
2918 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
2919 pExRateSet->numRates++;
2920 }
2921 }
2922 }
2923 }
2924 }//Parsing BSSDesc
2925 else
2926 {
2927 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
2928 }
2929 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
2930 return status;
2931}
2932
2933static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
2934 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
2935{
2936 int i;
2937 tANI_U8 *pDstRate;
2938 eCsrCfgDot11Mode cfgDot11Mode;
2939 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
2940 tANI_U32 OperationalRatesLength = 0;
2941 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
2942 tANI_U32 ExtendedOperationalRatesLength = 0;
2943 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
2944 tANI_U32 ProprietaryOperationalRatesLength = 0;
2945 tANI_U32 PropRatesEnable = 0;
2946 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
2947 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002948#if defined(VOSS_ENABLED)
2949 VOS_ASSERT( pIes != NULL );
2950#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 if( NULL != pIes )
2952 {
2953 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 // Originally, we thought that for 11a networks, the 11a rates are always
2955 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
2956 // appear in the Operational Rate set. Consequently, in either case, we
2957 // would blindly put the rates we support into our Operational Rate set
2958 // (including the basic rates, which we have already verified are
2959 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 // However, it turns out that this is not always the case. Some AP's
2961 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
2962 // too. Now, we're a little more careful:
2963 pDstRate = OperationalRates;
2964 if(pIes->SuppRates.present)
2965 {
2966 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
2967 {
2968 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
2969 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
2970 {
2971 *pDstRate++ = pIes->SuppRates.rates[ i ];
2972 OperationalRatesLength++;
2973 }
2974 }
2975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
2977 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
2978 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
2979 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
2980 {
2981 // If there are Extended Rates in the beacon, we will reflect those
2982 // extended rates that we support in out Extended Operational Rate
2983 // set:
2984 pDstRate = ExtendedOperationalRates;
2985 if(pIes->ExtSuppRates.present)
2986 {
2987 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
2988 {
2989 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
2990 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
2991 {
2992 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
2993 ExtendedOperationalRatesLength++;
2994 }
2995 }
2996 }
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 // Enable proprietary MAC features if peer node is Airgo node and STA
2999 // user wants to use them
3000 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3001 {
3002 PropRatesEnable = 1;
3003 }
3004 else
3005 {
3006 PropRatesEnable = 0;
3007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 // For ANI network companions, we need to populate the proprietary rate
3009 // set with any proprietary rates we found in the beacon, only if user
3010 // allows them...
3011 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3012 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3013 {
3014 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3015 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3016 {
3017 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3018 }
3019 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3020 }
3021 else {
3022 // No proprietary modes...
3023 ProprietaryOperationalRatesLength = 0;
3024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 /* Get MCS Rate */
3026 pDstRate = MCSRateIdxSet;
3027 if ( pIes->HTCaps.present )
3028 {
3029 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3030 {
3031 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3032 {
3033 MCSRateLength++;
3034 *pDstRate++ = i;
3035 }
3036 }
3037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 // Set the operational rate set CFG variables...
3039 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3040 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3041 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3042 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3043 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3044 ProprietaryOperationalRates,
3045 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3046 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3047 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3048 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3049 }//Parsing BSSDesc
3050 else
3051 {
3052 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3053 }
3054}
3055
Jeff Johnson295189b2012-06-20 16:38:30 -07003056static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3057 tCsrRoamProfile *pProfile )
3058{
3059 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3060 { 8,
3061 { SIR_MAC_RATE_6,
3062 SIR_MAC_RATE_9,
3063 SIR_MAC_RATE_12,
3064 SIR_MAC_RATE_18,
3065 SIR_MAC_RATE_24,
3066 SIR_MAC_RATE_36,
3067 SIR_MAC_RATE_48,
3068 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3070 { 4,
3071 { SIR_MAC_RATE_1,
3072 SIR_MAC_RATE_2,
3073 SIR_MAC_RATE_5_5,
3074 SIR_MAC_RATE_11 } } };
3075
3076
3077 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3078 { SIR_MAC_RATE_72,
3079 SIR_MAC_RATE_96,
3080 SIR_MAC_RATE_108 } };
3081 eCsrCfgDot11Mode cfgDot11Mode;
3082 eCsrBand eBand;
3083 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3084 tANI_U32 OperationalRatesLength = 0;
3085 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3086 tANI_U32 ExtendedOperationalRatesLength = 0;
3087 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3088 tANI_U32 ProprietaryOperationalRatesLength = 0;
3089 tANI_U32 PropRatesEnable = 0;
3090 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 if(pProfile->ChannelInfo.ChannelList)
3092 {
3093 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003095#ifdef WLAN_SOFTAP_FEATURE
3096 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
3097#else
3098 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel, &eBand );
3099#endif
3100 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3101 // networks, the 11b rates appear in the Operational Rate set. In either case,
3102 // we can blindly put the rates we support into our Operational Rate set
3103 // (including the basic rates, which we have already verified are supported
3104 // earlier in the roaming decision).
3105 if ( eCSR_BAND_5G == eBand )
3106 {
3107 // 11a rates into the Operational Rate Set.
3108 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3109 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3110 palCopyMemory( pMac->hHdd, OperationalRates,
3111 DefaultSupportedRates11a.supportedRateSet.rate,
3112 OperationalRatesLength );
3113
3114 // Nothing in the Extended rate set.
3115 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 // populate proprietary rates if user allows them
3117 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3118 {
3119 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3120 sizeof(*DefaultSupportedPropRates.propRate);
3121 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3122 DefaultSupportedPropRates.propRate,
3123 ProprietaryOperationalRatesLength );
3124 }
3125 else
3126 {
3127 // No proprietary modes
3128 ProprietaryOperationalRatesLength = 0;
3129 }
3130 }
3131 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3132 {
3133 // 11b rates into the Operational Rate Set.
3134 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3135 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3136 palCopyMemory( pMac->hHdd, OperationalRates,
3137 DefaultSupportedRates11b.supportedRateSet.rate,
3138 OperationalRatesLength );
3139 // Nothing in the Extended rate set.
3140 ExtendedOperationalRatesLength = 0;
3141 // No proprietary modes
3142 ProprietaryOperationalRatesLength = 0;
3143 }
3144 else
3145 {
3146 // 11G
3147
3148 // 11b rates into the Operational Rate Set.
3149 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3150 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3151 palCopyMemory( pMac->hHdd, OperationalRates,
3152 DefaultSupportedRates11b.supportedRateSet.rate,
3153 OperationalRatesLength );
3154
3155 // 11a rates go in the Extended rate set.
3156 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3157 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3158 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3159 DefaultSupportedRates11a.supportedRateSet.rate,
3160 ExtendedOperationalRatesLength );
3161
3162 // populate proprietary rates if user allows them
3163 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3164 {
3165 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3166 sizeof(*DefaultSupportedPropRates.propRate);
3167 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3168 DefaultSupportedPropRates.propRate,
3169 ProprietaryOperationalRatesLength );
3170 }
3171 else
3172 {
3173 // No proprietary modes
3174 ProprietaryOperationalRatesLength = 0;
3175 }
3176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3178 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3179 {
3180 PropRatesEnable = 1;
3181 }
3182 else
3183 {
3184 PropRatesEnable = 0;
3185 }
3186
3187 // Set the operational rate set CFG variables...
3188 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3189 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3190 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3191 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3192 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3193 ProprietaryOperationalRates,
3194 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3195 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003196}
Jeff Johnson295189b2012-06-20 16:38:30 -07003197void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3198{
3199 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3202 tANI_U32 sessionId;
3203 tSmeCmd *pCommand = NULL;
3204
3205 if(NULL == pEntry)
3206 {
3207 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
3208 return;
3209 }
3210 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3211 sessionId = pCommand->sessionId;
3212
3213 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3214 {
3215 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3216 }
3217}
3218
Jeff Johnson295189b2012-06-20 16:38:30 -07003219//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3220tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3221{
3222 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3223 {
3224 return (WNI_CFG_PHY_MODE_11B);
3225 }
3226 else
3227 {
3228 if(eCSR_BAND_24 == band)
3229 return (WNI_CFG_PHY_MODE_11G);
3230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 return (WNI_CFG_PHY_MODE_11A);
3232}
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
Jeff Johnsone7245742012-09-05 17:12:55 -07003234
3235#ifdef WLAN_FEATURE_11AC
3236ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3237{
3238 switch ( aniCBMode )
3239 {
3240 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3241 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3242 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3243 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3244 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3245 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3246 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3247 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3248 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003249 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003250 return PHY_SINGLE_CHANNEL_CENTERED;
3251 }
3252}
3253#endif
3254
Jeff Johnson295189b2012-06-20 16:38:30 -07003255//pIes may be NULL
3256eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3257 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3258 tDot11fBeaconIEs *pIes)
3259{
3260 eHalStatus status = eHAL_STATUS_SUCCESS;
3261 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3262 tANI_U8 channel = 0;
3263 //Make sure we have the domain info for the BSS we try to connect to.
3264 //Do we need to worry about sequence for OSs that are not Windows??
3265 if(pBssDesc)
3266 {
3267 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3268 {
3269 //Make sure the 11d info from this BSSDesc can be applied
3270 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3271 csrApplyCountryInformation( pMac, TRUE );
3272 }
Kirand170dcb2013-01-31 10:43:43 -08003273 if ((csrIs11dSupported (pMac)) && pIes)
3274 {
3275 if (!pIes->Country.present)
3276 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 //Qos
3280 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3281 //SSID
3282 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3283 //fragment threshold
3284 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3285 //RTS threshold
3286 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3287
3288 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3289
3290 //Auth type
3291 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3292 //encryption type
3293 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3294 //short slot time
3295 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003296#ifdef WLAN_SOFTAP_FEATURE
3297 //11d
3298 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3299 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3300 NULL, eANI_BOOLEAN_FALSE);
3301#endif
3302 /*//11h
3303 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3304 */
3305 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3306 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003307
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3309 {
3310 channel = pProfile->operationChannel;
3311 }
3312 else
3313 {
3314 if(pBssDesc)
3315 {
3316 channel = pBssDesc->channelId;
3317 }
3318 }
3319 if(0 != channel)
3320 {
3321 if(CSR_IS_CHANNEL_24GHZ(channel))
3322 {//for now if we are on 2.4 Ghz, CB will be always disabled
3323 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3324 }
3325 else
3326 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003327 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 }
3329 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003330#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003331 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3332 // in function csrConvertCBIniValueToPhyCBState()
3333 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3334 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003335 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003336 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003337 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003338 }
3339 else
3340 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003341 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003342 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003343 }
3344 else
3345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3347 //Rate
3348 //Fixed Rate
3349 if(pBssDesc)
3350 {
3351 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3352 }
3353 else
3354 {
3355 csrSetCfgRateSetFromProfile(pMac, pProfile);
3356 }
3357 //Make this the last CFG to set. The callback will trigger a join_req
3358 //Join time out
3359 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3360
3361 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 return (status);
3363}
3364
Jeff Johnson295189b2012-06-20 16:38:30 -07003365eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3366 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3367{
3368 eHalStatus status;
3369 tBssConfigParam *pBssConfig;
3370 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003371
3372 if(!pSession)
3373 {
3374 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3375 return eHAL_STATUS_FAILURE;
3376 }
3377
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3379 if(HAL_STATUS_SUCCESS(status))
3380 {
3381 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3382 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3383 if(HAL_STATUS_SUCCESS(status))
3384 {
3385 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003386 /* This will allow to pass cbMode during join req */
3387 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 //For IBSS, we need to prepare some more information
3389 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
3390#ifdef WLAN_SOFTAP_FEATURE
3391 || CSR_IS_INFRA_AP(pProfile)
3392#endif
3393 )
3394 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003395 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 }
3397 // If we are in an IBSS, then stop the IBSS...
3398 ////Not worry about WDS connection for now
3399 if ( csrIsConnStateIbss( pMac, sessionId ) )
3400 {
3401 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3402 }
3403 else
3404 {
3405 // if we are in an Infrastructure association....
3406 if ( csrIsConnStateInfra( pMac, sessionId ) )
3407 {
3408 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3409 // across SSIDs (roaming to a new SSID)... //
3410 //Not worry about WDS connection for now
3411 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3412 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3413 {
3414 // then we need to disassociate from the Infrastructure network...
3415 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3416 }
3417 else
3418 {
3419 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3420 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3421 if ( pBssDesc )
3422 {
3423 // Set parameters for this Bss.
3424 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3425 }
3426 }
3427 }
3428 else
3429 {
3430 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3431 // Nothing to stop.
3432 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
3433#ifdef WLAN_SOFTAP_FEATURE
3434 || CSR_IS_INFRA_AP(pProfile)
3435#endif
3436 )
3437 {
3438 // Set parameters for this Bss.
3439 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3440 }
3441 }
3442 }
3443 }//Success getting BSS config info
3444 palFreeMemory(pMac->hHdd, pBssConfig);
3445 }//Allocate memory
3446
3447 return (status);
3448}
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3451 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3452{
3453 eCsrJoinState eRoamState = eCsrContinueRoaming;
3454 eHalStatus status;
3455 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3456 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3457 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003458
3459 if(!pSession)
3460 {
3461 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3462 return (eCsrStopRoaming);
3463 }
3464
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 if( CSR_IS_WDS_STA( pProfile ) )
3466 {
3467 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3468 if( !HAL_STATUS_SUCCESS( status ) )
3469 {
3470 eRoamState = eCsrStopRoaming;
3471 }
3472 }
3473 else
3474 {
3475 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3476 {
3477 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3478 return (eCsrStopRoaming);
3479 }
3480 if ( csrIsInfraBssDesc( pBssDesc ) )
3481 {
3482 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3483 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3484 // have changed and handle the changes (without disturbing the current association).
3485
3486 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3487 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3488 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3489 )
3490 {
3491 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3492 // with Authenticating first. To force this, stop the current association (Disassociate) and
3493 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3494 // a new Association.
3495 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3496 {
3497 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d\n"), pProfile->AuthType, pProfile->EncryptionType);
3498 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3499 {
3500 eRoamState = eCsrReassocToSelfNoCapChange;
3501 }
3502 else
3503 {
3504 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 //The key changes
3506 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3507 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3508 if(HAL_STATUS_SUCCESS(status))
3509 {
3510 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003511 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 //Reapply the config including Keys so reassoc is happening.
3513 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3514 if(!HAL_STATUS_SUCCESS(status))
3515 {
3516 eRoamState = eCsrStopRoaming;
3517 }
3518 }
3519 else
3520 {
3521 eRoamState = eCsrStopRoaming;
3522 }
3523 }//same profile
3524 }
3525 else
3526 {
3527 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3528 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3529 {
3530 smsLog(pMac, LOGW, FL(" fail to issue disassociate\n"));
3531 eRoamState = eCsrStopRoaming;
3532 }
3533 }
3534 }
3535 else
3536 {
3537 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3538 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3539 // work much better.
3540 //
3541 //
3542 // stop the existing network before attempting to join the new network...
3543 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3544 {
3545 eRoamState = eCsrStopRoaming;
3546 }
3547 }
3548 }//Infra
3549 else
3550 {
3551 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3552 {
3553 eRoamState = eCsrStopRoaming;
3554 }
3555 }
3556 if( pIesLocal && !pScanResult->pvIes )
3557 {
3558 palFreeMemory(pMac->hHdd, pIesLocal);
3559 }
3560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 return( eRoamState );
3562}
3563
Jeff Johnson295189b2012-06-20 16:38:30 -07003564eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3565 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3566{
3567 eHalStatus status = eHAL_STATUS_SUCCESS;
3568 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3570 roamInfo.pBssDesc = pBssDesc;
3571 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3572 return (status);
3573}
Jeff Johnson295189b2012-06-20 16:38:30 -07003574//In case no matching BSS is found, use whatever default we can find
3575static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3576{
3577 //Need to get all negotiated types in place first
3578 //auth type
Jeff Johnson3d30ed12012-12-10 14:41:22 -08003579 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 {
3581 default:
3582 case eCSR_AUTH_TYPE_WPA:
3583 case eCSR_AUTH_TYPE_WPA_PSK:
3584 case eCSR_AUTH_TYPE_WPA_NONE:
3585 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3586 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3587 break;
3588
3589 case eCSR_AUTH_TYPE_SHARED_KEY:
3590 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3591 break;
3592
3593 case eCSR_AUTH_TYPE_AUTOSWITCH:
3594 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3595 break;
3596 }
3597 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3598 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3599 //In this case, the multicast encryption needs to follow the uncast ones.
3600 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3601 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3602}
3603
3604static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3605{
3606 eHalStatus status;
3607 tCsrScanResult *pScanResult = NULL;
3608 eCsrJoinState eRoamState = eCsrStopRoaming;
3609 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3610 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3611 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3612#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3613 v_U8_t acm_mask = 0;
3614#endif
3615 tANI_U32 sessionId = pCommand->sessionId;
3616 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3617 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3618 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003619
3620 if(!pSession)
3621 {
3622 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3623 return (eCsrStopRoaming);
3624 }
3625
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 do
3627 {
3628 // Check for Cardbus eject condition, before trying to Roam to any BSS
3629 //***if( !balIsCardPresent(pAdapter) ) break;
3630
3631 if(NULL != pBSSList)
3632 {
3633 // When handling AP's capability change, continue to associate to
3634 // same BSS and make sure pRoamBssEntry is not Null.
3635 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3636 {
3637 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3638 {
3639 //Try the first BSS
3640 pCommand->u.roamCmd.pLastRoamBss = NULL;
3641 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3642 }
3643 else
3644 {
3645 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3646 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3647 {
3648 //Done with all the BSSs
3649 //In this case, will tell HDD the completion
3650 break;
3651 }
3652 else
3653 {
3654 //We need to indicate to HDD that we are done with this one.
3655 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3656 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3657 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3658 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3659 pRoamInfo = &roamInfo;
3660 }
3661 }
3662 while(pCommand->u.roamCmd.pRoamBssEntry)
3663 {
3664 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 /*If concurrency enabled take the concurrent connected channel first. */
3666 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07003667 if (vos_concurrent_sessions_running() &&
3668 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 {
3670 concurrentChannel =
3671 csrGetConcurrentOperationChannel(pMac);
3672 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003673 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 if ((concurrentChannel) &&
3675 (concurrentChannel ==
3676 pScanResult->Result.BssDescriptor.channelId))
3677 {
3678 //make this 0 because we do not want the
3679 //below check to pass as we don't want to
3680 //connect on other channel
3681 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3682 FL("Concurrent channel match =%d"),
3683 concurrentChannel);
3684 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 }
3686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003687
3688 if (!concurrentChannel)
3689 {
3690
3691 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3692 sessionId, &pScanResult->Result.BssDescriptor,
3693 pCommand->u.roamCmd.roamId)))
3694 {
3695 //Ok to roam this
3696 break;
3697 }
3698 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003699 else
3700 {
3701 eRoamState = eCsrStopRoamingDueToConcurrency;
3702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3704 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3705 {
3706 //Done with all the BSSs
3707 fDone = eANI_BOOLEAN_TRUE;
3708 break;
3709 }
3710 }
3711 if(fDone)
3712 {
3713 break;
3714 }
3715 }
3716 }
3717 //We have something to roam, tell HDD when it is infra.
3718 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3719 //For WDS, the indication is eCSR_ROAM_WDS_IND
3720 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3721 {
3722 if(pRoamInfo)
3723 {
3724 pSession->bRefAssocStartCnt--;
3725 //Complete the last association attemp because a new one is about to be tried
3726 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3727 eCSR_ROAM_ASSOCIATION_COMPLETION,
3728 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3729 }
3730 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3731 if(pScanResult)
3732 {
3733 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3735 {
3736 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
3737 fDone = eANI_BOOLEAN_TRUE;
3738 eRoamState = eCsrStopRoaming;
3739 break;
3740 }
3741 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3742 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3743 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3744 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3745 CSR_IS_QOS_BSS(pIesLocal) &&
3746 CSR_IS_UAPSD_BSS(pIesLocal) )
3747 {
3748#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3750 pIesLocal);
3751 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3752#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 }
3754 else
3755 {
3756 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3757 }
3758 if( pIesLocal && !pScanResult->Result.pvIes)
3759 {
3760 palFreeMemory(pMac->hHdd, pIesLocal);
3761 }
3762 }
3763 else
3764 {
3765 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3766 }
3767 roamInfo.pProfile = pProfile;
3768 pSession->bRefAssocStartCnt++;
3769 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3770 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3773 {
3774 // If this is a start IBSS profile, then we need to start the IBSS.
3775 if ( CSR_IS_START_IBSS(pProfile) )
3776 {
3777 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 // Attempt to start this IBSS...
3779 csrRoamAssignDefaultParam( pMac, pCommand );
3780 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
3781 if(HAL_STATUS_SUCCESS(status))
3782 {
3783 if ( fSameIbss )
3784 {
3785 eRoamState = eCsrStartIbssSameIbss;
3786 }
3787 else
3788 {
3789 eRoamState = eCsrContinueRoaming;
3790 }
3791 }
3792 else
3793 {
3794 //it somehow fail need to stop
3795 eRoamState = eCsrStopRoaming;
3796 }
3797 break;
3798 }
3799 else if ( (CSR_IS_WDS_AP(pProfile))
3800#ifdef WLAN_SOFTAP_FEATURE
3801 || (CSR_IS_INFRA_AP(pProfile))
3802#endif
3803 )
3804 {
3805 // Attempt to start this WDS...
3806 csrRoamAssignDefaultParam( pMac, pCommand );
3807 /* For AP WDS, we dont have any BSSDescription */
3808 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
3809 if(HAL_STATUS_SUCCESS(status))
3810 {
3811 eRoamState = eCsrContinueRoaming;
3812 }
3813 else
3814 {
3815 //it somehow fail need to stop
3816 eRoamState = eCsrStopRoaming;
3817 }
3818 }
3819 else
3820 {
3821 //Nothing we can do
3822 smsLog(pMac, LOGW, FL("cannot continue without BSS list\n"));
3823 eRoamState = eCsrStopRoaming;
3824 break;
3825 }
3826 }
3827 else //We have BSS
3828 {
3829 //Need to assign these value because they are used in csrIsSameProfile
3830 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3831 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
3832 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
3833 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
3834 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
3835 {
3836 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3837 {
3838 eRoamState = eCsrStartIbssSameIbss;
3839 break;
3840 }
3841 }
3842 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
3843 {
3844 //trying to connect to the one already connected
3845 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
3846 eRoamState = eCsrReassocToSelfNoCapChange;
3847 break;
3848 }
3849 // Attempt to Join this Bss...
3850 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
3851 break;
3852 }
3853
3854 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
3856 {
3857 //Need to indicate association_completion if association_start has been done
3858 if(pSession->bRefAssocStartCnt > 0)
3859 {
3860 pSession->bRefAssocStartCnt--;
3861 //Complete the last association attemp because a new one is about to be tried
3862 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3863 eCSR_ROAM_ASSOCIATION_COMPLETION,
3864 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3865 }
3866 }
3867
3868 return( eRoamState );
3869}
3870
Jeff Johnson295189b2012-06-20 16:38:30 -07003871static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3872{
3873 eHalStatus status = eHAL_STATUS_SUCCESS;
3874 eCsrJoinState RoamState;
3875 tANI_U32 sessionId = pCommand->sessionId;
3876
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 //***if( hddIsRadioStateOn( pAdapter ) )
3878 {
3879 // Attept to join a Bss...
3880 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07003881
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07003883 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 {
3885 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 // and if connected in Infrastructure mode...
3887 if ( csrIsConnStateInfra(pMac, sessionId) )
3888 {
3889 //... then we need to issue a disassociation
3890 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
3891 if(!HAL_STATUS_SUCCESS(status))
3892 {
3893 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d\n"), status);
3894 //roam command is completed by caller in the failed case
3895 fComplete = eANI_BOOLEAN_TRUE;
3896 }
3897 }
3898 else if( csrIsConnStateIbss(pMac, sessionId) )
3899 {
3900 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3901 if(!HAL_STATUS_SUCCESS(status))
3902 {
3903 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
3904 //roam command is completed by caller in the failed case
3905 fComplete = eANI_BOOLEAN_TRUE;
3906 }
3907 }
3908#ifdef WLAN_SOFTAP_FEATURE
3909 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
3910 {
3911 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3912 if(!HAL_STATUS_SUCCESS(status))
3913 {
3914 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
3915 //roam command is completed by caller in the failed case
3916 fComplete = eANI_BOOLEAN_TRUE;
3917 }
3918 }
3919#endif
3920 else
3921 {
3922 fComplete = eANI_BOOLEAN_TRUE;
3923 }
3924 if(fComplete)
3925 {
3926 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07003927 if(eCsrStopRoamingDueToConcurrency == RoamState)
3928 {
3929 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
3930 }
3931 else
3932 {
3933 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
3934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 }
3936 }
3937 else if ( eCsrReassocToSelfNoCapChange == RoamState )
3938 {
3939 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
3940 }
3941 else if ( eCsrStartIbssSameIbss == RoamState )
3942 {
3943 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
3944 }
3945 }//hddIsRadioStateOn
3946
3947 return status;
3948}
Jeff Johnson295189b2012-06-20 16:38:30 -07003949eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3950{
3951 tANI_U32 sessionId;
3952 tCsrRoamSession *pSession;
3953 tCsrScanResult *pScanResult = NULL;
3954 tSirBssDescription *pBssDesc = NULL;
3955 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 sessionId = pCommand->sessionId;
3957 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003958
3959 if(!pSession)
3960 {
3961 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3962 return eHAL_STATUS_FAILURE;
3963 }
3964
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
3966 {
3967 //the roaming is cancelled. Simply complete the command
3968 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
3969 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
3970 return eHAL_STATUS_FAILURE;
3971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 if (pCommand->u.roamCmd.pRoamBssEntry)
3973 {
3974 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3975 pBssDesc = &pScanResult->Result.BssDescriptor;
3976 }
3977 else
3978 {
3979 //the roaming is cancelled. Simply complete the command
3980 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
3981 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
3982 return eHAL_STATUS_FAILURE;
3983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
3985 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
3986 return status;
3987}
3988
Jeff Johnson295189b2012-06-20 16:38:30 -07003989eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3990{
3991 eHalStatus status = eHAL_STATUS_SUCCESS;
3992 tCsrRoamInfo roamInfo;
3993 tANI_U32 sessionId = pCommand->sessionId;
3994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003995
3996 if(!pSession)
3997 {
3998 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3999 return eHAL_STATUS_FAILURE;
4000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004001
4002 switch ( pCommand->u.roamCmd.roamReason )
4003 {
4004 case eCsrForcedDisassoc:
4005 csrFreeRoamProfile(pMac, sessionId);
4006 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 case eCsrSmeIssuedDisassocForHandoff:
4009 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4010#if 0 // TODO : Confirm this change
4011 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4012#else
4013 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4014#endif
4015
4016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 case eCsrForcedDisassocMICFailure:
4018 csrFreeRoamProfile(pMac, sessionId);
4019 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
4020 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 case eCsrForcedDeauth:
4022 csrFreeRoamProfile(pMac, sessionId);
4023 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
4024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 case eCsrHddIssuedReassocToSameAP:
4026 case eCsrSmeIssuedReassocToSameAP:
4027 {
4028 tDot11fBeaconIEs *pIes = NULL;
4029
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 if( pSession->pConnectBssDesc )
4031 {
4032 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4033 if(!HAL_STATUS_SUCCESS(status) )
4034 {
4035 smsLog(pMac, LOGE, FL(" fail to parse IEs\n"));
4036 }
4037 else
4038 {
4039 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4040 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4041 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4043 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4044 pSession->bRefAssocStartCnt++;
4045 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4046 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4047
4048 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate\n"));
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004049 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4050 &pCommand->u.roamCmd.roamProfile );
4051 if(!HAL_STATUS_SUCCESS(status))
4052 {
4053 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
4054 }
4055
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 palFreeMemory(pMac->hHdd, pIes);
4057 pIes = NULL;
4058 }
4059 }
4060 break;
4061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 case eCsrCapsChange:
4063 smsLog(pMac, LOGE, FL("received eCsrCapsChange \n"));
4064 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4065 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4066 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 case eCsrSmeIssuedFTReassoc:
4068 smsLog(pMac, LOGE, FL("received FT Reassoc Req \n"));
4069 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4070 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004071
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 case eCsrStopBss:
4073 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4074 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4075 break;
4076
4077 case eCsrForcedDisassocSta:
4078 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4079 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4080 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4081 pCommand->u.roamCmd.reason);
4082 break;
4083
4084 case eCsrForcedDeauthSta:
4085 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4086 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4087 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4088 pCommand->u.roamCmd.reason);
4089 break;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004090
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004091 case eCsrPerformPreauth:
4092 smsLog(pMac, LOGE, FL("Attempting FT PreAuth Req \n"));
4093 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4094 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004095 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004096
4097 default:
4098 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4099
4100 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4101 {
4102 //Remember the roaming profile
4103 csrFreeRoamProfile(pMac, sessionId);
4104 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4105 {
4106 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4107 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4108 }
4109 }
4110
4111 //At this point, original uapsd_mask is saved in pCurRoamProfile
4112 //uapsd_mask in the pCommand may change from this point on.
4113
4114 // Attempt to roam with the new scan results (if we need to..)
4115 status = csrRoam( pMac, pCommand );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004116 if(!HAL_STATUS_SUCCESS(status))
4117 {
4118 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X\n"), status);
4119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 break;
4121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 return (status);
4123}
4124
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004125void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4126{
4127 pCommand->u.roamCmd.pLastRoamBss = NULL;
4128 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4129 //Because u.roamCmd is union and share with scanCmd and StatusChange
4130 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4131}
4132
Jeff Johnson295189b2012-06-20 16:38:30 -07004133void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4134{
4135 if(pCommand->u.roamCmd.fReleaseBssList)
4136 {
4137 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4138 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4139 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4140 }
4141 if(pCommand->u.roamCmd.fReleaseProfile)
4142 {
4143 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4144 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4145 }
4146 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4147 //Because u.roamCmd is union and share with scanCmd and StatusChange
4148 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4149}
4150
Jeff Johnson295189b2012-06-20 16:38:30 -07004151void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4152{
4153 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4154}
Jeff Johnson295189b2012-06-20 16:38:30 -07004155void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4156{
4157 tListElem *pEntry;
4158 tSmeCmd *pCommand;
4159 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004160 smsLog( pMac, LOG2, "Roam Completion ...\n" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4162 if ( pEntry )
4163 {
4164 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 // If the head of the queue is Active and it is a ROAM command, remove
4166 // and put this on the Free queue.
4167 if ( eSmeCommandRoam == pCommand->command )
4168 {
4169 //we need to process the result first before removing it from active list because state changes
4170 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4171 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4172 if( fReleaseCommand )
4173 {
4174 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4175 {
4176 csrReleaseCommandRoam( pMac, pCommand );
4177 }
4178 else
4179 {
4180 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004181 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 }
4183 }
4184 else
4185 {
4186 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004187 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 }
4189 }
4190 else
4191 {
4192 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
4193 }
4194 }
4195 else
4196 {
4197 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
4198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 if( fReleaseCommand )
4200 {
4201 smeProcessPendingQueue( pMac );
4202 }
4203}
4204
Jeff Johnson295189b2012-06-20 16:38:30 -07004205void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4206{
4207 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004208 if(!pSession)
4209 {
4210 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4211 return;
4212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4214 pSession->NumPmkidCandidate = 0;
4215}
Jeff Johnson295189b2012-06-20 16:38:30 -07004216#ifdef FEATURE_WLAN_WAPI
4217void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4218{
4219 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004220 if(!pSession)
4221 {
4222 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4223 return;
4224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4226 pSession->NumBkidCandidate = 0;
4227}
4228#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004229extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4230
Jeff Johnson295189b2012-06-20 16:38:30 -07004231static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4232 tSirBssDescription *pSirBssDesc,
4233 tDot11fBeaconIEs *pIes)
4234{
4235 eHalStatus status = eHAL_STATUS_SUCCESS;
4236 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4237 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004238
4239 if(!pSession)
4240 {
4241 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4242 return eHAL_STATUS_FAILURE;
4243 }
4244
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 if((eCSR_AUTH_TYPE_WPA == authType) ||
4246 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4247 (eCSR_AUTH_TYPE_RSN == authType) ||
4248 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4249#if defined WLAN_FEATURE_VOWIFI_11R
4250 ||
4251 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4252 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4253#endif /* FEATURE_WLAN_WAPI */
4254#ifdef FEATURE_WLAN_WAPI
4255 ||
4256 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4257 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4258#endif /* FEATURE_WLAN_WAPI */
4259 )
4260 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4262 {
4263 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
4264 }
4265 if( pIesLocal )
4266 {
4267 tANI_U32 nIeLen;
4268 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 if((eCSR_AUTH_TYPE_RSN == authType) ||
4270#if defined WLAN_FEATURE_VOWIFI_11R
4271 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4272 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4273#endif /* WLAN_FEATURE_VOWIFI_11R */
4274 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4275 {
4276 if(pIesLocal->RSN.present)
4277 {
4278 //Calculate the actual length
4279 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4280 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4281 + 2 //akm_suite_count
4282 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4283 + 2; //reserved
4284 if( pIesLocal->RSN.pmkid_count )
4285 {
4286 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4287 }
4288 //nIeLen doesn't count EID and length fields
4289 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4290 {
4291 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4292 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4293 //copy upto akm_suites
4294 pIeBuf = pSession->pWpaRsnRspIE + 2;
4295 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4296 pIeBuf += 8;
4297 if( pIesLocal->RSN.pwise_cipher_suite_count )
4298 {
4299 //copy pwise_cipher_suites
4300 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4301 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4302 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4303 }
4304 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4305 pIeBuf += 2;
4306 if( pIesLocal->RSN.akm_suite_count )
4307 {
4308 //copy akm_suites
4309 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4310 pIesLocal->RSN.akm_suite_count * 4);
4311 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4312 }
4313 //copy the rest
4314 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4315 pIesLocal->RSN.akm_suite_count * 4,
4316 2 + pIesLocal->RSN.pmkid_count * 4);
4317 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4318 }
4319 }
4320 }
4321 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4322 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4323 {
4324 if(pIesLocal->WPA.present)
4325 {
4326 //Calculate the actual length
4327 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4328 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4329 + 2 //auth_suite_count
4330 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4331 // The WPA capabilities follows the Auth Suite (two octects)--
4332 // this field is optional, and we always "send" zero, so just
4333 // remove it. This is consistent with our assumptions in the
4334 // frames compiler; c.f. bug 15234:
4335 //nIeLen doesn't count EID and length fields
4336 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4337 {
4338 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4339 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4340 pIeBuf = pSession->pWpaRsnRspIE + 2;
4341 //Copy WPA OUI
4342 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4343 pIeBuf += 4;
4344 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4345 pIesLocal->WPA.unicast_cipher_count * 4);
4346 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4347 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4348 pIesLocal->WPA.auth_suite_count * 4);
4349 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4350 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4351 }
4352 }
4353 }
4354#ifdef FEATURE_WLAN_WAPI
4355 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4356 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4357 {
4358 if(pIesLocal->WAPI.present)
4359 {
4360 //Calculate the actual length
4361 nIeLen = 4 //version + akm_suite_count
4362 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4363 + 2 //pwise_cipher_suite_count
4364 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4365 + 6; //gp_cipher_suite + preauth + reserved
4366 if( pIesLocal->WAPI.bkid_count )
4367 {
4368 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4369 }
4370
4371 //nIeLen doesn't count EID and length fields
4372 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4373 {
4374 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4375 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4376 pIeBuf = pSession->pWapiRspIE + 2;
4377 //copy upto akm_suite_count
4378 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4379 pIeBuf += 4;
4380 if( pIesLocal->WAPI.akm_suite_count )
4381 {
4382 //copy akm_suites
4383 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4384 pIesLocal->WAPI.akm_suite_count * 4);
4385 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4386 }
4387 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4388 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4390 {
4391 //copy pwise_cipher_suites
4392 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4393 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4394 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4395 }
4396 //gp_cipher_suite + preauth + reserved + bkid_count
4397 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4398 pIeBuf += 8;
4399 if( pIesLocal->WAPI.bkid_count )
4400 {
4401 //copy akm_suites
4402 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4403 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4404 }
4405 pSession->nWapiRspIeLength = nIeLen + 2;
4406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 }
4408 }
4409#endif /* FEATURE_WLAN_WAPI */
4410 if( !pIes )
4411 {
4412 //locally allocated
4413 palFreeMemory(pMac->hHdd, pIesLocal);
4414 }
4415 }
4416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 return (status);
4418}
4419
Jeff Johnson295189b2012-06-20 16:38:30 -07004420static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4421{
4422 v_U8_t bACWeights[WLANTL_MAX_AC];
4423 v_U8_t paramBk, paramBe, paramVi, paramVo;
4424 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4426 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4427 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4428 //This doesn't address the case where the lower AC needs a real higher weight
4429 if( pIEs->WMMParams.present )
4430 {
4431 //no change to the lowest ones
4432 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4433 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4434 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4435 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4436 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4437 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4438 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4439 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4440 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4441 {
4442 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4443 fWeightChange = VOS_TRUE;
4444 }
4445 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4446 {
4447 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4448 fWeightChange = VOS_TRUE;
4449 }
4450 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4451 {
4452 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4453 fWeightChange = VOS_TRUE;
4454 }
4455 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4456 {
4457 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4458 fWeightChange = VOS_TRUE;
4459 }
4460 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4461 {
4462 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4463 fWeightChange = VOS_TRUE;
4464 }
4465 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4466 {
4467 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4468 fWeightChange = VOS_TRUE;
4469 }
4470 if(fWeightChange)
4471 {
4472 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)\n"), bACWeights[0], bACWeights[1],
4473 bACWeights[2], bACWeights[3]);
4474 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4475 }
4476 }
4477}
Jeff Johnson295189b2012-06-20 16:38:30 -07004478#ifdef WLAN_FEATURE_VOWIFI_11R
4479//Returns whether the current association is a 11r assoc or not
4480tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4481{
4482#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4483 return csrNeighborRoamIs11rAssoc(pMac);
4484#else
4485 return eANI_BOOLEAN_FALSE;
4486#endif
4487}
4488#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004489#ifdef FEATURE_WLAN_CCX
4490//Returns whether the current association is a CCX assoc or not
4491tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4492{
4493#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4494 return csrNeighborRoamIsCCXAssoc(pMac);
4495#else
4496 return eANI_BOOLEAN_FALSE;
4497#endif
4498}
4499#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004500#ifdef FEATURE_WLAN_LFR
4501//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304502tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004503{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304504 tCsrRoamSession *pSession = NULL;
4505
4506 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4507 {
4508 pSession = CSR_GET_SESSION( pMac, sessionId );
4509 if (NULL != pSession->pCurRoamProfile)
4510 {
4511 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4512 {
4513 return eANI_BOOLEAN_FALSE;
4514 }
4515 }
4516 }
4517
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004518 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004519 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004520}
4521#endif
4522
Jeff Johnson295189b2012-06-20 16:38:30 -07004523//Return true means the command can be release, else not
4524static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4525 eCsrRoamCompleteResult Result, void *Context )
4526{
4527 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4528 tSirBssDescription *pSirBssDesc = NULL;
4529 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4530 tCsrScanResult *pScanResult = NULL;
4531 tCsrRoamInfo roamInfo;
4532 sme_QosAssocInfo assocInfo;
4533 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4534 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4535 tDot11fBeaconIEs *pIes = NULL;
4536 tANI_U32 sessionId = pCommand->sessionId;
4537 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4538 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4539 eRoamCmdStatus roamStatus;
4540 eCsrRoamResult roamResult;
4541 eHalStatus status;
4542 tANI_U32 key_timeout_interval = 0;
4543#ifdef WLAN_SOFTAP_FEATURE
4544 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
4545#endif
4546
Jeff Johnson32d95a32012-09-10 13:15:23 -07004547 if(!pSession)
4548 {
4549 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4550 return eANI_BOOLEAN_FALSE;
4551 }
4552
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 smsLog( pMac, LOG1, FL("Processing ROAM results...\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 switch( Result )
4555 {
4556 case eCsrJoinSuccess:
4557 // reset the IDLE timer
4558 // !!
4559 // !! fall through to the next CASE statement here is intentional !!
4560 // !!
4561 case eCsrReassocSuccess:
4562 if(eCsrReassocSuccess == Result)
4563 {
4564 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4565 }
4566 else
4567 {
4568 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4569 }
4570 // Success Join Response from LIM. Tell NDIS we are connected and save the
4571 // Connected state...
4572 smsLog(pMac, LOGW, FL("receives association indication\n"));
4573 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4574 //always free the memory here
4575 if(pSession->pWpaRsnRspIE)
4576 {
4577 pSession->nWpaRsnRspIeLength = 0;
4578 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4579 pSession->pWpaRsnRspIE = NULL;
4580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004581#ifdef FEATURE_WLAN_WAPI
4582 if(pSession->pWapiRspIE)
4583 {
4584 pSession->nWapiRspIeLength = 0;
4585 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4586 pSession->pWapiRspIE = NULL;
4587 }
4588#endif /* FEATURE_WLAN_WAPI */
4589#ifdef FEATURE_WLAN_BTAMP_UT_RF
4590 //Reset counter so no join retry is needed.
4591 pSession->maxRetryCount = 0;
4592 csrRoamStopJoinRetryTimer(pMac, sessionId);
4593#endif
4594 /* This creates problem since we have not saved the connected profile.
4595 So moving this after saving the profile
4596 */
4597 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4598 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4599 {
4600 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4601 }
4602 else
4603 {
4604 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 //Use the last connected bssdesc for reassoc-ing to the same AP.
4607 //NOTE: What to do when reassoc to a different AP???
4608 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4609 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4610 {
4611 pSirBssDesc = pSession->pConnectBssDesc;
4612 if(pSirBssDesc)
4613 {
4614 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4615 }
4616 }
4617 else
4618 {
4619
4620 if(pCommand->u.roamCmd.pRoamBssEntry)
4621 {
4622 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4623 if(pScanResult != NULL)
4624 {
4625 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4626 //this can be NULL
4627 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4628 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4629 }
4630 }
4631 }
4632 if( pSirBssDesc )
4633 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4636 //Save WPA/RSN IE
4637 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4638#ifdef FEATURE_WLAN_CCX
4639 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4640#endif
4641
4642 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4643 // substate change.
4644 // Moving even save profile above so that below mentioned conditon is also met.
4645 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4646 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4648 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4649 // will be dropped for the security context may not be set properly.
4650 //
4651 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4652 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4653 //
4654 // this reordering was done on titan_prod_usb branch and is being replicated here.
4655 //
4656
4657 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4658 !pProfile->bWPSAssociation)
4659 {
4660 // Issue the set Context request to LIM to establish the Unicast STA context
4661 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4662 pProfile->negotiatedUCEncryptionType,
4663 pSirBssDesc, &(pSirBssDesc->bssId),
4664 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4665 {
4666 smsLog( pMac, LOGE, FL(" Set context for unicast fail\n") );
4667 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4668 }
4669 // Issue the set Context request to LIM to establish the Broadcast STA context
4670 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4671 pSirBssDesc, &BroadcastMac,
4672 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4673 }
4674 else
4675 {
4676 //Need to wait for supplicant authtication
4677 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 //Set the subestate to WaitForKey in case authentiation is needed
4679 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4680
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 if(pProfile->bWPSAssociation)
4682 {
4683 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4684 }
4685 else
4686 {
4687 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4688 }
4689
4690 //Save sessionId in case of timeout
4691 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4692 //This time should be long enough for the rest of the process plus setting key
4693 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4694 {
4695 //Reset our state so nothting is blocked.
4696 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer\n") );
4697 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4698 }
4699 }
4700
4701 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4702 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 if(Context)
4704 {
4705 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4706 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4708 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4709#ifdef WLAN_FEATURE_VOWIFI_11R
4710 len += pJoinRsp->parsedRicRspLen;
4711#endif /* WLAN_FEATURE_VOWIFI_11R */
4712#ifdef FEATURE_WLAN_CCX
4713 len += pJoinRsp->tspecIeLen;
4714#endif
4715 if(len)
4716 {
4717 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4718 (void **)&pSession->connectedInfo.pbFrames, len)))
4719 {
4720 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4721 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4722 {
4723 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4724 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4725 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4726#ifdef WLAN_FEATURE_VOWIFI_11R
4727 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4728#endif /* WLAN_FEATURE_VOWIFI_11R */
4729#ifdef FEATURE_WLAN_CCX
4730 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4731#endif
4732 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4733 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4734 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4735 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4736 }
4737 else
4738 {
4739 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004740 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4742 pSession->connectedInfo.pbFrames = NULL;
4743 }
4744 }
4745 }
4746 if(pCommand->u.roamCmd.fReassoc)
4747 {
4748 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4749 }
4750 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4751 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4752 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4753 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4754 }
4755 else
4756 {
4757 if(pCommand->u.roamCmd.fReassoc)
4758 {
4759 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4760 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4761 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4762 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4763 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4764 }
4765 }
4766#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4767 // Indicate SME-QOS with reassoc success event, only after
4768 // copying the frames
4769 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 roamInfo.pBssDesc = pSirBssDesc;
4772 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4773 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4774#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4775 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4776#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4777 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07004778#ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
4779 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
4780 //It may be better to let QoS do this????
4781 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
4782 {
4783 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now\n",
4784 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
4785 pmcStartUapsd( pMac, NULL, NULL );
4786 }
4787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4789 if( pSession->bRefAssocStartCnt > 0 )
4790 {
4791 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004792 //Remove this code once SLM_Sessionization is supported
4793 //BMPS_WORKAROUND_NOT_NEEDED
4794 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07004795 {
4796 pMac->roam.configParam.doBMPSWorkaround = 1;
4797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4799 }
4800
4801 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 // reset the PMKID candidate list
4803 csrResetPMKIDCandidateList( pMac, sessionId );
4804 //Update TL's AC weight base on the current EDCA parameters
4805 //These parameters may change in the course of the connection, that sictuation
4806 //is not taken care here. This change is mainly to address a WIFI WMM test where
4807 //BE has a equal or higher TX priority than VI.
4808 //We only do this for infra link
4809 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
4810 {
4811 csrCheckAndUpdateACWeight(pMac, pIes);
4812 }
4813#ifdef FEATURE_WLAN_WAPI
4814 // reset the BKID candidate list
4815 csrResetBKIDCandidateList( pMac, sessionId );
4816#endif /* FEATURE_WLAN_WAPI */
4817 }
4818 else
4819 {
4820 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc\n");
4821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 csrScanCancelIdleScan(pMac);
4823 //Not to signal link up because keys are yet to be set.
4824 //The linkup function will overwrite the sub-state that we need to keep at this point.
4825 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
4826 {
4827 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
4828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
4830 //enough to let security and DHCP handshake succeed before entry into BMPS
4831 if (pmcShouldBmpsTimerRun(pMac))
4832 {
4833 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
4834 != eHAL_STATUS_SUCCESS)
4835 {
4836 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
4837 }
4838 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
4839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 break;
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 case eCsrStartBssSuccess:
4843 // on the StartBss Response, LIM is returning the Bss Description that we
4844 // are beaconing. Add this Bss Description to our scan results and
4845 // chain the Profile to this Bss Description. On a Start BSS, there was no
4846 // detected Bss description (no partner) so we issued the Start Bss to
4847 // start the Ibss without any Bss description. Lim was kind enough to return
4848 // the Bss Description that we start beaconing for the newly started Ibss.
4849 smsLog(pMac, LOG2, FL("receives start BSS ok indication\n"));
4850 status = eHAL_STATUS_FAILURE;
4851#ifdef WLAN_SOFTAP_FEATURE
4852 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
4853#endif
4854 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4855 if( CSR_IS_IBSS( pProfile ) )
4856 {
4857 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
4858 }
4859#ifdef WLAN_SOFTAP_FEATURE
4860 else if (CSR_IS_INFRA_AP(pProfile))
4861 {
4862 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
4863 }
4864#endif
4865 else
4866 {
4867 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
4868 }
4869 if( !CSR_IS_WDS_STA( pProfile ) )
4870 {
4871 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
4872#ifdef WLAN_SOFTAP_FEATURE
4873 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
4874#else
4875 pSirBssDesc = (tSirBssDescription *)Context;
4876#endif
4877 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
4878 {
4879 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs\n"));
4880 roamInfo.pBssDesc = pSirBssDesc;
4881 //We need to associate_complete it first, becasue Associate_start already indicated.
4882 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4883 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
4884 break;
4885 }
4886#ifdef WLAN_SOFTAP_FEATURE
4887 if (!CSR_IS_INFRA_AP(pProfile))
4888#endif
4889 {
4890 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
4891 }
4892 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
4893 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
4894 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4895 if(pSirBssDesc)
4896 {
4897 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4898 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4899 }
4900 //We are doen with the IEs so free it
4901 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004902#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4903 {
4904 vos_log_ibss_pkt_type *pIbssLog;
4905 tANI_U32 bi;
4906
4907 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
4908 if(pIbssLog)
4909 {
4910 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
4911 {
4912 //We start the IBSS (didn't find any matched IBSS out there)
4913 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
4914 }
4915 else
4916 {
4917 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
4918 }
4919 if(pSirBssDesc)
4920 {
4921 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
4922 pIbssLog->operatingChannel = pSirBssDesc->channelId;
4923 }
4924 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
4925 {
4926 //***U8 is not enough for beacon interval
4927 pIbssLog->beaconInterval = (v_U8_t)bi;
4928 }
4929 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
4930 }
4931 }
4932#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4933 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
4934 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07004935#ifdef WLAN_SOFTAP_FEATURE
4936 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
4937 {
4938#else
4939 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ))
4940 {
4941#endif
4942 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
4943 csrRoamIssueSetContextReq( pMac, sessionId,
4944 pProfile->negotiatedMCEncryptionType,
4945 pSirBssDesc, &BroadcastMac,
4946 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4947 }
4948 }
4949 else
4950 {
4951 //Keep the state to eCSR_ROAMING_STATE_JOINING
4952 //Need to send join_req.
4953 if(pCommand->u.roamCmd.pRoamBssEntry)
4954 {
4955 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
4956 {
4957 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4958 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4959 // Set the roaming substate to 'join attempt'...
4960 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowda071f6082013-01-16 13:39:39 -08004961 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 }
4963 }
4964 else
4965 {
4966 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc\n" );
4967 VOS_ASSERT( 0 );
4968 }
4969 }
4970 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
4971 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
4972 //trigger the connection start indication in Vista
4973 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
4974 {
4975 roamStatus = eCSR_ROAM_IBSS_IND;
4976 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
4977 if( CSR_IS_WDS( pProfile ) )
4978 {
4979 roamStatus = eCSR_ROAM_WDS_IND;
4980 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
4981 }
4982#ifdef WLAN_SOFTAP_FEATURE
4983 if( CSR_IS_INFRA_AP( pProfile ) )
4984 {
4985 roamStatus = eCSR_ROAM_INFRA_IND;
4986 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
4987 }
4988#endif
4989
4990 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
4991 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
4992 //trigger the connection start indication in Vista
4993 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4994 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4995 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4996 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
4997 {
4998 //We start the IBSS (didn't find any matched IBSS out there)
4999 roamInfo.pBssDesc = pSirBssDesc;
5000 }
5001#ifdef WLAN_SOFTAP_FEATURE
5002 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
5003#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005004 //Remove this code once SLM_Sessionization is supported
5005 //BMPS_WORKAROUND_NOT_NEEDED
5006 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005007 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005008 {
5009 pMac->roam.configParam.doBMPSWorkaround = 1;
5010 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005011
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5013 }
5014
5015 csrScanCancelIdleScan(pMac);
5016 //Only use this timer for ibss. BAP has its own timer for WDS
5017 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5018 {
5019 //start the join IBSS timer
5020 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5021 pSession->ibss_join_pending = TRUE;
5022 }
5023 if( HAL_STATUS_SUCCESS( status ) )
5024 {
5025 //Already sent join_req for the WDS station
5026 fReleaseCommand = eANI_BOOLEAN_FALSE;
5027 }
5028 else if( CSR_IS_WDS_STA( pProfile ) )
5029 {
5030 //need to send stop BSS because we fail to send join_req
5031 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5032 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5033 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 case eCsrStartBssFailure:
5037#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5038 {
5039 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5041 if(pIbssLog)
5042 {
5043 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5044 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5045 }
5046 }
5047#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 roamStatus = eCSR_ROAM_IBSS_IND;
5049 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5050 if( CSR_IS_WDS( pProfile ) )
5051 {
5052 roamStatus = eCSR_ROAM_WDS_IND;
5053 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5054 }
5055#ifdef WLAN_SOFTAP_FEATURE
5056 if( CSR_IS_INFRA_AP( pProfile ) )
5057 {
5058 roamStatus = eCSR_ROAM_INFRA_IND;
5059 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5060 }
5061#endif
5062 if(Context)
5063 {
5064 pSirBssDesc = (tSirBssDescription *)Context;
5065 }
5066 else
5067 {
5068 pSirBssDesc = NULL;
5069 }
5070 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5071 roamInfo.pBssDesc = pSirBssDesc;
5072 //We need to associate_complete it first, becasue Associate_start already indicated.
5073 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5074 csrSetDefaultDot11Mode( pMac );
5075 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 case eCsrSilentlyStopRoaming:
5077 // We are here because we try to start the same IBSS
5078 //No message to PE
5079 // return the roaming state to Joined.
5080 smsLog(pMac, LOGW, FL("receives silently roaming indication\n"));
5081 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5082 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5083 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5084 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5085 if( roamInfo.pBssDesc )
5086 {
5087 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5088 }
5089 //Since there is no change in the current state, simply pass back no result otherwise
5090 //HDD may be mistakenly mark to disconnected state.
5091 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5092 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 case eCsrSilentlyStopRoamingSaveState:
5095 //We are here because we try to connect to the same AP
5096 //No message to PE
5097 smsLog(pMac, LOGW, FL("receives silently stop roaming indication\n"));
5098 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5099
5100 //to aviod resetting the substate to NONE
5101 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5102 //No need to change substate to wai_for_key because there is no state change
5103 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5104 if( roamInfo.pBssDesc )
5105 {
5106 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5109 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5110 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5111 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5112 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5113 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5114 roamInfo.staId = pSession->connectedInfo.staId;
5115 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5116#if defined(VOSS_ENABLED)
5117 VOS_ASSERT( roamInfo.staId != 0 );
5118#endif
5119 pSession->bRefAssocStartCnt--;
5120 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5121 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5122 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5123 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 case eCsrReassocFailure:
5125#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5126 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5127#endif
5128 case eCsrJoinWdsFailure:
5129 smsLog(pMac, LOGW, FL("failed to join WDS\n"));
5130 csrFreeConnectBssDesc(pMac, sessionId);
5131 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5132 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5133 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5134 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5135 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5136 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5137 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5138 eCSR_ROAM_WDS_IND,
5139 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5140 //Need to issue stop_bss
5141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 case eCsrJoinFailure:
5143 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005144 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 default:
5146 {
5147 smsLog(pMac, LOGW, FL("receives no association indication\n"));
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005148 smsLog(pMac, LOG1, FL("Assoc ref count %d\n"),
5149 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5151 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5152 {
5153 //do not free for the other profiles as we need to send down stop BSS later
5154 csrFreeConnectBssDesc(pMac, sessionId);
5155 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5156 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5157 csrSetDefaultDot11Mode( pMac );
5158 }
5159
5160 switch( pCommand->u.roamCmd.roamReason )
5161 {
5162 // If this transition is because of an 802.11 OID, then we transition
5163 // back to INIT state so we sit waiting for more OIDs to be issued and
5164 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005165 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 case eCsrSmeIssuedAssocToSimilarAP:
5167 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005168 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5170 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5171 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5172 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5173 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 /* Defeaturize this later if needed */
5175#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5176 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5177 if (csrRoamIsHandoffInProgress(pMac))
5178 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 /* Should indicate neighbor roam algorithm about the connect failure here */
5180 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 if(pSession->bRefAssocStartCnt > 0)
5184 {
5185 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005186 if(eCsrJoinFailureDueToConcurrency == Result)
5187 {
5188 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5189 eCSR_ROAM_ASSOCIATION_COMPLETION,
5190 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5191 }
5192 else
5193 {
5194 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 eCSR_ROAM_ASSOCIATION_COMPLETION,
5196 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 }
Gopichand Nakkalad9a00c52012-12-31 16:43:00 -08005199 else
5200 {
5201 /* bRefAssocStartCnt is not incremented when
5202 * eRoamState == eCsrStopRoamingDueToConcurrency
5203 * in csrRoamJoinNextBss API. so handle this in
5204 * else case by sending assoc failure
5205 */
5206 csrRoamCallCallback(pMac, sessionId, NULL,
5207 pCommand->u.scanCmd.roamId,
5208 eCSR_ROAM_ASSOCIATION_FAILURE,
5209 eCSR_ROAM_RESULT_FAILURE);
5210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 smsLog(pMac, LOG1, FL(" roam(reason %d) failed\n"), pCommand->u.roamCmd.roamReason);
5212#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5213 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5214#endif
5215 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5216 csrScanStartIdleScan(pMac);
5217#ifdef FEATURE_WLAN_BTAMP_UT_RF
5218 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5219 //BT activity and not able to recevie WLAN traffic. Retry the join
5220 if( CSR_IS_WDS_STA(pProfile) )
5221 {
5222 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5223 }
5224#endif
5225 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 case eCsrHddIssuedReassocToSameAP:
5227 case eCsrSmeIssuedReassocToSameAP:
5228 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5229
5230 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5231#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5232 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5233#endif
5234 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5235 csrScanStartIdleScan(pMac);
5236 break;
5237 case eCsrForcedDisassoc:
5238 case eCsrForcedDeauth:
5239 case eCsrSmeIssuedIbssJoinFailure:
5240 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5241
5242 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5243 {
5244 // Notify HDD that IBSS join failed
5245 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5246 }
5247 else
5248 {
5249 csrRoamCallCallback(pMac, sessionId, NULL,
5250 pCommand->u.roamCmd.roamId,
5251 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5252 }
5253#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5254 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5255#endif
5256 csrRoamLinkDown(pMac, sessionId);
5257 csrScanStartIdleScan(pMac);
5258 break;
5259 case eCsrForcedIbssLeave:
5260 csrRoamCallCallback(pMac, sessionId, NULL,
5261 pCommand->u.roamCmd.roamId,
5262 eCSR_ROAM_IBSS_LEAVE,
5263 eCSR_ROAM_RESULT_IBSS_STOP);
5264 break;
5265 case eCsrForcedDisassocMICFailure:
5266 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5267
5268 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5269#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5270 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5271#endif
5272 csrScanStartIdleScan(pMac);
5273 break;
5274#ifdef WLAN_SOFTAP_FEATURE
5275 case eCsrStopBss:
5276 csrRoamCallCallback(pMac, sessionId, NULL,
5277 pCommand->u.roamCmd.roamId,
5278 eCSR_ROAM_INFRA_IND,
5279 eCSR_ROAM_RESULT_INFRA_STOPPED);
5280 break;
5281 case eCsrForcedDisassocSta:
5282 case eCsrForcedDeauthSta:
5283 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5284 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5285 {
5286 pSession = CSR_GET_SESSION(pMac, sessionId);
5287 if (!pSession)
5288 break;
5289
5290 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5291 {
5292 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5293 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5294 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5295 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5296 roamInfo.statusCode = eSIR_SME_SUCCESS;
5297 status = csrRoamCallCallback(pMac, sessionId,
5298 &roamInfo, pCommand->u.roamCmd.roamId,
5299 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5300 }
5301 }
5302 break;
5303#endif
5304 case eCsrLostLink1:
5305 // if lost link roam1 failed, then issue lost link Scan2 ...
5306 csrScanRequestLostLink2(pMac, sessionId);
5307 break;
5308 case eCsrLostLink2:
5309 // if lost link roam2 failed, then issue lost link scan3 ...
5310 csrScanRequestLostLink3(pMac, sessionId);
5311 break;
5312 case eCsrLostLink3:
5313 default:
5314 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5315
5316 //We are done with one round of lostlink roaming here
5317 csrScanHandleFailedLostlink3(pMac, sessionId);
5318 break;
5319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 break;
5321 }
5322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 return ( fReleaseCommand );
5324}
5325
Jeff Johnson295189b2012-06-20 16:38:30 -07005326eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5327{
5328 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 return (status);
5330}
5331
Jeff Johnson295189b2012-06-20 16:38:30 -07005332eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5333{
5334 eHalStatus status = eHAL_STATUS_SUCCESS;
5335 tANI_U32 size = 0;
5336
5337 do
5338 {
5339 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5340 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5341 {
5342 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5343 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5344 if(!HAL_STATUS_SUCCESS(status))
5345 {
5346 break;
5347 }
5348 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5349 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5350 }
5351 if(pSrcProfile->SSIDs.numOfSSIDs)
5352 {
5353 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5354 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5355 if(!HAL_STATUS_SUCCESS(status))
5356 {
5357 break;
5358 }
5359 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5360 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5361 }
5362 if(pSrcProfile->nWPAReqIELength)
5363 {
5364 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5365 if(!HAL_STATUS_SUCCESS(status))
5366 {
5367 break;
5368 }
5369 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5370 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5371 }
5372 if(pSrcProfile->nRSNReqIELength)
5373 {
5374 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5375 if(!HAL_STATUS_SUCCESS(status))
5376 {
5377 break;
5378 }
5379 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5380 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5381 }
5382#ifdef FEATURE_WLAN_WAPI
5383 if(pSrcProfile->nWAPIReqIELength)
5384 {
5385 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5386 if(!HAL_STATUS_SUCCESS(status))
5387 {
5388 break;
5389 }
5390 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5391 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5392 }
5393#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 if(pSrcProfile->nAddIEScanLength)
5395 {
5396 status = palAllocateMemory(pMac->hHdd,
5397 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5398 if(!HAL_STATUS_SUCCESS(status))
5399 {
5400 break;
5401 }
5402 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5403 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5404 pSrcProfile->nAddIEScanLength);
5405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 if(pSrcProfile->nAddIEAssocLength)
5407 {
5408 status = palAllocateMemory(pMac->hHdd,
5409 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5410 if(!HAL_STATUS_SUCCESS(status))
5411 {
5412 break;
5413 }
5414 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5415 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5416 pSrcProfile->nAddIEAssocLength);
5417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 if(pSrcProfile->ChannelInfo.ChannelList)
5419 {
5420 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5421 if(!HAL_STATUS_SUCCESS(status))
5422 {
5423 break;
5424 }
5425 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5426 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 pDstProfile->AuthType = pSrcProfile->AuthType;
5429 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5430 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5431 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5432 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5433 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5434 pDstProfile->BSSType = pSrcProfile->BSSType;
5435 pDstProfile->phyMode = pSrcProfile->phyMode;
5436 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5437
5438#ifdef FEATURE_WLAN_WAPI
5439 if(csrIsProfileWapi(pSrcProfile))
5440 {
5441 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5442 {
5443 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5444 }
5445 }
5446#endif /* FEATURE_WLAN_WAPI */
5447 pDstProfile->CBMode = pSrcProfile->CBMode;
5448 /*Save the WPS info*/
5449 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5450 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
5452#ifdef WLAN_SOFTAP_FEATURE
5453 pDstProfile->privacy = pSrcProfile->privacy;
5454 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5455 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5456 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5457 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5458 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5459 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5460 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5461 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5462 pDstProfile->wps_state = pSrcProfile->wps_state;
5463 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
5464#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005466#ifdef WLAN_FEATURE_VOWIFI_11R
5467 if (pSrcProfile->MDID.mdiePresent)
5468 {
5469 pDstProfile->MDID.mdiePresent = 1;
5470 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5471 }
5472#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 }while(0);
5474
5475 if(!HAL_STATUS_SUCCESS(status))
5476 {
5477 csrReleaseProfile(pMac, pDstProfile);
5478 pDstProfile = NULL;
5479 }
5480
5481 return (status);
5482}
Jeff Johnson295189b2012-06-20 16:38:30 -07005483eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5484{
5485 eHalStatus status = eHAL_STATUS_SUCCESS;
5486 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5487 do
5488 {
5489 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5490 if(pSrcProfile->bssid)
5491 {
5492 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5493 if(!HAL_STATUS_SUCCESS(status))
5494 {
5495 break;
5496 }
5497 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5498 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5499 }
5500 if(pSrcProfile->SSID.ssId)
5501 {
5502 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5503 if(!HAL_STATUS_SUCCESS(status))
5504 {
5505 break;
5506 }
5507 pDstProfile->SSIDs.numOfSSIDs = 1;
5508 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5509 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5510 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5511 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005512 if(pSrcProfile->nAddIEAssocLength)
5513 {
5514 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5515 if(!HAL_STATUS_SUCCESS(status))
5516 {
5517 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs \n") );
5518 break;
5519 }
5520 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5521 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5522 pSrcProfile->nAddIEAssocLength);
5523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5525 if(!HAL_STATUS_SUCCESS(status))
5526 {
5527 break;
5528 }
5529 pDstProfile->ChannelInfo.numOfChannels = 1;
5530 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 pDstProfile->AuthType.numEntries = 1;
5532 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5533 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5534 pDstProfile->EncryptionType.numEntries = 1;
5535 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5536 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5537 pDstProfile->mcEncryptionType.numEntries = 1;
5538 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5539 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5540 pDstProfile->BSSType = pSrcProfile->BSSType;
5541 pDstProfile->CBMode = pSrcProfile->CBMode;
5542 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5543#ifdef WLAN_FEATURE_VOWIFI_11R
5544 if (pSrcProfile->MDID.mdiePresent)
5545 {
5546 pDstProfile->MDID.mdiePresent = 1;
5547 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5548 }
5549#endif
5550
5551 }while(0);
5552
5553 if(!HAL_STATUS_SUCCESS(status))
5554 {
5555 csrReleaseProfile(pMac, pDstProfile);
5556 pDstProfile = NULL;
5557 }
5558
5559 return (status);
5560}
5561
Jeff Johnson295189b2012-06-20 16:38:30 -07005562eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5563 tScanResultHandle hBSSList,
5564 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5565 tANI_BOOLEAN fClearScan)
5566{
5567 eHalStatus status = eHAL_STATUS_SUCCESS;
5568 tSmeCmd *pCommand;
5569
5570 pCommand = csrGetCommandBuffer(pMac);
5571 if(NULL == pCommand)
5572 {
5573 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5574 status = eHAL_STATUS_RESOURCES;
5575 }
5576 else
5577 {
5578 if( fClearScan )
5579 {
5580 csrScanCancelIdleScan(pMac);
5581 csrScanAbortMacScanNotForConnect(pMac);
5582 }
5583 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5584 if(NULL == pProfile)
5585 {
5586 //We can roam now
5587 //Since pProfile is NULL, we need to build our own profile, set everything to default
5588 //We can only support open and no encryption
5589 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5590 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5591 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5592 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5593 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5594 }
5595 else
5596 {
5597 //make a copy of the profile
5598 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5599 if(HAL_STATUS_SUCCESS(status))
5600 {
5601 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5602 }
5603 }
5604 pCommand->command = eSmeCommandRoam;
5605 pCommand->sessionId = (tANI_U8)sessionId;
5606 pCommand->u.roamCmd.hBSSList = hBSSList;
5607 pCommand->u.roamCmd.roamId = roamId;
5608 pCommand->u.roamCmd.roamReason = reason;
5609 //We need to free the BssList when the command is done
5610 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5611 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5613 FL("CSR PERSONA=%d"),
5614 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5616 if( !HAL_STATUS_SUCCESS( status ) )
5617 {
5618 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5619 csrReleaseCommandRoam( pMac, pCommand );
5620 }
5621 }
5622
5623 return (status);
5624}
Jeff Johnson295189b2012-06-20 16:38:30 -07005625eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5626 tCsrRoamModifyProfileFields *pMmodProfileFields,
5627 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5628{
5629 eHalStatus status = eHAL_STATUS_SUCCESS;
5630 tSmeCmd *pCommand;
5631
5632 pCommand = csrGetCommandBuffer(pMac);
5633 if(NULL == pCommand)
5634 {
5635 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5636 status = eHAL_STATUS_RESOURCES;
5637 }
5638 else
5639 {
5640 csrScanCancelIdleScan(pMac);
5641 csrScanAbortMacScanNotForConnect(pMac);
5642 if(pProfile)
5643 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 //This is likely trying to reassoc to different profile
5645 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5646 //make a copy of the profile
5647 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5648 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 }
5650 else
5651 {
5652 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5653 //how to update WPA/WPA2 info in roamProfile??
5654 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 if(HAL_STATUS_SUCCESS(status))
5657 {
5658 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5659 }
5660 pCommand->command = eSmeCommandRoam;
5661 pCommand->sessionId = (tANI_U8)sessionId;
5662 pCommand->u.roamCmd.roamId = roamId;
5663 pCommand->u.roamCmd.roamReason = reason;
5664 //We need to free the BssList when the command is done
5665 //For reassoc there is no BSS list, so the boolean set to false
5666 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5667 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5668 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5670 if( !HAL_STATUS_SUCCESS( status ) )
5671 {
5672 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5673 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5674 csrReleaseCommandRoam( pMac, pCommand );
5675 }
5676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 return (status);
5678}
5679
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005680eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
5681 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
5682// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5683{
5684 eHalStatus status = eHAL_STATUS_SUCCESS;
5685 tSmeCmd *pCommand;
5686
5687 pCommand = csrGetCommandBuffer(pMac);
5688 if(NULL == pCommand)
5689 {
5690 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5691 status = eHAL_STATUS_RESOURCES;
5692 }
5693 else
5694 {
5695 if(pBssDescription)
5696 {
5697 //copy over the parameters we need later
5698 pCommand->command = eSmeCommandRoam;
5699 pCommand->sessionId = (tANI_U8)sessionId;
5700 pCommand->u.roamCmd.roamReason = reason;
5701 //this is the important parameter
5702 //in this case we are using this field for the "next" BSS
5703 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
5704 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
5705 if( !HAL_STATUS_SUCCESS( status ) )
5706 {
5707 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d\n"), status );
5708 csrReleaseCommandPreauth( pMac, pCommand );
5709 }
5710 }
5711 else
5712 {
5713 //Return failure
5714 status = eHAL_STATUS_RESOURCES;
5715 }
5716 }
5717 return (status);
5718}
5719
5720eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
5721{
5722 tListElem *pEntry;
5723 tSmeCmd *pCommand;
5724 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5725 if ( pEntry )
5726 {
5727 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5728 if ( (eSmeCommandRoam == pCommand->command) &&
5729 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
5730 {
5731 smsLog( pMac, LOGE, FL("DQ-Command = %d, Reason = %d \n"),
5732 pCommand->command, pCommand->u.roamCmd.roamReason);
5733 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
5734 csrReleaseCommandPreauth( pMac, pCommand );
5735 }
5736 } else {
5737 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d \n"),
5738 pCommand->command, pCommand->u.roamCmd.roamReason);
5739 }
5740 }
5741 else {
5742 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP\n"));
5743 }
5744 smeProcessPendingQueue( pMac );
5745 return eHAL_STATUS_SUCCESS;
5746}
5747
Jeff Johnson295189b2012-06-20 16:38:30 -07005748eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5749 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5750{
5751 eHalStatus status = eHAL_STATUS_FAILURE;
5752 tScanResultHandle hBSSList;
5753 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5755 if(HAL_STATUS_SUCCESS(status))
5756 {
5757 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5758 if(pRoamId)
5759 {
5760 *pRoamId = roamId;
5761 }
5762 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5763 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5764 if(!HAL_STATUS_SUCCESS(status))
5765 {
5766 smsLog(pMac, LOGE, FL("failed to start a join process\n"));
5767 csrScanResultPurge(pMac, hBSSList);
5768 }
5769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 return (status);
5771}
5772
Jeff Johnson295189b2012-06-20 16:38:30 -07005773eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5774 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5775{
5776 eHalStatus status = eHAL_STATUS_SUCCESS;
5777 tScanResultHandle hBSSList;
5778 tCsrScanResultFilter *pScanFilter;
5779 tANI_U32 roamId = 0;
5780 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5781 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 if (NULL == pProfile)
5783 {
5784 smsLog(pMac, LOGP, FL("No profile specified"));
5785 return eHAL_STATUS_FAILURE;
5786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"),
5788 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 if( CSR_IS_WDS( pProfile ) &&
5790 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5791 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005792 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d\n"),
5793 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 return status;
5795 }
5796 csrRoamCancelRoaming(pMac, sessionId);
5797 csrScanRemoveFreshScanCommand(pMac, sessionId);
5798 csrScanCancelIdleScan(pMac);
5799 //Only abort the scan if it is not used for other roam/connect purpose
5800 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005801#ifdef WLAN_SOFTAP_FEATURE
5802 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5803 {
5804 csrScanDisable(pMac);
5805 }
5806#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5808 //Check whether ssid changes
5809 if(csrIsConnStateConnected(pMac, sessionId))
5810 {
5811 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5812 {
5813 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5814 }
5815 }
5816#ifdef FEATURE_WLAN_BTAMP_UT_RF
5817 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
5818#endif
5819 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
5820 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005821 smsLog(pMac, LOG1, FL("is called with BSSList\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
5823 if(pRoamId)
5824 {
5825 roamId = *pRoamId;
5826 }
5827 if(!HAL_STATUS_SUCCESS(status))
5828 {
5829 fCallCallback = eANI_BOOLEAN_TRUE;
5830 }
5831 }
5832 else
5833 {
5834 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5835 if(HAL_STATUS_SUCCESS(status))
5836 {
5837 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5838 //Try to connect to any BSS
5839 if(NULL == pProfile)
5840 {
5841 //No encryption
5842 pScanFilter->EncryptionType.numEntries = 1;
5843 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5844 }//we don't have a profile
5845 else
5846 {
5847 //Here is the profile we need to connect to
5848 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
5849 }//We have a profile
5850 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5851 if(pRoamId)
5852 {
5853 *pRoamId = roamId;
5854 }
5855
5856 if(HAL_STATUS_SUCCESS(status))
5857 {
5858 /*Save the WPS info*/
5859 if(NULL != pProfile)
5860 {
5861 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
5862 }
5863 else
5864 {
5865 pScanFilter->bWPSAssociation = 0;
5866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 do
5868 {
5869 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
5870#ifdef WLAN_SOFTAP_FEATURE
5871 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
5872#endif
5873 )
5874 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005875 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
5877 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5878 if(!HAL_STATUS_SUCCESS(status))
5879 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005880 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 fCallCallback = eANI_BOOLEAN_TRUE;
5882 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005883 else
5884 {
5885 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
5886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 break;
5888 }
5889 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Mohit Khanna23863762012-09-11 17:40:09 -07005890 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d\n", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 if(HAL_STATUS_SUCCESS(status))
5892 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5894 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5895 if(!HAL_STATUS_SUCCESS(status))
5896 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005897 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 csrScanResultPurge(pMac, hBSSList);
5899 fCallCallback = eANI_BOOLEAN_TRUE;
5900 }
5901 }//Have scan result
5902 else if(NULL != pProfile)
5903 {
5904 //Check whether it is for start ibss
5905 if(CSR_IS_START_IBSS(pProfile))
5906 {
5907 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
5908 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5909 if(!HAL_STATUS_SUCCESS(status))
5910 {
5911 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X\n", status);
5912 fCallCallback = eANI_BOOLEAN_TRUE;
5913 }
5914 }
5915 else
5916 {
5917 //scan for this SSID
5918 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
5919 if(!HAL_STATUS_SUCCESS(status))
5920 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005921 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 fCallCallback = eANI_BOOLEAN_TRUE;
5923 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005924 else
5925 {
5926 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
5927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 }
5929 }
5930 else
5931 {
5932 fCallCallback = eANI_BOOLEAN_TRUE;
5933 }
5934 } while (0);
5935 if(NULL != pProfile)
5936 {
5937 //we need to free memory for filter if profile exists
5938 csrFreeScanFilter(pMac, pScanFilter);
5939 }
5940 }//Got the scan filter from profile
5941
5942 palFreeMemory(pMac->hHdd, pScanFilter);
5943 }//allocated memory for pScanFilter
5944 }//No Bsslist coming in
5945 //tell the caller if we fail to trigger a join request
5946 if( fCallCallback )
5947 {
5948 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
5949 }
5950
5951 return (status);
5952}
Jeff Johnson295189b2012-06-20 16:38:30 -07005953eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5954 tCsrRoamModifyProfileFields modProfileFields,
5955 tANI_U32 *pRoamId)
5956{
5957 eHalStatus status = eHAL_STATUS_SUCCESS;
5958 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
5959 tANI_U32 roamId = 0;
5960 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 if (NULL == pProfile)
5962 {
5963 smsLog(pMac, LOGP, FL("No profile specified"));
5964 return eHAL_STATUS_FAILURE;
5965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
5967 csrRoamCancelRoaming(pMac, sessionId);
5968 csrScanRemoveFreshScanCommand(pMac, sessionId);
5969 csrScanCancelIdleScan(pMac);
5970 csrScanAbortMacScanNotForConnect(pMac);
5971 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 if(csrIsConnStateConnected(pMac, sessionId))
5973 {
5974 if(pProfile)
5975 {
5976 if(pProfile->SSIDs.numOfSSIDs &&
5977 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5978 {
5979 fCallCallback = eANI_BOOLEAN_FALSE;
5980 }
5981 else
5982 {
5983 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile\n"));
5984 }
5985 }
5986 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
5987 &pSession->connectedProfile.modifyProfileFields,
5988 sizeof(tCsrRoamModifyProfileFields)))
5989 {
5990 fCallCallback = eANI_BOOLEAN_FALSE;
5991 }
5992 else
5993 {
5994 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
5995 "in tCsrRoamModifyProfileFields got modified\n"));
5996 }
5997 }
5998 else
5999 {
6000 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc\n"));
6001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if(!fCallCallback)
6003 {
6004 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6005 if(pRoamId)
6006 {
6007 *pRoamId = roamId;
6008 }
6009
Jeff Johnson295189b2012-06-20 16:38:30 -07006010 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6011 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 }
6013 else
6014 {
6015 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6016 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 return status;
6019}
Jeff Johnson295189b2012-06-20 16:38:30 -07006020eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6021{
6022 eHalStatus status = eHAL_STATUS_FAILURE;
6023 tScanResultHandle hBSSList = NULL;
6024 tCsrScanResultFilter *pScanFilter = NULL;
6025 tANI_U32 roamId;
6026 tCsrRoamProfile *pProfile = NULL;
6027 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006028
6029 if(!pSession)
6030 {
6031 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6032 return eHAL_STATUS_FAILURE;
6033 }
6034
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 do
6036 {
6037 if(pSession->pCurRoamProfile)
6038 {
6039 csrScanCancelIdleScan(pMac);
6040 csrScanAbortMacScanNotForConnect(pMac);
6041 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6042 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6043 if(!HAL_STATUS_SUCCESS(status))
6044 break;
6045 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6046 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6047 if(!HAL_STATUS_SUCCESS(status))
6048 break;
6049 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6050 if(!HAL_STATUS_SUCCESS(status))
6051 {
6052 break;
6053 }
6054 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6055 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6056 if(!HAL_STATUS_SUCCESS(status))
6057 {
6058 break;
6059 }
6060 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6061 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6062 if(HAL_STATUS_SUCCESS(status))
6063 {
6064 //we want to put the last connected BSS to the very beginning, if possible
6065 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6066 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6067 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6068 if(!HAL_STATUS_SUCCESS(status))
6069 {
6070 csrScanResultPurge(pMac, hBSSList);
6071 break;
6072 }
6073 }
6074 else
6075 {
6076 //Do a scan on this profile
6077 //scan for this SSID only in case the AP suppresses SSID
6078 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6079 if(!HAL_STATUS_SUCCESS(status))
6080 {
6081 break;
6082 }
6083 }
6084 }//We have a profile
6085 else
6086 {
6087 smsLog(pMac, LOGW, FL("cannot find a roaming profile\n"));
6088 break;
6089 }
6090 }while(0);
6091 if(pScanFilter)
6092 {
6093 csrFreeScanFilter(pMac, pScanFilter);
6094 palFreeMemory(pMac->hHdd, pScanFilter);
6095 }
6096 if(NULL != pProfile)
6097 {
6098 csrReleaseProfile(pMac, pProfile);
6099 palFreeMemory(pMac->hHdd, pProfile);
6100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 return (status);
6102}
Jeff Johnson295189b2012-06-20 16:38:30 -07006103eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6104{
6105 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 if(csrIsConnStateConnected(pMac, sessionId))
6107 {
6108 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6109 if(HAL_STATUS_SUCCESS(status))
6110 {
6111 status = csrRoamJoinLastProfile(pMac, sessionId);
6112 }
6113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 return (status);
6115}
6116
Jeff Johnson295189b2012-06-20 16:38:30 -07006117eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6118{
6119 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 smsLog(pMac, LOGW, FL("is called\n"));
6121 csrRoamCancelRoaming(pMac, sessionId);
6122 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6123 if(csrIsConnStateDisconnected(pMac, sessionId))
6124 {
6125 status = csrRoamJoinLastProfile(pMac, sessionId);
6126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 return (status);
6128}
6129
Jeff Johnson295189b2012-06-20 16:38:30 -07006130eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6131{
6132 eHalStatus status = eHAL_STATUS_SUCCESS;
6133 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6134 eCsrRoamSubState NewSubstate;
6135 tANI_U32 sessionId = pCommand->sessionId;
6136
6137 // change state to 'Roaming'...
6138 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6139
6140 if ( csrIsConnStateIbss( pMac, sessionId ) )
6141 {
6142 // If we are in an IBSS, then stop the IBSS...
6143 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6144 fComplete = (!HAL_STATUS_SUCCESS(status));
6145 }
6146 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6147 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07006148 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 -07006149 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6150 //Restore AC weight in case we change it
6151 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6152 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6153 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6154 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6155 {
6156 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6157 }
6158 if( fDisassoc )
6159 {
6160 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6161 }
6162 else
6163 {
6164 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6165 }
6166 fComplete = (!HAL_STATUS_SUCCESS(status));
6167 }
6168 else if ( csrIsConnStateWds( pMac, sessionId ) )
6169 {
6170 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6171 {
6172 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6173 fComplete = (!HAL_STATUS_SUCCESS(status));
6174 }
6175 //This has to be WDS station
6176 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6177 {
6178
6179 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6180 if( fDisassoc )
6181 {
6182 status = csrRoamIssueDisassociate( pMac, sessionId,
6183 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6184 fComplete = (!HAL_STATUS_SUCCESS(status));
6185 }
6186 }
6187 } else {
6188 // we got a dis-assoc request while not connected to any peer
6189 // just complete the command
6190 fComplete = eANI_BOOLEAN_TRUE;
6191 status = eHAL_STATUS_FAILURE;
6192 }
6193 if(fComplete)
6194 {
6195 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6196 }
6197
6198 if(HAL_STATUS_SUCCESS(status))
6199 {
6200 if ( csrIsConnStateInfra( pMac, sessionId ) )
6201 {
6202 //Set the state to disconnect here
6203 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6204 }
6205 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006206 else
6207 {
6208 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 return (status);
6211}
6212
Jeff Johnson295189b2012-06-20 16:38:30 -07006213/* This is been removed from latest code base */
6214/*
6215static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6216{
6217 eHalStatus status;
6218 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6220 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 return ( status );
6222}
6223*/
6224
Jeff Johnson295189b2012-06-20 16:38:30 -07006225eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6226{
6227 eHalStatus status = eHAL_STATUS_SUCCESS;
6228 tSmeCmd *pCommand;
6229 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 do
6231 {
6232 smsLog( pMac, LOGE, FL(" reason = %d\n"), reason );
6233 pCommand = csrGetCommandBuffer( pMac );
6234 if ( !pCommand )
6235 {
6236 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6237 status = eHAL_STATUS_RESOURCES;
6238 break;
6239 }
6240 //Change the substate in case it is wait-for-key
6241 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6242 {
6243 csrRoamStopWaitForKeyTimer( pMac );
6244 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6245 }
6246 pCommand->command = eSmeCommandRoam;
6247 pCommand->sessionId = (tANI_U8)sessionId;
6248 switch ( reason )
6249 {
6250 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6251 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6252 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 case eCSR_DISCONNECT_REASON_DEAUTH:
6254 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6255 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 case eCSR_DISCONNECT_REASON_HANDOFF:
6257 fHighPriority = eANI_BOOLEAN_TRUE;
6258 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6259 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6261 case eCSR_DISCONNECT_REASON_DISASSOC:
6262 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6265 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6266 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6268 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6269 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 default:
6271 break;
6272 }
6273 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6274 if( !HAL_STATUS_SUCCESS( status ) )
6275 {
6276 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6277 csrReleaseCommandRoam( pMac, pCommand );
6278 }
6279 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 return( status );
6281}
6282
Jeff Johnson295189b2012-06-20 16:38:30 -07006283eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6284{
6285 eHalStatus status = eHAL_STATUS_SUCCESS;
6286 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 pCommand = csrGetCommandBuffer( pMac );
6288 if ( NULL != pCommand )
6289 {
6290 //Change the substate in case it is wait-for-key
6291 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6292 {
6293 csrRoamStopWaitForKeyTimer( pMac );
6294 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6295 }
6296 pCommand->command = eSmeCommandRoam;
6297 pCommand->sessionId = (tANI_U8)sessionId;
6298 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6299 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6300 if( !HAL_STATUS_SUCCESS( status ) )
6301 {
6302 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6303 csrReleaseCommandRoam( pMac, pCommand );
6304 }
6305 }
6306 else
6307 {
6308 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6309 status = eHAL_STATUS_RESOURCES;
6310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 return ( status );
6312}
6313
Jeff Johnson295189b2012-06-20 16:38:30 -07006314eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6315{
6316 eHalStatus status = eHAL_STATUS_SUCCESS;
6317 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006318
6319 if(!pSession)
6320 {
6321 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6322 return eHAL_STATUS_FAILURE;
6323 }
6324
Jeff Johnson295189b2012-06-20 16:38:30 -07006325#ifdef FEATURE_WLAN_BTAMP_UT_RF
6326 //Stop te retry
6327 pSession->maxRetryCount = 0;
6328 csrRoamStopJoinRetryTimer(pMac, sessionId);
6329#endif
6330 //Not to call cancel roaming here
6331 //Only issue disconnect when necessary
6332 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6333 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6334 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6335
6336 {
6337 smsLog(pMac, LOG2, FL("called\n"));
6338 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 return (status);
6341}
6342
Jeff Johnson295189b2012-06-20 16:38:30 -07006343eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6344{
6345 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006346
6347 if(!pSession)
6348 {
6349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6350 return eHAL_STATUS_FAILURE;
6351 }
6352
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 csrRoamCancelRoaming(pMac, sessionId);
6354 pSession->ibss_join_pending = FALSE;
6355 csrRoamStopIbssJoinTimer(pMac, sessionId);
6356 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6357
6358 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6359}
6360
Jeff Johnson295189b2012-06-20 16:38:30 -07006361eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6362 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6363{
6364 eHalStatus status = eHAL_STATUS_SUCCESS;
6365 tDot11fBeaconIEs *pIesTemp = pIes;
6366 tANI_U8 index;
6367 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6368 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006369
6370 if(!pSession)
6371 {
6372 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6373 return eHAL_STATUS_FAILURE;
6374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006375
6376 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6377 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6378 pConnectProfile->AuthInfo = pProfile->AuthType;
6379 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6380 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6381 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6382 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6383 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6384 pConnectProfile->BSSType = pProfile->BSSType;
6385 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6386 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006387 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6388
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006390 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6391 if(pProfile->nAddIEAssocLength)
6392 {
6393 status = palAllocateMemory(pMac->hHdd,
6394 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6395 if(!HAL_STATUS_SUCCESS(status))
6396 {
6397 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6398 return eHAL_STATUS_FAILURE;
6399 }
6400 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6401 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6402 pProfile->nAddIEAssocLength);
6403 }
6404
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 //Save bssid
6406 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6407#ifdef WLAN_FEATURE_VOWIFI_11R
6408 if (pSirBssDesc->mdiePresent)
6409 {
6410 pConnectProfile->MDID.mdiePresent = 1;
6411 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6412 }
6413#endif
6414#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006415 if ((csrIsProfileCCX(pProfile) ||
6416 ((pIesTemp->CCXVersion.present)
6417 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6418 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6419 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6420 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
6421 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
6422 && (!(csrIsProfile11r( pProfile )))
6423 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 {
6425 pConnectProfile->isCCXAssoc = 1;
6426 }
6427#endif
6428 //save ssid
6429 if( NULL == pIesTemp )
6430 {
6431 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6432 }
6433 if(HAL_STATUS_SUCCESS(status))
6434 {
6435 if(pIesTemp->SSID.present)
6436 {
6437 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6438 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6439 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6440 }
6441
6442 //Save the bss desc
6443 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306444
6445 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306447 //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 -07006448 pConnectProfile->qap = TRUE;
6449 }
6450 else
6451 {
6452 pConnectProfile->qap = FALSE;
6453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 if ( NULL == pIes )
6455 {
6456 //Free memory if it allocated locally
6457 palFreeMemory(pMac->hHdd, pIesTemp);
6458 }
6459 }
6460 //Save Qos connection
6461 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6462
6463 if(!HAL_STATUS_SUCCESS(status))
6464 {
6465 csrFreeConnectBssDesc(pMac, sessionId);
6466 }
6467 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6468 {
6469 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6470 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6471 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6472 {
6473 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6474 break;
6475 }
6476 pConnectProfile->handoffPermitted = FALSE;
6477 }
6478
6479 return (status);
6480}
6481
Jeff Johnson295189b2012-06-20 16:38:30 -07006482static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6483{
6484 tListElem *pEntry = NULL;
6485 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 //The head of the active list is the request we sent
6487 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6488 if(pEntry)
6489 {
6490 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6493 {
6494 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6495 {
6496#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6497 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6498#endif
6499 }
6500 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6501 }
6502 else
6503 {
6504 tANI_U32 roamId = 0;
6505 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006506 if(!pSession)
6507 {
6508 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6509 return;
6510 }
6511
Jeff Johnson295189b2012-06-20 16:38:30 -07006512
6513 //The head of the active list is the request we sent
6514 //Try to get back the same profile and roam again
6515 if(pCommand)
6516 {
6517 roamId = pCommand->u.roamCmd.roamId;
6518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6520 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
6521 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6522#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6523 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6524 if (csrRoamIsHandoffInProgress(pMac))
6525 {
6526 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6527 /* Should indicate neighbor roam algorithm about the connect failure here */
6528 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6529 }
6530#endif
6531 if (pCommand)
6532 {
6533 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6534 {
6535 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6536 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6537 csrRoamReissueRoamCommand(pMac);
6538 }
6539 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6540 {
6541 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6542 }
6543 else
6544 {
6545 csrRoam(pMac, pCommand);
6546 }
6547 }
6548 else
6549 {
6550 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6551 }
6552 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6553}
6554
Jeff Johnson295189b2012-06-20 16:38:30 -07006555eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6556 tDot11fBeaconIEs *pIes,
6557 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6558{
6559 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
6561 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6562 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6563
6564 // Set the roaming substate to 'join attempt'...
6565 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 // attempt to Join this BSS...
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006567 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 return (status);
6569}
6570
Jeff Johnson295189b2012-06-20 16:38:30 -07006571static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6572 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6573{
6574 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 // Set the roaming substate to 'join attempt'...
6576 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6577
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006578 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006579
6580 // attempt to Join this BSS...
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006581 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006582}
6583
Jeff Johnson295189b2012-06-20 16:38:30 -07006584void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6585{
6586 tListElem *pEntry;
6587 tSmeCmd *pCommand;
6588 tCsrRoamInfo roamInfo;
6589 tANI_U32 sessionId;
6590 tCsrRoamSession *pSession;
6591
6592 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6593 if(pEntry)
6594 {
6595 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6596 if ( eSmeCommandRoam == pCommand->command )
6597 {
6598 sessionId = pCommand->sessionId;
6599 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006600
6601 if(!pSession)
6602 {
6603 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6604 return;
6605 }
6606
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 if( pCommand->u.roamCmd.fStopWds )
6608 {
6609 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6610 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6611 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6612 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6613#ifdef WLAN_SOFTAP_FEATURE
6614 if (CSR_IS_WDS(&pSession->connectedProfile)){
6615#endif
6616 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6617 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6618 eCSR_ROAM_WDS_IND,
6619 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
6620#ifdef WLAN_SOFTAP_FEATURE
6621 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6622 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6623 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6624 eCSR_ROAM_INFRA_IND,
6625 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6626 }
6627
6628#endif
6629
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6631 {
6632 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated\n");
6633 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6634 }
6635 }
6636 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6637 {
6638 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated\n");
6639 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6640 }
6641 }
6642 else
6643 {
6644 smsLog(pMac, LOGW, " Command is not roaming after disassociated\n");
6645 }
6646 }
6647 else
6648 {
6649 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available\n");
6650 }
6651}
6652
Jeff Johnson295189b2012-06-20 16:38:30 -07006653tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6654{
6655 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6656 tListElem *pEntry;
6657 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 //alwasy lock active list before locking pending list
6659 csrLLLock( &pMac->sme.smeCmdActiveList );
6660 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6661 if(pEntry)
6662 {
6663 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6664 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6665 {
6666 fRet = eANI_BOOLEAN_TRUE;
6667 }
6668 }
6669 if(eANI_BOOLEAN_FALSE == fRet)
6670 {
6671 csrLLLock(&pMac->sme.smeCmdPendingList);
6672 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6673 while(pEntry)
6674 {
6675 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6676 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6677 {
6678 fRet = eANI_BOOLEAN_TRUE;
6679 break;
6680 }
6681 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6682 }
6683 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6684 }
6685 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 return (fRet);
6687}
6688
Jeff Johnson295189b2012-06-20 16:38:30 -07006689tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6690{
6691 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6692 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6694 {
6695 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6696 {
6697 break;
6698 }
6699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 return ( fRet );
6701}
6702
Jeff Johnson295189b2012-06-20 16:38:30 -07006703tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6704{
6705 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 //alwasy lock active list before locking pending list
6707 csrLLLock( &pMac->sme.smeCmdActiveList );
6708 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6709 if(eANI_BOOLEAN_FALSE == fRet)
6710 {
6711 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6712 }
6713 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 return (fRet);
6715}
6716
Jeff Johnson295189b2012-06-20 16:38:30 -07006717tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6718{
6719 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6720 tListElem *pEntry;
6721 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 //alwasy lock active list before locking pending list
6723 csrLLLock( &pMac->sme.smeCmdActiveList );
6724 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6725 if( pEntry )
6726 {
6727 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6728 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6729 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6730 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6731 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6732 {
6733 fRet = eANI_BOOLEAN_TRUE;
6734 }
6735 }
6736 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 return (fRet);
6738}
Jeff Johnson295189b2012-06-20 16:38:30 -07006739eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6740{
6741 eHalStatus status = eHAL_STATUS_SUCCESS;
6742 tSmeCmd *pCommand = NULL;
6743 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6744 tANI_BOOLEAN fRemoveCmd = FALSE;
6745 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 // Delete the old assoc command. All is setup for reassoc to be serialized
6747 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6748 if ( pEntry )
6749 {
6750 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6751 if ( !pCommand )
6752 {
6753 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6754 return eHAL_STATUS_RESOURCES;
6755 }
6756 if ( eSmeCommandRoam == pCommand->command )
6757 {
6758 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6759 {
6760 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6761 }
6762 else
6763 {
6764 smsLog( pMac, LOGE, FL(" Unexpected active roam command present \n") );
6765 }
6766 if (fRemoveCmd == FALSE)
6767 {
6768 // Implies we did not get the serialized assoc command we
6769 // were expecting
6770 pCommand = NULL;
6771 }
6772 }
6773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 if(NULL == pCommand)
6775 {
6776 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command\n") );
6777 return eHAL_STATUS_RESOURCES;
6778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 do
6780 {
6781 //Change the substate in case it is wait-for-key
6782 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6783 {
6784 csrRoamStopWaitForKeyTimer( pMac );
6785 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6786 }
6787 pCommand->command = eSmeCommandRoam;
6788 pCommand->sessionId = (tANI_U8)sessionId;
6789 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6791 if( !HAL_STATUS_SUCCESS( status ) )
6792 {
6793 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6794 csrReleaseCommandRoam( pMac, pCommand );
6795 }
6796 } while( 0 );
6797
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 return( status );
6799}
6800static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6801{
6802 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6803 tCsrScanResult *pScanResult = NULL;
6804 tSirBssDescription *pBssDesc = NULL;
6805 tSmeCmd *pCommand = NULL;
6806 tANI_U32 sessionId;
6807 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 if(NULL == pEntry)
6809 {
6810 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
6811 return;
6812 }
6813 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6814 sessionId = pCommand->sessionId;
6815 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006816
6817 if(!pSession)
6818 {
6819 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6820 return;
6821 }
6822
Jeff Johnson295189b2012-06-20 16:38:30 -07006823 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
6824 {
6825 //the roaming is cancelled. Simply complete the command
6826 smsLog(pMac, LOGW, FL(" Roam command cancelled\n"));
6827 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
6828 }
6829 else
6830 {
6831 if ( CCM_IS_RESULT_SUCCESS(result) )
6832 {
6833 smsLog(pMac, LOG2, "Cfg sequence complete\n");
6834 // Successfully set the configuration parameters for the new Bss. Attempt to
6835 // join the roaming Bss.
6836 if(pCommand->u.roamCmd.pRoamBssEntry)
6837 {
6838 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
6839 pBssDesc = &pScanResult->Result.BssDescriptor;
6840 }
6841 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
6842 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
6843#ifdef WLAN_SOFTAP_FEATURE
6844 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
6845#endif
6846 )
6847 {
6848 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
6849 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
6850 pBssDesc, pCommand->u.roamCmd.roamId )))
6851 {
6852 smsLog(pMac, LOGW, " CSR start BSS failed\n");
6853 //We need to complete the command
6854 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6855 }
6856 }
6857 else
6858 {
6859 if (!pCommand->u.roamCmd.pRoamBssEntry)
6860 {
6861 smsLog(pMac, LOGW, " pRoamBssEntry is NULL\n");
6862 //We need to complete the command
6863 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
6864 return;
6865 }
6866 // If we are roaming TO an Infrastructure BSS...
6867 VOS_ASSERT(pScanResult != NULL);
6868 if ( csrIsInfraBssDesc( pBssDesc ) )
6869 {
6870 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
6872 {
6873 // ..and currently in an Infrastructure connection....
6874 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
6875 {
6876 // ...and the SSIDs are equal, then we Reassoc.
6877 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
6878 pIesLocal ) )
6879 // ..and currently in an infrastructure connection
6880 {
6881 // then issue a Reassoc.
6882 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
6883 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
6884 &pCommand->u.roamCmd.roamProfile );
6885 }
6886 else
6887 {
6888
6889 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
6890 // previously associated AP.
6891 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
6892 pIesLocal,
6893 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
6894 {
6895 //try something else
6896 csrRoam( pMac, pCommand );
6897 }
6898 }
6899 }
6900 else
6901 {
6902 eHalStatus status = eHAL_STATUS_SUCCESS;
6903
6904 /* We need to come with other way to figure out that this is because of HO in BMP
6905 The below API will be only available for Android as it uses a different HO algorithm */
6906 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
6907 * use join request */
6908#ifdef WLAN_FEATURE_VOWIFI_11R
6909 if (csrRoamIsHandoffInProgress(pMac) &&
6910 csrRoamIs11rAssoc(pMac))
6911 {
6912 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
6913 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
6914 }
6915 else
6916#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006917#ifdef FEATURE_WLAN_CCX
6918 if (csrRoamIsHandoffInProgress(pMac) &&
6919 csrRoamIsCCXAssoc(pMac))
6920 {
6921 // Now serialize the reassoc command.
6922 status = csrRoamIssueReassociateCmd(pMac, sessionId);
6923 }
6924 else
6925#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006926#ifdef FEATURE_WLAN_LFR
6927 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05306928 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006929 {
6930 // Now serialize the reassoc command.
6931 status = csrRoamIssueReassociateCmd(pMac, sessionId);
6932 }
6933 else
6934#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 // else we are not connected and attempting to Join. Issue the
6936 // Join request.
6937 {
6938 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
6939 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
6940 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
6941 }
6942 if(!HAL_STATUS_SUCCESS(status))
6943 {
6944 //try something else
6945 csrRoam( pMac, pCommand );
6946 }
6947 }
6948 if( !pScanResult->Result.pvIes )
6949 {
6950 //Locally allocated
6951 palFreeMemory(pMac->hHdd, pIesLocal);
6952 }
6953 }
6954 }//if ( csrIsInfraBssDesc( pBssDesc ) )
6955 else
6956 {
6957 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description\n"));
6958 }
6959 }//else
6960 }//if ( WNI_CFG_SUCCESS == result )
6961 else
6962 {
6963 // In the event the configuration failed, for infra let the roam processor
6964 //attempt to join something else...
6965 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
6966 {
6967 csrRoam(pMac, pCommand);
6968 }
6969 else
6970 {
6971 //We need to complete the command
6972 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
6973 {
6974 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6975 }
6976 else
6977 {
6978 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6979 }
6980 }
6981 }
6982 }//we have active entry
6983}
6984
Jeff Johnson295189b2012-06-20 16:38:30 -07006985static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
6986{
6987 //No one is sending eWNI_SME_AUTH_REQ to PE.
6988 smsLog(pMac, LOGW, FL("is no-op\n"));
6989 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
6990 {
6991 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful\n" );
6992 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
6993 // join the new one...
6994 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
6996 }
6997 else {
6998 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]\n", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
6999 /***profHandleLostLinkAfterReset(pAdapter);
7000 // In the event the authenticate fails, let the roam processor attempt to join something else...
7001 roamRoam( pAdapter );***/
7002 }
7003}
7004
Jeff Johnson295189b2012-06-20 16:38:30 -07007005static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7006{
7007 eCsrRoamCompleteResult result;
7008 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7009 tCsrRoamInfo roamInfo;
7010 tANI_U32 roamId = 0;
7011
7012 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7013 {
7014 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful\n" );
7015 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 /* Defeaturize this part later if needed */
7017#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7018 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7019 * we need the response contents while processing the result in csrRoamProcessResults() */
7020 if (csrRoamIsHandoffInProgress(pMac))
7021 {
7022 /* Need to dig more on indicating events to SME QoS module */
7023 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7024 csrRoamComplete( pMac, result, pSmeJoinRsp);
7025 }
7026 else
7027#endif
7028 {
7029 csrRoamComplete( pMac, result, NULL );
7030 }
7031 }
7032 /* Should we handle this similar to handling the join failure? Is it ok
7033 * to call csrRoamComplete() with state as CsrJoinFailure */
7034 else
7035 {
7036 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
7037 result = eCsrReassocFailure;
7038#ifdef WLAN_FEATURE_VOWIFI_11R
7039 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7040 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7041 {
7042 // Inform HDD to turn off FT flag in HDD
7043 if (pNeighborRoamInfo)
7044 {
7045 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7046 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7047 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007048 /*
7049 * Since the above callback sends a disconnect
7050 * to HDD, we should clean-up our state
7051 * machine as well to be in sync with the upper
7052 * layers. There is no need to send a disassoc
7053 * since: 1) we will never reassoc to the current
7054 * AP in LFR, and 2) there is no need to issue a
7055 * disassoc to the AP with which we were trying
7056 * to reassoc.
7057 */
7058 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7059 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 }
7061 }
7062#endif
7063 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7064 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7065 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7066 //The disassoc rsp message will remove the command from active list
7067 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7068 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7069 {
7070 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7071 }
7072 }
7073}
7074
Jeff Johnson295189b2012-06-20 16:38:30 -07007075static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7076{
Jeff Johnson295189b2012-06-20 16:38:30 -07007077#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7078 {
7079 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7081 if(pIbssLog)
7082 {
7083 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7084 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7085 {
7086 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7087 }
7088 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7089 }
7090 }
7091#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7093 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7094 {
7095 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7096 }
7097 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7098 {
7099 csrRoamReissueRoamCommand(pMac);
7100 }
7101}
7102
Jeff Johnson295189b2012-06-20 16:38:30 -07007103void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7104{
7105 tSirResultCodes statusCode;
7106#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7107 tScanResultHandle hBSSList;
7108 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7109 eHalStatus status;
7110 tCsrRoamInfo roamInfo;
7111 tCsrScanResultFilter *pScanFilter = NULL;
7112 tANI_U32 roamId = 0;
7113 tCsrRoamProfile *pCurRoamProfile = NULL;
7114 tListElem *pEntry = NULL;
7115 tSmeCmd *pCommand = NULL;
7116#endif
7117 tANI_U32 sessionId;
7118 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007119
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 tSirSmeDisassocRsp SmeDisassocRsp;
7121
7122 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7123 sessionId = SmeDisassocRsp.sessionId;
7124 statusCode = SmeDisassocRsp.statusCode;
7125
7126 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d\n", sessionId);
7127
7128 if ( csrIsConnStateInfra( pMac, sessionId ) )
7129 {
7130 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007133
7134 if(!pSession)
7135 {
7136 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7137 return;
7138 }
7139
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7141 {
7142 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7143 }
7144 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7145 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7146 {
7147 if ( eSIR_SME_SUCCESS == statusCode )
7148 {
7149 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully\n" );
7150 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7151 }
7152 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7155 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007156 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d\n", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007157#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007158 /*
7159 * First ensure if the roam profile is in the scan cache.
7160 * If not, post a reassoc failure and disconnect.
7161 */
7162 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7163 if(HAL_STATUS_SUCCESS(status))
7164 {
7165 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7166 status = csrRoamPrepareFilterFromProfile(pMac,
7167 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7168 if(!HAL_STATUS_SUCCESS(status))
7169 {
7170 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
7171 __func__, status);
7172 goto POST_ROAM_FAILURE;
7173 }
7174 else
7175 {
7176 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7177 if (!HAL_STATUS_SUCCESS(status))
7178 {
7179 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
7180 __func__, status);
7181 goto POST_ROAM_FAILURE;
7182 }
7183 }
7184 }
7185 else
7186 {
7187 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
7188 __func__, status);
7189 goto POST_ROAM_FAILURE;
7190 }
7191
7192 /*
7193 * After ensuring that the roam profile is in the scan result list,
7194 * dequeue the command from the active list.
7195 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7197 if ( pEntry )
7198 {
7199 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007200 /* If the head of the queue is Active and it is a ROAM command, remove
7201 * and put this on the Free queue.
7202 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007203 if ( eSmeCommandRoam == pCommand->command )
7204 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007205
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007206 /*
7207 * we need to process the result first before removing it from active list
7208 * because state changes still happening insides roamQProcessRoamResults so
7209 * no other roam command should be issued.
7210 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7212 if(pCommand->u.roamCmd.fReleaseProfile)
7213 {
7214 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7215 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007217 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 else
7220 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007221 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d\n",
7222 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 }
7224 }
7225 else
7226 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007227 smsLog( pMac, LOGE, "%s: roam command not active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 }
7229 }
7230 else
7231 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007232 smsLog( pMac, LOGE, "%s: NO commands are active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007234
7235 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7237
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007238 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7239 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7240 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007241
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007242 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7243 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007244
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007245 /* Copy the connected profile to apply the same for this connection as well */
7246 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7247 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007249 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7250 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7251 //make sure to put it at the head of the cmd queue
7252 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7253 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7254 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7255
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 if(!HAL_STATUS_SUCCESS(status))
7257 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007258 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
7259 __func__, status);
7260 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 }
7262
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007263 /* Notify sub-modules like QoS etc. that handoff happening */
7264 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
7265 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 csrFreeScanFilter(pMac, pScanFilter);
7267 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007268 return;
7269 }
7270
7271POST_ROAM_FAILURE:
7272 if (pScanFilter)
7273 {
7274 csrFreeScanFilter(pMac, pScanFilter);
7275 palFreeMemory( pMac->hHdd, pScanFilter );
7276 }
7277 if (pCurRoamProfile)
7278 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7279
7280 /* Inform the upper layers that the reassoc failed */
7281 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7282 csrRoamCallCallback(pMac, sessionId,
7283 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7284
7285 /*
7286 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7287 * Upon success, we would re-enter this routine after receiving the disassoc
7288 * response and will fall into the reassoc fail sub-state. And, eventually
7289 * call csrRoamComplete which would remove the roam command from SME active
7290 * queue.
7291 */
7292 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7293 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7294 {
7295 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
7296 __func__, status);
7297 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007299#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007300
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7302 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7303 {
7304 // Disassoc due to Reassoc failure falls into this codepath....
7305 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7306 }
7307 else
7308 {
7309 if ( eSIR_SME_SUCCESS == statusCode )
7310 {
7311 // Successfully disassociated from the 'old' Bss...
7312 //
7313 // We get Disassociate response in three conditions.
7314 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7315 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7316 // Infrastructure network.
7317 // - Third is where we are doing an Infra to Infra roam between networks with different
7318 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7319
7320 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully\n" );
7321 }
7322 else
7323 {
7324 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX\n", statusCode );
7325 }
7326 //We are not done yet. Get the data and continue roaming
7327 csrRoamReissueRoamCommand(pMac);
7328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007329}
7330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7332{
7333 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
7335 smsLog(pMac, LOGW, FL("is no-op\n"));
7336 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7337 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7338 {
7339 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7340 }
7341 else
7342 {
7343 if ( eSIR_SME_SUCCESS == statusCode )
7344 {
7345 // Successfully deauth from the 'old' Bss...
7346 //
7347 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully\n" );
7348 }
7349 else
7350 {
7351 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX\n", statusCode );
7352 }
7353 //We are not done yet. Get the data and continue roaming
7354 csrRoamReissueRoamCommand(pMac);
7355 }
7356}
7357
Jeff Johnson295189b2012-06-20 16:38:30 -07007358static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7359{
7360 eCsrRoamCompleteResult result;
7361
7362 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7363 {
7364 smsLog( pMac, LOGW, "SmeStartBssReq Successful\n" );
7365 result = eCsrStartBssSuccess;
7366 }
7367 else
7368 {
7369 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX\n", pSmeStartBssRsp->statusCode );
7370 //Let csrRoamComplete decide what to do
7371 result = eCsrStartBssFailure;
7372 }
7373#ifdef WLAN_SOFTAP_FEATURE
7374 csrRoamComplete( pMac, result, pSmeStartBssRsp);
7375#else
7376 csrRoamComplete( pMac, result, &pSmeStartBssRsp->bssDescription );
7377#endif
7378}
7379
Jeff Johnson295189b2012-06-20 16:38:30 -07007380/*
7381 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7382 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7383 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7384 For the messages where sender allocates memory for specific structures, then it can be
7385 cast accordingly.
7386*/
7387void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7388{
7389 tSirSmeRsp *pSmeRsp;
7390 tSmeIbssPeerInd *pIbssPeerInd;
7391 tCsrRoamInfo roamInfo;
7392 // TODO Session Id need to be acquired in this function
7393 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d\n",
7396 pSmeRsp->messageType, pSmeRsp->messageType,
7397 pMac->roam.curSubState[pSmeRsp->sessionId] );
7398#if defined ANI_PRODUCT_TYPE_AP
7399 pSmeRsp->messageType = pal_be16_to_cpu(pSmeRsp->messageType);
7400 pSmeRsp->length = pal_be16_to_cpu(pSmeRsp->length);
7401 pSmeRsp->statusCode = pal_be32_to_cpu(pSmeRsp->statusCode);
7402#else
7403 pSmeRsp->messageType = (pSmeRsp->messageType);
7404 pSmeRsp->length = (pSmeRsp->length);
7405 pSmeRsp->statusCode = (pSmeRsp->statusCode);
7406#endif
7407 switch (pSmeRsp->messageType)
7408 {
7409
7410 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7411 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7412 {
7413 //We sent a JOIN_REQ
7414 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7415 }
7416 break;
7417
7418 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7419 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7420 {
7421 //We sent a AUTH_REQ
7422 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7423 }
7424 break;
7425
7426 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7427 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7428 {
7429 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7430 }
7431 break;
7432
7433 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7434 {
7435 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7436 }
7437 break;
7438
7439 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7440 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7441 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7442 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7443 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7444 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7445//HO
7446 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7447 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07007448 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d\n"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7450 }
7451 break;
7452
7453 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7454 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7455 {
7456 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7457 }
7458 break;
7459
7460 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7461 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7462 {
7463 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7464 }
7465 break;
7466
7467 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7468 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7469 {
7470 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7474 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7475 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
7476 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state\n");
7477 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7478 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7479 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7480 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7481 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7482 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7483 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7484 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7485 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 default:
7487 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d\n",
7488 pSmeRsp->messageType, pSmeRsp->messageType,
7489 pMac->roam.curSubState[pSmeRsp->sessionId] );
7490
7491 //If we are connected, check the link status change
7492 if(!csrIsConnStateDisconnected(pMac, sessionId))
7493 {
7494 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7495 }
7496 break;
7497 }
7498}
7499
Jeff Johnson295189b2012-06-20 16:38:30 -07007500void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7501{
7502 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 switch (pSirMsg->messageType)
7504 {
7505 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07007506 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 csrRoamStatsRspProcessor( pMac, pSirMsg );
7508 break;
7509#ifdef WLAN_SOFTAP_FEATURE
7510 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7511 {
7512 tCsrRoamSession *pSession;
7513 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7514 tCsrRoamInfo roamInfo;
7515 tCsrRoamInfo *pRoamInfo = NULL;
7516 tANI_U32 sessionId;
7517 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7520 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7522 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7523 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007524
7525 if(!pSession)
7526 {
7527 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7528 return;
7529 }
7530
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7532 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7534 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7535 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7537 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7539 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7542 {
7543 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7544 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7545 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7546 }
7547 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7548 {
7549 vos_sleep( 100 );
7550 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7551 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7552 }
7553
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 }
7555 break;
7556#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007557 default:
7558 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7559 break;
7560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007561}
7562
Jeff Johnson295189b2012-06-20 16:38:30 -07007563eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7564 tSirBssDescription *pBssDescription,
7565 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7566 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7567 tANI_U8 keyId, tANI_U16 keyLength,
7568 tANI_U8 *pKey, tANI_U8 paeRole )
7569{
7570 eHalStatus status = eHAL_STATUS_SUCCESS;
7571 tAniEdType edType;
7572
7573 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7574 {
7575 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7576 }
7577
7578 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7579
7580 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7581 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7582 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7583 addKey )
7584 {
7585 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 setKey.encType = EncryptType;
7587 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7588 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7589 setKey.paeRole = paeRole; //0 for supplicant
7590 setKey.keyId = keyId; // Kye index
7591 setKey.keyLength = keyLength;
7592 if( keyLength )
7593 {
7594 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7595 }
7596 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 return (status);
7599}
7600
Jeff Johnson295189b2012-06-20 16:38:30 -07007601static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7602 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7603{
7604 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7605 tSmeCmd *pCommand = NULL;
7606#ifdef FEATURE_WLAN_CCX
7607 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7608#endif /* FEATURE_WLAN_CCX */
7609
7610 do
7611 {
7612 pCommand = csrGetCommandBuffer(pMac);
7613 if(NULL == pCommand)
7614 {
7615 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7616 status = eHAL_STATUS_RESOURCES;
7617 break;
7618 }
7619 pCommand->command = eSmeCommandSetKey;
7620 pCommand->sessionId = (tANI_U8)sessionId;
7621 // validate the key length, Adjust if too long...
7622 // for static WEP the keys are not set thru' SetContextReq
7623 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7624 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7625 {
7626 //KeyLength maybe 0 for static WEP
7627 if( pSetKey->keyLength )
7628 {
7629 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7630 {
7631 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7632 break;
7633 }
7634
7635 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7636 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7637 }
7638 }
7639 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7640 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7641 {
7642 //KeyLength maybe 0 for static WEP
7643 if( pSetKey->keyLength )
7644 {
7645 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7646 {
7647 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7648 break;
7649 }
7650
7651 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7652 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7653 }
7654 }
7655 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7656 {
7657 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7658 {
7659 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7660 break;
7661 }
7662 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7663 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7664 }
7665 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7666 {
7667 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7668 {
7669 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7670 break;
7671 }
7672 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7673 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7674 }
7675#ifdef FEATURE_WLAN_WAPI
7676 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7677 {
7678 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7679 {
7680 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7681 break;
7682 }
7683 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7684 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7685 }
7686#endif /* FEATURE_WLAN_WAPI */
7687#ifdef FEATURE_WLAN_CCX
7688 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7689 {
7690 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7691 {
7692 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7693 break;
7694 }
7695 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7696 pSession->ccxCckmInfo.reassoc_req_num=1;
7697 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7698 status = eHAL_STATUS_SUCCESS;
7699 break;
7700 }
7701#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07007702
Jeff Johnson295189b2012-06-20 16:38:30 -07007703#ifdef WLAN_FEATURE_11W
7704 //Check for 11w BIP
7705 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7706 {
7707 tANI_U16 count = 0;
7708 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7709 {
7710 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7711 break;
7712 }
7713 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7714 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7715 }
7716#endif
7717 status = eHAL_STATUS_SUCCESS;
7718 pCommand->u.setKeyCmd.roamId = roamId;
7719 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7720 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7721 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7722 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7723 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7724 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7725 //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
7726
7727 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7728 if( !HAL_STATUS_SUCCESS( status ) )
7729 {
7730 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7731 }
7732 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007733 // Free the command if there has been a failure, or it is a
7734 // "local" operation like the set CCX CCKM KRK key.
7735 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7736#ifdef FEATURE_WLAN_CCX
7737 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7738#endif /* FEATURE_WLAN_CCX */
7739 )
7740 {
7741 csrReleaseCommandSetKey( pMac, pCommand );
7742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 return( status );
7744}
7745
Jeff Johnson295189b2012-06-20 16:38:30 -07007746eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7747 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7748{
7749 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7750 tSmeCmd *pCommand = NULL;
7751 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007752 do
7753 {
7754 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7755 {
7756 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7757 status = eHAL_STATUS_CSR_WRONG_STATE;
7758 break;
7759 }
7760 pCommand = csrGetCommandBuffer(pMac);
7761 if(NULL == pCommand)
7762 {
7763 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7764 status = eHAL_STATUS_RESOURCES;
7765 break;
7766 }
7767 pCommand->command = eSmeCommandRemoveKey;
7768 pCommand->sessionId = (tANI_U8)sessionId;
7769 pCommand->u.removeKeyCmd.roamId = roamId;
7770 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7771 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7772 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7773 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7774 {
7775 //in this case, put it to the end of the Q incase there is a set key pending.
7776 fImediate = eANI_BOOLEAN_FALSE;
7777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
7779 pRemoveKey->encType, pRemoveKey->keyId,
7780 pCommand->u.removeKeyCmd.peerMac[0],
7781 pCommand->u.removeKeyCmd.peerMac[1],
7782 pCommand->u.removeKeyCmd.peerMac[2],
7783 pCommand->u.removeKeyCmd.peerMac[3],
7784 pCommand->u.removeKeyCmd.peerMac[4],
7785 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7787 if( !HAL_STATUS_SUCCESS( status ) )
7788 {
7789 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7790 break;
7791 }
7792 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007793 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7794 {
7795 csrReleaseCommandRemoveKey( pMac, pCommand );
7796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 return (status );
7798}
7799
Jeff Johnson295189b2012-06-20 16:38:30 -07007800eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7801{
7802 eHalStatus status;
7803 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7804 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7805 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7806 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007807#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7808 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7809 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7811 {
7812 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7813 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7814 {
7815 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7816 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7817 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7818 }
7819 else
7820 {
7821 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7822 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7823 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7824 }
7825 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7826 if(CSR_IS_ENC_TYPE_STATIC(edType))
7827 {
7828 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 //It has to be static WEP here
7830 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
7831 {
7832 setKeyEvent.keyId = (v_U8_t)defKeyId;
7833 }
7834 }
7835 else
7836 {
7837 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
7838 }
7839 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7840 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7841 }
7842#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 if( csrIsSetKeyAllowed(pMac, sessionId) )
7844 {
7845 status = csrSendMBSetContextReqMsg( pMac, sessionId,
7846 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
7847 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
7848 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
7849 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
7850 pCommand->u.setKeyCmd.keyRsc);
7851 }
7852 else
7853 {
7854 smsLog( pMac, LOGW, FL(" cannot process not connected\n") );
7855 //Set this status so the error handling take care of the case.
7856 status = eHAL_STATUS_CSR_WRONG_STATE;
7857 }
7858 if( !HAL_STATUS_SUCCESS(status) )
7859 {
7860 smsLog( pMac, LOGE, FL(" error status %d\n"), status );
7861 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007862#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7863 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7864 {
7865 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7866 {
7867 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
7868 }
7869 else
7870 {
7871 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
7872 }
7873 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
7874 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7875 }
7876#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 return ( status );
7879}
7880
Jeff Johnson295189b2012-06-20 16:38:30 -07007881eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7882{
7883 eHalStatus status;
7884 tpSirSmeRemoveKeyReq pMsg = NULL;
7885 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
7886 tANI_U8 *p;
7887 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007888#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7889 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7890 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7892 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
7893 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7894 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7895 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7896 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
7897 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7898 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
7899#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 if( csrIsSetKeyAllowed(pMac, sessionId) )
7901 {
7902 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
7903 }
7904 else
7905 {
7906 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7907 //Set the error status so error handling kicks in below
7908 status = eHAL_STATUS_CSR_WRONG_STATE;
7909 }
7910 if( HAL_STATUS_SUCCESS( status ) )
7911 {
7912 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
7913 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
7914 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07007915 pMsg->sessionId = (tANI_U8)sessionId;
7916 pMsg->transactionId = 0;
7917 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
7918 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
7919 // bssId - copy from session Info
7920 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
7921 p += sizeof(tSirMacAddr);
7922 // peerMacAddr
7923 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
7924 p += sizeof(tSirMacAddr);
7925 // edType
7926 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
7927 p++;
7928 // weptype
7929 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
7930 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
7931 {
7932 *p = (tANI_U8)eSIR_WEP_STATIC;
7933 }
7934 else
7935 {
7936 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
7937 }
7938 p++;
7939 //keyid
7940 *p = pCommand->u.removeKeyCmd.keyId;
7941 p++;
7942 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 status = palSendMBMessage(pMac->hHdd, pMsg);
7944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 if( !HAL_STATUS_SUCCESS( status ) )
7946 {
7947 smsLog( pMac, LOGE, FL(" error status \n"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007948#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7949 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07007950 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
7952#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
7954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 return ( status );
7956}
7957
Jeff Johnson295189b2012-06-20 16:38:30 -07007958eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7959{
7960 eHalStatus status;
7961
7962 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7963 {
7964 status = eHAL_STATUS_CSR_WRONG_STATE;
7965 }
7966 else
7967 {
7968 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
7969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 return ( status );
7971}
7972
Jeff Johnson295189b2012-06-20 16:38:30 -07007973/*
7974 Prepare a filter base on a profile for parsing the scan results.
7975 Upon successful return, caller MUST call csrFreeScanFilter on
7976 pScanFilter when it is done with the filter.
7977*/
7978eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
7979 tCsrScanResultFilter *pScanFilter)
7980{
7981 eHalStatus status = eHAL_STATUS_SUCCESS;
7982 tANI_U32 size = 0;
7983 tANI_U8 index = 0;
7984
7985 do
7986 {
7987 if(pProfile->BSSIDs.numOfBSSIDs)
7988 {
7989 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
7990 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
7991 if(!HAL_STATUS_SUCCESS(status))
7992 {
7993 break;
7994 }
7995 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
7996 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
7997 }
7998 if(pProfile->SSIDs.numOfSSIDs)
7999 {
8000 if( !CSR_IS_WDS_STA( pProfile ) )
8001 {
8002 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8003 }
8004 else
8005 {
8006 //For WDS station
8007 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8008 pScanFilter->SSIDs.numOfSSIDs = 1;
8009 }
8010 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8011 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8012 if(!HAL_STATUS_SUCCESS(status))
8013 {
8014 break;
8015 }
8016 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8017 }
8018 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8019 {
8020 pScanFilter->ChannelInfo.numOfChannels = 0;
8021 pScanFilter->ChannelInfo.ChannelList = NULL;
8022 }
8023 else if(pProfile->ChannelInfo.numOfChannels)
8024 {
8025 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8026 pScanFilter->ChannelInfo.numOfChannels = 0;
8027 if(HAL_STATUS_SUCCESS(status))
8028 {
8029 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8030 {
8031 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8032 {
8033 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8034 = pProfile->ChannelInfo.ChannelList[index];
8035 pScanFilter->ChannelInfo.numOfChannels++;
8036 }
8037 else
8038 {
8039 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid\n"), pProfile->ChannelInfo.ChannelList[index]);
8040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 }
8043 else
8044 {
8045 break;
8046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 }
8048 else
8049 {
8050 smsLog(pMac, LOGW, FL("Channel list empty\n"));
8051 status = eHAL_STATUS_FAILURE;
8052 break;
8053 }
8054 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8055 pScanFilter->authType = pProfile->AuthType;
8056 pScanFilter->EncryptionType = pProfile->EncryptionType;
8057 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8058 pScanFilter->BSSType = pProfile->BSSType;
8059 pScanFilter->phyMode = pProfile->phyMode;
8060#ifdef FEATURE_WLAN_WAPI
8061 //check if user asked for WAPI with 11n or auto mode, in that case modify
8062 //the phymode to 11g
8063 if(csrIsProfileWapi(pProfile))
8064 {
8065 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8066 {
8067 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8068 }
8069 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8070 {
8071 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8072 }
8073 if(!pScanFilter->phyMode)
8074 {
8075 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8076 }
8077 }
8078#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 /*Save the WPS info*/
8080 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 if( pProfile->countryCode[0] )
8082 {
8083 //This causes the matching function to use countryCode as one of the criteria.
8084 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8085 WNI_CFG_COUNTRY_CODE_LEN );
8086 }
8087#ifdef WLAN_FEATURE_VOWIFI_11R
8088 if (pProfile->MDID.mdiePresent)
8089 {
8090 pScanFilter->MDID.mdiePresent = 1;
8091 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8092 }
8093#endif
8094
8095 }while(0);
8096
8097 if(!HAL_STATUS_SUCCESS(status))
8098 {
8099 csrFreeScanFilter(pMac, pScanFilter);
8100 }
8101
8102 return(status);
8103}
8104
Jeff Johnson295189b2012-06-20 16:38:30 -07008105tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8106 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8107{
8108 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8109 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 do
8111 {
8112 // Validate the type is ok...
8113 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8114 pCommand = csrGetCommandBuffer( pMac );
8115 if ( !pCommand )
8116 {
8117 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
8118 break;
8119 }
8120 //Change the substate in case it is waiting for key
8121 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8122 {
8123 csrRoamStopWaitForKeyTimer( pMac );
8124 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8125 }
8126 pCommand->command = eSmeCommandWmStatusChange;
8127 pCommand->sessionId = (tANI_U8)sessionId;
8128 pCommand->u.wmStatusChangeCmd.Type = Type;
8129 if ( eCsrDisassociated == Type )
8130 {
8131 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8132 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8133 }
8134 else
8135 {
8136 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8137 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8138 }
8139 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8140 {
8141 fCommandQueued = eANI_BOOLEAN_TRUE;
8142 }
8143 else
8144 {
8145 smsLog( pMac, LOGE, FL(" fail to send message \n") );
8146 csrReleaseCommandWmStatusChange( pMac, pCommand );
8147 }
8148
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8150 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 return( fCommandQueued );
8153}
8154
Jeff Johnson295189b2012-06-20 16:38:30 -07008155static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8156{
8157 v_S7_t rssi = 0;
8158 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8159 if(pGetRssiReq)
8160 {
8161 if(NULL != pGetRssiReq->pVosContext)
8162 {
8163 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8164 }
8165 else
8166 {
8167 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL\n"));
8168 return;
8169 }
8170
8171 if(NULL != pGetRssiReq->rssiCallback)
8172 {
8173 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8174 }
8175 else
8176 {
8177 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL\n"));
8178 return;
8179 }
8180 }
8181 else
8182 {
8183 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL\n"));
8184 }
8185 return;
8186}
Jeff Johnsone7245742012-09-05 17:12:55 -07008187static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8188{
8189 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8190 if(pTlRssiInd)
8191 {
8192 if(NULL != pTlRssiInd->tlCallback)
8193 {
8194 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08008195 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008196 }
8197 else
8198 {
8199 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL\n"));
8200 }
8201 }
8202 else
8203 {
8204 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL\n"));
8205 }
8206 return;
8207}
Jeff Johnson295189b2012-06-20 16:38:30 -07008208
8209void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8210{
8211 tSirSmeAssocInd *pAssocInd;
8212 tSirSmeDisassocInd *pDisassocInd;
8213 tSirSmeDeauthInd *pDeauthInd;
8214 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8215 tSirSmeNewBssInfo *pNewBss;
8216 tSmeIbssPeerInd *pIbssPeerInd;
8217 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8218 tSirSmeApNewCaps *pApNewCaps;
8219 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8220 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8221 tCsrRoamInfo *pRoamInfo = NULL;
8222 tCsrRoamInfo roamInfo;
8223 eHalStatus status;
8224 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8225 tCsrRoamSession *pSession = NULL;
8226 tpSirSmeSwitchChannelInd pSwitchChnInd;
8227 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08008228#ifdef WLAN_SOFTAP_FEATURE
8229 tSmeCmd pCommand;
8230#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008231#if defined ANI_PRODUCT_TYPE_AP
8232 pSirMsg->messageType = pal_be16_to_cpu(pSirMsg->messageType);
8233 pSirMsg->length = pal_be16_to_cpu(pSirMsg->length);
8234 pSirMsg->statusCode = pal_be32_to_cpu(pSirMsg->statusCode);
8235#else
8236 pSirMsg->messageType = (pSirMsg->messageType);
8237 pSirMsg->length = (pSirMsg->length);
8238 pSirMsg->statusCode = (pSirMsg->statusCode);
8239#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 switch( pSirMsg->messageType )
8242 {
8243 case eWNI_SME_ASSOC_IND:
8244 {
8245 tCsrRoamSession *pSession;
8246 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME\n"));
8247 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8248 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8249 if( HAL_STATUS_SUCCESS( status ) )
8250 {
8251 pSession = CSR_GET_SESSION(pMac, sessionId);
8252
Jeff Johnson32d95a32012-09-10 13:15:23 -07008253 if(!pSession)
8254 {
8255 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8256 return;
8257 }
8258
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 pRoamInfo = &roamInfo;
8260
8261 // Required for indicating the frames to upper layer
8262 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8263 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8264
8265 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8266 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8267 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8268 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8269
8270 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8271 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8272 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8273
8274 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8275 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8277 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
8278#ifdef WLAN_SOFTAP_FEATURE
8279 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8280 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8281#endif
8282 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8283#ifdef WLAN_SOFTAP_FEATURE
8284 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8285 {
8286 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8287 {
8288 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8289 pSession->pConnectBssDesc,
8290 &(pRoamInfo->peerMac),
8291 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8292 pRoamInfo->fAuthRequired = FALSE;
8293 }
8294 else
8295 {
8296 pRoamInfo->fAuthRequired = TRUE;
8297 }
8298 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8299 if (!HAL_STATUS_SUCCESS(status))
8300 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8301 }
8302#endif
8303 /* Send Association completion message to PE */
8304 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8305
8306 /* send a message to CSR itself just to avoid the EAPOL frames going
8307 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8309 {
8310 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8311 }
8312#ifdef WLAN_SOFTAP_FEATURE
8313 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8314 {
8315 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8316 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8317 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8318 }
8319#endif
8320 }
8321 }
8322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 case eWNI_SME_DISASSOC_IND:
8324 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 // Check if AP dis-associated us because of MIC failure. If so,
8326 // then we need to take action immediately and not wait till the
8327 // the WmStatusChange requests is pushed and processed
8328 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8329 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8330 if( HAL_STATUS_SUCCESS( status ) )
8331 {
8332 // If we are in neighbor preauth done state then on receiving
8333 // disassoc or deauth we dont roam instead we just disassoc
8334 // from current ap and then go to disconnected state
8335 // This happens for CCX and 11r FT connections ONLY.
8336#ifdef WLAN_FEATURE_VOWIFI_11R
8337 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8338 {
8339 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8340 }
8341#endif
8342#ifdef FEATURE_WLAN_CCX
8343 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8344 {
8345 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8346 }
8347#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008348#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308349 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008350 {
8351 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8352 }
8353#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 pSession = CSR_GET_SESSION( pMac, sessionId );
8355
Jeff Johnson32d95a32012-09-10 13:15:23 -07008356 if(!pSession)
8357 {
8358 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8359 return;
8360 }
8361
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 if ( csrIsConnStateInfra( pMac, sessionId ) )
8363 {
8364 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008366#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8367 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8368#endif
8369 csrRoamLinkDown(pMac, sessionId);
8370 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
8371#ifdef WLAN_SOFTAP_FEATURE
8372 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8373 {
8374
8375 pRoamInfo = &roamInfo;
8376
8377 pRoamInfo->statusCode = pDisassocInd->statusCode;
8378 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8379
8380 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8381
8382 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8383 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8384
8385 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08008386
8387 /*
8388 * STA/P2P client got disassociated so remove any pending deauth
8389 * commands in sme pending list
8390 */
8391 pCommand.command = eSmeCommandRoam;
8392 pCommand.sessionId = (tANI_U8)sessionId;
8393 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8394 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8395 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 }
8397#endif
8398 }
8399 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 case eWNI_SME_DEAUTH_IND:
8401 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC\n"));
8402 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8403 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8404 if( HAL_STATUS_SUCCESS( status ) )
8405 {
8406 // If we are in neighbor preauth done state then on receiving
8407 // disassoc or deauth we dont roam instead we just disassoc
8408 // from current ap and then go to disconnected state
8409 // This happens for CCX and 11r FT connections ONLY.
8410#ifdef WLAN_FEATURE_VOWIFI_11R
8411 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8412 {
8413 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8414 }
8415#endif
8416#ifdef FEATURE_WLAN_CCX
8417 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8418 {
8419 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8420 }
8421#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008422#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308423 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008424 {
8425 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8426 }
8427#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 pSession = CSR_GET_SESSION( pMac, sessionId );
8429
Jeff Johnson32d95a32012-09-10 13:15:23 -07008430 if(!pSession)
8431 {
8432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8433 return;
8434 }
8435
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 if ( csrIsConnStateInfra( pMac, sessionId ) )
8437 {
8438 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008440#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8441 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8442#endif
8443 csrRoamLinkDown(pMac, sessionId);
8444 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
8445#ifdef WLAN_SOFTAP_FEATURE
8446 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8447 {
8448
8449 pRoamInfo = &roamInfo;
8450
8451 pRoamInfo->statusCode = pDeauthInd->statusCode;
8452 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8453
8454 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8455
8456 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8457 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8458
8459 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8460 }
8461#endif
8462 }
8463 break;
8464
8465 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
8466 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME\n"));
8467 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8468 //Update with the new channel id.
8469 //The channel id is hidden in the statusCode.
8470 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8471 if( HAL_STATUS_SUCCESS( status ) )
8472 {
8473 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008474 if(!pSession)
8475 {
8476 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8477 return;
8478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8480 if(pSession->pConnectBssDesc)
8481 {
8482 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8483 }
8484 }
8485 break;
8486
8487 case eWNI_SME_DEAUTH_RSP:
8488 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME\n"));
8489#ifdef WLAN_SOFTAP_FEATURE
8490 {
8491 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8492 sessionId = pDeauthRsp->sessionId;
8493 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8494 {
8495 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008496 if(!pSession)
8497 {
8498 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8499 return;
8500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8502 {
8503 pRoamInfo = &roamInfo;
8504 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8505 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8506 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8507 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8508 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8509 }
8510 }
8511 }
8512#endif
8513 break;
8514
8515 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008516 /* session id is invalid here so cant use it to access the array curSubstate as index */
8517 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008518#ifdef WLAN_SOFTAP_FEATURE
8519 {
8520 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8521 sessionId = pDisassocRsp->sessionId;
8522 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8523 {
8524 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008525 if(!pSession)
8526 {
8527 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8528 return;
8529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8531 {
8532 pRoamInfo = &roamInfo;
8533 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8534 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8535 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8536 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8537 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8538 }
8539 }
8540 }
8541#endif
8542 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 case eWNI_SME_MIC_FAILURE_IND:
8544 {
8545 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8546 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8547 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008548#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8549 {
8550 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008551 if(!pSession)
8552 {
8553 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8554 return;
8555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8557 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8558 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8559 secEvent.encryptionModeMulticast =
8560 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8561 secEvent.encryptionModeUnicast =
8562 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8563 secEvent.authMode =
8564 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8565 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8566 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8567 }
8568#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8570 if( HAL_STATUS_SUCCESS( status ) )
8571 {
8572 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8573 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8574 pRoamInfo = &roamInfo;
8575 if(pMicInd->info.multicast)
8576 {
8577 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8578 }
8579 else
8580 {
8581 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8582 }
8583 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8584 }
8585 }
8586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008587#ifdef WLAN_SOFTAP_FEATURE
8588 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8589 {
8590 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8591 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME\n"));
8593
8594 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8595 if( HAL_STATUS_SUCCESS( status ) )
8596 {
8597 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8598 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8599 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8600 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8601 }
8602 }
8603 break;
8604#endif
8605
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8607 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8608 switch( pStatusChangeMsg->statusChangeCode )
8609 {
8610 case eSIR_SME_IBSS_ACTIVE:
8611 sessionId = csrFindIbssSession( pMac );
8612 if( CSR_SESSION_ID_INVALID != sessionId )
8613 {
8614 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008615 if(!pSession)
8616 {
8617 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8618 return;
8619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8621 if(pSession->pConnectBssDesc)
8622 {
8623 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8624 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8625 pRoamInfo = &roamInfo;
8626 }
8627 else
8628 {
8629 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8630 }
8631 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8632 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8633 }
8634 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008635 case eSIR_SME_IBSS_INACTIVE:
8636 sessionId = csrFindIbssSession( pMac );
8637 if( CSR_SESSION_ID_INVALID != sessionId )
8638 {
8639 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008640 if(!pSession)
8641 {
8642 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8643 return;
8644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008645 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8646 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8647 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8648 }
8649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8651 sessionId = csrFindIbssSession( pMac );
8652 if( CSR_SESSION_ID_INVALID != sessionId )
8653 {
8654 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008655 if(!pSession)
8656 {
8657 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8658 return;
8659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 // update the connection state information
8661 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008662#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8663 {
8664 vos_log_ibss_pkt_type *pIbssLog;
8665 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8667 if(pIbssLog)
8668 {
8669 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8670 if(pNewBss)
8671 {
8672 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8673 if(pNewBss->ssId.length)
8674 {
8675 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8676 }
8677 pIbssLog->operatingChannel = pNewBss->channelNumber;
8678 }
8679 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8680 {
8681 //***U8 is not enough for beacon interval
8682 pIbssLog->beaconInterval = (v_U8_t)bi;
8683 }
8684 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8685 }
8686 }
8687#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8689 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8690 pSession->pConnectBssDesc,
8691 &Broadcastaddr,
8692 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8693 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8694 roamStatus = eCSR_ROAM_IBSS_IND;
8695 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8696 pRoamInfo = &roamInfo;
8697 //This BSSID is th ereal BSSID, let's save it
8698 if(pSession->pConnectBssDesc)
8699 {
8700 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8701 }
8702 // Stop the join IBSS timer in case of join, for
8703 // genuine merge do nothing
8704 if(pSession->ibss_join_pending)
8705 {
8706 pSession->ibss_join_pending = FALSE;
8707 csrRoamStopIbssJoinTimer(pMac, sessionId);
8708 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8709 }
8710 }
8711 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE\n");
8712 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 // detection by LIM that the capabilities of the associated AP have changed.
8714 case eSIR_SME_AP_CAPS_CHANGED:
8715 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
8716 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED\n");
8717 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8718 if( HAL_STATUS_SUCCESS( status ) )
8719 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008720 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8721 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8722 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8723 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8724 )
8725 {
8726 csrScanForCapabilityChange( pMac, pApNewCaps );
8727 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8728 roamStatus = eCSR_ROAM_GEN_INFO;
8729 }
8730 else
8731 {
8732 smsLog(pMac, LOGW,
8733 "Skipping csrScanForCapabilityChange as "
8734 "CSR is in state %d and sub-state %d\n",
8735 pMac->roam.curState[sessionId],
8736 pMac->roam.curSubState[sessionId]);
8737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 }
8739 break;
8740
8741 default:
8742 roamStatus = eCSR_ROAM_FAILED;
8743 result = eCSR_ROAM_RESULT_NONE;
8744 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 } // end switch on statusChangeCode
8746 if(eCSR_ROAM_RESULT_NONE != result)
8747 {
8748 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8749 }
8750 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 case eWNI_SME_IBSS_NEW_PEER_IND:
8752 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008753#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8754 {
8755 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8757 if(pIbssLog)
8758 {
8759 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8760 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8761 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8762 }
8763 }
8764#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 sessionId = csrFindIbssSession( pMac );
8766 if( CSR_SESSION_ID_INVALID != sessionId )
8767 {
8768 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008769
8770 if(!pSession)
8771 {
8772 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8773 return;
8774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008775 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8776 if(pSession->pConnectBssDesc)
8777 {
8778 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8779 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8780 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8781 {
8782 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8783 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8784 if(HAL_STATUS_SUCCESS(status))
8785 {
8786 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8787 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8788 roamInfo.nBeaconLength);
8789 }
8790 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8791 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8792 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8793 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8794 pSession->pConnectBssDesc->length);
8795 if(HAL_STATUS_SUCCESS(status))
8796 {
8797 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8798 pSession->pConnectBssDesc->length);
8799 }
8800 if(HAL_STATUS_SUCCESS(status))
8801 {
8802 pRoamInfo = &roamInfo;
8803 }
8804 else
8805 {
8806 if(roamInfo.pbFrames)
8807 {
8808 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8809 }
8810 if(roamInfo.pBssDesc)
8811 {
8812 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8813 }
8814 }
8815 }
8816 else
8817 {
8818 pRoamInfo = &roamInfo;
8819 }
8820 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8821 pSession->pConnectBssDesc,
8822 &(pIbssPeerInd->peerAddr),
8823 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8824 }
8825 else
8826 {
8827 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8828 }
8829 //send up the sec type for the new peer
8830 if (pRoamInfo)
8831 {
8832 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8833 }
8834 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
8835 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
8836 if(pRoamInfo)
8837 {
8838 if(roamInfo.pbFrames)
8839 {
8840 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8841 }
8842 if(roamInfo.pBssDesc)
8843 {
8844 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8845 }
8846 }
8847 }
8848 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8850 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
8851 sessionId = csrFindIbssSession( pMac );
8852 if( CSR_SESSION_ID_INVALID != sessionId )
8853 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008854#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8855 {
8856 vos_log_ibss_pkt_type *pIbssLog;
8857
8858 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8859 if(pIbssLog)
8860 {
8861 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
8862 if(pIbssPeerInd)
8863 {
8864 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8865 }
8866 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8867 }
8868 }
8869#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM\n");
8871 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8872 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8873 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8874 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8875 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8876 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8877 }
8878 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 case eWNI_SME_SETCONTEXT_RSP:
8880 {
8881 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
8882 tListElem *pEntry;
8883 tSmeCmd *pCommand;
8884
8885 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8886 if ( pEntry )
8887 {
8888 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8889 if ( eSmeCommandSetKey == pCommand->command )
8890 {
8891 sessionId = pCommand->sessionId;
8892 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008893
8894 if(!pSession)
8895 {
8896 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8897 return;
8898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008899
8900#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8901 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
8902 {
8903 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
8904 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8905 if( pRsp->peerMacAddr[0] & 0x01 )
8906 {
8907 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8908 }
8909 else
8910 {
8911 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8912 }
8913 setKeyEvent.encryptionModeMulticast =
8914 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8915 setKeyEvent.encryptionModeUnicast =
8916 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8917 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8918 setKeyEvent.authMode =
8919 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8920 if( eSIR_SUCCESS != pRsp->statusCode )
8921 {
8922 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8923 }
8924 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8925 }
8926#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8927 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
8928 {
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08008929 csrRoamStopWaitForKeyTimer( pMac );
8930
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 //We are done with authentication, whethere succeed or not
8932 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 //We do it here because this linkup function is not called after association
8934 //when a key needs to be set.
8935 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
8936 {
8937 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
8938 }
8939 }
Jeff Johnson43971f52012-07-17 12:26:56 -07008940 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 {
8942 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07008943 //Make sure we install the GTK before indicating to HDD as authenticated
8944 //This is to prevent broadcast packets go out after PTK and before GTK.
8945 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
8946 sizeof(tSirMacAddr) ) )
8947 {
Yathishd8713192012-12-10 14:21:35 -08008948#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
8949 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
8950 {
8951 tpSirSetActiveModeSetBncFilterReq pMsg;
8952 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
8953 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
8954 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
8955 pMsg->seesionId = sessionId;
8956 status = palSendMBMessage(pMac->hHdd, pMsg );
8957 }
8958#endif
8959 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07008960 }
8961 else
8962 {
8963 result = eCSR_ROAM_RESULT_NONE;
8964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 pRoamInfo = &roamInfo;
8966 }
8967 else
8968 {
8969 result = eCSR_ROAM_RESULT_FAILURE;
8970 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...\n",
8971 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
8972 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
8973 }
8974 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
8975 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07008976 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
8977 // can go ahead and initiate the TSPEC if any are pending
8978 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07008979#ifdef FEATURE_WLAN_CCX
8980 //Send Adjacent AP repot to new AP.
8981 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
8982 pSession->isPrevApInfoValid &&
8983 pSession->connectedProfile.isCCXAssoc)
8984 {
8985#ifdef WLAN_FEATURE_VOWIFI
8986 csrCcxSendAdjacentApRepMsg(pMac, pSession);
8987#endif
8988 pSession->isPrevApInfoValid = FALSE;
8989 }
8990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008991 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
8992 {
8993 csrReleaseCommandSetKey( pMac, pCommand );
8994 }
8995 }
8996 else
8997 {
8998 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
8999 }
9000 }
9001 else
9002 {
9003 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 smeProcessPendingQueue( pMac );
9006 }
9007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 case eWNI_SME_REMOVEKEY_RSP:
9009 {
9010 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9011 tListElem *pEntry;
9012 tSmeCmd *pCommand;
9013
9014 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9015 if ( pEntry )
9016 {
9017 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9018 if ( eSmeCommandRemoveKey == pCommand->command )
9019 {
9020 sessionId = pCommand->sessionId;
9021 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009022
9023 if(!pSession)
9024 {
9025 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9026 return;
9027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009028#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9029 {
9030 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9031 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9032 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9033 removeKeyEvent.encryptionModeMulticast =
9034 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9035 removeKeyEvent.encryptionModeUnicast =
9036 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9037 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9038 removeKeyEvent.authMode =
9039 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9040 if( eSIR_SUCCESS != pRsp->statusCode )
9041 {
9042 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9043 }
9044 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9045 }
9046#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009047 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 {
9049 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9050 result = eCSR_ROAM_RESULT_NONE;
9051 pRoamInfo = &roamInfo;
9052 }
9053 else
9054 {
9055 result = eCSR_ROAM_RESULT_FAILURE;
9056 }
9057 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9058 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9059 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9060 {
9061 csrReleaseCommandRemoveKey( pMac, pCommand );
9062 }
9063 }
9064 else
9065 {
9066 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9067 }
9068 }
9069 else
9070 {
9071 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 smeProcessPendingQueue( pMac );
9074 }
9075 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07009077 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 csrRoamStatsRspProcessor( pMac, pSirMsg );
9079 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009080 case eWNI_SME_GET_RSSI_REQ:
Mohit Khanna23863762012-09-11 17:40:09 -07009081 smsLog( pMac, LOG2, FL("GetRssiReq from self\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009082 csrUpdateRssi( pMac, pSirMsg );
9083 break;
9084
Jeff Johnson295189b2012-06-20 16:38:30 -07009085#ifdef WLAN_FEATURE_VOWIFI_11R
9086 case eWNI_SME_FT_PRE_AUTH_RSP:
9087 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9088 break;
9089#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9091 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
9092 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted\n"));
9093 sessionId = pSmeMaxAssocInd->sessionId;
9094 roamInfo.sessionId = sessionId;
9095 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9096 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9097 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9098 break;
9099
9100 case eWNI_SME_BTAMP_LOG_LINK_IND:
9101 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread\n"));
9102 btampEstablishLogLinkHdlr( pSirMsg );
9103 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009104 case eWNI_SME_RSSI_IND:
9105 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread\n"));
9106 csrRoamRssiIndHdlr( pMac, pSirMsg );
9107 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009108
9109 default:
9110 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009112}
9113
Jeff Johnson295189b2012-06-20 16:38:30 -07009114void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9115 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9116{
9117 if(pSession)
9118 {
9119 if(pSession->bRefAssocStartCnt)
9120 {
9121 pSession->bRefAssocStartCnt--;
9122 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9123 //Need to call association_completion because there is an assoc_start pending.
9124 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9125 eCSR_ROAM_ASSOCIATION_COMPLETION,
9126 eCSR_ROAM_RESULT_FAILURE);
9127 }
9128 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9129 }
9130 else
9131 {
9132 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9133 }
9134}
9135
9136
9137eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9138{
9139 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009140 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9141 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9142 {
9143 status = csrScanRequestLostLink1( pMac, sessionId );
9144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009145 return(status);
9146}
9147
Jeff Johnson295189b2012-06-20 16:38:30 -07009148//return a boolean to indicate whether roaming completed or continue.
9149tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9150 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9151{
9152 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9153 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9154 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9155 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009156 if(!pSession)
9157 {
9158 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9159 return eANI_BOOLEAN_FALSE;
9160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 //Check whether time is up
9162 if(pSession->fCancelRoaming || fForce ||
9163 ((curTime - pSession->roamingStartTime) > roamTime) ||
9164 eCsrReassocRoaming == pSession->roamingReason ||
9165 eCsrDynamicRoaming == pSession->roamingReason)
9166 {
9167 smsLog(pMac, LOGW, FL(" indicates roaming completion\n"));
9168 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9169 {
9170 //roaming is cancelled, tell HDD to indicate disconnect
9171 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9172 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9173 //to be eSIR_BEACON_MISSED
9174 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9175 {
9176 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9177 }
9178 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9179 {
9180 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9181 }
9182 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9183 {
9184 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9185 }
9186 else
9187 {
9188 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9189 }
9190 }
9191 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9192 pSession->roamingReason = eCsrNotRoaming;
9193 }
9194 else
9195 {
9196 pSession->roamResult = roamResult;
9197 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9198 {
9199 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9200 pSession->roamingReason = eCsrNotRoaming;
9201 }
9202 else
9203 {
9204 fCompleted = eANI_BOOLEAN_FALSE;
9205 }
9206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 return(fCompleted);
9208}
9209
Jeff Johnson295189b2012-06-20 16:38:30 -07009210void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9211{
9212 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009213
9214 if(!pSession)
9215 {
9216 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9217 return;
9218 }
9219
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 if(CSR_IS_ROAMING(pSession))
9221 {
9222 smsLog(pMac, LOGW, " Cancelling roaming\n");
9223 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9224 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9225 {
9226 //No need to do anything in here because the handler takes care of it
9227 }
9228 else
9229 {
9230 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9231 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9232 //Roaming is stopped after here
9233 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9234 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9235 csrScanAbortMacScan(pMac);
9236 csrRoamStopRoamingTimer(pMac, sessionId);
9237 }
9238 }
9239}
9240
Jeff Johnson295189b2012-06-20 16:38:30 -07009241void csrRoamRoamingTimerHandler(void *pv)
9242{
9243 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9244 tpAniSirGlobal pMac = pInfo->pMac;
9245 tANI_U32 sessionId = pInfo->sessionId;
9246 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009247
9248 if(!pSession)
9249 {
9250 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9251 return;
9252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009253
9254 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9255 {
9256 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9257 {
9258 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9259 pSession->roamingReason = eCsrNotRoaming;
9260 }
9261 }
9262}
9263
Jeff Johnson295189b2012-06-20 16:38:30 -07009264eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9265{
9266 eHalStatus status;
9267 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009268
9269 if(!pSession)
9270 {
9271 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9272 return eHAL_STATUS_FAILURE;
9273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009274
9275 smsLog(pMac, LOG1, " csrScanStartRoamingTimer \n ");
9276 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9277 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9278
9279 return (status);
9280}
9281
Jeff Johnson295189b2012-06-20 16:38:30 -07009282eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9283{
9284 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9285}
9286
Jeff Johnson295189b2012-06-20 16:38:30 -07009287void csrRoamWaitForKeyTimeOutHandler(void *pv)
9288{
9289 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9290 tpAniSirGlobal pMac = pInfo->pMac;
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009291 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9292
9293 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d\n",
9294 pMac->roam.neighborRoamInfo.neighborRoamState,
9295 pMac->roam.curSubState[pInfo->sessionId]);
9296
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9298 {
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009299#ifdef FEATURE_WLAN_LFR
9300 if (csrNeighborRoamIsHandoffInProgress(pMac))
9301 {
9302 /*
9303 * Enable heartbeat timer when hand-off is in progress
9304 * and Key Wait timer expired.
9305 */
9306 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
9307 " (nHBCount=%d)\n",
9308 pMac->roam.configParam.HeartbeatThresh24);
9309 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9310 pMac->roam.configParam.HeartbeatThresh24,
9311 NULL, eANI_BOOLEAN_FALSE);
9312 }
9313#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 smsLog(pMac, LOGW, " SME pre-auth state timeout. \n ");
9315 //Change the substate so command queue is unblocked.
9316 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009317 if (pSession)
9318 {
9319 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9320 {
9321 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9322 smeProcessPendingQueue(pMac);
9323 }
9324 else
9325 {
9326 smsLog(pMac, LOGW, "%s: could not post link up\n",
9327 __func__);
9328 }
9329 }
9330 else
9331 {
9332 smsLog(pMac, LOGW, "%s: session not found\n", __func__);
9333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009334 }
9335
9336}
9337
Jeff Johnson295189b2012-06-20 16:38:30 -07009338eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9339{
9340 eHalStatus status;
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009341#ifdef FEATURE_WLAN_LFR
9342 if (csrNeighborRoamIsHandoffInProgress(pMac))
9343 {
9344 /* Disable heartbeat timer when hand-off is in progress */
9345 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d\n",
9346 __func__,
9347 pMac->roam.neighborRoamInfo.neighborRoamState,
9348 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9349 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9350 }
9351#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer \n ");
9353 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9354
9355 return (status);
9356}
9357
Jeff Johnson295189b2012-06-20 16:38:30 -07009358eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9359{
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009360 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d\n",
9361 pMac->roam.neighborRoamInfo.neighborRoamState,
9362 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9363#ifdef FEATURE_WLAN_LFR
9364 if (csrNeighborRoamIsHandoffInProgress(pMac))
9365 {
9366 /*
9367 * Enable heartbeat timer when hand-off is in progress
9368 * and Key Wait timer got stopped for some reason
9369 */
9370 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
9371 " (nHBCount=%d)\n",
9372 pMac->roam.configParam.HeartbeatThresh24);
9373 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9374 pMac->roam.configParam.HeartbeatThresh24,
9375 NULL, eANI_BOOLEAN_FALSE);
9376 }
9377#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9379}
9380
Jeff Johnson295189b2012-06-20 16:38:30 -07009381void csrRoamIbssJoinTimerHandler(void *pv)
9382{
9383 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9384 tpAniSirGlobal pMac = pInfo->pMac;
9385 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9386 tANI_U32 sessionId = pInfo->sessionId;
9387 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009388
9389 if(!pSession)
9390 {
9391 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9392 return;
9393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009394
9395 pSession->ibss_join_pending = FALSE;
9396 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9397 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9398 // Send an IBSS stop request to PE
9399 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009400}
Jeff Johnson295189b2012-06-20 16:38:30 -07009401eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9402{
9403 eHalStatus status;
9404 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009405
9406 if(!pSession)
9407 {
9408 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9409 return eHAL_STATUS_FAILURE;
9410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009411
9412 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer \n ");
9413 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9414 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9415
9416 return (status);
9417}
Jeff Johnson295189b2012-06-20 16:38:30 -07009418eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9419{
9420 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9421}
Jeff Johnson295189b2012-06-20 16:38:30 -07009422void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9423 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9424{
9425 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9426 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9428 /* To silence the KW tool Null chaeck is added */
9429 if(!pSession)
9430 {
9431 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9432 return;
9433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009434
9435 if(pCommand)
9436 {
9437 roamId = pCommand->u.roamCmd.roamId;
9438#if defined(VOSS_ENABLED)
9439 VOS_ASSERT( sessionId == pCommand->sessionId );
9440#endif
9441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009442 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9443 {
9444 //if success, force roaming completion
9445 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9446 }
9447 else
9448 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009449 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d\n"), roamResult);
9451 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9452 }
9453}
9454
Jeff Johnson295189b2012-06-20 16:38:30 -07009455eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9456{
9457 eHalStatus status = eHAL_STATUS_SUCCESS;
9458 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9459 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9460 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9461 tCsrRoamInfo *pRoamInfo = NULL;
9462 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009463 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009465 /* To silence the KW tool Null chaeck is added */
9466 if(!pSession)
9467 {
9468 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9469 return eHAL_STATUS_FAILURE;
9470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009471 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009472 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9474 if ( eWNI_SME_DISASSOC_IND == type )
9475 {
9476 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9477 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9478 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009479 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 }
9481 else if ( eWNI_SME_DEAUTH_IND == type )
9482 {
9483 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9484 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9485 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009486 /* Convert into proper reason code */
9487 pSession->joinFailStatusCode.reasonCode =
9488 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
9489 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON : pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 }
9491 else
9492 {
9493 smsLog(pMac, LOGW, FL("gets an unknown type (%d)\n"), type);
9494 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009495 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 }
9497
9498 // call profile lost link routine here
9499#ifdef WLAN_SOFTAP_FEATURE
9500 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
9501#endif
9502 {
9503 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9504 }
9505
9506 if ( eWNI_SME_DISASSOC_IND == type )
9507 {
9508 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9509 }
9510 else if ( eWNI_SME_DEAUTH_IND == type )
9511 {
9512 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009514 if(!HAL_STATUS_SUCCESS(status))
9515 {
9516 //If fail to send confirmation to PE, not to trigger roaming
9517 fToRoam = eANI_BOOLEAN_FALSE;
9518 }
9519
9520 //tell HDD to disconnect
9521 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9522 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9523 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9524#ifdef WLAN_SOFTAP_FEATURE
9525 if( eWNI_SME_DISASSOC_IND == type)
9526 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009527 //staMacAddr
9528 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9529 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 else if( eWNI_SME_DEAUTH_IND == type )
9532 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009533 //staMacAddr
9534 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9535 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009537#endif
9538 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)\n"), roamInfo.staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 if(fToRoam)
9540 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009541 //Tell HDD about the lost link
9542 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 //Only remove the connected BSS in infrastructure mode
9544 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9545 //Not to do anying for lostlink with WDS
9546 if( pMac->roam.configParam.nRoamingTime )
9547 {
9548 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9549 ( eWNI_SME_DEAUTH_IND == type ) ?
9550 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9551 {
9552 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9553 //For IBSS, we need to give some more info to HDD
9554 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9555 {
9556 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9557 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9558 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9559 }
9560 else
9561 {
9562 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9563 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009564 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9566 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9567 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9568 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9569 }
9570 else
9571 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009572 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 fToRoam = eANI_BOOLEAN_FALSE;
9574 }
9575 }
9576 else
9577 {
9578 //We are told not to roam, indicate lostlink
9579 fToRoam = eANI_BOOLEAN_FALSE;
9580 }
9581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 if(!fToRoam)
9583 {
9584 if( eWNI_SME_DISASSOC_IND == type)
9585 {
9586 //staMacAddr
9587 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9588 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9589 }
9590 else if( eWNI_SME_DEAUTH_IND == type )
9591 {
9592 //staMacAddr
9593 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9594 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9595 }
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009596 //Tell HDD about the lost link
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08009597#ifdef WLAN_SOFTAP_FEATURE
9598 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
9599#endif
9600 {
9601 /* Dont call csrRoamCallCallback for GO/SoftAp case as this indication
9602 * was alredy given as part of eWNI_SME_DISASSOC_IND msg handling in
9603 * csrRoamCheckForLinkStatusChange API.
9604 */
9605 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9606 }
9607
9608 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 Still enable idle scan for polling in case concurrent sessions are running */
9610 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9611 {
9612 csrScanStartIdleScan(pMac);
9613 }
9614 }
9615
9616 return (status);
9617}
9618
Jeff Johnson295189b2012-06-20 16:38:30 -07009619eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9620{
9621 eHalStatus status = eHAL_STATUS_SUCCESS;
9622 tListElem *pEntry = NULL;
9623 tSmeCmd *pCommand = NULL;
9624 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009625
9626 if(!pSession)
9627 {
9628 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9629 return eHAL_STATUS_FAILURE;
9630 }
9631
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 //Only remove the connected BSS in infrastructure mode
9634 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9635 if(pMac->roam.configParam.nRoamingTime)
9636 {
9637 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9638 {
9639 //before starting the lost link logic release the roam command for handoff
9640 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9641 if(pEntry)
9642 {
9643 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9644 }
9645 if(pCommand)
9646 {
9647 if (( eSmeCommandRoam == pCommand->command ) &&
9648 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9649 {
9650 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9651 {
9652 csrReleaseCommandRoam( pMac, pCommand );
9653 }
9654 }
9655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 smsLog( pMac, LOGW, "Lost link roaming started ...\n");
9657 }
9658 }
9659 else
9660 {
9661 //We are told not to roam, indicate lostlink
9662 status = eHAL_STATUS_FAILURE;
9663 }
9664
9665 return (status);
9666}
Jeff Johnson295189b2012-06-20 16:38:30 -07009667void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9668{
9669 tListElem *pEntry;
9670 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9672 if ( pEntry )
9673 {
9674 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9675 if ( eSmeCommandWmStatusChange == pCommand->command )
9676 {
9677 // Nothing to process in a Lost Link completion.... It just kicks off a
9678 // roaming sequence.
9679 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9680 {
9681 csrReleaseCommandWmStatusChange( pMac, pCommand );
9682 }
9683 else
9684 {
9685 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command\n");
9686 }
9687
9688 }
9689 else
9690 {
9691 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...\n" );
9692 }
9693 }
9694 else
9695 {
9696 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...\n" );
9697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 smeProcessPendingQueue( pMac );
9699}
9700
Jeff Johnson295189b2012-06-20 16:38:30 -07009701void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9702{
9703 eHalStatus status = eHAL_STATUS_FAILURE;
9704 tSirSmeRsp *pSirSmeMsg;
9705 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009706
9707 if(!pSession)
9708 {
9709 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9710 return;
9711 }
9712
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 switch ( pCommand->u.wmStatusChangeCmd.Type )
9714 {
9715 case eCsrDisassociated:
9716 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9717 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9718 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009719 case eCsrDeauthenticated:
9720 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9721 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9722 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 default:
9724 smsLog(pMac, LOGW, FL("gets an unknown command %d\n"), pCommand->u.wmStatusChangeCmd.Type);
9725 break;
9726 }
9727 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9728 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9729 {
9730 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9731 {
9732 //This is not good
9733 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command\n"));
9734 }
9735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9737 // command here since there is nothing else to do.
9738 csrRoamWmStatusChangeComplete( pMac );
9739}
9740
Jeff Johnson295189b2012-06-20 16:38:30 -07009741//This function returns band and mode information.
9742//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9743//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
9744#ifdef WLAN_SOFTAP_FEATURE
9745static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9746 tANI_U8 operationChn, eCsrBand *pBand )
9747#else
9748static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, eCsrPhyMode phyModeIn,
9749 tANI_U8 operationChn, eCsrBand *pBand )
9750#endif
9751{
Jeff Johnson295189b2012-06-20 16:38:30 -07009752#ifdef WLAN_SOFTAP_FEATURE
9753 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9754 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9755 pMac->roam.configParam.ProprietaryRatesEnabled);
9756#else
9757 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(phyModeIn,
9758 pMac->roam.configParam.ProprietaryRatesEnabled);
9759#endif
9760 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 //If the global setting for dot11Mode is set to auto/abg, we overwrite the setting in the profile.
9763#ifdef WLAN_SOFTAP_FEATURE
9764 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9765 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9766 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9767 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
9768#else
9769 if( (eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9770 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode) ||
9771 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009772#endif
9773 {
9774 switch( pMac->roam.configParam.uCfgDot11Mode )
9775 {
9776 case eCSR_CFG_DOT11_MODE_11A:
9777 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9778 eBand = eCSR_BAND_5G;
9779 break;
9780 case eCSR_CFG_DOT11_MODE_11B:
9781 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9782 eBand = eCSR_BAND_24;
9783 break;
9784 case eCSR_CFG_DOT11_MODE_11G:
9785 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9786 eBand = eCSR_BAND_24;
9787 break;
9788 case eCSR_CFG_DOT11_MODE_11N:
9789 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9790 eBand = eCSR_BAND_24;
9791 break;
9792 //case eCSR_CFG_DOT11_MODE_BEST:
9793 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9794 // eBand = eCSR_BAND_24;
9795 // break;
9796 default:
9797 // Global dot11 Mode setting is 11a/b/g.
9798 // use the channel number to determine the Mode setting.
9799 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9800 {
9801 eBand = pMac->roam.configParam.eBand;
9802 if(eCSR_BAND_24 == eBand)
9803 {
9804 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9805 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9806 }
9807 else
9808 {
9809 //prefer 5GHz
9810 eBand = eCSR_BAND_5G;
9811 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9812 }
9813 }
9814 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9815 {
9816 // channel is a 2.4GHz channel. Set mode to 11g.
9817 //
9818 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9819 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9820 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9821 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9822 // the IBSS network in 11b mode instead of 11g mode.
9823 //
9824 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9825 // then start the IBSS in b mode.
9826 //
9827 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9828 // the user will have to set the do11Mode in the property page to 11g to force it.
9829 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9830 eBand = eCSR_BAND_24;
9831 }
9832 else
9833 {
9834 // else, it's a 5.0GHz channel. Set mode to 11a.
9835 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9836 eBand = eCSR_BAND_5G;
9837 }
9838 break;
9839 }//switch
9840 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9841 else
9842 {
9843 //dot11 mode is set, lets pick the band
9844 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9845 {
9846 // channel is Auto also.
9847 eBand = pMac->roam.configParam.eBand;
9848 if(eCSR_BAND_ALL == eBand)
9849 {
9850 //prefer 5GHz
9851 eBand = eCSR_BAND_5G;
9852 }
9853 }
9854 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9855 {
9856 eBand = eCSR_BAND_24;
9857 }
9858 else
9859 {
9860 eBand = eCSR_BAND_5G;
9861 }
9862 }
9863 if(pBand)
9864 {
9865 *pBand = eBand;
9866 }
9867
9868 if (operationChn == 14){
9869 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode \n"));
9870 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9871 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009872
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -08009873 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
9874 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 -07009875 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009876#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009877 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009878#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009879 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
9880 {
9881 //We cannot do 11n here
9882 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9883 {
9884 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9885 }
9886 else
9887 {
9888 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9889 }
9890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 return( cfgDot11Mode );
9892}
9893
Jeff Johnson295189b2012-06-20 16:38:30 -07009894eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
9895{
9896 eHalStatus status;
9897 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009898
9899 if(!pSession)
9900 {
9901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9902 return eHAL_STATUS_FAILURE;
9903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009904
9905#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9906 {
9907 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9909 if(pIbssLog)
9910 {
9911 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
9912 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9913 }
9914 }
9915#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 pSession->ibss_join_pending = FALSE;
9917 csrRoamStopIbssJoinTimer(pMac, sessionId );
9918 // Set the roaming substate to 'stop Bss request'...
9919 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
9920
9921 // attempt to stop the Bss (reason code is ignored...)
9922 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08009923 if(!HAL_STATUS_SUCCESS(status))
9924 {
9925 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
9926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 return (status);
9928}
9929
Jeff Johnson295189b2012-06-20 16:38:30 -07009930//pNumChan is a caller allocated space with the sizeof pChannels
9931eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
9932{
9933
9934 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
9935 (tANI_U8 *)pChannels,
9936 pNumChan));
9937}
9938
Kirand170dcb2013-01-31 10:43:43 -08009939tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
9940{
9941 tANI_U32 cfgLength = 0;
9942 tANI_U16 cfgId = 0;
9943 tPowerdBm maxTxPwr = 0;
9944 tANI_U8 *pCountryInfo = NULL;
9945 eHalStatus status;
9946 tANI_U8 count = 0;
9947 tANI_U8 firstChannel;
9948 tANI_U8 maxChannels;
9949
9950 if (CSR_IS_CHANNEL_5GHZ(channel))
9951 {
9952 cfgId = WNI_CFG_MAX_TX_POWER_5;
9953 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
9954 }
9955 else if (CSR_IS_CHANNEL_24GHZ(channel))
9956 {
9957 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
9958 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
9959 }
9960 else
9961 return maxTxPwr;
9962
9963 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
9964 if (status != eHAL_STATUS_SUCCESS)
9965 {
9966 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
9967 FL("%s: palAllocateMemory() failed, status = %d"),
9968 __FUNCTION__, status);
9969 goto error;
9970 }
9971 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
9972 if (status != eHAL_STATUS_SUCCESS)
9973 {
9974 goto error;
9975 }
9976 /* Identify the channel and maxtxpower */
9977 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
9978 {
9979 firstChannel = pCountryInfo[count++];
9980 maxChannels = pCountryInfo[count++];
9981 maxTxPwr = pCountryInfo[count++];
9982
9983 if ((channel >= firstChannel) &&
9984 (channel < (firstChannel + maxChannels)))
9985 {
9986 break;
9987 }
9988 }
9989
9990error:
9991 if (NULL != pCountryInfo)
9992 palFreeMemory(pMac->hHdd, pCountryInfo);
9993
9994 return maxTxPwr;
9995}
9996
9997
Jeff Johnson295189b2012-06-20 16:38:30 -07009998tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
9999{
10000 tANI_BOOLEAN fValid = FALSE;
10001 tANI_U32 idxValidChannels;
10002 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10003
10004 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10005 {
10006 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10007 {
10008 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10009 {
10010 fValid = TRUE;
10011 break;
10012 }
10013 }
10014 }
10015 pMac->roam.numValidChannels = len;
10016 return fValid;
10017}
10018
Jeff Johnson295189b2012-06-20 16:38:30 -070010019tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10020{
10021 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10022 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10024 {
10025 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10026 {
10027 fValid = eANI_BOOLEAN_TRUE;
10028 break;
10029 }
10030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 return (fValid);
10032}
10033
Jeff Johnson295189b2012-06-20 16:38:30 -070010034//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010035 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010036{
Jeff Johnsone7245742012-09-05 17:12:55 -070010037 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 tANI_U8 centerChn;
10039 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10041 {
10042 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10043 }
10044 else
10045 {
10046 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10047 }
10048 //Figure what the other side's CB mode
10049 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10050 {
10051 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10052 {
10053 if(pIes->HTInfo.present)
10054 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010055 /* This is called during INFRA STA/CLIENT and should use the merged value of
10056 * supported channel width and recommended tx width as per standard
10057 */
10058 smsLog(pMac, LOG1, "scws %u rtws %u sco %u\n",
10059 pIes->HTCaps.supportedChannelWidthSet,
10060 pIes->HTInfo.recommendedTxWidthSet,
10061 pIes->HTInfo.secondaryChannelOffset);
10062
10063 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10064 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010066 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10067 switch (eRet) {
10068 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10069 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10070 break;
10071 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10072 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10073 break;
10074 case PHY_SINGLE_CHANNEL_CENTERED:
10075 default:
10076 centerChn = primaryChn;
10077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010078 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010079 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010081 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode\n", centerChn);
10082 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 }
10084 }
10085 }
10086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010087 return eRet;
10088}
Jeff Johnson295189b2012-06-20 16:38:30 -070010089tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10090{
10091 tANI_BOOLEAN fFound = FALSE;
10092 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10094 {
10095 if( pCipherList->encryptionType[idx] == encryptionType )
10096 {
10097 fFound = TRUE;
10098 break;
10099 }
10100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010101 return fFound;
10102}
Jeff Johnson295189b2012-06-20 16:38:30 -070010103tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10104{
10105 tANI_BOOLEAN fFound = FALSE;
10106 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10108 {
10109 if( pAuthList->authType[idx] == authType )
10110 {
10111 fFound = TRUE;
10112 break;
10113 }
10114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 return fFound;
10116}
Jeff Johnson295189b2012-06-20 16:38:30 -070010117tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10118{
10119 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10120 tCsrScanResultFilter *pScanFilter = NULL;
10121 eHalStatus status = eHAL_STATUS_SUCCESS;
10122
10123 if(pProfile1 && pProfile2)
10124 {
10125 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10126 if(HAL_STATUS_SUCCESS(status))
10127 {
10128 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10129 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10130 if(HAL_STATUS_SUCCESS(status))
10131 {
10132 fCheck = eANI_BOOLEAN_FALSE;
10133 do
10134 {
10135 tANI_U32 i;
10136 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10137 {
10138 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10139 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10140 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10141 if ( fCheck ) break;
10142 }
10143 if(!fCheck)
10144 {
10145 break;
10146 }
10147 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10148 || pProfile2->BSSType != pProfile1->BSSType
10149 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10150 )
10151 {
10152 fCheck = eANI_BOOLEAN_FALSE;
10153 break;
10154 }
10155#ifdef WLAN_FEATURE_VOWIFI_11R
10156 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10157 {
10158 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10159 {
10160 fCheck = eANI_BOOLEAN_FALSE;
10161 break;
10162 }
10163 }
10164#endif
10165 //Match found
10166 fCheck = eANI_BOOLEAN_TRUE;
10167 }while(0);
10168 csrFreeScanFilter(pMac, pScanFilter);
10169 }
10170 palFreeMemory(pMac->hHdd, pScanFilter);
10171 }
10172 }
10173
10174 return (fCheck);
10175}
10176
Jeff Johnson295189b2012-06-20 16:38:30 -070010177tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10178{
10179 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10180 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 do
10182 {
10183 //Only check for static WEP
10184 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10185 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10186 {
10187 fCheck = eANI_BOOLEAN_TRUE;
10188 break;
10189 }
10190 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10191 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10192 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10193 {
10194 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10195 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10196 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10197 {
10198 break;
10199 }
10200 }
10201 if( i == CSR_MAX_NUM_KEY)
10202 {
10203 fCheck = eANI_BOOLEAN_TRUE;
10204 }
10205 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 return (fCheck);
10207}
10208
Jeff Johnson295189b2012-06-20 16:38:30 -070010209//IBSS
10210
Jeff Johnson295189b2012-06-20 16:38:30 -070010211tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10212{
10213 tANI_U8 channel = 0;
10214 tANI_U32 idx;
10215 tANI_U32 idxValidChannels;
10216 tANI_BOOLEAN fFound = FALSE;
10217 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10218
10219 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10220 {
10221 channel = pMac->roam.configParam.AdHocChannel5G;
10222 if(!csrRoamIsChannelValid(pMac, channel))
10223 {
10224 channel = 0;
10225 }
10226 }
10227 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10228 {
10229 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10230 {
10231 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10232 {
10233 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10234 {
10235 fFound = TRUE;
10236 channel = csrStartIbssChannels50[ idx ];
10237 }
10238 }
10239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10241 if (!fFound)
10242 {
10243 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10244 {
10245 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10246 {
10247 channel = csrStartIbssChannels50[ idx ];
10248 break;
10249 }
10250 }
10251 }
10252 }//if
10253
10254 return( channel );
10255}
10256
Jeff Johnson295189b2012-06-20 16:38:30 -070010257tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10258{
10259 tANI_U8 channel = 1;
10260 tANI_U32 idx;
10261 tANI_U32 idxValidChannels;
10262 tANI_BOOLEAN fFound = FALSE;
10263 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10264
10265 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10266 {
10267 channel = pMac->roam.configParam.AdHocChannel24;
10268 if(!csrRoamIsChannelValid(pMac, channel))
10269 {
10270 channel = 0;
10271 }
10272 }
10273
10274 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10275 {
10276 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10277 {
10278 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10279 {
10280 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10281 {
10282 fFound = TRUE;
10283 channel = csrStartIbssChannels24[ idx ];
10284 }
10285 }
10286 }
10287 }
10288
10289 return( channel );
10290}
10291
Jeff Johnson295189b2012-06-20 16:38:30 -070010292static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10293 tCsrRoamStartBssParams *pParam )
10294{
10295 eCsrCfgDot11Mode cfgDot11Mode;
10296 eCsrBand eBand;
10297 tANI_U8 channel = 0;
10298 tSirNwType nwType;
10299 tANI_U8 operationChannel = 0;
10300
10301 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10302 {
10303 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10304 }
10305
10306#ifdef WLAN_SOFTAP_FEATURE
10307 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
10308#else
10309 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel, &eBand );
10310#endif
10311
10312#ifdef WLAN_FEATURE_P2P
10313 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10314 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10315 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10316 )
10317 {
10318 /* This should never happen */
10319 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
10320 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B\n"),
10321 pProfile->csrPersona);
10322 VOS_ASSERT(0);
10323 }
10324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010325 switch( cfgDot11Mode )
10326 {
10327 case eCSR_CFG_DOT11_MODE_11G:
10328 nwType = eSIR_11G_NW_TYPE;
10329 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 case eCSR_CFG_DOT11_MODE_11B:
10331 nwType = eSIR_11B_NW_TYPE;
10332 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 case eCSR_CFG_DOT11_MODE_11A:
10334 nwType = eSIR_11A_NW_TYPE;
10335 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010336 default:
10337 case eCSR_CFG_DOT11_MODE_11N:
10338 case eCSR_CFG_DOT11_MODE_TAURUS:
10339 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10340 if(eCSR_BAND_24 == eBand)
10341 {
10342 nwType = eSIR_11G_NW_TYPE;
10343 }
10344 else
10345 {
10346 nwType = eSIR_11A_NW_TYPE;
10347 }
10348 break;
10349 }
10350
10351 pParam->extendedRateSet.numRates = 0;
10352
10353 switch ( nwType )
10354 {
10355 default:
10356 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)\n"), nwType);
10357 case eSIR_11A_NW_TYPE:
10358
10359 pParam->operationalRateSet.numRates = 8;
10360
10361 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10362 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10363 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10364 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10365 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10366 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10367 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10368 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10369
10370 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10371 {
10372 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10373 if( 0 == channel &&
10374 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10375 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10376 )
10377 {
10378 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10379 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10380 nwType = eSIR_11B_NW_TYPE;
10381 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10382 pParam->operationalRateSet.numRates = 4;
10383 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10384 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10385 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10386 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10387 }
10388 }
10389 else
10390 {
10391 channel = operationChannel;
10392 }
10393 break;
10394
10395 case eSIR_11B_NW_TYPE:
10396 pParam->operationalRateSet.numRates = 4;
10397 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10398 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10399 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10400 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010401 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10402 {
10403 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10404 }
10405 else
10406 {
10407 channel = operationChannel;
10408 }
10409
10410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 case eSIR_11G_NW_TYPE:
10412#ifdef WLAN_FEATURE_P2P
10413 /* For P2P Client and P2P GO, disable 11b rates */
10414 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10415 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10416 )
10417 {
10418 pParam->operationalRateSet.numRates = 8;
10419
10420 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10421 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10422 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10423 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10424 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10425 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10426 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10427 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10428 }
10429 else
10430#endif
10431 {
10432 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010433 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10434 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10435 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10436 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10437
10438 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10440 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10441 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10442 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10443 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10444 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10445 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10446 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10447 }
10448
10449 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10450 {
10451 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10452 }
10453 else
10454 {
10455 channel = operationChannel;
10456 }
10457
10458 break;
10459 }
10460 pParam->operationChn = channel;
10461 pParam->sirNwType = nwType;
10462}
10463
Jeff Johnson295189b2012-06-20 16:38:30 -070010464static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10465 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10466{
10467
10468 if( pParam )
10469 {
10470 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010471 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 pParam->operationChn = pBssDesc->channelId;
10473 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10474
10475 if( pIes )
10476 {
10477 if(pIes->SuppRates.present)
10478 {
10479 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10480 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10481 {
10482 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX\n"),
10483 pIes->SuppRates.num_rates);
10484 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10485 }
10486 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10487 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10488 }
10489 if( pIes->SSID.present )
10490 {
10491 pParam->ssId.length = pIes->SSID.num_ssid;
10492 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10493 }
10494 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 }
10496 else
10497 {
10498 pParam->ssId.length = 0;
10499 pParam->operationalRateSet.numRates = 0;
10500 }
10501 }
10502}
10503
Jeff Johnson295189b2012-06-20 16:38:30 -070010504static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10505{
10506 tANI_U8 MaxRate = 0;
10507 tANI_U32 i;
10508 tANI_U8 *pRate;
10509
10510 pRate = pSirRateSet->rate;
10511 for ( i = 0; i < pSirRateSet->numRates; i++ )
10512 {
10513 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10514 }
10515
10516 // Save the max rate in the connected state information...
10517
10518 // modify LastRates variable as well
10519
10520 return;
10521}
10522
Jeff Johnson295189b2012-06-20 16:38:30 -070010523//this function finds a valid secondary channel for channel bonding with "channel".
10524//Param: channel -- primary channel, caller must validate it
10525// cbChoice -- CB directory
10526//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10527static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10528{
10529 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010530 switch (cbChoice)
10531 {
10532 case eCSR_CB_OFF:
10533 chnUp = 0;
10534 chnDown = 0;
10535 break;
10536 case eCSR_CB_DOWN:
10537 chnUp = 0;
10538 chnDown = channel - CSR_CB_CHANNEL_GAP;
10539 break;
10540 case eCSR_CB_UP:
10541 chnUp = channel + CSR_CB_CHANNEL_GAP;
10542 chnDown = 0;
10543 break;
10544 case eCSR_CB_AUTO:
10545 //consider every other value means auto
10546 default:
10547 chnUp = channel + CSR_CB_CHANNEL_GAP;
10548 chnDown = channel - CSR_CB_CHANNEL_GAP;
10549 break;
10550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 //if CB_UP or auto, try channel up first
10552 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10553 {
10554 //found a valid up channel for channel bonding
10555 //check whether the center channel is valid
10556 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10557 {
10558 chnRet = chnUp;
10559 }
10560 }
10561 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10562 {
10563 //found a valid down channel for channel bonding
10564 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10565 {
10566 chnRet = chnDown;
10567 }
10568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010569 return chnRet;
10570}
10571
Jeff Johnson295189b2012-06-20 16:38:30 -070010572eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10573 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10574{
10575 eHalStatus status = eHAL_STATUS_SUCCESS;
10576 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 // Set the roaming substate to 'Start BSS attempt'...
10578 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010579#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10580 //Need to figure out whether we need to log WDS???
10581 if( CSR_IS_IBSS( pProfile ) )
10582 {
10583 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10585 if(pIbssLog)
10586 {
10587 if(pBssDesc)
10588 {
10589 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10590 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10591 }
10592 else
10593 {
10594 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10595 }
10596 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10597 pParam->ssId.length);
10598 if(pProfile->ChannelInfo.numOfChannels == 0)
10599 {
10600 pIbssLog->channelSetting = AUTO_PICK;
10601 }
10602 else
10603 {
10604 pIbssLog->channelSetting = SPECIFIED;
10605 }
10606 pIbssLog->operatingChannel = pParam->operationChn;
10607 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10608 }
10609 }
10610#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10611 //Put RSN information in for Starting BSS
10612 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10613 pParam->pRSNIE = pProfile->pRSNReqIE;
10614
Jeff Johnson295189b2012-06-20 16:38:30 -070010615#ifdef WLAN_SOFTAP_FEATURE
10616 pParam->privacy = pProfile->privacy;
10617 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10618 pParam->authType = pProfile->csr80211AuthType;
10619 pParam->beaconInterval = pProfile->beaconInterval;
10620 pParam->dtimPeriod = pProfile->dtimPeriod;
10621 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10622 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10623 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10624 {
10625 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10626 {
10627 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10628 }
10629 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010630 pParam->protEnabled = pProfile->protEnabled;
10631 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10632 pParam->ht_protection = pProfile->cfg_protection;
10633 pParam->wps_state = pProfile->wps_state;
10634#endif
10635
Jeff Johnson295189b2012-06-20 16:38:30 -070010636#ifdef WLAN_SOFTAP_FEATURE
10637 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10638 &eBand);
10639#else
10640 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile->operationChannel,
10641 &eBand);
10642#endif
10643 pParam->bssPersona = pProfile->csrPersona;
10644 // When starting an IBSS, start on the channel from the Profile.
10645 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010646 return (status);
10647}
10648
Jeff Johnson295189b2012-06-20 16:38:30 -070010649static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010650 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010651{
10652 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010653 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 eCsrCBChoice cbChoice;
10655 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010656
10657 if(!pSession)
10658 {
10659 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10660 return;
10661 }
10662
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 if( pBssDesc )
10664 {
10665 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10666 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10667 //The following code has to be do after that.
10668 //For WDS station, use selfMac as the self BSSID
10669 if( CSR_IS_WDS_STA( pProfile ) )
10670 {
10671 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10672 }
10673 }
10674 else
10675 {
10676 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010677 //Use the first SSID
10678 if(pProfile->SSIDs.numOfSSIDs)
10679 {
10680 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10681 }
10682 //For WDS station, use selfMac as the self BSSID
10683 if( CSR_IS_WDS_STA( pProfile ) )
10684 {
10685 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10686 }
10687 //Use the first BSSID
10688 else if( pProfile->BSSIDs.numOfBSSIDs )
10689 {
10690 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10691 }
10692 else
10693 {
10694 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10695 }
10696 }
10697 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 //Set operating channel in pProfile which will be used
10699 //in csrRoamSetBssConfigCfg() to determine channel bonding
10700 //mode and will be configured in CFG later
10701 pProfile->operationChannel = Channel;
10702
10703 if(Channel == 0)
10704 {
10705 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS\n");
10706 }
10707 else
10708 {
10709
10710 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010711 if (CSR_IS_INFRA_AP(pProfile))
10712 {
10713 if(CSR_IS_CHANNEL_24GHZ(Channel))
10714 {
10715 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10716 }
10717 else
10718 {
10719 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10720 }
10721 smsLog(pMac, LOG1, "##softap cbMode %d\n", cbMode);
10722 pBssConfig->cbMode = cbMode;
10723 pSession->bssParams.cbMode = cbMode;
10724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010725
10726 if( CSR_IS_START_IBSS( pProfile ) )
10727 {
10728 //TBH: channel bonding is not supported for Libra
10729 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10730 {
10731 Channel = pProfile->ChannelInfo.ChannelList[0];
10732 cbChoice = pProfile->CBMode;
10733 }
10734 else {
10735 cbChoice = pMac->roam.configParam.cbChoice;
10736 }
10737 pSession->bssParams.operationChn = Channel;
10738 //make sure channel is valid
10739 if(!csrRoamIsChannelValid(pMac, Channel))
10740 {
10741 //set Channel to 0 to let lim know this is invalid
10742 //We still send this request down to lim even though we know the channel is wrong because
10743 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10744 Channel = 0;
10745 pSession->bssParams.operationChn = 0;
10746 }
10747 else {
10748 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 if(CSR_IS_CHANNEL_24GHZ(Channel))
10750 {
10751 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10752 }
10753 else
10754 {
10755 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10756 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 //now we have a valid channel
10758 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10759 {
10760 //let's pick a secondard channel
10761 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 if(SecondChn > Channel)
10763 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010764 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 }
10766 else if(SecondChn && SecondChn < Channel)
10767 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010768 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010769 }
10770 else
10771 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010772 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 }
10774 pSession->bssParams.cbMode = cbMode;
10775 }
10776 else
10777 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010778 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 }
10780 }
10781 }
10782 }
10783}
10784
Jeff Johnson295189b2012-06-20 16:38:30 -070010785static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10786 tANI_BOOLEAN *pfSameIbss )
10787{
10788 eHalStatus status = eHAL_STATUS_SUCCESS;
10789 tANI_BOOLEAN fSameIbss = FALSE;
10790
10791 if ( csrIsConnStateIbss( pMac, sessionId ) )
10792 {
10793 // Check if any profile parameter has changed ? If any profile parameter
10794 // has changed then stop old BSS and start a new one with new parameters
10795 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10796 {
10797 fSameIbss = TRUE;
10798 }
10799 else
10800 {
10801 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10802 }
10803 }
10804 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10805 {
10806 // Disassociate from the connected Infrastructure network...
10807 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10808 }
10809 else
10810 {
10811 tBssConfigParam *pBssConfig;
10812
10813 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10814 if(HAL_STATUS_SUCCESS(status))
10815 {
10816 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10817 // there is no Bss description before we start an IBSS so we need to adopt
10818 // all Bss configuration parameters from the Profile.
10819 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10820 if(HAL_STATUS_SUCCESS(status))
10821 {
10822 //save dotMode
10823 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10824 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010825 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010826 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10827 }
10828
10829 palFreeMemory(pMac->hHdd, pBssConfig);
10830 }//Allocate memory
10831 }
10832
10833 if(pfSameIbss)
10834 {
10835 *pfSameIbss = fSameIbss;
10836 }
10837 return( status );
10838}
10839
Jeff Johnson295189b2012-06-20 16:38:30 -070010840static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10841 tSirSmeNewBssInfo *pNewBss )
10842{
10843 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010844
10845 if(!pSession)
10846 {
10847 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10848 return;
10849 }
10850
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 if( pNewBss )
10852 {
10853 // Set the operating channel.
10854 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10855 // move the BSSId from the BSS description into the connected state information.
10856 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10857 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010859 return;
10860}
10861
Jeff Johnson295189b2012-06-20 16:38:30 -070010862#ifdef FEATURE_WLAN_WAPI
10863eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10864 tANI_U32 numItems )
10865{
10866 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10867 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10869 {
10870 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10871 return status;
10872 }
10873 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d\n", numItems);
10874 pSession = CSR_GET_SESSION( pMac, sessionId );
10875 if(numItems <= CSR_MAX_BKID_ALLOWED)
10876 {
10877 status = eHAL_STATUS_SUCCESS;
10878 //numItems may be 0 to clear the cache
10879 pSession->NumBkidCache = (tANI_U16)numItems;
10880 if(numItems && pBKIDCache)
10881 {
10882 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
10883 sizeof(tBkidCacheInfo) * numItems );
10884 }
10885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010886 return (status);
10887}
Jeff Johnson295189b2012-06-20 16:38:30 -070010888eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
10889 tBkidCacheInfo *pBkidCache)
10890{
10891 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10892 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010893 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10894 {
10895 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10896 return status;
10897 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 pSession = CSR_GET_SESSION( pMac, sessionId );
10899 if(pNum && pBkidCache)
10900 {
10901 if(pSession->NumBkidCache == 0)
10902 {
10903 *pNum = 0;
10904 status = eHAL_STATUS_SUCCESS;
10905 }
10906 else if(*pNum >= pSession->NumBkidCache)
10907 {
10908 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
10909 {
10910 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10911 pSession->NumBkidCache);
10912 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
10913 }
10914 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
10915 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
10916 *pNum = pSession->NumBkidCache;
10917 status = eHAL_STATUS_SUCCESS;
10918 }
10919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010920 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010921}
Jeff Johnson295189b2012-06-20 16:38:30 -070010922tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10923{
10924 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070010925}
10926#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070010927eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
10928 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
10929{
10930 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10931 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010932
10933 if(!pSession)
10934 {
10935 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10936 return eHAL_STATUS_FAILURE;
10937 }
10938
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d\n", numItems);
10940 if(numItems <= CSR_MAX_PMKID_ALLOWED)
10941 {
10942#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10943 {
10944 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
10945 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
10946 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
10947 secEvent.encryptionModeMulticast =
10948 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10949 secEvent.encryptionModeUnicast =
10950 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10951 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
10952 secEvent.authMode =
10953 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
10954 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10955 }
10956#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 status = eHAL_STATUS_SUCCESS;
10958 //numItems may be 0 to clear the cache
10959 pSession->NumPmkidCache = (tANI_U16)numItems;
10960 if(numItems && pPMKIDCache)
10961 {
10962 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
10963 sizeof(tPmkidCacheInfo) * numItems );
10964 }
10965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 return (status);
10967}
10968
Jeff Johnson295189b2012-06-20 16:38:30 -070010969tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10970{
10971 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
10972}
10973
Jeff Johnson295189b2012-06-20 16:38:30 -070010974eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
10975{
10976 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10977 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010978
10979 if(!pSession)
10980 {
10981 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10982 return eHAL_STATUS_FAILURE;
10983 }
10984
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 if(pNum && pPmkidCache)
10986 {
10987 if(pSession->NumPmkidCache == 0)
10988 {
10989 *pNum = 0;
10990 status = eHAL_STATUS_SUCCESS;
10991 }
10992 else if(*pNum >= pSession->NumPmkidCache)
10993 {
10994 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
10995 {
10996 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10997 pSession->NumPmkidCache);
10998 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
10999 }
11000 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11001 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11002 *pNum = pSession->NumPmkidCache;
11003 status = eHAL_STATUS_SUCCESS;
11004 }
11005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011006 return (status);
11007}
11008
Jeff Johnson295189b2012-06-20 16:38:30 -070011009eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11010{
11011 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11012 tANI_U32 len;
11013 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011014
11015 if(!pSession)
11016 {
11017 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11018 return eHAL_STATUS_FAILURE;
11019 }
11020
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 if(pLen)
11022 {
11023 len = *pLen;
11024 *pLen = pSession->nWpaRsnReqIeLength;
11025 if(pBuf)
11026 {
11027 if(len >= pSession->nWpaRsnReqIeLength)
11028 {
11029 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11030 }
11031 }
11032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011033 return (status);
11034}
11035
Jeff Johnson295189b2012-06-20 16:38:30 -070011036eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11037{
11038 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11039 tANI_U32 len;
11040 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011041
11042 if(!pSession)
11043 {
11044 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11045 return eHAL_STATUS_FAILURE;
11046 }
11047
Jeff Johnson295189b2012-06-20 16:38:30 -070011048 if(pLen)
11049 {
11050 len = *pLen;
11051 *pLen = pSession->nWpaRsnRspIeLength;
11052 if(pBuf)
11053 {
11054 if(len >= pSession->nWpaRsnRspIeLength)
11055 {
11056 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11057 }
11058 }
11059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 return (status);
11061}
Jeff Johnson295189b2012-06-20 16:38:30 -070011062#ifdef FEATURE_WLAN_WAPI
11063eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11064{
11065 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11066 tANI_U32 len;
11067 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011068
11069 if(!pSession)
11070 {
11071 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11072 return eHAL_STATUS_FAILURE;
11073 }
11074
Jeff Johnson295189b2012-06-20 16:38:30 -070011075 if(pLen)
11076 {
11077 len = *pLen;
11078 *pLen = pSession->nWapiReqIeLength;
11079 if(pBuf)
11080 {
11081 if(len >= pSession->nWapiReqIeLength)
11082 {
11083 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11084 }
11085 }
11086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 return (status);
11088}
Jeff Johnson295189b2012-06-20 16:38:30 -070011089eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11090{
11091 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11092 tANI_U32 len;
11093 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011094
11095 if(!pSession)
11096 {
11097 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11098 return eHAL_STATUS_FAILURE;
11099 }
11100
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 if(pLen)
11102 {
11103 len = *pLen;
11104 *pLen = pSession->nWapiRspIeLength;
11105 if(pBuf)
11106 {
11107 if(len >= pSession->nWapiRspIeLength)
11108 {
11109 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11110 }
11111 }
11112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 return (status);
11114}
11115#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011116eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11117{
11118 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11119 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011120
11121 if(!pSession)
11122 {
11123 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11124 return (retStatus);
11125 }
11126
Jeff Johnson295189b2012-06-20 16:38:30 -070011127 if(CSR_IS_ROAMING(pSession))
11128 {
11129 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11130 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011132 return (retStatus);
11133}
11134
Jeff Johnson295189b2012-06-20 16:38:30 -070011135//This function remove the connected BSS from te cached scan result
11136eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11137 tCsrRoamConnectedProfile *pConnProfile)
11138{
11139 eHalStatus status = eHAL_STATUS_FAILURE;
11140 tCsrScanResultFilter *pScanFilter = NULL;
11141 tListElem *pEntry;
11142 tCsrScanResult *pResult;
11143 tDot11fBeaconIEs *pIes;
11144 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011145 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11146 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11147 {
11148 do
11149 {
11150 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11151 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11152 if(!HAL_STATUS_SUCCESS(status)) break;
11153 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11154 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11155 if(!HAL_STATUS_SUCCESS(status)) break;
11156 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11157 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11158 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11159 {
11160 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11161 if(!HAL_STATUS_SUCCESS(status)) break;
11162 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11163 }
11164 pScanFilter->authType.numEntries = 1;
11165 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11166 pScanFilter->BSSType = pConnProfile->BSSType;
11167 pScanFilter->EncryptionType.numEntries = 1;
11168 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11169 pScanFilter->mcEncryptionType.numEntries = 1;
11170 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11171 //We ignore the channel for now, BSSID should be enough
11172 pScanFilter->ChannelInfo.numOfChannels = 0;
11173 //Also ignore the following fields
11174 pScanFilter->uapsd_mask = 0;
11175 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11176 pScanFilter->countryCode[0] = 0;
11177 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011178 csrLLLock(&pMac->scan.scanResultList);
11179 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11180 while( pEntry )
11181 {
11182 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11183 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11184 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11185 pScanFilter, NULL, NULL, NULL, &pIes);
11186 //Release the IEs allocated by csrMatchBSS is needed
11187 if( !pResult->Result.pvIes )
11188 {
11189 //need to free the IEs since it is allocated by csrMatchBSS
11190 palFreeMemory(pMac->hHdd, pIes);
11191 }
11192 if(fMatch)
11193 {
11194 //We found the one
11195 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11196 {
11197 //Free the memory
11198 csrFreeScanResultEntry( pMac, pResult );
11199 }
11200 break;
11201 }
11202 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11203 }//while
11204 csrLLUnlock(&pMac->scan.scanResultList);
11205 }while(0);
11206 if(pScanFilter)
11207 {
11208 csrFreeScanFilter(pMac, pScanFilter);
11209 palFreeMemory(pMac->hHdd, pScanFilter);
11210 }
11211 }
11212 return (status);
11213}
11214
Jeff Johnson295189b2012-06-20 16:38:30 -070011215//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011216eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11217{
11218 eHalStatus status = eHAL_STATUS_SUCCESS;
11219 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011220 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11221 {
11222 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11223 {
11224 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11225 {
11226 //co-exist with IBSS or BT-AMP is not supported
11227 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d\n", sessionId );
11228 status = eHAL_STATUS_CSR_WRONG_STATE;
11229 break;
11230 }
11231 if( csrIsConnStateInfra( pMac, sessionId ) )
11232 {
11233 if( chnId &&
11234 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11235 {
11236 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)\n",
11237 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11238 status = eHAL_STATUS_CSR_WRONG_STATE;
11239 break;
11240 }
11241 }
11242 }
11243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 return ( status );
11245}
11246
Jeff Johnson295189b2012-06-20 16:38:30 -070011247static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11248{
11249 eHalStatus status = eHAL_STATUS_SUCCESS;
11250 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11251 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011252
11253 if(!pSession)
11254 {
11255 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11256 return eHAL_STATUS_FAILURE;
11257 }
11258
Jeff Johnson295189b2012-06-20 16:38:30 -070011259 if ( csrIsConnStateIbss( pMac, sessionId ) )
11260 {
11261 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11262 }
11263 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11264 {
11265 // Disassociate from the connected Infrastructure network...
11266 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11267 }
11268 else
11269 {
11270#if defined(VOSS_ENABLED)
11271 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11272 //Otherwise we need to add code to handle the
11273 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11274 //send stop_bss to PE, before we can continue.
11275 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
11276#endif
11277 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11278 /* Assume HDD provide bssid in profile */
11279 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11280 // there is no Bss description before we start an WDS so we need
11281 // to adopt all Bss configuration parameters from the Profile.
11282 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11283 if(HAL_STATUS_SUCCESS(status))
11284 {
11285 //Save profile for late use
11286 csrFreeRoamProfile( pMac, sessionId );
11287 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11288 (void **)&pSession->pCurRoamProfile,
11289 sizeof(tCsrRoamProfile))))
11290 {
11291 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11292 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011295 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11297 }
11298 }
11299
11300 return( status );
11301}
11302
Jeff Johnson295189b2012-06-20 16:38:30 -070011303////////////////////Mail box
11304
Jeff Johnson295189b2012-06-20 16:38:30 -070011305//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11306//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11307static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11308 tSirBssDescription *pBssDescription,
11309 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11310{
11311 tCsrChannelSet channelGroup;
11312 tSirMacCapabilityInfo *pAP_capabilityInfo;
11313 tAniBool fTmp;
11314 tANI_BOOLEAN found = FALSE;
11315 tANI_U32 size = 0;
Kirand170dcb2013-01-31 10:43:43 -080011316 tANI_S8 pwrLimit = 0;
11317 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11319 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11320 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11321 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 // 802.11h
11323 //We can do this because it is in HOST CPU order for now.
11324 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kirand170dcb2013-01-31 10:43:43 -080011325 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11326 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11327 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 fTmp = (tAniBool)pal_cpu_to_be32(1);
11329 }
11330 else
11331 fTmp = (tAniBool)0;
11332
11333 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11334 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11335 pBuf += sizeof(tAniBool);
11336 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kirand170dcb2013-01-31 10:43:43 -080011337 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 // This is required for 11k test VoWiFi Ent: Test 2.
11339 // We need the power capabilities for Assoc Req.
11340 // This macro is provided by the halPhyCfg.h. We pick our
11341 // max and min capability by the halPhy provided macros
Kirand170dcb2013-01-31 10:43:43 -080011342 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11343 if (0 != pwrLimit)
11344 {
11345 *pBuf++ = pwrLimit;
11346 }
11347 else
11348 {
11349 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 size = sizeof(pMac->roam.validChannelList);
11352 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11353 {
11354 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11355 for ( i = 0; i < size; i++)
11356 {
11357 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11358
11359 }
11360 }
11361 else
11362 {
11363 smsLog(pMac, LOGE, FL("can not find any valid channel\n"));
11364 *pBuf++ = 0; //tSirSupChnl->numChnl
11365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011366 //Check whether it is ok to enter UAPSD
11367#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11368 if( btcIsReadyForUapsd(pMac) )
11369#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11370 {
11371 *pBuf++ = uapsdMask;
11372 }
11373#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11374 else
11375 {
11376 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)\n"), uapsdMask);
11377 *pBuf++ = 0;
11378 }
11379#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11380
Jeff Johnson295189b2012-06-20 16:38:30 -070011381 // move the entire BssDescription into the join request.
11382 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11383 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11385}
11386
Jeff Johnson295189b2012-06-20 16:38:30 -070011387/*
11388 * The communication between HDD and LIM is thru mailbox (MB).
11389 * Both sides will access the data structure "tSirSmeJoinReq".
11390 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11391 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11392 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11393 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11394 */
11395eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011396 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011397{
11398 eHalStatus status = eHAL_STATUS_SUCCESS;
11399 tSirSmeJoinReq *pMsg;
11400 tANI_U8 *pBuf;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011401 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 tANI_U16 msgLen, wTmp, ieLen;
11403 tSirMacRateSet OpRateSet;
11404 tSirMacRateSet ExRateSet;
11405 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11406 tANI_U32 dwTmp;
11407 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011408
11409 if(!pSession)
11410 {
11411 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11412 return eHAL_STATUS_FAILURE;
11413 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011414 /* To satisfy klockworks */
11415 if (NULL == pBssDescription)
11416 {
11417 smsLog(pMac, LOGE, FL(" pBssDescription is NULL\n"));
11418 return eHAL_STATUS_FAILURE;
11419 }
11420
Jeff Johnson295189b2012-06-20 16:38:30 -070011421 do {
11422 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11423 pSession->joinFailStatusCode.reasonCode = 0;
11424 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11425 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11426 // IE fields, but the length field in the bssDescription needs to be interpreted to
11427 // determine length of the IE fields.
11428 //
11429 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11430 // add in the length from the bssDescription (then add the size of the 'length' field
11431 // itself because that is NOT included in the length field).
11432 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11433 pBssDescription->length + sizeof( pBssDescription->length ) +
11434 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 -070011435 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11436 if ( !HAL_STATUS_SUCCESS(status) ) break;
11437 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011438 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 pMsg->length = pal_cpu_to_be16(msgLen);
11440 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011441 // sessionId
11442 *pBuf = (tANI_U8)sessionId;
11443 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 // transactionId
11445 *pBuf = 0;
11446 *( pBuf + 1 ) = 0;
11447 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 // ssId
11449 if( pIes->SSID.present && pIes->SSID.num_ssid )
11450 {
11451 // ssId len
11452 *pBuf = pIes->SSID.num_ssid;
11453 pBuf++;
11454 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11455 pBuf += pIes->SSID.num_ssid;
11456 }
11457 else
11458 {
11459 *pBuf = 0;
11460 pBuf++;
11461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 // selfMacAddr
11463 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11464 pBuf += sizeof(tSirMacAddr);
11465 // bsstype
11466 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11467 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11468 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11469 pBuf += sizeof(tSirBssType);
11470 // dot11mode
11471 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11472 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 //Persona
11474 *pBuf = (tANI_U8)pProfile->csrPersona;
11475 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011476 //CBMode
11477 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11478 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011479
11480 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011481 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11482
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 // uapsdPerAcBitmask
11484 *pBuf = pProfile->uapsd_mask;
11485 pBuf++;
11486
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011487
11488
11489#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
Jeff Johnson295189b2012-06-20 16:38:30 -070011490#endif /*(WNI_POLARIS_FW_PACKAGE == ADVANCED)*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011492 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 {
11494 // OperationalRateSet
11495 if (OpRateSet.numRates) {
11496 *pBuf++ = OpRateSet.numRates;
11497 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11498 pBuf += OpRateSet.numRates;
11499 } else *pBuf++ = 0;
11500 // ExtendedRateSet
11501 if (ExRateSet.numRates) {
11502 *pBuf++ = ExRateSet.numRates;
11503 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11504 pBuf += ExRateSet.numRates;
11505 } else *pBuf++ = 0;
11506 }
11507 else
11508 {
11509 *pBuf++ = 0;
11510 *pBuf++ = 0;
11511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 // rsnIE
11513 if ( csrIsProfileWpa( pProfile ) )
11514 {
11515 // Insert the Wpa IE into the join request
11516 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11517 (tCsrWpaIe *)( wpaRsnIE ) );
11518 }
11519 else if( csrIsProfileRSN( pProfile ) )
11520 {
11521 // Insert the RSN IE into the join request
11522 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11523 (tCsrRSNIe *)( wpaRsnIE ) );
11524 }
11525#ifdef FEATURE_WLAN_WAPI
11526 else if( csrIsProfileWapi( pProfile ) )
11527 {
11528 // Insert the WAPI IE into the join request
11529 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11530 (tCsrWapiIe *)( wpaRsnIE ) );
11531 }
11532#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 else
11534 {
11535 ieLen = 0;
11536 }
11537 //remember the IE for future use
11538 if( ieLen )
11539 {
11540 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11541 {
11542 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);
11543 ieLen = DOT11F_IE_RSN_MAX_LEN;
11544 }
11545#ifdef FEATURE_WLAN_WAPI
11546 if( csrIsProfileWapi( pProfile ) )
11547 {
11548 //Check whether we need to allocate more memory
11549 if(ieLen > pSession->nWapiReqIeLength)
11550 {
11551 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11552 {
11553 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11554 }
11555 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11556 if(!HAL_STATUS_SUCCESS(status)) break;
11557 }
11558 pSession->nWapiReqIeLength = ieLen;
11559 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11560 wTmp = pal_cpu_to_be16( ieLen );
11561 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11562 pBuf += sizeof(tANI_U16);
11563 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11564 pBuf += ieLen;
11565 }
11566 else//should be WPA/WPA2 otherwise
11567#endif /* FEATURE_WLAN_WAPI */
11568 {
11569 //Check whether we need to allocate more memory
11570 if(ieLen > pSession->nWpaRsnReqIeLength)
11571 {
11572 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11573 {
11574 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11575 }
11576 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11577 if(!HAL_STATUS_SUCCESS(status)) break;
11578 }
11579 pSession->nWpaRsnReqIeLength = ieLen;
11580 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11581 wTmp = pal_cpu_to_be16( ieLen );
11582 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11583 pBuf += sizeof(tANI_U16);
11584 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11585 pBuf += ieLen;
11586 }
11587 }
11588 else
11589 {
11590 //free whatever old info
11591 pSession->nWpaRsnReqIeLength = 0;
11592 if(pSession->pWpaRsnReqIE)
11593 {
11594 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11595 pSession->pWpaRsnReqIE = NULL;
11596 }
11597#ifdef FEATURE_WLAN_WAPI
11598 pSession->nWapiReqIeLength = 0;
11599 if(pSession->pWapiReqIE)
11600 {
11601 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11602 pSession->pWapiReqIE = NULL;
11603 }
11604#endif /* FEATURE_WLAN_WAPI */
11605 //length is two bytes
11606 *pBuf = 0;
11607 *(pBuf + 1) = 0;
11608 pBuf += 2;
11609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011610#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011611 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011613 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 //length is two bytes
11615 *pBuf = 0;
11616 *(pBuf + 1) = 0;
11617 pBuf += 2;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011618 }
11619 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011621 // cckmIE
11622 if( csrIsProfileCCX( pProfile ) )
11623 {
11624 // Insert the CCKM IE into the join request
11625 ieLen = csrConstructCcxCckmIe( pMac,
11626 pSession,
11627 pProfile,
11628 pBssDescription,
11629 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011630 pSession->nWpaRsnReqIeLength,
11631 (void *)( wpaRsnIE ) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011632 }
11633 else
11634 {
11635 ieLen = 0;
11636 }
11637 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11638 if( ieLen )
11639 {
11640 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11641 wTmp = pal_cpu_to_be16( ieLen );
11642 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11643 pBuf += sizeof(tANI_U16);
11644 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11645 pBuf += ieLen;
11646 }
11647 else
11648 {
11649 //Indicate you have no CCKM IE
11650 //length is two bytes
11651 *pBuf = 0;
11652 *(pBuf + 1) = 0;
11653 pBuf += 2;
11654 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011655 }
11656#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 // addIEScan
11658 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11659 {
11660 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 if(ieLen > pSession->nAddIEScanLength)
11662 {
11663 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11664 {
11665 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11666 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011667 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 (void **)&pSession->pAddIEScan, ieLen);
11669 if(!HAL_STATUS_SUCCESS(status)) break;
11670 }
11671 pSession->nAddIEScanLength = ieLen;
11672 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11673 pProfile->pAddIEScan, ieLen);
11674 wTmp = pal_cpu_to_be16( ieLen );
11675 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11676 pBuf += sizeof(tANI_U16);
11677 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11678 pBuf += ieLen;
11679 }
11680 else
11681 {
11682 pSession->nAddIEScanLength = 0;
11683 if(pSession->pAddIEScan)
11684 {
11685 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11686 pSession->pAddIEScan = NULL;
11687 }
11688 *pBuf = 0;
11689 *(pBuf + 1) = 0;
11690 pBuf += 2;
11691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 // addIEAssoc
11693 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11694 {
11695 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011696 if(ieLen > pSession->nAddIEAssocLength)
11697 {
11698 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11699 {
11700 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11701 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011702 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011703 (void **)&pSession->pAddIEAssoc, ieLen);
11704 if(!HAL_STATUS_SUCCESS(status)) break;
11705 }
11706 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011707 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 pProfile->pAddIEAssoc, ieLen);
11709 wTmp = pal_cpu_to_be16( ieLen );
11710 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11711 pBuf += sizeof(tANI_U16);
11712 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11713 pBuf += ieLen;
11714 }
11715 else
11716 {
11717 pSession->nAddIEAssocLength = 0;
11718 if(pSession->pAddIEAssoc)
11719 {
11720 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11721 pSession->pAddIEAssoc = NULL;
11722 }
11723 *pBuf = 0;
11724 *(pBuf + 1) = 0;
11725 pBuf += 2;
11726 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011727
11728 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011729 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011730 //Unmask any AC in reassoc that is ACM-set
11731 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11732 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011734 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11735 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011736#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011737 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011738#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011739 uapsd_mask &= ~(acm_mask);
11740 }
11741 else
11742 {
11743 uapsd_mask = 0;
11744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011745 }
11746 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011747
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11749 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011750 pBuf += sizeof(tANI_U32);
11751
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11753 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011754 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011755#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011756 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
11757 if (csrIsProfile11r( pProfile ) )
11758 {
11759 // is11Rconnection;
11760 dwTmp = pal_cpu_to_be32(TRUE);
11761 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11762 pBuf += sizeof(tAniBool);
11763 }
11764 else
11765 {
11766 // is11Rconnection;
11767 dwTmp = pal_cpu_to_be32(FALSE);
11768 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11769 pBuf += sizeof(tAniBool);
11770 }
11771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011772#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011773 /* A profile can not be both CCX and 11R. But an 802.11R AP
11774 * may be advertising support for CCX as well. So if we are
11775 * associating Open or explicitly CCX then we will get CCX.
11776 * If we are associating explictly 11R only then we will get
11777 * 11R.
11778 */
11779 if ((csrIsProfileCCX(pProfile) ||
11780 ((pIes->CCXVersion.present)
11781 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011782 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11783 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11784 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011785 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11786 && (!(csrIsProfile11r( pProfile )))
11787 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11788 {
11789 // isCCXconnection;
11790 dwTmp = pal_cpu_to_be32(TRUE);
11791 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11792 pBuf += sizeof(tAniBool);
11793 }
11794 else
11795 {
11796 //isCCXconnection;
11797 dwTmp = pal_cpu_to_be32(FALSE);
11798 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11799 pBuf += sizeof(tAniBool);
11800 }
11801
11802 if (eWNI_SME_JOIN_REQ == messageType)
11803 {
11804 tCCXTspecInfo ccxTspec;
11805 // CCX-Tspec IEs in the ASSOC request is presently not supported
11806 // so nullify the TSPEC parameters
11807 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11808 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11809 pBuf += sizeof(tCCXTspecInfo);
11810 }
11811 else if (eWNI_SME_REASSOC_REQ == messageType)
11812 {
11813 if ((csrIsProfileCCX(pProfile) ||
11814 ((pIes->CCXVersion.present)
11815 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011816 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11817 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11818 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011819 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11820 && (!(csrIsProfile11r( pProfile )))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011821 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 {
11823 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 // CCX Tspec information
11825 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11826 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11827 *pBuf = ccxTspec.numTspecs;
11828 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 // Copy the TSPEC information only if present
11830 if (ccxTspec.numTspecs) {
11831 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11832 }
11833 pBuf += sizeof(ccxTspec.tspec);
11834 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011835 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 tCCXTspecInfo ccxTspec;
11838 // CCX-Tspec IEs in the ASSOC request is presently not supported
11839 // so nullify the TSPEC parameters
11840 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11841 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11842 pBuf += sizeof(tCCXTspecInfo);
11843 }
11844 }
11845#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011846#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011847 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011848 if (pMac->roam.configParam.isFastTransitionEnabled
11849#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011850 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011851#endif
11852 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011853 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011854 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011856 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 }
11858 else
11859 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011860 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011862 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 }
11864#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070011865#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011866 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070011867 {
11868 //legacy fast roaming enabled
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011869 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011870 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011871 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011872 }
11873 else
11874 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011875 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011876 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011877 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011878 }
11879#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011880
11881 // txLdpcIniFeatureEnabled
11882 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
11883 pBuf++;
11884
Kirand170dcb2013-01-31 10:43:43 -080011885 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
11886 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
11887 {
11888 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
11889 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
11890 csrApplyPower2Current(pMac);
11891 }
11892
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -080011893#ifdef WLAN_FEATURE_11AC
Kirand170dcb2013-01-31 10:43:43 -080011894 // txBFIniFeatureEnabled
11895 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
11896 pBuf++;
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -080011897#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011898 //BssDesc
11899 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
11900 (tANI_U8)pProfile->uapsd_mask);
11901 status = palSendMBMessage(pMac->hHdd, pMsg );
11902 if(!HAL_STATUS_SUCCESS(status))
11903 {
11904 break;
11905 }
11906 else
11907 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011908#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011909 if (eWNI_SME_JOIN_REQ == messageType)
11910 {
11911 //Tush-QoS: notify QoS module that join happening
11912 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
11913 }
11914 else if (eWNI_SME_REASSOC_REQ == messageType)
11915 {
11916 //Tush-QoS: notify QoS module that reassoc happening
11917 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
11918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011919#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070011922 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070011923}
11924
Jeff Johnson295189b2012-06-20 16:38:30 -070011925//
11926eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
11927{
11928 eHalStatus status = eHAL_STATUS_SUCCESS;
11929 tSirSmeDisassocReq *pMsg;
11930 tANI_U8 *pBuf;
11931 tANI_U16 wTmp;
11932#ifdef WLAN_SOFTAP_FEATURE
11933 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11934 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
11935 return eHAL_STATUS_FAILURE;
11936#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011937 do {
11938 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
11939 if ( !HAL_STATUS_SUCCESS(status) ) break;
11940 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
11941 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
11942 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 pBuf = &pMsg->sessionId;
11944 // sessionId
11945 *pBuf++ = (tANI_U8)sessionId;
11946 // transactionId
11947 *pBuf = 0;
11948 *( pBuf + 1 ) = 0;
11949 pBuf += sizeof(tANI_U16);
11950
11951#ifdef WLAN_SOFTAP_FEATURE
11952 if ( (pSession->pCurRoamProfile != NULL ) &&
11953 ( reasonCode == eSIR_MAC_UNSPEC_FAILURE_REASON ) &&
11954 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) || (CSR_IS_WDS_AP(pSession->pCurRoamProfile))))
11955 {
11956 // Set the bssid address before sending the message to LIM
11957 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
11958 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070011959 // Set the peer MAC address before sending the message to LIM
11960 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
11961 pBuf = pBuf + sizeof ( tSirMacAddr );
11962 }
11963 else
11964 {
11965#endif
11966 // Set the peer MAC address before sending the message to LIM
11967 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
11968 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070011969 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
11970 pBuf = pBuf + sizeof ( tSirMacAddr );
11971#ifdef WLAN_SOFTAP_FEATURE
11972 }
11973#endif
11974 if(!HAL_STATUS_SUCCESS(status))
11975 {
11976 palFreeMemory(pMac->hHdd, pMsg);
11977 break;
11978 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 // reasonCode
11980 wTmp = pal_cpu_to_be16(reasonCode);
11981 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11982 if(!HAL_STATUS_SUCCESS(status))
11983 {
11984 palFreeMemory(pMac->hHdd, pMsg);
11985 break;
11986 }
11987 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
11989 Here we should not send the disassoc over the air to the AP */
11990 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
11991#ifdef WLAN_FEATURE_VOWIFI_11R
11992 && csrRoamIs11rAssoc(pMac)
11993#endif
11994 )
11995 {
11996 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
11997 }
11998 pBuf += sizeof(tANI_U8);
11999 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012000 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 return( status );
12002}
Jeff Johnson295189b2012-06-20 16:38:30 -070012003#ifdef WLAN_SOFTAP_FEATURE
12004eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12005{
12006 eHalStatus status = eHAL_STATUS_SUCCESS;
12007 tSirSmeTkipCntrMeasReq *pMsg;
12008 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 do
12010 {
12011 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12012 if ( !HAL_STATUS_SUCCESS(status) ) break;
12013 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12014 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12015 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012016 pBuf = &pMsg->sessionId;
12017 // sessionId
12018 *pBuf++ = (tANI_U8)sessionId;
12019 // transactionId
12020 *pBuf = 0;
12021 *( pBuf + 1 ) = 0;
12022 pBuf += sizeof(tANI_U16);
12023 // bssid
12024 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12025 pBuf = pBuf + sizeof ( tSirMacAddr );
12026 // bEnable
12027 *pBuf = (tANI_BOOLEAN)bEnable;
12028 if(!HAL_STATUS_SUCCESS(status))
12029 {
12030 palFreeMemory(pMac->hHdd, pMsg);
12031 break;
12032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012033 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 return( status );
12036}
Jeff Johnson295189b2012-06-20 16:38:30 -070012037eHalStatus
12038csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12039 VOS_MODULE_ID modId, tSirMacAddr bssId,
12040 void *pUsrContext, void *pfnSapEventCallback,
12041 tANI_U8 *pAssocStasBuf )
12042{
12043 eHalStatus status = eHAL_STATUS_SUCCESS;
12044 tSirSmeGetAssocSTAsReq *pMsg;
12045 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12046 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 do
12048 {
12049 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12050 if (!HAL_STATUS_SUCCESS(status)) break;
12051 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12052 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 pBuf = (tANI_U8 *)&pMsg->bssId;
12054 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 // bssId
12056 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12057 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 // modId
12059 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12060 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12061 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 // pUsrContext
12063 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12064 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12065 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 // pfnSapEventCallback
12067 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12068 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12069 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 // pAssocStasBuf
12071 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12072 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12073 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 status = palSendMBMessage( pMac->hHdd, pMsg );
12076 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 return( status );
12078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012079eHalStatus
12080csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12081 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12082 {
12083 eHalStatus status = eHAL_STATUS_SUCCESS;
12084 tSirSmeGetWPSPBCSessionsReq *pMsg;
12085 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12086 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 do
12088 {
12089 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12090 if (!HAL_STATUS_SUCCESS(status)) break;
12091 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12092 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12094 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012095 // pUsrContext
12096 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12097 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12098 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 // pSapEventCallback
12100 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12101 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12102 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 // bssId
12104 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12105 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 // MAC Address of STA in WPS session
12107 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12108 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 return( status );
12113}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012114
12115eHalStatus
12116csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12117{
12118 tpSirChangeBIParams pMsg;
12119 tANI_U16 len = 0;
12120 eHalStatus status = eHAL_STATUS_SUCCESS;
12121 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12122
12123 if(!pSession)
12124 {
12125 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12126 return eHAL_STATUS_FAILURE;
12127 }
12128
12129 //NO need to update the Beacon Params if update beacon parameter flag is not set
12130 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12131 return eHAL_STATUS_SUCCESS;
12132
12133 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12134
12135 /* Create the message and send to lim */
12136 len = sizeof(tSirChangeBIParams);
12137 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12138 if(HAL_STATUS_SUCCESS(status))
12139 {
12140 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12141 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12142 pMsg->length = len;
12143
12144 // bssId
12145 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
12146 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
12147 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12148 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12149 pMsg->sessionId = sessionId;
12150 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d\n"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
12151 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12152 status = palSendMBMessage(pMac->hHdd, pMsg);
12153 }
12154 return status;
12155}
12156
Jeff Johnson295189b2012-06-20 16:38:30 -070012157#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012158eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12159{
12160 eHalStatus status = eHAL_STATUS_SUCCESS;
12161 tSirSmeDeauthReq *pMsg;
12162 tANI_U8 *pBuf;
12163 tANI_U16 wTmp;
12164 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12165 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12166 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 do {
12168 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12169 if ( !HAL_STATUS_SUCCESS(status) ) break;
12170 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12171 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12172 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12173 //sessionId
12174 pBuf = &pMsg->sessionId;
12175 *pBuf++ = (tANI_U8)sessionId;
12176
12177 //tansactionId
12178 *pBuf = 0;
12179 *(pBuf + 1 ) = 0;
12180 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012181 if ((pSession->pCurRoamProfile != NULL) && (
12182#ifdef WLAN_SOFTAP_FEATURE
12183 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12184#endif
12185 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12186 // Set the BSSID before sending the message to LIM
12187 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12188 pBuf = pBuf + sizeof(tSirMacAddr);
12189 }
12190 else
12191 {
12192 // Set the BSSID before sending the message to LIM
12193 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12194 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 }
12196 if(!HAL_STATUS_SUCCESS(status))
12197 {
12198 palFreeMemory(pMac->hHdd, pMsg);
12199 break;
12200 }
12201 // Set the peer MAC address before sending the message to LIM
12202 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12203 pBuf = pBuf + sizeof(tSirMacAddr);
12204 if(!HAL_STATUS_SUCCESS(status))
12205 {
12206 palFreeMemory(pMac->hHdd, pMsg);
12207 break;
12208 }
12209 wTmp = pal_cpu_to_be16(reasonCode);
12210 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12211 if(!HAL_STATUS_SUCCESS(status))
12212 {
12213 palFreeMemory(pMac->hHdd, pMsg);
12214 break;
12215 }
12216 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 return( status );
12219}
12220
Jeff Johnson295189b2012-06-20 16:38:30 -070012221eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12222{
12223 eHalStatus status = eHAL_STATUS_SUCCESS;
12224 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 do {
12226 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12227 if ( !HAL_STATUS_SUCCESS(status) ) break;
12228 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12229 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12230 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12231 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12232 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12233 if(!HAL_STATUS_SUCCESS(status))
12234 {
12235 palFreeMemory(pMac->hHdd, pMsg);
12236 break;
12237 }
12238//To test reconn
12239 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12240 if(!HAL_STATUS_SUCCESS(status))
12241 {
12242 palFreeMemory(pMac->hHdd, pMsg);
12243 break;
12244 }
12245//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 return( status );
12249}
12250
Jeff Johnson295189b2012-06-20 16:38:30 -070012251eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12252{
12253 eHalStatus status = eHAL_STATUS_SUCCESS;
12254 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012255 do {
12256 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12257 if ( !HAL_STATUS_SUCCESS(status) ) break;
12258 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12259 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12260 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12261 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12262 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12263 if(!HAL_STATUS_SUCCESS(status))
12264 {
12265 palFreeMemory(pMac->hHdd, pMsg);
12266 break;
12267 }
12268 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12269 if(!HAL_STATUS_SUCCESS(status))
12270 {
12271 palFreeMemory(pMac->hHdd, pMsg);
12272 break;
12273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 return( status );
12277}
Jeff Johnson295189b2012-06-20 16:38:30 -070012278eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12279{
12280 eHalStatus status = eHAL_STATUS_SUCCESS;
12281 tSirSmeAssocCnf *pMsg;
12282 tANI_U8 *pBuf;
12283 tSirResultCodes statusCode;
12284 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 do {
12286 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12287 if ( !HAL_STATUS_SUCCESS(status) ) break;
12288 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12289 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12290 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 pBuf = (tANI_U8 *)&pMsg->statusCode;
12292 if(HAL_STATUS_SUCCESS(Halstatus))
12293 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12294 else
12295 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12296 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12297 pBuf += sizeof(tSirResultCodes);
12298 // bssId
12299 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12300 pBuf += sizeof (tSirMacAddr);
12301 // peerMacAddr
12302 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12303 pBuf += sizeof (tSirMacAddr);
12304 // aid
12305 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12306 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12307 pBuf += sizeof (tANI_U16);
12308 // alternateBssId
12309 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12310 pBuf += sizeof (tSirMacAddr);
12311 // alternateChannelId
12312 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 status = palSendMBMessage( pMac->hHdd, pMsg );
12314 if(!HAL_STATUS_SUCCESS(status))
12315 {
12316 //pMsg is freed by palSendMBMessage
12317 break;
12318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012319 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 return( status );
12321}
Jeff Johnson295189b2012-06-20 16:38:30 -070012322#ifdef WLAN_SOFTAP_FEATURE
12323eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12324 tpSirSmeAssocInd pAssocInd,
12325 eHalStatus Halstatus,
12326 tANI_U8 sessionId)
12327{
12328 tSirMsgQ msgQ;
12329 eHalStatus status = eHAL_STATUS_SUCCESS;
12330 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12331 tANI_U8 *pBuf;
12332 tSirResultCodes statusCode;
12333 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 do {
12335 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12336 if ( !HAL_STATUS_SUCCESS(status) ) break;
12337 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012338
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12340 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12341
12342 pMsg->sessionId = sessionId;
12343
12344 pBuf = (tANI_U8 *)&pMsg->statusCode;
12345 if(HAL_STATUS_SUCCESS(Halstatus))
12346 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12347 else
12348 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12349 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12350 pBuf += sizeof(tSirResultCodes);
12351 // bssId
12352 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12353 pBuf += sizeof (tSirMacAddr);
12354 // peerMacAddr
12355 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12356 pBuf += sizeof (tSirMacAddr);
12357 // StaId
12358 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12359 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12360 pBuf += sizeof (tANI_U16);
12361 // alternateBssId
12362 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12363 pBuf += sizeof (tSirMacAddr);
12364 // alternateChannelId
12365 *pBuf = 11;
12366 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12368 //Wmm
12369 *pBuf = pAssocInd->wmmEnabledSta;
12370 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012371 //RSN IE
12372 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12373 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 //Additional IE
12375 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12376 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 //reassocReq
12378 *pBuf = pAssocInd->reassocReq;
12379 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12381 msgQ.bodyptr = pMsg;
12382 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 return( status );
12386}
12387#endif
12388
Jeff Johnson295189b2012-06-20 16:38:30 -070012389eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12390 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12391 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12392 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12393 tANI_U8 *pKeyRsc )
12394{
12395 tSirSmeSetContextReq *pMsg;
12396 tANI_U16 msgLen;
12397 eHalStatus status = eHAL_STATUS_FAILURE;
12398 tAniEdType tmpEdType;
12399 tAniKeyDirection tmpDirection;
12400 tANI_U8 *pBuf;
12401 tANI_U8 *p;
12402 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12406 // key set. Since we only support upto one key, we always allocate memory for 1 key
12407 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12408 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12409 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12410 ( sizeof( pMsg->keyMaterial.key ) );
12411
12412 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12413 if ( !HAL_STATUS_SUCCESS(status) ) break;
12414 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12415 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12416 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 //sessionId
12418 pBuf = &pMsg->sessionId;
12419 *pBuf = (tANI_U8)sessionId;
12420 pBuf++;
12421 // transactionId
12422 *pBuf = 0;
12423 *(pBuf + 1) = 0;
12424 pBuf += sizeof(tANI_U16);
12425 // peerMacAddr
12426 palCopyMemory( pMac->hHdd, pBuf,
12427 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12428
12429 pBuf += sizeof(tSirMacAddr);
12430
12431 // bssId
12432 palCopyMemory( pMac->hHdd, pBuf,
12433 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12434
12435 pBuf += sizeof(tSirMacAddr);
12436
12437 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12439 // in the tSirKeyMaterial keyMaterial; field).
12440 //
12441 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12442 // shorter than this max size. Is LIM interpreting this ok ?
12443 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 -070012444 // set pMsg->keyMaterial.edType
12445 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12446 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12447 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 // set the pMsg->keyMaterial.numKeys field
12449 *p = numKeys;
12450 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 // set pSirKey->keyId = keyId;
12452 *p = keyId;
12453 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 // set pSirKey->unicast = (tANI_U8)fUnicast;
12455 *p = (tANI_U8)fUnicast;
12456 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 // set pSirKey->keyDirection = aniKeyDirection;
12458 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12459 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12460 p += sizeof(tAniKeyDirection);
12461 // pSirKey->keyRsc = ;;
12462 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12463 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 // set pSirKey->paeRole
12465 *p = paeRole; // 0 is Supplicant
12466 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 // set pSirKey->keyLength = keyLength;
12468 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 if ( keyLength && pKey )
12470 {
12471 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12472 if(keyLength == 16)
12473 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012474 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 -070012475 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12476 pKey[5], pKey[6], pKey[7], pKey[8],
12477 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12478 }
12479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012481 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 return( status );
12483}
12484
Jeff Johnson295189b2012-06-20 16:38:30 -070012485eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12486 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12487{
12488 eHalStatus status;
12489 tSirSmeStartBssReq *pMsg;
12490 tANI_U8 *pBuf = NULL;
12491 tANI_U8 *wTmpBuf = NULL;
12492 tANI_U16 msgLen, wTmp;
12493 tANI_U32 dwTmp;
12494 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012495 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012496#ifdef WLAN_SOFTAP_FEATURE
12497 tANI_U32 authType;
12498#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012500
12501 if(!pSession)
12502 {
12503 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12504 return eHAL_STATUS_FAILURE;
12505 }
12506
Jeff Johnson295189b2012-06-20 16:38:30 -070012507 do {
12508 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12509 pSession->joinFailStatusCode.reasonCode = 0;
12510 msgLen = sizeof(tSirSmeStartBssReq);
12511 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12512 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12514 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 //sessionId
12518 *pBuf = (tANI_U8)sessionId;
12519 pBuf++;
12520 // transactionId
12521 *pBuf = 0;
12522 *(pBuf + 1) = 0;
12523 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 // bssid
12525 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12526 pBuf += sizeof(tSirMacAddr);
12527 // selfMacAddr
12528 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12529 pBuf += sizeof(tSirMacAddr);
12530 // beaconInterval
12531 if( pBssDesc && pBssDesc->beaconInterval )
12532 {
12533 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12534 }
12535#ifdef WLAN_SOFTAP_FEATURE
12536 else if(pParam->beaconInterval)
12537 {
12538 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12539 }
12540#endif
12541 else
12542 {
12543 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12544 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012545 if(csrIsconcurrentsessionValid (pMac, sessionId,
12546 pParam->bssPersona)
12547 == eHAL_STATUS_SUCCESS )
12548 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012549 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012550 pParam->bssPersona);
12551 //Update the beacon Interval
12552 pParam->beaconInterval = wTmp;
12553 }
12554 else
12555 {
12556 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***\n"));
12557 status = eHAL_STATUS_FAILURE;
12558 return status;
12559 }
12560
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12562 pBuf += sizeof(tANI_U16);
12563 // dot11mode
12564 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12565 pBuf += 1;
12566 // bssType
12567 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12568 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12569 pBuf += sizeof(tSirBssType);
12570 // ssId
12571 if( pParam->ssId.length )
12572 {
12573 // ssId len
12574 *pBuf = pParam->ssId.length;
12575 pBuf++;
12576 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12577 pBuf += pParam->ssId.length;
12578 }
12579 else
12580 {
12581 *pBuf = 0;
12582 pBuf++;
12583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 // set the channel Id
12585 *pBuf = pParam->operationChn;
12586 pBuf++;
12587 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012588 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12589 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12590 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012591
12592#ifdef WLAN_SOFTAP_FEATURE
12593 // Set privacy
12594 *pBuf = pParam->privacy;
12595 pBuf++;
12596
12597 //Set Uapsd
12598 *pBuf = pParam->ApUapsdEnable;
12599 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 //Set SSID hidden
12601 *pBuf = pParam->ssidHidden;
12602 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12604 pBuf++;
12605
12606 //Ht protection Enable/Disable
12607 *pBuf = (tANI_U8)pParam->protEnabled;
12608 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 //Enable Beacons to Receive for OBSS protection Enable/Disable
12610 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12611 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012612 //set cfg related to protection
12613 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12614 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12615 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 // Set Auth type
12617 authType = pal_cpu_to_be32(pParam->authType);
12618 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12619 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 // Set DTIM
12621 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12622 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12623 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 // Set wps_state
12625 *pBuf = pParam->wps_state;
12626 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012627#endif
12628 //Persona
12629 *pBuf = (tANI_U8)pParam->bssPersona;
12630 pBuf++;
12631
Gopichand Nakkalab7ed0a62013-01-04 11:41:02 -080012632 //txLdpcIniFeatureEnabled
12633 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12634 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012635
Jeff Johnson295189b2012-06-20 16:38:30 -070012636
12637 // set RSN IE
12638 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12639 {
12640 status = eHAL_STATUS_INVALID_PARAMETER;
12641 palFreeMemory( pMac->hHdd, pMsg );
12642 break;
12643 }
12644 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12645 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12646 pBuf += sizeof(tANI_U16);
12647 if( wTmp )
12648 {
12649 wTmp = pParam->nRSNIELength;
12650 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12651 pBuf += wTmp;
12652 }
12653 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12654 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12655 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12657 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12659 pBuf += pParam->operationalRateSet.numRates ;
12660 *pBuf++ = pParam->extendedRateSet.numRates;
12661 if(0 != pParam->extendedRateSet.numRates)
12662 {
12663 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12664 pBuf += pParam->extendedRateSet.numRates;
12665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12667 pMsg->length = pal_cpu_to_be16(msgLen);
12668
12669 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 return( status );
12672}
12673
Jeff Johnson295189b2012-06-20 16:38:30 -070012674eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12675{
12676 eHalStatus status = eHAL_STATUS_FAILURE;
12677 tSirSmeStopBssReq *pMsg;
12678 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12679 tANI_U8 *pBuf;
12680 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012681
12682 if(!pSession)
12683 {
12684 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12685 return eHAL_STATUS_FAILURE;
12686 }
12687
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 do {
12689 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12690 if ( !HAL_STATUS_SUCCESS(status) ) break;
12691 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12692 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12693 pBuf = &pMsg->sessionId;
12694 //sessionId
12695 *pBuf = (tANI_U8)sessionId;
12696 pBuf++;
12697 // transactionId
12698 *pBuf = 0;
12699 pBuf += sizeof(tANI_U16);
12700 //reason code
12701 *pBuf = 0;
12702 pBuf += sizeof(tSirResultCodes);
12703 // bssid
12704 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12705 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12706 {
12707 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12708 }
12709 else
12710 {
12711 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12712 }
12713 pBuf += sizeof(tSirMacAddr);
12714 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12715 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 status = palSendMBMessage( pMac->hHdd, pMsg );
12717#if 0
12718 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12719 if ( !HAL_STATUS_SUCCESS(status) ) break;
12720 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12721 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12722 pMsg->reasonCode = 0;
12723 // bssid
12724 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12725 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12726 {
12727 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12728 }
12729 else
12730 {
12731 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12732 }
12733 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12734 pMsg->transactionId = 0;
12735 pMsg->sessionId = (tANI_U8)sessionId;
12736 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12737 status = palSendMBMessage( pMac->hHdd, pMsg );
12738#endif
12739 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 return( status );
12741}
12742
Jeff Johnson295189b2012-06-20 16:38:30 -070012743eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12744 tCsrRoamModifyProfileFields *pModProfileFields,
12745 tANI_U32 *pRoamId, v_BOOL_t fForce)
12746{
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 eHalStatus status = eHAL_STATUS_FAILURE;
12748 tANI_U32 roamId = 0;
12749 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 if((csrIsConnStateConnected(pMac, sessionId)) &&
12751 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12752 &pSession->connectedProfile.modifyProfileFields,
12753 sizeof(tCsrRoamModifyProfileFields)))) )
12754 {
12755 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12756 if(pRoamId)
12757 {
12758 *pRoamId = roamId;
12759 }
12760
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12762 eCsrSmeIssuedReassocToSameAP, roamId,
12763 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 return status;
12766}
Jeff Johnson295189b2012-06-20 16:38:30 -070012767static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12768{
12769 eHalStatus status = eHAL_STATUS_SUCCESS;
12770 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12772 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12773 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12774 return (status);
12775}
Jeff Johnson295189b2012-06-20 16:38:30 -070012776eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12777{
12778 eHalStatus status = eHAL_STATUS_SUCCESS;
12779 tListElem *pEntry = NULL;
12780 tSmeCmd *pCommand = NULL;
12781 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 do
12783 {
12784 if(pMsg == NULL)
12785 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012786 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 status = eHAL_STATUS_FAILURE;
12788 break;
12789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12791 if(pEntry)
12792 {
12793 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12794 if(eSmeCommandAddStaSession == pCommand->command)
12795 {
12796 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
12797 smsLog( pMac, LOG1, "Add Sta rsp status = %d\n", pRsp->status );
12798 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 //Remove this command out of the active list
12801 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12802 {
12803 //Now put this command back on the avilable command list
12804 csrReleaseCommand(pMac, pCommand);
12805 }
12806 smeProcessPendingQueue( pMac );
12807 }
12808 else
12809 {
12810 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 -070012811 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 status = eHAL_STATUS_FAILURE;
12813 break;
12814 }
12815 }
12816 else
12817 {
12818 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 -070012819 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 status = eHAL_STATUS_FAILURE;
12821 break;
12822 }
12823 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012825}
Jeff Johnson295189b2012-06-20 16:38:30 -070012826eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12827{
12828 tSirSmeAddStaSelfReq *pMsg;
12829 tANI_U16 msgLen;
12830 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12833 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12835 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12838 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012839 // self station address
12840 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012841 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 pMsg->selfMacAddr[0],
12843 pMsg->selfMacAddr[1],
12844 pMsg->selfMacAddr[2],
12845 pMsg->selfMacAddr[3],
12846 pMsg->selfMacAddr[4],
12847 pMsg->selfMacAddr[5]);
12848 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 return( status );
12851}
Jeff Johnson295189b2012-06-20 16:38:30 -070012852eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12853{
12854 eHalStatus status = eHAL_STATUS_SUCCESS;
12855 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012856 pCommand = csrGetCommandBuffer(pMac);
12857 if(NULL == pCommand)
12858 {
12859 status = eHAL_STATUS_RESOURCES;
12860 }
12861 else
12862 {
12863 pCommand->command = eSmeCommandAddStaSession;
12864 pCommand->sessionId = (tANI_U8)sessionId;
12865 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12867 if( !HAL_STATUS_SUCCESS( status ) )
12868 {
12869 //Should be panic??
12870 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12871 }
12872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 return (status);
12874}
Jeff Johnson295189b2012-06-20 16:38:30 -070012875eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12876{
12877 return csrSendMBAddSelfStaReqMsg( pMac,
12878 pCommand->u.addStaSessionCmd.selfMacAddr );
12879}
Jeff Johnson295189b2012-06-20 16:38:30 -070012880eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12881 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12882{
12883 eHalStatus status = eHAL_STATUS_SUCCESS;
12884 tANI_U32 i;
12885 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 *pbSessionId = CSR_SESSION_ID_INVALID;
12887 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
12888 {
12889 if( !CSR_IS_SESSION_VALID( pMac, i ) )
12890 {
12891 pSession = CSR_GET_SESSION( pMac, i );
12892 status = eHAL_STATUS_SUCCESS;
12893 pSession->sessionActive = eANI_BOOLEAN_TRUE;
12894 pSession->sessionId = (tANI_U8)i;
12895 pSession->callback = callback;
12896 pSession->pContext = pContext;
12897 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
12898 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
12900 &pSession->roamingTimerInfo);
12901 if(!HAL_STATUS_SUCCESS(status))
12902 {
12903 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer\n"));
12904 break;
12905 }
12906#ifdef FEATURE_WLAN_BTAMP_UT_RF
12907 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
12908 &pSession->joinRetryTimerInfo);
12909 if(!HAL_STATUS_SUCCESS(status))
12910 {
12911 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer\n"));
12912 break;
12913 }
12914#endif
12915 pSession->ibssJoinTimerInfo.pMac = pMac;
12916 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
12918 &pSession->ibssJoinTimerInfo);
12919 if(!HAL_STATUS_SUCCESS(status))
12920 {
12921 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer\n"));
12922 break;
12923 }
12924 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
12925 break;
12926 }
12927 }
12928 if( CSR_ROAM_SESSION_MAX == i )
12929 {
12930 //No session is available
12931 status = eHAL_STATUS_RESOURCES;
12932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 return ( status );
12934}
Jeff Johnson295189b2012-06-20 16:38:30 -070012935eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12936{
12937 eHalStatus status = eHAL_STATUS_SUCCESS;
12938 tListElem *pEntry = NULL;
12939 tSmeCmd *pCommand = NULL;
12940 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012941 do
12942 {
12943 if(pMsg == NULL)
12944 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012945 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 status = eHAL_STATUS_FAILURE;
12947 break;
12948 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12950 if(pEntry)
12951 {
12952 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12953 if(eSmeCommandDelStaSession == pCommand->command)
12954 {
12955 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
12957 smsLog( pMac, LOG1, "Del Sta rsp status = %d\n", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 //This session is done.
12959 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 if(pCommand->u.delStaSessionCmd.callback)
12961 {
12962
12963 status = sme_ReleaseGlobalLock( &pMac->sme );
12964 if ( HAL_STATUS_SUCCESS( status ) )
12965 {
12966 pCommand->u.delStaSessionCmd.callback(
12967 pCommand->u.delStaSessionCmd.pContext);
12968 status = sme_AcquireGlobalLock( &pMac->sme );
12969 if (! HAL_STATUS_SUCCESS( status ) )
12970 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012971 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 return status;
12973 }
12974 }
12975 else {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012976 smsLog(pMac, LOGE, "%s: Failed to Release Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 }
12978 }
12979
12980 //Remove this command out of the active list
12981 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12982 {
12983 //Now put this command back on the avilable command list
12984 csrReleaseCommand(pMac, pCommand);
12985 }
12986 smeProcessPendingQueue( pMac );
12987 }
12988 else
12989 {
12990 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 -070012991 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 status = eHAL_STATUS_FAILURE;
12993 break;
12994 }
12995 }
12996 else
12997 {
12998 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 -070012999 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 status = eHAL_STATUS_FAILURE;
13001 break;
13002 }
13003 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013005}
Jeff Johnson295189b2012-06-20 16:38:30 -070013006eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13007{
13008 tSirSmeDelStaSelfReq *pMsg;
13009 tANI_U16 msgLen;
13010 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13013 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13015 if ( !HAL_STATUS_SUCCESS(status) ) break;
13016
13017 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13019 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013020 // self station address
13021 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013022 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 return( status );
13025}
Jeff Johnson295189b2012-06-20 16:38:30 -070013026eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13027 tSirMacAddr sessionMacAddr,
13028 csrRoamSessionCloseCallback callback,
13029 void *pContext)
13030{
13031 eHalStatus status = eHAL_STATUS_SUCCESS;
13032 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 pCommand = csrGetCommandBuffer(pMac);
13034 if(NULL == pCommand)
13035 {
13036 status = eHAL_STATUS_RESOURCES;
13037 }
13038 else
13039 {
13040 pCommand->command = eSmeCommandDelStaSession;
13041 pCommand->sessionId = (tANI_U8)sessionId;
13042 pCommand->u.delStaSessionCmd.callback = callback;
13043 pCommand->u.delStaSessionCmd.pContext = pContext;
13044 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013045 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13046 if( !HAL_STATUS_SUCCESS( status ) )
13047 {
13048 //Should be panic??
13049 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
13050 }
13051 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 return (status);
13053}
Jeff Johnson295189b2012-06-20 16:38:30 -070013054eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13055{
13056 return csrSendMBDelSelfStaReqMsg( pMac,
13057 pCommand->u.delStaSessionCmd.selfMacAddr );
13058}
Jeff Johnson295189b2012-06-20 16:38:30 -070013059static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13060{
13061 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13062 tListElem *pEntry, *pNext;
13063 tSmeCmd *pCommand;
13064 tDblLinkList localList;
13065
13066 vos_mem_zero(&localList, sizeof(tDblLinkList));
13067 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13068 {
13069 smsLog(pMac, LOGE, FL(" failed to open list"));
13070 return;
13071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 csrLLLock(pList);
13073 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13074 while(pEntry != NULL)
13075 {
13076 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13077 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13078 if(pCommand->sessionId == sessionId)
13079 {
13080 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13081 {
13082 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13083 }
13084 }
13085 pEntry = pNext;
13086 }
13087 csrLLUnlock(pList);
13088
13089 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13090 {
13091 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13092 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13093 }
13094 csrLLClose(&localList);
13095}
13096
Jeff Johnson295189b2012-06-20 16:38:30 -070013097void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13098{
13099 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13100 {
13101 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 csrRoamStop(pMac, sessionId);
13103 csrFreeConnectBssDesc(pMac, sessionId);
13104 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13105 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13106 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13107#ifdef FEATURE_WLAN_BTAMP_UT_RF
13108 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13109#endif
13110 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13111 purgeSmeSessionCmdList(pMac, sessionId);
13112 purgeCsrSessionCmdList(pMac, sessionId);
13113 csrInitSession(pMac, sessionId);
13114 }
13115}
13116
Jeff Johnson295189b2012-06-20 16:38:30 -070013117eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13118 tANI_BOOLEAN fSync,
13119 csrRoamSessionCloseCallback callback,
13120 void *pContext )
13121{
13122 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13124 {
13125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13126 if(fSync)
13127 {
13128 csrCleanupSession(pMac, sessionId);
13129 }
13130 else
13131 {
13132 purgeSmeSessionCmdList(pMac, sessionId);
13133 purgeCsrSessionCmdList(pMac, sessionId);
13134 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13135 pSession->selfMacAddr, callback, pContext);
13136 }
13137 }
13138 else
13139 {
13140 status = eHAL_STATUS_INVALID_PARAMETER;
13141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 return ( status );
13143}
13144
Jeff Johnson295189b2012-06-20 16:38:30 -070013145static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13146{
13147 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013148
13149 if(!pSession)
13150 {
13151 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13152 return;
13153 }
13154
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13156 pSession->sessionId = CSR_SESSION_ID_INVALID;
13157 pSession->callback = NULL;
13158 pSession->pContext = NULL;
13159 pSession->ibss_join_pending = FALSE;
13160 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13161 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13162 csrFreeRoamProfile( pMac, sessionId );
13163 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13164 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13165 csrFreeConnectBssDesc(pMac, sessionId);
13166 csrScanEnable(pMac);
13167 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13168 if(pSession->pWpaRsnReqIE)
13169 {
13170 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13171 pSession->pWpaRsnReqIE = NULL;
13172 }
13173 pSession->nWpaRsnReqIeLength = 0;
13174 if(pSession->pWpaRsnRspIE)
13175 {
13176 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13177 pSession->pWpaRsnRspIE = NULL;
13178 }
13179 pSession->nWpaRsnRspIeLength = 0;
13180#ifdef FEATURE_WLAN_WAPI
13181 if(pSession->pWapiReqIE)
13182 {
13183 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13184 pSession->pWapiReqIE = NULL;
13185 }
13186 pSession->nWapiReqIeLength = 0;
13187 if(pSession->pWapiRspIE)
13188 {
13189 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13190 pSession->pWapiRspIE = NULL;
13191 }
13192 pSession->nWapiRspIeLength = 0;
13193#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 if(pSession->pAddIEScan)
13195 {
13196 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13197 pSession->pAddIEScan = NULL;
13198 }
13199 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 if(pSession->pAddIEAssoc)
13201 {
13202 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13203 pSession->pAddIEAssoc = NULL;
13204}
13205 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013206}
13207
Jeff Johnson295189b2012-06-20 16:38:30 -070013208eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13209{
13210 eHalStatus status = eHAL_STATUS_FAILURE;
13211 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13213 {
13214 if( CSR_IS_SESSION_VALID( pMac, i ) )
13215 {
13216 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13217 {
13218 //Found it
13219 status = eHAL_STATUS_SUCCESS;
13220 *pSessionId = i;
13221 break;
13222 }
13223 }
13224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 return( status );
13226}
13227
Jeff Johnson295189b2012-06-20 16:38:30 -070013228//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13229//session because for IBSS, the bssid changes.
13230static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13231{
13232 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13233 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13235 {
13236 if( CSR_IS_SESSION_VALID( pMac, i ) )
13237 {
13238 pSession = CSR_GET_SESSION( pMac, i );
13239 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13240 {
13241 //Found it
13242 nRet = i;
13243 break;
13244 }
13245 }
13246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 return (nRet);
13248}
Jeff Johnson295189b2012-06-20 16:38:30 -070013249static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13250{
13251 /* Update the current BSS info in ho control block based on connected
13252 profile info from pmac global structure */
13253
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x\n",
13255 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13256 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 /* Check for user misconfig of RSSI trigger threshold */
13258 pMac->roam.configParam.vccRssiThreshold =
13259 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13260 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13261 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 /* Check for user misconfig of UL MAC Loss trigger threshold */
13263 pMac->roam.configParam.vccUlMacLossThreshold =
13264 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13265 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13267 {
13268 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 /* Indicate the neighbor roal algorithm about the connect indication */
13270 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13271 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13272 }
13273#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013274}
13275
Jeff Johnson295189b2012-06-20 16:38:30 -070013276static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13277{
13278 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013279
13280 if(!pSession)
13281 {
13282 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13283 return;
13284 }
13285
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 //Only to handle the case for Handover on infra link
13287 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13288 {
13289 return;
13290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13292 csrRoamDeregStatisticsReq(pMac);
13293 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13294#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13295 /* Indicate the neighbor roal algorithm about the disconnect indication */
13296 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13297#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013298
13299 //Remove this code once SLM_Sessionization is supported
13300 //BMPS_WORKAROUND_NOT_NEEDED
13301 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013302 csrIsInfraApStarted( pMac ) &&
13303 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013304 {
13305 pMac->roam.configParam.doBMPSWorkaround = 0;
13306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013307}
13308
Jeff Johnson295189b2012-06-20 16:38:30 -070013309void csrRoamTlStatsTimerHandler(void *pv)
13310{
13311 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13312 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13314
Jeff Johnsone7245742012-09-05 17:12:55 -070013315 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13316
Jeff Johnson295189b2012-06-20 16:38:30 -070013317#if 0
13318 // TODO Persession .???
13319 //req TL for stats
13320 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13321 {
13322 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL\n"));
13323 }
13324 else
13325 {
13326 //save in SME
13327 csrRoamSaveStatsFromTl(pMac, tlStats);
13328 }
13329#endif
13330 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13331 {
13332 if(pMac->roam.tlStatsReqInfo.periodicity)
13333 {
13334 //start timer
13335 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13336 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13337 if(!HAL_STATUS_SUCCESS(status))
13338 {
13339 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer\n"));
13340 return;
13341 }
13342 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13343 }
13344 }
13345}
Jeff Johnson295189b2012-06-20 16:38:30 -070013346void csrRoamPeStatsTimerHandler(void *pv)
13347{
13348 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13349 eHalStatus status;
13350 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13351 VOS_STATUS vosStatus;
13352 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 pPeStatsReqListEntry->timerRunning = FALSE;
13354 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13355 {
13356 // If we entered here, meaning the timer could not be successfully
13357 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13358
13359 /* Destroy the timer */
13360 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13361 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13362 {
13363 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer\n"));
13364 }
13365
13366 // Free the entry
13367 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13368 pPeStatsReqListEntry = NULL;
13369 }
13370 else
13371 {
13372 if(!pPeStatsReqListEntry->rspPending)
13373 {
13374 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13375 pPeStatsReqListEntry->staId);
13376 if(!HAL_STATUS_SUCCESS(status))
13377 {
13378 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE\n"));
13379 }
13380 else
13381 {
13382 pPeStatsReqListEntry->rspPending = TRUE;
13383 }
13384 }
13385
13386 //send down a req
13387 if(pPeStatsReqListEntry->periodicity &&
13388 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13389 {
13390 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13391 if(ePMC_FULL_POWER == powerState)
13392 {
13393 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13394 {
13395 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13396 }
13397 }
13398 else
13399 {
13400 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13401 {
13402 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13403 }
13404 }
13405 //start timer
13406 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13407 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13408 {
13409 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer\n"));
13410 return;
13411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 pPeStatsReqListEntry->timerRunning = TRUE;
13413
13414 }
13415
13416 }
13417}
Jeff Johnson295189b2012-06-20 16:38:30 -070013418void csrRoamStatsClientTimerHandler(void *pv)
13419{
13420 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013421 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13422 {
13423#if 0
13424 // TODO Stats fix for multisession
13425 //start the timer
13426 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13427
13428 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13429 {
13430 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 }
13432#endif
13433 }
13434#if 0
13435 //send up the stats report
13436 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13437 pStaEntry->staId, pStaEntry->pContext);
13438#endif
13439}
13440
13441
13442
Jeff Johnson295189b2012-06-20 16:38:30 -070013443eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13444{
13445 tAniGetPEStatsReq *pMsg;
13446 eHalStatus status = eHAL_STATUS_SUCCESS;
13447 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13448 if ( !HAL_STATUS_SUCCESS(status) )
13449 {
13450 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req \n");
13451 return status;
13452 }
13453 // need to initiate a stats request to PE
13454 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13455 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13456 pMsg->staId = staId;
13457 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 if(!HAL_STATUS_SUCCESS(status))
13460 {
13461 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req \n");
13462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 return status;
13464}
Jeff Johnson295189b2012-06-20 16:38:30 -070013465void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13466{
13467 tAniGetPEStatsRsp *pSmeStatsRsp;
13468 eHalStatus status = eHAL_STATUS_FAILURE;
13469 tListElem *pEntry = NULL;
13470 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13471 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13472 tANI_U32 tempMask = 0;
13473 tANI_U8 counter = 0;
13474 tANI_U8 *pStats = NULL;
13475 tANI_U32 length = 0;
13476 v_PVOID_t pvosGCtx;
13477 v_S7_t rssi = 0;
13478 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13480 if(pSmeStatsRsp->rc)
13481 {
13482 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure\n"));
13483 goto post_update;
13484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 tempMask = pSmeStatsRsp->statsMask;
13486 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 /* subtract all statistics from this length, and after processing the entire
13488 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13489 * in this 'stats' message.
13490 */
13491 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 //new stats info from PE, fill up the stats strucutres in PMAC
13493 while(tempMask)
13494 {
13495 if(tempMask & 1)
13496 {
13497 switch(counter)
13498 {
13499 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013500 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13502 pStats, sizeof(tCsrSummaryStatsInfo));
13503 if(!HAL_STATUS_SUCCESS(status))
13504 {
13505 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats\n"));
13506 }
13507 pStats += sizeof(tCsrSummaryStatsInfo);
13508 length -= sizeof(tCsrSummaryStatsInfo);
13509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013511 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13513 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13514 if(!HAL_STATUS_SUCCESS(status))
13515 {
13516 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats\n"));
13517 }
13518 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13519 length -= sizeof(tCsrGlobalClassAStatsInfo);
13520 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013522 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13524 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13525 if(!HAL_STATUS_SUCCESS(status))
13526 {
13527 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats\n"));
13528 }
13529 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13530 length -= sizeof(tCsrGlobalClassBStatsInfo);
13531 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013533 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13535 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13536 if(!HAL_STATUS_SUCCESS(status))
13537 {
13538 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats\n"));
13539 }
13540 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13541 length -= sizeof(tCsrGlobalClassCStatsInfo);
13542 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013544 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13546 {
13547 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13548 pStats, sizeof(tCsrPerStaStatsInfo));
13549 }
13550 else
13551 {
13552 status = eHAL_STATUS_FAILURE;
13553 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d\n"), pSmeStatsRsp->staId);
13554 VOS_ASSERT( 0 );
13555 }
13556 if(!HAL_STATUS_SUCCESS(status))
13557 {
13558 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats\n"));
13559 }
13560 pStats += sizeof(tCsrPerStaStatsInfo);
13561 length -= sizeof(tCsrPerStaStatsInfo);
13562 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 default:
13564 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type\n"));
13565 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 }
13567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 tempMask >>=1;
13569 counter++;
13570 }
13571 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13572 if (length != 0)
13573 {
13574 pRssi = (tANI_U32*)pStats;
13575 rssi = (v_S7_t)*pRssi;
13576 }
13577 else
13578 {
13579 /* If riva is not sending rssi, continue to use the hack */
13580 rssi = RSSI_HACK_BMPS;
13581 }
13582 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013583post_update:
13584 //make sure to update the pe stats req list
13585 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13586 if(pEntry)
13587 {
13588 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13589 pPeStaEntry->rspPending = FALSE;
13590
13591 }
13592 //check the one timer cases
13593 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13594 if(pEntry)
13595 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 if(pTempStaEntry->timerExpired)
13598 {
13599 //send up the stats report
13600 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13601 pTempStaEntry->staId, pTempStaEntry->pContext);
13602 //also remove from the client list
13603 csrRoamRemoveStatListEntry(pMac, pEntry);
13604 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 }
13606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013607}
Jeff Johnson295189b2012-06-20 16:38:30 -070013608tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13609{
13610 tListElem *pEntry = NULL;
13611 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 if(!pEntry)
13614 {
13615 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013616 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 return NULL;
13618 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 while( pEntry )
13620 {
13621 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 if(pTempStaEntry->statsMask == statsMask)
13623 {
Mohit Khanna23863762012-09-11 17:40:09 -070013624 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 break;
13626 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13628 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 return pEntry;
13630}
13631
Jeff Johnson295189b2012-06-20 16:38:30 -070013632tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13633 tANI_BOOLEAN update)
13634{
13635 tListElem *pEntry;
13636 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 if(!pEntry)
13639 {
13640 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013641 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 "upper layer client(s)\n");
13643 return NULL;
13644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 while( pEntry )
13646 {
13647 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13649 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13650 {
Mohit Khanna23863762012-09-11 17:40:09 -070013651 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 if(update)
13653 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013654 pTempStaEntry->periodicity = pStaEntry->periodicity;
13655 pTempStaEntry->callback = pStaEntry->callback;
13656 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 }
13658 break;
13659 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 return pEntry;
13663}
Jeff Johnson295189b2012-06-20 16:38:30 -070013664tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13665{
13666 tListElem *pEntry;
13667 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 if(!pEntry)
13670 {
13671 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013672 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 "upper layer client(s)\n");
13674 return NULL;
13675 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 while( pEntry )
13677 {
13678 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13680 {
Mohit Khanna23863762012-09-11 17:40:09 -070013681 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 break;
13683 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 return pEntry;
13687}
Jeff Johnson295189b2012-06-20 16:38:30 -070013688eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13689 csrRoamLinkQualityIndCallback callback,
13690 void *pContext)
13691{
13692 pMac->roam.linkQualityIndInfo.callback = callback;
13693 pMac->roam.linkQualityIndInfo.context = pContext;
13694 if( NULL == callback )
13695 {
13696 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13697 }
13698 else
13699 {
13700 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 /* do we need to invoke the callback to notify client of initial value ?? */
13702 }
13703 return eHAL_STATUS_SUCCESS;
13704}
Jeff Johnson295189b2012-06-20 16:38:30 -070013705void csrRoamVccTrigger(tpAniSirGlobal pMac)
13706{
13707 eCsrRoamLinkQualityInd newVccLinkQuality;
13708 tANI_U32 ul_mac_loss = 0;
13709 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13711 /*-------------------------------------------------------------------------
13712 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013713 Check for a change in link quality and notify client if necessary
13714 -------------------------------------------------------------------------*/
13715 ul_mac_loss_trigger_threshold =
13716 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d\n",
13719 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13721 {
13722 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR \n");
13723 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13724 }
13725 else
13726 {
13727 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD\n");
13728 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13731 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13733 {
13734 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary\n");
13735 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13736 {
13737 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d\n",
13738 newVccLinkQuality );
13739
13740 /* we now invoke the callback once to notify client of initial value */
13741 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13742 pMac->roam.linkQualityIndInfo.context );
13743 //event: EVENT_WLAN_VCC
13744 }
13745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013746 pMac->roam.vccLinkQuality = newVccLinkQuality;
13747
Jeff Johnson295189b2012-06-20 16:38:30 -070013748}
Jeff Johnson295189b2012-06-20 16:38:30 -070013749VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13750 v_U8_t rssiNotification,
13751 void * context)
13752{
13753 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13754 eCsrRoamLinkQualityInd newVccLinkQuality;
13755 // TODO : Session info unavailable
13756 tANI_U32 sessionId = 0;
13757 VOS_STATUS status = VOS_STATUS_SUCCESS;
13758 /*-------------------------------------------------------------------------
13759 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 Check for a change in link quality and notify client if necessary
13761 -------------------------------------------------------------------------*/
13762 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d\n",
13763 pMac->roam.configParam.vccRssiThreshold);
13764 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13765 {
13766 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected\n");
13767 return VOS_STATUS_SUCCESS;
13768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13770 {
13771 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR\n");
13772 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13773 }
13774 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13775 {
13776 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD \n");
13777 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13778 }
13779 else
13780 {
13781 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d\n", rssiNotification);
13782 //Set to this so the code below won't do anything
13783 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 VOS_ASSERT(0);
13785 }
13786
Jeff Johnson295189b2012-06-20 16:38:30 -070013787 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13788 {
13789 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary\n");
13790 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13791 {
13792 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d\n",
13793 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 /* we now invoke the callback once to notify client of initial value */
13795 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13796 pMac->roam.linkQualityIndInfo.context );
13797 //event: EVENT_WLAN_VCC
13798 }
13799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 return status;
13802}
Jeff Johnson295189b2012-06-20 16:38:30 -070013803tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13804 tDblLinkList *pStaList,
13805 tCsrStatsClientReqInfo *pStaEntry)
13806{
13807 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 //if same entity requested for same set of stats with different periodicity &
13810 // callback update it
13811 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13812 {
13813
13814 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13815 if (!HAL_STATUS_SUCCESS(status))
13816 {
13817 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
13818 "entry\n");
13819 return NULL;
13820 }
13821
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 pNewStaEntry->callback = pStaEntry->callback;
13823 pNewStaEntry->pContext = pStaEntry->pContext;
13824 pNewStaEntry->periodicity = pStaEntry->periodicity;
13825 pNewStaEntry->requesterId = pStaEntry->requesterId;
13826 pNewStaEntry->statsMask = pStaEntry->statsMask;
13827 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13828 pNewStaEntry->pMac = pStaEntry->pMac;
13829 pNewStaEntry->staId = pStaEntry->staId;
13830 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13831
13832 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13833 }
13834 return pNewStaEntry;
13835}
13836
Jeff Johnson295189b2012-06-20 16:38:30 -070013837tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13838 tDblLinkList *pStaList,
13839 tCsrPeStatsReqInfo *pStaEntry)
13840{
13841 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13844 if (!HAL_STATUS_SUCCESS(status))
13845 {
13846 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
13847 "entry\n");
13848 return NULL;
13849 }
13850
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13852 pNewStaEntry->numClient = pStaEntry->numClient;
13853 pNewStaEntry->periodicity = pStaEntry->periodicity;
13854 pNewStaEntry->statsMask = pStaEntry->statsMask;
13855 pNewStaEntry->pMac = pStaEntry->pMac;
13856 pNewStaEntry->staId = pStaEntry->staId;
13857 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13858 pNewStaEntry->rspPending = pStaEntry->rspPending;
13859
13860 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 return pNewStaEntry;
13862}
Jeff Johnson295189b2012-06-20 16:38:30 -070013863eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13864 tCsrRssiCallback callback,
13865 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13866{
13867 eHalStatus status = eHAL_STATUS_SUCCESS;
13868 vos_msg_t msg;
13869 tANI_U32 sessionId;
13870
13871 tAniGetRssiReq *pMsg;
13872 smsLog(pMac, LOG2, FL("called"));
13873 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13874 if ( !HAL_STATUS_SUCCESS(status) )
13875 {
13876 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req \n");
13877 return status;
13878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13880
13881 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13882 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13883 pMsg->sessionId = sessionId;
13884 pMsg->staId = staId;
13885 pMsg->rssiCallback = callback;
13886 pMsg->pDevContext = pContext;
13887 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 msg.type = eWNI_SME_GET_RSSI_REQ;
13889 msg.bodyptr = pMsg;
13890 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
13892 {
13893 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self \n");
13894 palFreeMemory(pMac->hHdd, (void *)pMsg);
13895 status = eHAL_STATUS_FAILURE;
13896 }
13897 smsLog(pMac, LOG2, FL("returned"));
13898 return status;
13899}
Jeff Johnson295189b2012-06-20 16:38:30 -070013900eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
13901 tANI_U32 statsMask,
13902 tCsrStatsCallback callback,
13903 tANI_U32 periodicity, tANI_BOOLEAN cache,
13904 tANI_U8 staId, void *pContext)
13905{
13906 tCsrStatsClientReqInfo staEntry;
13907 tCsrStatsClientReqInfo *pStaEntry = NULL;
13908 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13909 tListElem *pEntry = NULL;
13910 tANI_BOOLEAN found = FALSE;
13911 eHalStatus status = eHAL_STATUS_SUCCESS;
13912 tANI_BOOLEAN insertInClientList = FALSE;
13913 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070013914 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070013915
13916 if( csrIsAllSessionDisconnected(pMac) )
13917 {
13918 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected\n", pMac->roam.curState);
13919 return eHAL_STATUS_FAILURE;
13920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 if((!statsMask) && (!callback))
13922 {
13923 //msg
13924 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request\n");
13925 return eHAL_STATUS_FAILURE;
13926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 //for the search list method for deregister
13928 staEntry.requesterId = requesterId;
13929 staEntry.statsMask = statsMask;
13930 //requester wants to deregister or just an error
13931 if((statsMask) && (!callback))
13932 {
13933 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
13934 if(!pEntry)
13935 {
13936 //msg
13937 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
13938 "find any existing request in statsClientReqList\n");
13939 return eHAL_STATUS_FAILURE;
13940 }
13941 else
13942 {
13943 //clean up & return
13944 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070013945 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013947 pStaEntry->pPeStaEntry->numClient--;
13948 //check if we need to delete the entry from peStatsReqList too
13949 if(!pStaEntry->pPeStaEntry->numClient)
13950 {
13951 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
13952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070013954
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 //check if we need to stop the tl stats timer too
13956 pMac->roam.tlStatsReqInfo.numClient--;
13957 if(!pMac->roam.tlStatsReqInfo.numClient)
13958 {
13959 if(pMac->roam.tlStatsReqInfo.timerRunning)
13960 {
13961 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
13962 if(!HAL_STATUS_SUCCESS(status))
13963 {
13964 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer\n"));
13965 return eHAL_STATUS_FAILURE;
13966 }
13967 }
13968 pMac->roam.tlStatsReqInfo.periodicity = 0;
13969 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13970 }
13971 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 // Destroy the vos timer...
13973 vosStatus = vos_timer_destroy( &pStaEntry->timer );
13974 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13975 {
13976 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer\n"));
13977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 csrRoamRemoveStatListEntry(pMac, pEntry);
13979 pStaEntry = NULL;
13980 return eHAL_STATUS_SUCCESS;
13981 }
13982 }
13983
13984 if(cache && !periodicity)
13985 {
13986 //return the cached stats
13987 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
13988 }
13989 else
13990 {
13991 //add the request in the client req list
13992 staEntry.callback = callback;
13993 staEntry.pContext = pContext;
13994 staEntry.periodicity = periodicity;
13995 staEntry.pPeStaEntry = NULL;
13996 staEntry.staId = staId;
13997 staEntry.pMac = pMac;
13998 staEntry.timerExpired = FALSE;
13999
14000
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 //if periodic report requested with non cached result from PE/TL
14002 if(periodicity)
14003 {
14004
14005 //if looking for stats from PE
14006 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14007 {
14008
14009 //check if same request made already & waiting for rsp
14010 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14011 periodicity, &found, staId);
14012 if(!pPeStaEntry)
14013 {
14014 //bail out, maxed out on number of req for PE
14015 return eHAL_STATUS_FAILURE;
14016 }
14017 else
14018 {
14019 staEntry.pPeStaEntry = pPeStaEntry;
14020 }
14021
14022 }
14023 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14024 if(statsMask & (1 << eCsrGlobalClassDStats))
14025 {
14026 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14027 {
14028 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL\n"));
14029 }
14030 else
14031 {
14032
14033 //update periodicity
14034 if(pMac->roam.tlStatsReqInfo.periodicity)
14035 {
14036 pMac->roam.tlStatsReqInfo.periodicity =
14037 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14038 }
14039 else
14040 {
14041 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14042 }
14043 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14044 {
14045 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14046 }
14047
14048 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14049 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014050 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14051 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014053 //req TL for class D stats
14054 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14055 {
14056 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14057 }
14058 else
14059 {
14060 //save in SME
14061 csrRoamSaveStatsFromTl(pMac, pTlStats);
14062 }
14063 vos_mem_free(pTlStats);
14064 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014065 }
14066 else
14067 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014068 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014070
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 if(pMac->roam.tlStatsReqInfo.periodicity)
14072 {
14073 //start timer
14074 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14075 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14076 if(!HAL_STATUS_SUCCESS(status))
14077 {
14078 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer\n"));
14079 return eHAL_STATUS_FAILURE;
14080 }
14081 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14082 }
14083 }
14084 }
14085 pMac->roam.tlStatsReqInfo.numClient++;
14086 }
14087
14088 insertInClientList = TRUE;
14089 }
14090 //if one time report requested with non cached result from PE/TL
14091 else if(!cache && !periodicity)
14092 {
14093 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14094 {
14095 //send down a req
14096 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14097 if(!HAL_STATUS_SUCCESS(status))
14098 {
14099 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE\n"));
14100 }
14101 //so that when the stats rsp comes back from PE we respond to upper layer
14102 //right away
14103 staEntry.timerExpired = TRUE;
14104 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 }
14106 if(statsMask & (1 << eCsrGlobalClassDStats))
14107 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014108 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14109 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014111 //req TL for class D stats
14112 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14113 {
14114 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14115 }
14116 else
14117 {
14118 //save in SME
14119 csrRoamSaveStatsFromTl(pMac, pTlStats);
14120 }
14121 vos_mem_free(pTlStats);
14122 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 }
14124 else
14125 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014126 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014128
14129 }
14130 //if looking for stats from TL only
14131 if(!insertInClientList)
14132 {
14133 //return the stats
14134 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 if(insertInClientList)
14138 {
14139 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14140 if(!pStaEntry)
14141 {
14142 //msg
14143 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList\n");
14144 return eHAL_STATUS_FAILURE;
14145 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014146 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014147 //Init & start timer if needed
14148 if(periodicity)
14149 {
14150 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14151 csrRoamStatsClientTimerHandler, pStaEntry );
14152 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14153 {
14154 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer\n"));
14155 return eHAL_STATUS_FAILURE;
14156 }
14157 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14158 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14159 {
14160 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
14161 return eHAL_STATUS_FAILURE;
14162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 }
14166 return eHAL_STATUS_SUCCESS;
14167}
14168
Jeff Johnson295189b2012-06-20 16:38:30 -070014169tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14170 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14171{
14172 tANI_BOOLEAN found = FALSE;
14173 eHalStatus status = eHAL_STATUS_SUCCESS;
14174 tCsrPeStatsReqInfo staEntry;
14175 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14176 tListElem *pStaEntry = NULL;
14177 VOS_STATUS vosStatus;
14178 tPmcPowerState powerState;
14179 *pFound = FALSE;
14180
14181 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14182 if(pStaEntry)
14183 {
14184 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14185 if(pTempStaEntry->periodicity)
14186 {
14187 pTempStaEntry->periodicity =
14188 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14189 }
14190 else
14191 {
14192 pTempStaEntry->periodicity = periodicity;
14193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 pTempStaEntry->numClient++;
14195 found = TRUE;
14196 }
14197 else
14198 {
14199 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14200 staEntry.numClient = 1;
14201 staEntry.periodicity = periodicity;
14202 staEntry.pMac = pMac;
14203 staEntry.rspPending = FALSE;
14204 staEntry.staId = staId;
14205 staEntry.statsMask = statsMask;
14206 staEntry.timerRunning = FALSE;
14207 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14208 if(!pTempStaEntry)
14209 {
14210 //msg
14211 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList\n");
14212 return NULL;
14213 }
14214 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014215 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14216 if(ePMC_FULL_POWER == powerState)
14217 {
14218 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14219 {
14220 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14221 }
14222 }
14223 else
14224 {
14225 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14226 {
14227 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14228 }
14229 }
14230 if(!pTempStaEntry->timerRunning)
14231 {
14232 //send down a req in case of one time req, for periodic ones wait for timer to expire
14233 if(!pTempStaEntry->rspPending &&
14234 !pTempStaEntry->periodicity)
14235 {
14236 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14237 if(!HAL_STATUS_SUCCESS(status))
14238 {
14239 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE\n"));
14240 }
14241 else
14242 {
14243 pTempStaEntry->rspPending = TRUE;
14244 }
14245 }
14246 if(pTempStaEntry->periodicity)
14247 {
14248 if(!found)
14249 {
14250
14251 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14252 csrRoamPeStatsTimerHandler, pTempStaEntry );
14253 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14254 {
14255 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer\n"));
14256 return NULL;
14257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 }
14259 //start timer
14260 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d\n", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14262 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14263 {
14264 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer\n"));
14265 return NULL;
14266 }
14267 pTempStaEntry->timerRunning = TRUE;
14268 }
14269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 *pFound = found;
14271 return pTempStaEntry;
14272}
14273
Jeff Johnson295189b2012-06-20 16:38:30 -070014274/*
14275 pStaEntry is no longer invalid upon the return of this function.
14276*/
14277static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14278{
14279 if(pEntry)
14280 {
14281 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14282 {
14283 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014284 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 }
14286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014287
14288void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14289{
14290 tListElem *pEntry;
14291 tCsrPeStatsReqInfo *pTempStaEntry;
14292 VOS_STATUS vosStatus;
14293 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 if(!pEntry)
14295 {
14296 //list empty
14297 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE\n");
14298 return;
14299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 while( pEntry )
14301 {
14302 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14304 {
14305 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found\n");
14306 if(pTempStaEntry->timerRunning)
14307 {
14308 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14309 /* If we are not able to stop the timer here, just remove
14310 * the entry from the linked list. Destroy the timer object
14311 * and free the memory in the timer CB
14312 */
14313 if( vosStatus == VOS_STATUS_SUCCESS )
14314 {
14315 /* the timer is successfully stopped */
14316 pTempStaEntry->timerRunning = FALSE;
14317
14318 /* Destroy the timer */
14319 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14320 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14321 {
14322 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer\n"));
14323 }
14324 }
14325 else
14326 {
14327 // the timer could not be stopped. Hence destroy and free the
14328 // memory for the PE stat entry in the timer CB.
14329 pTempStaEntry->timerStopFailed = TRUE;
14330 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014332
14333 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14334 {
14335 // Only free the memory if we could stop the timer successfully
14336 if(!pTempStaEntry->timerStopFailed)
14337 {
14338 palFreeMemory(pMac->hHdd, pTempStaEntry);
14339 pTempStaEntry = NULL;
14340 }
14341 break;
14342 }
14343
14344 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14345 }
14346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 return;
14348}
14349
14350
Jeff Johnsone7245742012-09-05 17:12:55 -070014351void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014352{
14353
Jeff Johnsone7245742012-09-05 17:12:55 -070014354 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14355 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14356 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14357 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14358 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14359 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14360 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014362 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14363 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14364 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14365 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14366 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14367 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014369 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14370 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014371
14372}
14373
Jeff Johnson295189b2012-06-20 16:38:30 -070014374void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14375 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14376{
14377 tANI_U8 stats[500];
14378 tANI_U8 *pStats = NULL;
14379 tANI_U32 tempMask = 0;
14380 tANI_U8 counter = 0;
14381 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 if(!callback)
14383 {
14384 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL\n"));
14385 return;
14386 }
14387 if(!statsMask)
14388 {
14389 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0\n"));
14390 return;
14391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014392 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014393 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 while(tempMask)
14395 {
14396 if(tempMask & 1)
14397 {
14398 //new stats info from PE, fill up the stats strucutres in PMAC
14399 switch(counter)
14400 {
14401 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014402 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14404 sizeof(tCsrSummaryStatsInfo));
14405 if(!HAL_STATUS_SUCCESS(status))
14406 {
14407 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats\n"));
14408 }
14409 pStats += sizeof(tCsrSummaryStatsInfo);
14410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014411 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014412 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14414 sizeof(tCsrGlobalClassAStatsInfo));
14415 if(!HAL_STATUS_SUCCESS(status))
14416 {
14417 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats\n"));
14418 }
14419 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014422 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014423 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14424 sizeof(tCsrGlobalClassBStatsInfo));
14425 if(!HAL_STATUS_SUCCESS(status))
14426 {
14427 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats\n"));
14428 }
14429 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014430 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014432 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014433 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14434 sizeof(tCsrGlobalClassCStatsInfo));
14435 if(!HAL_STATUS_SUCCESS(status))
14436 {
14437 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats\n"));
14438 }
14439 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 case eCsrGlobalClassDStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014442 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14444 sizeof(tCsrGlobalClassDStatsInfo));
14445 if(!HAL_STATUS_SUCCESS(status))
14446 {
14447 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats\n"));
14448 }
14449 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014450 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014452 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14454 sizeof(tCsrPerStaStatsInfo));
14455 if(!HAL_STATUS_SUCCESS(status))
14456 {
14457 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats\n"));
14458 }
14459 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014461 default:
14462 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type\n"));
14463 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 }
14465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 tempMask >>=1;
14467 counter++;
14468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014469 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014470}
14471
Jeff Johnson295189b2012-06-20 16:38:30 -070014472eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14473{
14474 tListElem *pEntry = NULL;
14475 tListElem *pPrevEntry = NULL;
14476 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14477 eHalStatus status = eHAL_STATUS_SUCCESS;
14478 VOS_STATUS vosStatus;
14479 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014480 if(!pEntry)
14481 {
14482 //list empty
14483 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
14484 "upper layer client(s)\n");
14485 return status;
14486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 while( pEntry )
14488 {
14489 if(pPrevEntry)
14490 {
14491 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14492 //send up the stats report
14493 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14494 pTempStaEntry->staId, pTempStaEntry->pContext);
14495 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14499 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014500 pTempStaEntry->pPeStaEntry->numClient--;
14501 //check if we need to delete the entry from peStatsReqList too
14502 if(!pTempStaEntry->pPeStaEntry->numClient)
14503 {
14504 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 //check if we need to stop the tl stats timer too
14508 pMac->roam.tlStatsReqInfo.numClient--;
14509 if(!pMac->roam.tlStatsReqInfo.numClient)
14510 {
14511 if(pMac->roam.tlStatsReqInfo.timerRunning)
14512 {
14513 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14514 if(!HAL_STATUS_SUCCESS(status))
14515 {
14516 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer\n"));
14517 //we will continue
14518 }
14519 }
14520 pMac->roam.tlStatsReqInfo.periodicity = 0;
14521 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 if (pTempStaEntry->periodicity)
14524 {
14525 //While creating StaEntry in csrGetStatistics,
14526 //Initializing and starting timer only when periodicity is set.
14527 //So Stop and Destroy timer only when periodicity is set.
14528
Jeff Johnsone7245742012-09-05 17:12:55 -070014529 vos_timer_stop( &pTempStaEntry->timer );
14530 // Destroy the vos timer...
14531 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14532 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14533 {
14534 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer\n"));
14535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014537
Jeff Johnson295189b2012-06-20 16:38:30 -070014538
14539 pPrevEntry = pEntry;
14540 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14541 }
14542 //the last one
14543 if(pPrevEntry)
14544 {
14545 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14546 //send up the stats report
14547 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14548 pTempStaEntry->staId, pTempStaEntry->pContext);
14549 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 return status;
14552
14553}
14554
Jeff Johnson295189b2012-06-20 16:38:30 -070014555eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14556 tRequestFullPowerReason *pReason,
14557 tANI_BOOLEAN *pfNeedPower )
14558{
14559 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14560 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14561 tPmcState pmcState;
14562 eHalStatus status = eHAL_STATUS_SUCCESS;
14563 // TODO : Session info unavailable
14564 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 if( pfNeedPower )
14566 {
14567 *pfNeedPower = eANI_BOOLEAN_FALSE;
14568 }
14569 //We only handle CSR commands
14570 if( !(eSmeCsrCommandMask & pCommand->command) )
14571 {
14572 return eHAL_STATUS_SUCCESS;
14573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 //Check PMC state first
14575 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 switch( pmcState )
14577 {
14578 case REQUEST_IMPS:
14579 case IMPS:
14580 if( eSmeCommandScan == pCommand->command )
14581 {
14582 switch( pCommand->u.scanCmd.reason )
14583 {
14584 case eCsrScanGetResult:
14585 case eCsrScanBGScanAbort:
14586 case eCsrScanBGScanEnable:
14587 case eCsrScanGetScanChnInfo:
14588 //Internal process, no need for full power
14589 fNeedFullPower = eANI_BOOLEAN_FALSE;
14590 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 default:
14592 //Other scans are real scan, ask for power
14593 fNeedFullPower = eANI_BOOLEAN_TRUE;
14594 break;
14595 } //switch
14596 }
14597 else
14598 {
14599 //ask for power for roam and status change
14600 fNeedFullPower = eANI_BOOLEAN_TRUE;
14601 }
14602 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014603 case REQUEST_BMPS:
14604 case BMPS:
14605 case REQUEST_START_UAPSD:
14606 case UAPSD:
14607 //We treat WOWL same as BMPS
14608 case REQUEST_ENTER_WOWL:
14609 case WOWL:
14610 if( eSmeCommandRoam == pCommand->command )
14611 {
14612 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14613 tCsrScanResult *pScanResult;
14614 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 switch ( pCommand->u.roamCmd.roamReason )
14616 {
14617 case eCsrForcedDisassoc:
14618 case eCsrForcedDisassocMICFailure:
14619 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14620 fNeedFullPower = eANI_BOOLEAN_TRUE;
14621 break;
14622 case eCsrSmeIssuedDisassocForHandoff:
14623 case eCsrForcedDeauth:
14624 case eCsrHddIssuedReassocToSameAP:
14625 case eCsrSmeIssuedReassocToSameAP:
14626 fNeedFullPower = eANI_BOOLEAN_TRUE;
14627 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014628 case eCsrCapsChange:
14629 fNeedFullPower = eANI_BOOLEAN_TRUE;
14630 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 default:
14632 //Check whether the profile is already connected. If so, no need for full power
14633 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14634 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14635 {
14636 //Only need to check the first one
14637 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14638 if( pEntry )
14639 {
14640 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14641#if 0
14642 // TODO : Session Specific info pConnectBssDesc
14643 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14644 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14645 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14646 {
14647 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14648 // with Authenticating first. To force this, stop the current association (Disassociate) and
14649 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14650 // a new Association.
14651 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14652 {
14653 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14654 {
14655 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14656 //No need for full power
14657 //Set the flag so the code later can avoid to do the above
14658 //check again.
14659 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14660 break;
14661 }
14662 }
14663 }
14664#endif
14665 }
14666 }
14667 //If we are here, full power is needed
14668 fNeedFullPower = eANI_BOOLEAN_TRUE;
14669 break;
14670 }
14671 }
14672 else if( eSmeCommandWmStatusChange == pCommand->command )
14673 {
14674 //need full power for all
14675 fNeedFullPower = eANI_BOOLEAN_TRUE;
14676 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14677 }
Mohit Khannac0b992f2012-12-04 15:08:18 -080014678#ifdef FEATURE_WLAN_TDLS
14679 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14680 {
14681 //TDLS link is getting established. need full power
14682 fNeedFullPower = eANI_BOOLEAN_TRUE;
14683 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14684 }
14685#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 case REQUEST_STOP_UAPSD:
14688 case REQUEST_EXIT_WOWL:
14689 if( eSmeCommandRoam == pCommand->command )
14690 {
14691 fNeedFullPower = eANI_BOOLEAN_TRUE;
14692 switch ( pCommand->u.roamCmd.roamReason )
14693 {
14694 case eCsrForcedDisassoc:
14695 case eCsrForcedDisassocMICFailure:
14696 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14697 break;
14698 default:
14699 break;
14700 }
14701 }
14702 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 case STOPPED:
14704 case REQUEST_STANDBY:
14705 case STANDBY:
14706 case LOW_POWER:
14707 //We are not supposed to do anything
14708 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d\n" ), pmcState );
14709 status = eHAL_STATUS_FAILURE;
14710 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 case FULL_POWER:
14712 case REQUEST_FULL_POWER:
14713 default:
14714 //No need to ask for full power. This has to be FULL_POWER state
14715 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 if( pReason )
14718 {
14719 *pReason = reason;
14720 }
14721 if( pfNeedPower )
14722 {
14723 *pfNeedPower = fNeedFullPower;
14724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 return ( status );
14726}
14727
Jeff Johnson295189b2012-06-20 16:38:30 -070014728static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14729{
14730 eHalStatus status = eHAL_STATUS_SUCCESS;
14731 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14732 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14735 {
14736 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 return ( status );
14739}
14740
Jeff Johnson295189b2012-06-20 16:38:30 -070014741tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14742{
14743 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 if( pCmd )
14745 {
14746 pMac->roam.sPendingCommands++;
14747 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014748 return ( pCmd );
14749}
14750
Jeff Johnson295189b2012-06-20 16:38:30 -070014751void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14752{
14753 if (pMac->roam.sPendingCommands > 0)
14754 {
14755 //All command allocated through csrGetCommandBuffer need to
14756 //decrement the pending count when releasing.
14757 pMac->roam.sPendingCommands--;
14758 smeReleaseCommand( pMac, pCommand );
14759 }
14760 else
14761 {
14762 smsLog(pMac, LOGE, FL( "no pending commands"));
14763 VOS_ASSERT(0);
14764 }
14765}
14766
Jeff Johnson295189b2012-06-20 16:38:30 -070014767//Return SUCCESS is the command is queued, failed
14768eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14769{
14770 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14772 {
14773 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14774 pCommand->u.scanCmd.reason);
14775 return eHAL_STATUS_CSR_WRONG_STATE;
14776 }
14777
14778 //We can call request full power first before putting the command into pending Q
14779 //because we are holding SME lock at this point.
14780 status = csrRequestFullPower( pMac, pCommand );
14781 if( HAL_STATUS_SUCCESS( status ) )
14782 {
14783 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 //make sure roamCmdPendingList is not empty first
14785 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14786 if( fNoCmdPending )
14787 {
14788 smePushCommand( pMac, pCommand, fHighPriority );
14789 }
14790 else
14791 {
14792 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14793 //no list lock is needed since SME lock is held
14794 if( !fHighPriority )
14795 {
14796 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14797 }
14798 else {
14799 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14800 }
14801 }
14802 }
14803 else if( eHAL_STATUS_PMC_PENDING == status )
14804 {
14805 //no list lock is needed since SME lock is held
14806 if( !fHighPriority )
14807 {
14808 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14809 }
14810 else {
14811 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14812 }
14813 //Let caller know the command is queue
14814 status = eHAL_STATUS_SUCCESS;
14815 }
14816 else
14817 {
14818 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14819 //release the command.
14820 smsLog( pMac, LOGE, FL( " cannot queue command %d\n" ), pCommand->command );
14821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014822 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014823}
Jeff Johnson295189b2012-06-20 16:38:30 -070014824#ifdef WLAN_SOFTAP_FEATURE
14825eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14826{
14827 eHalStatus status = eHAL_STATUS_SUCCESS;
14828 tSirUpdateAPWPSIEsReq *pMsg;
14829 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14830
14831 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14832 if (NULL == pSession)
14833 {
14834 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14835 return eHAL_STATUS_FAILURE;
14836 }
14837
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 do
14839 {
14840 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14841 if (!HAL_STATUS_SUCCESS(status)) break;
14842 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14843 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14844
14845 pBuf = (tANI_U8 *)&pMsg->transactionId;
14846 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 // transactionId
14848 *pBuf = 0;
14849 *( pBuf + 1 ) = 0;
14850 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 // bssId
14852 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14853 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 //sessionId
14855 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 // APWPSIEs
14857 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
14858 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 return ( status );
14863}
Jeff Johnson295189b2012-06-20 16:38:30 -070014864eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
14865{
14866 eHalStatus status = eHAL_STATUS_SUCCESS;
14867 tSirUpdateAPWPARSNIEsReq *pMsg;
14868 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14870 if (NULL == pSession)
14871 {
14872 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14873 return eHAL_STATUS_FAILURE;
14874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 do
14876 {
14877 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
14878 if (!HAL_STATUS_SUCCESS(status)) break;
14879 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
14880 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 pBuf = (tANI_U8 *)&pMsg->transactionId;
14882 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 // transactionId
14884 *pBuf = 0;
14885 *( pBuf + 1 ) = 0;
14886 pBuf += sizeof(tANI_U16);
14887
14888 // bssId
14889 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14890 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 // sessionId
14892 *pBuf++ = (tANI_U8)sessionId;
14893
14894 // APWPARSNIEs
14895 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
14896 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014898 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 return ( status );
14901}
Jeff Johnson295189b2012-06-20 16:38:30 -070014902#endif //#ifdef WLAN_SOFTAP_FEATURE
14903
14904#ifdef WLAN_FEATURE_VOWIFI_11R
14905//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
14906eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
14907{
14908 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14909 tpSirFTPreAuthReq pftPreAuthReq;
14910 tANI_U16 auth_req_len = 0;
14911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 auth_req_len = sizeof(tSirFTPreAuthReq);
14913 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
14914 if (pftPreAuthReq == NULL)
14915 {
14916 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
14917 return eHAL_STATUS_RESOURCES;
14918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 // Save the SME Session ID here. We need it while processing the preauth response
14920 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014921 vos_mem_zero(pftPreAuthReq, auth_req_len);
14922
14923 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
14924 sizeof(pBssDescription->length) + pBssDescription->length);
14925
14926 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
14927
14928 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
14929
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
14932
Jeff Johnson295189b2012-06-20 16:38:30 -070014933#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080014934 if (csrRoamIs11rAssoc(pMac) &&
14935 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 {
14937 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
14938 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
14939 pMac->ft.ftSmeContext.auth_ft_ies_length);
14940 }
14941 else
14942#endif
14943 {
14944 pftPreAuthReq->ft_ies_length = 0;
14945 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070014946 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
14947 sizeof(pBssDescription->length) + pBssDescription->length);
14948 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
14950}
Jeff Johnson295189b2012-06-20 16:38:30 -070014951/*--------------------------------------------------------------------------
14952 * This will receive and process the FT Pre Auth Rsp from the current
14953 * associated ap.
14954 *
14955 * This will invoke the hdd call back. This is so that hdd can now
14956 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
14957 ------------------------------------------------------------------------*/
14958void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
14959{
14960 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14961 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014962#ifdef FEATURE_WLAN_LFR
14963 tCsrRoamInfo roamInfo;
14964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014965
14966#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
14967 smsLog( pMac, LOGE, FL("Preauth response status code %d"), pFTPreAuthRsp->status);
14968#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070014969#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
14970 status = csrNeighborRoamPreauthRspHandler(pMac, (VOS_STATUS)pFTPreAuthRsp->status);
14971 if (status != eHAL_STATUS_SUCCESS) {
14972 /*
14973 * Bail out if pre-auth was not even processed.
14974 */
14975 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
14976 return;
14977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014978#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 /* The below function calls/timers should be invoked only if the pre-auth is successful */
14980 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
14981 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 // Implies a success
14983 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
14985 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
14986 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
14988 * actual transition from the current to handoff AP is triggered */
14989 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
14990 60 * PAL_TIMER_TO_MS_UNIT,
14991 eANI_BOOLEAN_FALSE);
14992 if (eHAL_STATUS_SUCCESS != status)
14993 {
14994 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d\n"), status);
14995 return;
14996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 // Save the received response
14998 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
14999 if (csrRoamIs11rAssoc(pMac))
15000 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15001 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15002
15003 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015004#ifdef FEATURE_WLAN_LFR
15005 // If Legacy Fast Roaming is enabled, signal the supplicant
15006 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015007 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015008 {
15009 // Save the bssid from the received response
15010 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15011 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15012 }
15013
15014#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015015
15016 // Done with it, init it.
15017 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15018}
15019#endif
15020#ifdef FEATURE_WLAN_BTAMP_UT_RF
15021void csrRoamJoinRetryTimerHandler(void *pv)
15022{
15023 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15024 tpAniSirGlobal pMac = pInfo->pMac;
15025 tANI_U32 sessionId = pInfo->sessionId;
15026 tCsrRoamSession *pSession;
15027
15028 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15029 {
15030 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d\n" ), sessionId );
15031 pSession = CSR_GET_SESSION( pMac, sessionId );
15032 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15033 {
15034 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15035 {
15036 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile\n" ) );
15037 }
15038 }
15039 }
15040}
Jeff Johnson295189b2012-06-20 16:38:30 -070015041eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15042{
15043 eHalStatus status = eHAL_STATUS_FAILURE;
15044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15045
15046 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15047 {
15048 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left\n "), sessionId, pSession->maxRetryCount);
15049 pSession->maxRetryCount--;
15050 pSession->joinRetryTimerInfo.pMac = pMac;
15051 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15052 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15053 if(!HAL_STATUS_SUCCESS(status))
15054 {
15055 smsLog(pMac, LOGE, FL(" fail to start timer status %s \n "), status);
15056 }
15057 }
15058 else
15059 {
15060 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)\n "),
15061 pSession->maxRetryCount);
15062 }
15063
15064 return (status);
15065}
Jeff Johnson295189b2012-06-20 16:38:30 -070015066eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15067{
15068 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer \n ");
15069 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15070 {
15071 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15072 }
15073
15074 return eHAL_STATUS_SUCCESS;
15075}
15076#endif
15077
15078
15079/*
15080 pBuf points to the beginning of the message
15081 LIM packs disassoc rsp as below,
15082 messageType - 2 bytes
15083 messageLength - 2 bytes
15084 sessionId - 1 byte
15085 transactionId - 2 bytes (tANI_U16)
15086 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15087 peerMacAddr - 6 bytes
15088 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15089*/
15090static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15091{
15092 if(pBuf && pRsp)
15093 {
15094 pBuf += 4; //skip type and length
15095 pRsp->sessionId = *pBuf++;
15096 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15097 pBuf += 2;
15098 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15099 pBuf += 4;
15100 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15101 }
15102}
15103
Jeff Johnsond13512a2012-07-17 11:42:19 -070015104eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15105{
15106 static uNvTables nvTables;
15107 eHalStatus status = eHAL_STATUS_SUCCESS;
15108 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15109
15110 /* read the country code from NV and use it */
15111 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15112 {
15113 palCopyMemory( pMac->hHdd, pCountry,
15114 nvTables.defaultCountryTable.countryCode,
15115 WNI_CFG_COUNTRY_CODE_LEN );
15116 return status;
15117 }
15118 else
15119 {
15120 palCopyMemory( pMac->hHdd, pCountry,
15121 "XXX",
15122 WNI_CFG_COUNTRY_CODE_LEN );
15123 status = eHAL_STATUS_FAILURE;
15124 return status;
15125 }
15126}
15127
15128eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15129{
15130 palCopyMemory( pMac->hHdd, pCountry,
15131 pMac->scan.countryCode11d,
15132 WNI_CFG_COUNTRY_CODE_LEN );
15133 return eHAL_STATUS_SUCCESS;
15134}