blob: f39780fc7e597cb352851aa13945086b0f842fa2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070044
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46 \file csrApiRoam.c
47
48 Implementation for the Common Roaming interfaces.
49
50 Copyright (C) 2008 Qualcomm, Incorporated
51
52
53 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070054/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070055 EDIT HISTORY FOR FILE
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057 This section contains comments describing changes made to the module.
58 Notice that changes are listed in reverse chronological order.
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060 when who what, where, why
61---------- --- --------------------------------------------------------
6206/03/10 js Added support to hostapd driven
63 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070064===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "aniGlobal.h" //for tpAniSirGlobal
66#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070068#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "palApi.h"
70#include "csrInsideApi.h"
71#include "smsDebug.h"
72#include "logDump.h"
73#include "smeQosInternal.h"
74#include "wlan_qct_tl.h"
75#include "smeInside.h"
76#include "vos_diag_core_event.h"
77#include "vos_diag_core_log.h"
78#include "csrApi.h"
79#include "pmc.h"
80#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
82#include "csrNeighborRoam.h"
83#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#ifdef FEATURE_WLAN_CCX
85#include "csrCcx.h"
86#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define CSR_NUM_IBSS_START_CHANNELS_50 4
88#define CSR_NUM_IBSS_START_CHANNELS_24 3
89#define CSR_DEF_IBSS_START_CHANNEL_50 36
90#define CSR_DEF_IBSS_START_CHANNEL_24 1
91#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080092#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
94/*---------------------------------------------------------------------------
95 OBIWAN recommends [8 10]% : pick 9%
96---------------------------------------------------------------------------*/
97#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070098/*---------------------------------------------------------------------------
99 OBIWAN recommends -85dBm
100---------------------------------------------------------------------------*/
101#define CSR_VCC_RSSI_THRESHOLD 80
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
103#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
104#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
105#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//We use constatnt 4 here
107//This macro returns true when higher AC parameter is bigger than lower AC for a difference
108//The bigger the number, the less chance of TX
109//It must put lower AC as the first parameter.
110#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111//Flag to send/do not send disassoc frame over the air
112#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#define MAX_CB_VALUE_IN_INI (2)
115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
121static const char KR_3[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
122 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
123 108, 112, 116, 120, 124, 149, 153, 157, 161};
124static const char KR_24[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
125 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
126 108, 112, 116, 120, 124, 149, 153, 157, 161};
127static const char KR_25[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
128 36, 40, 44, 48, 149, 153, 157, 161};
129#endif
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/*--------------------------------------------------------------------------
132 Type declarations
133 ------------------------------------------------------------------------*/
134#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700135int diagAuthTypeFromCSRType(eCsrAuthType authType)
136{
137 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 switch(authType)
139 {
140 case eCSR_AUTH_TYPE_SHARED_KEY:
141 n = AUTH_SHARED;
142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 case eCSR_AUTH_TYPE_WPA:
144 n = AUTH_WPA_EAP;
145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 case eCSR_AUTH_TYPE_WPA_PSK:
147 n = AUTH_WPA_PSK;
148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 case eCSR_AUTH_TYPE_RSN:
150 n = AUTH_WPA2_EAP;
151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700153#ifdef WLAN_FEATURE_11W
154 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
155#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 n = AUTH_WPA2_PSK;
157 break;
158#ifdef FEATURE_WLAN_WAPI
159 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
160 n = AUTH_WAPI_CERT;
161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
163 n = AUTH_WAPI_PSK;
164 break;
165#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 default:
167 break;
168 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 return (n);
170}
Jeff Johnson295189b2012-06-20 16:38:30 -0700171int diagEncTypeFromCSRType(eCsrEncryptionType encType)
172{
173 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 switch(encType)
175 {
176 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
177 case eCSR_ENCRYPT_TYPE_WEP40:
178 n = ENC_MODE_WEP40;
179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
181 case eCSR_ENCRYPT_TYPE_WEP104:
182 n = ENC_MODE_WEP104;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_ENCRYPT_TYPE_TKIP:
185 n = ENC_MODE_TKIP;
186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 case eCSR_ENCRYPT_TYPE_AES:
188 n = ENC_MODE_AES;
189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700190#ifdef FEATURE_WLAN_WAPI
191 case eCSR_ENCRYPT_TYPE_WPI:
192 n = ENC_MODE_SMS4;
193 break;
194#endif /* FEATURE_WLAN_WAPI */
195 default:
196 break;
197 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700198 return (n);
199}
Jeff Johnson295189b2012-06-20 16:38:30 -0700200#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700201static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
202static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700203static void initConfigParam(tpAniSirGlobal pMac);
204static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
205 eCsrRoamCompleteResult Result, void *Context );
206static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
207 tCsrRoamProfile *pProfile,
208 tANI_BOOLEAN *pfSameIbss );
209static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
210static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700211 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
212static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
214static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
215eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
216eHalStatus csrRoamClose(tpAniSirGlobal pMac);
217void csrRoamMICErrorTimerHandler(void *pv);
218void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
219tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
220
221static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
222static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
223static void csrRoamRoamingTimerHandler(void *pv);
224eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
225eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
226static void csrRoamIbssJoinTimerHandler(void *pv);
227eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
228eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
229static void csrRoamWaitForKeyTimeOutHandler(void *pv);
230
231static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700232static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
234eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
235 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
236 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
237 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
238 tANI_U8 *pKeyRsc );
239static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
240 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
241 tCsrRoamProfile *pProfile );
242void csrRoamStatisticsTimerHandler(void *pv);
243void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
245VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
246 v_U8_t rssiNotification,
247 void * context);
248static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
249void csrRoamVccTrigger(tpAniSirGlobal pMac);
250eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
251/*
252 pStaEntry is no longer invalid upon the return of this function.
253*/
254static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700256static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700257tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
258 tDblLinkList *pStaList,
259 tCsrStatsClientReqInfo *pStaEntry);
260void csrRoamStatsClientTimerHandler(void *pv);
261tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
262 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
263void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
264 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700265void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266void csrRoamTlStatsTimerHandler(void *pv);
267void csrRoamPeStatsTimerHandler(void *pv);
268tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
269void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
270tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
271eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
272static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
273static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
274static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
275static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
276 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
277//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
278static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
279void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
280#ifdef FEATURE_WLAN_BTAMP_UT_RF
281void csrRoamJoinRetryTimerHandler(void *pv);
282#endif
283extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700286void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288//Initialize global variables
289static void csrRoamInitGlobals(tpAniSirGlobal pMac)
290{
291 if(pMac)
292 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800293 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
294 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 }
296 return;
297}
298
Jeff Johnson295189b2012-06-20 16:38:30 -0700299static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
300{
301 if(pMac)
302 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800303 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 }
305 return;
306}
Jeff Johnson295189b2012-06-20 16:38:30 -0700307eHalStatus csrOpen(tpAniSirGlobal pMac)
308{
309 eHalStatus status = eHAL_STATUS_SUCCESS;
310 static uNvTables nvTables;
311 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 v_REGDOMAIN_t regId;
313 tANI_U32 i;
314
315 do
316 {
317 /* Initialize CSR Roam Globals */
318 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
320 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
321
322 initConfigParam(pMac);
323 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
324 break;
325 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
326 break;
327 pMac->roam.nextRoamId = 1; //Must not be 0
328 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
329 break;
330 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
331 break;
332 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
333 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
335 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
336 {
337 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
338 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
339 status = eHAL_STATUS_SUCCESS;
340 }
341 else
342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800343 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 //hardcoded for now
345 pMac->scan.countryCodeDefault[0] = 'U';
346 pMac->scan.countryCodeDefault[1] = 'S';
347 pMac->scan.countryCodeDefault[2] = 'I';
348 //status = eHAL_STATUS_SUCCESS;
349 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700350 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 WDA_SetRegDomain(pMac, regId);
353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
356 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
357 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 }while(0);
359
360 return (status);
361}
362
Jeff Johnson295189b2012-06-20 16:38:30 -0700363eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
364{
365 eHalStatus status = eHAL_STATUS_SUCCESS;
366 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
367 v_REGDOMAIN_t regId;
368 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 if(NULL == apCntryCode)
370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800371 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return eHAL_STATUS_FAILURE;
373 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700374 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 /* To get correct Regulatory domain from NV table
376 * 2 character Country code should be used
377 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700378 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
379/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700381
382 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800384 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700385 return eHAL_STATUS_FAILURE;
386 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700387*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
389 if (status != eHAL_STATUS_SUCCESS)
390 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700391 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 return status;
393 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 status = WDA_SetRegDomain(hHal, regId);
395 if (status != eHAL_STATUS_SUCCESS)
396 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700397 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 return status;
399 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 pMac->scan.domainIdDefault = regId;
401 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700402 /* Clear CC field */
403 palFillMemory( pMac->hHdd,
404 pMac->scan.countryCodeDefault,
405 WNI_CFG_COUNTRY_CODE_LEN,
406 0 );
407 /* Copy 2 or 3 bytes country code */
408 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
409 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 /* If 2 bytes country code, 3rd byte must be filled with space */
411 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
412 {
413 palFillMemory( pMac->hHdd,
414 pMac->scan.countryCodeDefault + 2,
415 1,
416 0x20 );
417 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
419 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
420 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 return status;
422}
Jeff Johnson295189b2012-06-20 16:38:30 -0700423eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
424{
425 eHalStatus status = eHAL_STATUS_SUCCESS;
426 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
427 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
429 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
431 {
432 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
433 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
434 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
435 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
436 }
437 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
438
439 return status;
440}
Jeff Johnson295189b2012-06-20 16:38:30 -0700441eHalStatus csrClose(tpAniSirGlobal pMac)
442{
443 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800444
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 csrStop(pMac);
446 csrRoamClose(pMac);
447 csrScanClose(pMac);
448 csrLLClose(&pMac->roam.statsClientReqList);
449 csrLLClose(&pMac->roam.peStatsReqList);
450 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 /* DeInit Globals */
452 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 return (status);
454}
Jeff Johnson295189b2012-06-20 16:38:30 -0700455eHalStatus csrStart(tpAniSirGlobal pMac)
456{
457 eHalStatus status = eHAL_STATUS_SUCCESS;
458 tANI_U32 i;
459
460 do
461 {
462 //save the global vos context
463 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
464 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
466
467 status = csrRoamStart(pMac);
468 if(!HAL_STATUS_SUCCESS(status)) break;
469 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
470 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
471 if(!HAL_STATUS_SUCCESS(status)) break;
472 pMac->roam.sPendingCommands = 0;
473 csrScanEnable(pMac);
474#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
475 status = csrNeighborRoamInit(pMac);
476#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
477 pMac->roam.tlStatsReqInfo.numClient = 0;
478 pMac->roam.tlStatsReqInfo.periodicity = 0;
479 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
480 //init the link quality indication also
481 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
482 if(!HAL_STATUS_SUCCESS(status))
483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800484 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 break;
486 }
487 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488#if defined(ANI_LOGDUMP)
489 csrDumpInit(pMac);
490#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 return (status);
492}
493
Jeff Johnson295189b2012-06-20 16:38:30 -0700494eHalStatus csrStop(tpAniSirGlobal pMac)
495{
496 tANI_U32 sessionId;
497 tANI_U32 i;
498
499 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
500 {
501 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
502 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 csrScanDisable(pMac);
504 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
505 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
507
508#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
509 csrNeighborRoamClose(pMac);
510#endif
511 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 // deregister from PMC since we register during csrStart()
513 // (ignore status since there is nothing we can do if it fails)
514 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 //Reset the domain back to the deault
516 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800517 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700518
519 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
520 {
521 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
522 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
523 }
524
525 return (eHAL_STATUS_SUCCESS);
526}
527
Jeff Johnson295189b2012-06-20 16:38:30 -0700528eHalStatus csrReady(tpAniSirGlobal pMac)
529{
530 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 csrScanGetSupportedChannels( pMac );
532 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
533 //use it to init the background scan list
534 csrInitBGScanChannelList(pMac);
535 /* HDD issues the init scan */
536 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800537 /* If the gScanAgingTime is set to '0' then scan results aging timeout
538 based on timer feature is not enabled*/
539 if(0 != pMac->scan.scanResultCfgAgingTime )
540 {
541 csrScanStartResultCfgAgingTimer(pMac);
542 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 //Store the AC weights in TL for later use
544 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 status = csrInitChannelList( pMac );
546 if ( ! HAL_STATUS_SUCCESS( status ) )
547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800548 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 status );
550 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 return (status);
552}
Jeff Johnson295189b2012-06-20 16:38:30 -0700553void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
554{
555 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
557 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
558}
Jeff Johnson295189b2012-06-20 16:38:30 -0700559void csrSetGlobalCfgs( tpAniSirGlobal pMac )
560{
Jeff Johnsone7245742012-09-05 17:12:55 -0700561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
563 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
564 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
565 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
566 NULL, eANI_BOOLEAN_FALSE);
567 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700568 /* 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
569 * Once session is established we will use the session related params stored in PE session for CB mode
570 */
571 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
573
574 //Update the operating mode to configured value during initialization,
575 //So that client can advertise full capabilities in Probe request frame.
576 csrSetDefaultDot11Mode( pMac );
577}
578
Jeff Johnson295189b2012-06-20 16:38:30 -0700579eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
580{
581 eHalStatus status = eHAL_STATUS_SUCCESS;
582 tANI_U32 i;
583 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 do
585 {
586 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
587 {
588 pSession = CSR_GET_SESSION( pMac, i );
589 pSession->roamingTimerInfo.pMac = pMac;
590 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
591 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
593 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
594 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
595 &pMac->roam.WaitForKeyTimerInfo);
596 if(!HAL_STATUS_SUCCESS(status))
597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800598 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 break;
600 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
602 if(!HAL_STATUS_SUCCESS(status))
603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800604 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 return eHAL_STATUS_FAILURE;
606 }
607 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 return (status);
609}
610
Jeff Johnson295189b2012-06-20 16:38:30 -0700611eHalStatus csrRoamClose(tpAniSirGlobal pMac)
612{
613 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
615 {
616 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
617 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
619 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
621 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 return (eHAL_STATUS_SUCCESS);
623}
624
Jeff Johnson295189b2012-06-20 16:38:30 -0700625eHalStatus csrRoamStart(tpAniSirGlobal pMac)
626{
627 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 return (eHAL_STATUS_SUCCESS);
629}
630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
632{
633 csrRoamStopRoamingTimer(pMac, sessionId);
634 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
635 csrRoamDeregStatisticsReq(pMac);
636}
Jeff Johnson295189b2012-06-20 16:38:30 -0700637eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
638{
639 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800640 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 {
642 status = eHAL_STATUS_SUCCESS;
643 *pState = pMac->roam.roamSession[sessionId].connectState;
644 }
645 return (status);
646}
647
Jeff Johnson295189b2012-06-20 16:38:30 -0700648eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
649{
650 eHalStatus status = eHAL_STATUS_FAILURE;
651 tANI_U32 size = 0;
652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700653
654 if(!pSession)
655 {
656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
657 return eHAL_STATUS_FAILURE;
658 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700659
660 if(pProfile)
661 {
662 if(pSession->pConnectBssDesc)
663 {
664 do
665 {
666 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
667 if(size)
668 {
669 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
670 if(HAL_STATUS_SUCCESS(status))
671 {
672 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
673 }
674 else
675 break;
676 }
677 else
678 {
679 pProfile->pBssDesc = NULL;
680 }
681 pProfile->AuthType = pSession->connectedProfile.AuthType;
682 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
683 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
684 pProfile->BSSType = pSession->connectedProfile.BSSType;
685 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
686 pProfile->CBMode = pSession->connectedProfile.CBMode;
687 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
688 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
689#ifdef WLAN_FEATURE_VOWIFI_11R
690 if (pSession->connectedProfile.MDID.mdiePresent)
691 {
692 pProfile->MDID.mdiePresent = 1;
693 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
694 }
695 else
696 {
697 pProfile->MDID.mdiePresent = 0;
698 pProfile->MDID.mobilityDomain = 0;
699 }
700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700701#ifdef FEATURE_WLAN_CCX
702 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
704 {
705 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
706 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
707 pProfile->ccxCckmInfo.reassoc_req_num=
708 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
709 pProfile->ccxCckmInfo.krk_plumbed =
710 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
711 }
712#endif
713 }while(0);
714 }
715 }
716
717 return (status);
718}
719
Jeff Johnson295189b2012-06-20 16:38:30 -0700720eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
721{
722 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700723
724 if((csrIsConnStateConnected(pMac, sessionId)) ||
725 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 {
727 if(pProfile)
728 {
729 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
730 }
731 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 return (status);
733}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700734
Jeff Johnson295189b2012-06-20 16:38:30 -0700735eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
736{
737 eHalStatus status = eHAL_STATUS_SUCCESS;
738
739 if(pProfile->pBssDesc)
740 {
741 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
742 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700743 if(pProfile->pAddIEAssoc)
744 {
745 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
746 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
748 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
749 return (status);
750}
751
Jeff Johnson295189b2012-06-20 16:38:30 -0700752static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
753{
754 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 if( pConnectedInfo->pbFrames )
756 {
757 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
758 pConnectedInfo->pbFrames = NULL;
759 }
760 pConnectedInfo->nBeaconLength = 0;
761 pConnectedInfo->nAssocReqLength = 0;
762 pConnectedInfo->nAssocRspLength = 0;
763 pConnectedInfo->staId = 0;
764#ifdef WLAN_FEATURE_VOWIFI_11R
765 pConnectedInfo->nRICRspLength = 0;
766#endif
767#ifdef FEATURE_WLAN_CCX
768 pConnectedInfo->nTspecIeLength = 0;
769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 return ( status );
771}
772
Jeff Johnson295189b2012-06-20 16:38:30 -0700773
774
Jeff Johnsone7245742012-09-05 17:12:55 -0700775
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700776void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
777{
778 csrReinitPreauthCmd(pMac, pCommand);
779 csrReleaseCommand( pMac, pCommand );
780}
781
Jeff Johnson295189b2012-06-20 16:38:30 -0700782void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
783{
784 csrReinitRoamCmd(pMac, pCommand);
785 csrReleaseCommand( pMac, pCommand );
786}
787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
789{
790 csrReinitScanCmd(pMac, pCommand);
791 csrReleaseCommand( pMac, pCommand );
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
795{
796 csrReinitWmStatusChangeCmd(pMac, pCommand);
797 csrReleaseCommand( pMac, pCommand );
798}
799
Jeff Johnson295189b2012-06-20 16:38:30 -0700800void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
801{
802 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
803}
804
Jeff Johnson295189b2012-06-20 16:38:30 -0700805void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
806{
807 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
808}
809
Jeff Johnson295189b2012-06-20 16:38:30 -0700810void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
811{
812 csrReinitSetKeyCmd(pMac, pCommand);
813 csrReleaseCommand( pMac, pCommand );
814}
Jeff Johnson295189b2012-06-20 16:38:30 -0700815void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
816{
817 csrReinitRemoveKeyCmd(pMac, pCommand);
818 csrReleaseCommand( pMac, pCommand );
819}
Jeff Johnson295189b2012-06-20 16:38:30 -0700820void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
821{
822
823 if( eSmeCsrCommandMask & pCommand->command )
824 {
825 switch (pCommand->command)
826 {
827 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800828 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800829 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700830 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 if (NULL != pCommand->u.scanCmd.callback)
832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800833 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
835 }
836 csrReleaseCommandScan( pMac, pCommand );
837 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 case eSmeCommandRoam:
839 csrReleaseCommandRoam( pMac, pCommand );
840 break;
841
842 case eSmeCommandWmStatusChange:
843 csrReleaseCommandWmStatusChange( pMac, pCommand );
844 break;
845
846 case eSmeCommandSetKey:
847 csrReleaseCommandSetKey( pMac, pCommand );
848 break;
849
850 case eSmeCommandRemoveKey:
851 csrReleaseCommandRemoveKey( pMac, pCommand );
852 break;
853
854 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800855 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 csrReleaseCommand( pMac, pCommand );
857 break;
858 }
859 }
860}
861
Jeff Johnson295189b2012-06-20 16:38:30 -0700862void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
863{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800864 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 if(pMac->roam.curSubState[sessionId] == NewSubstate)
867 {
868 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700869 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 pMac->roam.curSubState[sessionId] = NewSubstate;
871}
872
Jeff Johnson295189b2012-06-20 16:38:30 -0700873eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
874{
875 eCsrRoamState PreviousState;
876
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800877 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
879 PreviousState = pMac->roam.curState[sessionId];
880
881 if ( NewRoamState != pMac->roam.curState[sessionId] )
882 {
883 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
884 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
885 {
886 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
887 }
888
889 pMac->roam.curState[sessionId] = NewRoamState;
890 }
891 return( PreviousState );
892}
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
895{
896 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 if(catOffset)
898 {
899 pMac->roam.configParam.bCatRssiOffset = catOffset;
900 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
901 {
902 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
903 }
904 }
905}
906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907static void initConfigParam(tpAniSirGlobal pMac)
908{
909 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
911 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
912 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
915 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
916 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
917 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
918 pMac->roam.configParam.HeartbeatThresh24 = 40;
919 pMac->roam.configParam.HeartbeatThresh50 = 40;
920 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
921 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
922 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700923 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 pMac->roam.configParam.RTSThreshold = 2346;
925 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
926 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
927 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
928 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
929 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
930 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
931 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
932 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
933 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
934 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
935 {
936 pMac->roam.configParam.BssPreferValue[i] = i;
937 }
938 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
939 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
940 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
941 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
943 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
944 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
945 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
946 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
947 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800948 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
949 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700950 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700951#ifdef WLAN_AP_STA_CONCURRENCY
952 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
953 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
954 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
955 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
956 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700957 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
958 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
961 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
962 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
963 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700964#ifdef WLAN_FEATURE_VOWIFI_11R
965 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700967#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
968 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
969 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
970 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
971 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
972 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
973 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
974 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
975 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
976 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
977 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
978 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -0800979 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700980#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700981#ifdef WLAN_FEATURE_11AC
982 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
983#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 pMac->roam.configParam.addTSWhenACMIsOff = 0;
986 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700987
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700988 //Remove this code once SLM_Sessionization is supported
989 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700990 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700991
Jeff Johnsone7245742012-09-05 17:12:55 -0700992}
Jeff Johnson295189b2012-06-20 16:38:30 -0700993eCsrBand csrGetCurrentBand(tHalHandle hHal)
994{
995 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
996 return pMac->roam.configParam.bandCapability;
997}
Srinivas Girigowdade697412013-02-14 16:31:48 -0800998
999#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1000tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
1001{
1002 /* Get country code from CFG */
1003 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
1004 tANI_U8 i = 0;
1005 v_BOOL_t retVal = FALSE;
1006 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1007 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1008
1009 /* Compare against KR valid list */
1010 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1011 (NULL != pCountryValidChannelList))
1012 {
1013 for (i = 0; i <(*pNumChannels); i++)
1014 {
1015 if (channel == pCountryValidChannelList[i])
1016 {
1017 retVal = TRUE;
1018 break;
1019 }
1020 }
1021 }
1022 else
1023 {
1024 retVal = csrRoamIsChannelValid(pMac, channel);
1025 }
1026
1027 return retVal;
1028}
1029
1030void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1031{
1032 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1033 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1034}
1035
1036/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001037 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001038*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001039eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001040{
1041 eHalStatus status = eHAL_STATUS_SUCCESS;
1042 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1043
1044 /* Free up the memory first (if required) */
1045 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1046 {
1047 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1048 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001049 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001050 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001051 return status;
1052}
1053
1054
1055
1056/*
1057 This function flushes the roam scan cache and creates fresh cache
1058 based on the input channel list
1059*/
1060eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1061 const tANI_U8 *pChannelList,
1062 const tANI_U8 numChannels)
1063{
1064 eHalStatus status = eHAL_STATUS_SUCCESS;
1065 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1066
Srinivas Girigowdade697412013-02-14 16:31:48 -08001067 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1068
1069 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1070 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1071
1072 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1073 {
1074 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1075 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1076 return eHAL_STATUS_RESOURCES;
1077 }
1078
1079 /* Update the roam global structure */
1080 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1081 pChannelList,
1082 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1083 return status;
1084}
1085
1086/* This function modifies the bgscan channel list set via config ini or
1087 runtime, whenever the band changes.
1088 if the band is auto, then no operation is performed on the channel list
1089 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1090 if the band is 5G, then make sure channel list contains only 5G valid channels
1091*/
1092eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1093 eCsrBand eBand)
1094{
1095 eHalStatus status = eHAL_STATUS_SUCCESS;
1096 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1097 tANI_U8 outNumChannels = 0;
1098 tANI_U8 inNumChannels = 0;
1099 tANI_U8 *inPtr = NULL;
1100 tANI_U8 i = 0;
1101 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1102
1103 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1104
1105 {
1106 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1107 "No update required for channel list "
1108 "either cfg.ini channel list is not set up or "
1109 "auto band (Band %d)", eBand);
1110 return status;
1111 }
1112
1113 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1114 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1115 if (eCSR_BAND_24 == eBand)
1116 {
1117 for (i = 0; i < inNumChannels; i++)
1118 {
1119 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1120 {
1121 ChannelList[outNumChannels++] = inPtr[i];
1122 }
1123 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001124 csrFlushBgScanRoamChannelList(pMac);
1125 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001126 }
1127 else if (eCSR_BAND_5G == eBand)
1128 {
1129 for (i = 0; i < inNumChannels; i++)
1130 {
1131 /* Add 5G Non-DFS channel */
1132 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1133 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1134 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1135 {
1136 ChannelList[outNumChannels++] = inPtr[i];
1137 }
1138 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001139 csrFlushBgScanRoamChannelList(pMac);
1140 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001141 }
1142 else if (eCSR_BAND_ALL == eBand)
1143 {
1144 for (i = 0; i < inNumChannels; i++)
1145 {
1146 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1147 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1148 {
1149 ChannelList[outNumChannels++] = inPtr[i];
1150 }
1151 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001152 csrFlushBgScanRoamChannelList(pMac);
1153 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001154 }
1155 else
1156 {
1157 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1158 "Invalid band, No operation carried out (Band %d)", eBand);
1159 status = eHAL_STATUS_INVALID_PARAMETER;
1160 }
1161
1162 return status;
1163}
1164
1165/*
1166 This function initializes the valid channel list based on country code
1167*/
1168eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1169 tANI_U8 Revision)
1170{
1171 eHalStatus status = eHAL_STATUS_SUCCESS;
1172 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001173 tANI_U8 **pOutChannelList = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001174 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1175 const tANI_U8 *pChannelList = NULL;
1176
1177 if (SME_KR_3 == Revision)
1178 {
1179 pChannelList = KR_3;
1180 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1181 }
1182 else if (SME_KR_24 == Revision)
1183 {
1184 pChannelList = KR_24;
1185 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1186 }
1187 else if (SME_KR_25 == Revision)
1188 {
1189 pChannelList = KR_25;
1190 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1191 }
1192 else
1193 return eHAL_STATUS_INVALID_PARAMETER;
1194
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001195 /* Free any existing channel list */
1196 vos_mem_free(*pOutChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001197
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001198 *pOutChannelList = vos_mem_malloc(*pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001199
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001200 if (NULL == *pOutChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001201 {
1202 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1203 *pNumChannels = 0;
1204 return eHAL_STATUS_RESOURCES;
1205 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001206 /* Update the roam global structure */
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001207 palCopyMemory(pMac->hHdd, *pOutChannelList, pChannelList, *pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001208 return status;
1209}
1210
1211#endif
1212
Jeff Johnson295189b2012-06-20 16:38:30 -07001213eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1214{
1215 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1216 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1218 (eBand == eCSR_BAND_24))
1219 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001220 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001222 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001223 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 pMac->roam.configParam.uCfgDot11Mode, eBand);
1225 return eHAL_STATUS_INVALID_PARAMETER;
1226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1228 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1229 (eBand == eCSR_BAND_5G))
1230 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001231 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001233 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001234 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 pMac->roam.configParam.uCfgDot11Mode, eBand);
1236 return eHAL_STATUS_INVALID_PARAMETER;
1237 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001238 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001239 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001240 pMac->roam.configParam.eBand = eBand;
1241 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001243#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1244 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 status = csrInitGetChannels( pMac );
1247 if (eHAL_STATUS_SUCCESS == status)
1248 csrInitChannelList( hHal );
1249 return status;
1250}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001251
1252
Jeff Johnsone7245742012-09-05 17:12:55 -07001253/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1254 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1255 * Ideally we should have kept the ini value and enum value same and representing the same
1256 * cb values as in 11n standard i.e.
1257 * Set to 1 (SCA) if the secondary channel is above the primary channel
1258 * Set to 3 (SCB) if the secondary channel is below the primary channel
1259 * Set to 0 (SCN) if no secondary channel is present
1260 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1261 * 0 - secondary none
1262 * 1 - secondary LOW
1263 * 2 - secondary HIGH
1264 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1265 * The enum values are as follows:
1266 * PHY_SINGLE_CHANNEL_CENTERED = 0
1267 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1268 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1269 */
1270ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1271{
1272
1273 ePhyChanBondState phyCbState;
1274 switch (cbIniValue) {
1275 // secondary none
1276 case 0:
1277 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1278 break;
1279 // secondary LOW
1280 case 1:
1281 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1282 break;
1283 // secondary HIGH
1284 case 2:
1285 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1286 break;
1287#ifdef WLAN_FEATURE_11AC
1288 case 3:
1289 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1290 break;
1291 case 4:
1292 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1293 break;
1294 case 5:
1295 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1296 break;
1297 case 6:
1298 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1299 break;
1300 case 7:
1301 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1302 break;
1303 case 8:
1304 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1305 break;
1306 case 9:
1307 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1308 break;
1309#endif
1310 default:
1311 // If an invalid value is passed, disable CHANNEL BONDING
1312 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1313 break;
1314 }
1315 return phyCbState;
1316}
1317
1318v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1319{
1320
1321 v_U32_t cbIniValue;
1322 switch (phyCbState) {
1323 // secondary none
1324 case PHY_SINGLE_CHANNEL_CENTERED:
1325 cbIniValue = 0;
1326 break;
1327 // secondary LOW
1328 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1329 cbIniValue = 1;
1330 break;
1331 // secondary HIGH
1332 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1333 cbIniValue = 2;
1334 break;
1335#ifdef WLAN_FEATURE_11AC
1336 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1337 cbIniValue = 3;
1338 break;
1339 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1340 cbIniValue = 4;
1341 break;
1342 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1343 cbIniValue = 5;
1344 break;
1345 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1346 cbIniValue = 6;
1347 break;
1348 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1349 cbIniValue = 7;
1350 break;
1351 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1352 cbIniValue = 8;
1353 break;
1354 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1355 cbIniValue = 9;
1356 break;
1357#endif
1358 default:
1359 // return some invalid value
1360 cbIniValue = 10;
1361 break;
1362 }
1363 return cbIniValue;
1364}
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1367{
1368 eHalStatus status = eHAL_STATUS_SUCCESS;
1369
1370 if(pParam)
1371 {
1372 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1373 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1374 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1375 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1376 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1377 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1378
1379 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001380 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1381
Jeff Johnsone7245742012-09-05 17:12:55 -07001382 /* channelBondingMode5GHz plays a dual role right now
1383 * 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
1384 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1385 */
1386 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001388 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001389 }
1390 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1391 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1392 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001393 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001394 }
1395 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1397 pMac->roam.configParam.phyMode = pParam->phyMode;
1398 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1399 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1400 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1401 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1402 pMac->roam.configParam.TxRate = pParam->TxRate;
1403 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1404 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1405 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1406 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1407 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001408 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 //if HDD passed down non zero values then only update,
1410 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001411 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 {
1413 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1414 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001415 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 {
1417 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1418 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001419 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 {
1421 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1422 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001423 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 {
1425 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1426 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001427 if (pParam->nActiveMaxChnTimeBtc)
1428 {
1429 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1430 }
1431 if (pParam->nActiveMinChnTimeBtc)
1432 {
1433 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1434 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001435#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001436 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001437 {
1438 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1439 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001440 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001441 {
1442 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1443 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001444 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001445 {
1446 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1447 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001448 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001449 {
1450 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1451 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001452 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001453 {
1454 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1455 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001456 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001457 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001458 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1459 }
1460 if (pParam->nNumP2PChanCombinedConc)
1461 {
1462 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001463 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001464#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001466 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 {
1468 //Change the unit from second to microsecond
1469 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1471 {
1472 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1473 }
1474 else
1475 {
1476 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1477 }
1478 }
1479 else
1480 {
1481 pMac->roam.configParam.impsSleepTime = 0;
1482 }
1483 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1485 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 //if HDD passed down non zero values for age params, then only update,
1487 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001488 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 {
1490 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 if(pParam->scanAgeTimeNCNPS)
1493 {
1494 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if(pParam->scanAgeTimeNCPS)
1497 {
1498 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001500 if(pParam->scanAgeTimeCNPS)
1501 {
1502 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1503 }
1504 if(pParam->scanAgeTimeCPS)
1505 {
1506 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1507 }
1508
1509 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1510 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1511 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1512 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1513 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1514 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1516 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1518 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1519 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1520 //Assign this before calling CsrInit11dInfo
1521 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 if( csrIs11dSupported( pMac ) )
1523 {
1524 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1525 }
1526 else
1527 {
1528 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1529 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001530
1531 /* Initialize the power + channel information if 11h is enabled.
1532 If 11d is enabled this information has already been initialized */
1533 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1534 {
1535 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1536 }
1537
1538
Jeff Johnson295189b2012-06-20 16:38:30 -07001539#ifdef WLAN_FEATURE_VOWIFI_11R
1540 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001541 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001542#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001543#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001545 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001546 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001547 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001548 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001549 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001550 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001551 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001552 pMac->roam.configParam.nProbes = pParam->nProbes;
1553 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001554#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001555#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1556 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
1557#endif
1558#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001559 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1560#endif
1561
Jeff Johnson295189b2012-06-20 16:38:30 -07001562#ifdef FEATURE_WLAN_CCX
1563 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1564#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001565#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1566 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001567 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1568 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1569 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1570 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1571 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1572 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1573 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1574 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 {
1576 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001577 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1579 {
1580 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1581 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001582 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 }
1584#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1586 pMac->scan.fValidateList = pParam->fValidateList;
1587 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1588 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001589 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001591 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1592 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1593 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1594 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1595 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1596 * single session
1597 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001598 //Remove this code once SLM_Sessionization is supported
1599 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001600 pMac->roam.configParam.doBMPSWorkaround = 0;
1601
Jeff Johnsone7245742012-09-05 17:12:55 -07001602#ifdef WLAN_FEATURE_11AC
1603 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001604 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001605 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001606#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001607 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 }
1609
1610 return status;
1611}
1612
Jeff Johnson295189b2012-06-20 16:38:30 -07001613eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1614{
1615 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 if(pParam)
1617 {
1618 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1619 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1620 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1621 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1622 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1623 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001624 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1625 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1627 pParam->phyMode = pMac->roam.configParam.phyMode;
1628 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1629 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1630 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1631 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1632 pParam->TxRate = pMac->roam.configParam.TxRate;
1633 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1634 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1635 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1636 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1637 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1639 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1640 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1641 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001642 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1643 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1644 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001645#ifdef WLAN_AP_STA_CONCURRENCY
1646 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1647 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1648 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1649 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1650 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001651 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1652 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 //Change the unit from microsecond to second
1655 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1656 pParam->eBand = pMac->roam.configParam.eBand;
1657 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1658 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1659 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1660 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1661 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1662 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1663 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1664 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1665 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1666 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1667 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1668 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1669 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1671 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1672 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1673 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1675 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1676 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1677 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1678 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001679 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001680 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001681 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001682 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001683
1684#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1685 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1686#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001687#ifdef WLAN_FEATURE_11AC
1688 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001689 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001690 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001691#endif
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001692 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 csrSetChannels(pMac, pParam);
1694
1695 status = eHAL_STATUS_SUCCESS;
1696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 return (status);
1698}
1699
Jeff Johnson295189b2012-06-20 16:38:30 -07001700eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1701{
1702 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1703 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1704 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1705 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 do
1707 {
1708 if(eCSR_BAND_24 == eBand)
1709 {
1710 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1711 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1712 }
1713 if(eCSR_BAND_5G == eBand)
1714 {
1715 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1716 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1717 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1718 )
1719 {
1720 break;
1721 }
1722 }
1723 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1724 {
1725 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1726 }
1727 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1728 {
1729 newPhyMode = eCSR_DOT11_MODE_AUTO;
1730 }
1731 else
1732 {
1733 //Check for dual band and higher capability first
1734 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1735 {
1736 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1737 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1738 }
1739 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1740 {
1741 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1742 if(eCSR_BAND_24 == eBand) break;
1743 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1744 eBand = eCSR_BAND_5G;
1745 }
1746 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1747 {
1748 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1749 if(eCSR_BAND_5G == eBand) break;
1750 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1751 eBand = eCSR_BAND_24;
1752 }
1753 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1754 {
1755 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1756 if(eCSR_BAND_5G == eBand) break;
1757 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1758 eBand = eCSR_BAND_24;
1759 }
1760 else if(eCSR_DOT11_MODE_11n & phyMode)
1761 {
1762 newPhyMode = eCSR_DOT11_MODE_11n;
1763 }
1764 else if(eCSR_DOT11_MODE_abg & phyMode)
1765 {
1766 newPhyMode = eCSR_DOT11_MODE_abg;
1767 }
1768 else if(eCSR_DOT11_MODE_11a & phyMode)
1769 {
1770 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1771 {
1772 if(eCSR_BAND_ALL == eBand)
1773 {
1774 newPhyMode = eCSR_DOT11_MODE_abg;
1775 }
1776 else
1777 {
1778 //bad setting
1779 break;
1780 }
1781 }
1782 else
1783 {
1784 newPhyMode = eCSR_DOT11_MODE_11a;
1785 eBand = eCSR_BAND_5G;
1786 }
1787 }
1788 else if(eCSR_DOT11_MODE_11g & phyMode)
1789 {
1790 newPhyMode = eCSR_DOT11_MODE_11g;
1791 eBand = eCSR_BAND_24;
1792 }
1793 else if(eCSR_DOT11_MODE_11b & phyMode)
1794 {
1795 newPhyMode = eCSR_DOT11_MODE_11b;
1796 eBand = eCSR_BAND_24;
1797 }
1798 else
1799 {
1800 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001801 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 newPhyMode = eCSR_DOT11_MODE_AUTO;
1803 }
1804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 //Done validating
1806 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 //Now we need to check whether a restart is needed.
1808 if(eBand != pMac->roam.configParam.eBand)
1809 {
1810 fRestartNeeded = eANI_BOOLEAN_TRUE;
1811 break;
1812 }
1813 if(newPhyMode != pMac->roam.configParam.phyMode)
1814 {
1815 fRestartNeeded = eANI_BOOLEAN_TRUE;
1816 break;
1817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 if(HAL_STATUS_SUCCESS(status))
1820 {
1821 pMac->roam.configParam.eBand = eBand;
1822 pMac->roam.configParam.phyMode = newPhyMode;
1823 if(pfRestartNeeded)
1824 {
1825 *pfRestartNeeded = fRestartNeeded;
1826 }
1827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 return (status);
1829}
1830
Jeff Johnson295189b2012-06-20 16:38:30 -07001831void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1832{
1833 tANI_U8 Index;
1834 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 // for dual band NICs, don't need to trim the channel list....
1836 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1837 {
1838 // 2.4 GHz band operation requires the channel list to be trimmed to
1839 // the 2.4 GHz channels only...
1840 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1841 {
1842 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1843 Index++ )
1844 {
1845 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1846 {
1847 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1848 cChannels++;
1849 }
1850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1852 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1853 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1854 // only if we need to.
1855 //
1856 // The amount of memory to clear is the number of channesl that we trimmed
1857 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1858
1859 if ( pChannelList->numChannels > cChannels )
1860 {
1861 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1862 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1863
1864 }
1865
1866 pChannelList->numChannels = cChannels;
1867 }
1868 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1869 {
1870 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1871 {
1872 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1873 {
1874 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1875 cChannels++;
1876 }
1877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1879 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1880 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1881 // only if we need to.
1882 //
1883 // The amount of memory to clear is the number of channesl that we trimmed
1884 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1885 if ( pChannelList->numChannels > cChannels )
1886 {
1887 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1888 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1889 }
1890
1891 pChannelList->numChannels = cChannels;
1892 }
1893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001894}
Jeff Johnson295189b2012-06-20 16:38:30 -07001895#define INFRA_AP_DEFAULT_CHANNEL 6
1896eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1897{
1898 tANI_U8 index= 0;
1899 eHalStatus status = eHAL_STATUS_FAILURE;
1900 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1901 {
1902 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1903 status = eHAL_STATUS_SUCCESS;
1904 break;
1905 }
1906 }
1907 return status;
1908}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001909
1910eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1911{
1912 eHalStatus status = eHAL_STATUS_SUCCESS;
1913 tANI_U8 num20MHzChannelsFound = 0;
1914 VOS_STATUS vosStatus;
1915 tANI_U8 num40MHzChannelsFound = 0;
1916 tANI_U8 Index = 0;
1917 tANI_U8 channelList = 0;
1918
1919 // Updating the defaultpower Table for changed Domain Id
1920 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1921 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1922
1923 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1924 {
1925 smsLog( pMac, LOGE, FL("failed to get channels"));
1926 status = eHAL_STATUS_FAILURE;
1927 }
1928 else
1929 {
1930 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1931 {
1932 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1933 }
1934
1935 // Move the only 5GHZ channel list to the global data,
1936 // As 2.4GHZ list coming from the AP for the changed domain
1937 // structure -- this will be used as the scan list
1938 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1939 {
1940 // If Channel is 5GHz just break the for loop
1941 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
1942 break;
1943 }
1944 // Update the 5G channels from nv.bin
1945 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1946 {
1947 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
1948 {
Krunal Sonia75019a2013-05-01 01:08:22 -07001949 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1950 {
1951 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
1952 channelList++;
1953 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001954 }
1955 }
1956
1957 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1958 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
1959 // Filling the remaining index as Zero Just for causion
1960 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
1961 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
1962 }
1963 return status;
1964}
1965
1966eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
1967{
1968 eHalStatus status = eHAL_STATUS_SUCCESS;
1969 tANI_U8 num20MHzChannelsFound = 0;
1970 VOS_STATUS vosStatus;
1971 tANI_U8 Index = 0;
1972 tANI_U8 num40MHzChannelsFound = 0;
1973 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
1974 tANI_U8 channelList = 0;
1975
1976 // Read the scan channel list (including the power limit) from EEPROM
1977 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1978 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1979
1980 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1981 {
1982 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1983 status = eHAL_STATUS_FAILURE;
1984 }
1985 else
1986 {
1987 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1988 {
1989 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1990 }
1991
1992 // Move the 2.4GHZ channel list only to the global data,
1993 // As 5GHz list been provided by AP as part of 11d IE
1994 // structure -- this will be used as the scan list
1995 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
1996 {
1997 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
1998 {
1999 // First taking the 5GHz channel list backup
2000 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2001 nuum5GchannelListBackup++;
2002 }
2003 }
2004 // Updating the 2.4GHz list
2005 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2006 {
2007 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
2008 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[Index].chanId;
2009 }
2010 // Restoring the Backed up 5 GHZ channels
2011 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2012 {
Krunal Sonia75019a2013-05-01 01:08:22 -07002013 if (Index < WNI_CFG_VALID_CHANNEL_LIST_LEN)
2014 {
2015 pMac->scan.base20MHzChannels.channelList[ Index ] = channelList5GBackup[channelList];
2016 Index++;
2017 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002018 }
2019
2020 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2021 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > Index) ? num20MHzChannelsFound : Index;
2022 }
2023 return (status);
2024}
2025
Jeff Johnson295189b2012-06-20 16:38:30 -07002026eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2027{
2028 eHalStatus status = eHAL_STATUS_SUCCESS;
2029 tANI_U8 num20MHzChannelsFound = 0;
2030 VOS_STATUS vosStatus;
2031 tANI_U8 Index = 0;
2032 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002033
Jeff Johnson295189b2012-06-20 16:38:30 -07002034
2035 //TODO: this interface changed to include the 40MHz channel list
2036 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2037 // Read the scan channel list (including the power limit) from EEPROM
2038 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2039 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2040 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002042 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 status = eHAL_STATUS_FAILURE;
2044 }
2045 else
2046 {
2047 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2048 {
2049 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2050 }
2051 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2052 // Move the channel list to the global data
2053 // structure -- this will be used as the scan list
2054 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2055 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 }
2058 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2059 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2060 {
2061 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2062 }
2063 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2064 {
2065 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2066 }
2067 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 return (status);
2070}
2071
Jeff Johnson295189b2012-06-20 16:38:30 -07002072eHalStatus csrInitChannelList( tHalHandle hHal )
2073{
2074 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2075 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2077 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002078 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2079 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002081 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083 return (status);
2084}
Jeff Johnson295189b2012-06-20 16:38:30 -07002085eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2086 tCsrUpdateConfigParam *pUpdateConfigParam)
2087{
2088 eHalStatus status = eHAL_STATUS_FAILURE;
2089 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2091 status = CsrInit11dInfo(pMac, ps11dinfo);
2092 return status;
2093}
2094
Jeff Johnson295189b2012-06-20 16:38:30 -07002095static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2096{
2097 eHalStatus status = eHAL_STATUS_FAILURE;
2098 tANI_U8 index;
2099 tANI_U32 count=0;
2100 tSirMacChanInfo *pChanInfo;
2101 tSirMacChanInfo *pChanInfoStart;
2102 tANI_BOOLEAN applyConfig = TRUE;
2103
2104 if(!ps11dinfo)
2105 {
2106 return (status);
2107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2109 {
2110 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2111 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2112 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2113 if(!HAL_STATUS_SUCCESS(status)) return (status);
2114 }
2115 else
2116 {
2117 //No change
2118 return (eHAL_STATUS_SUCCESS);
2119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 //legacy maintenance
2121 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2122 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2123 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 //Tush: at csropen get this initialized with default, during csr reset if this
2125 // already set with some value no need initilaize with default again
2126 if(0 == pMac->scan.countryCodeCurrent[0])
2127 {
2128 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2129 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2130 if(!HAL_STATUS_SUCCESS(status)) return (status);
2131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 // need to add the max power channel list
2133 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2134 {
2135 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2136 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002137 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2138 {
2139 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2140 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2141 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2142 pChanInfo++;
2143 count++;
2144 }
2145 if(count)
2146 {
2147 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2148 }
2149 palFreeMemory(pMac->hHdd, pChanInfoStart);
2150 }
2151 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2152 if( HAL_STATUS_SUCCESS(status) )
2153 {
2154 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2155 {
2156 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2157 {
2158 applyConfig = FALSE;
2159 }
2160 }
2161
2162 if(TRUE == applyConfig)
2163 {
2164 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002165 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002166 }
2167
2168 }
2169 return (status);
2170}
2171/* Initialize the Channel + Power List in the local cache and in the CFG */
2172eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2173{
2174 tANI_U8 index;
2175 tANI_U32 count=0;
2176 tSirMacChanInfo *pChanInfo;
2177 tSirMacChanInfo *pChanInfoStart;
2178
2179 if(!ps11dinfo || !pMac)
2180 {
2181 return eHAL_STATUS_FAILURE;
2182 }
2183
2184 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2185 {
2186 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2187 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002188
2189 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2190 {
2191 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2192 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2193 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2194 pChanInfo++;
2195 count++;
2196 }
2197 if(count)
2198 {
2199 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2200 }
2201 palFreeMemory(pMac->hHdd, pChanInfoStart);
2202 }
2203
Jeff Johnsone7245742012-09-05 17:12:55 -07002204 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002205}
2206
2207//pCommand may be NULL
2208//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2209void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2210{
2211 tListElem *pEntry, *pNextEntry;
2212 tSmeCmd *pDupCommand;
2213 tDblLinkList localList;
2214
2215 vos_mem_zero(&localList, sizeof(tDblLinkList));
2216 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2217 {
2218 smsLog(pMac, LOGE, FL(" failed to open list"));
2219 return;
2220 }
2221 csrLLLock( &pMac->sme.smeCmdPendingList );
2222 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2223 while( pEntry )
2224 {
2225 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2226 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 // Remove the previous command if..
2228 // - the new roam command is for the same RoamReason...
2229 // - the new roam command is a NewProfileList.
2230 // - the new roam command is a Forced Dissoc
2231 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2232 if (
2233 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2234 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002235 /* This peermac check is requried for Softap/GO scenarios
2236 * For STA scenario below OR check will suffice as pCommand will
2237 * always be NULL for STA scenarios
2238 */
2239 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2241 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2242 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2243 ||
2244 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002245 ( (sessionId == pDupCommand->sessionId) &&
2246 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 ((eCsrForcedDisassoc == eRoamReason) ||
2248 (eCsrHddIssued == eRoamReason))
2249 )
2250 )
2251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002252 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 // Remove the 'stale' roam command from the pending list...
2254 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2255 {
2256 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2257 }
2258 }
2259 pEntry = pNextEntry;
2260 }
2261 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2262
2263 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2264 {
2265 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2266 //Tell caller that the command is cancelled
2267 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2268 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2269 csrReleaseCommandRoam(pMac, pDupCommand);
2270 }
2271 csrLLClose(&localList);
2272}
Jeff Johnson295189b2012-06-20 16:38:30 -07002273eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2274 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2275{
2276 eHalStatus status = eHAL_STATUS_SUCCESS;
2277#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2278 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2279#endif
2280 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2282 {
2283 pSession = CSR_GET_SESSION( pMac, sessionId );
2284 }
2285 else
2286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002287 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 VOS_ASSERT(0);
2289 return eHAL_STATUS_FAILURE;
2290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002293 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002295 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2296 /*
2297 * Decrement bRefAssocStartCnt for FT reassoc failure.
2298 * Reason: For FT reassoc failures, we first call
2299 * csrRoamCallCallback before notifying a failed roam
2300 * completion through csrRoamComplete. The latter in
2301 * turn calls csrRoamProcessResults which tries to
2302 * once again call csrRoamCallCallback if bRefAssocStartCnt
2303 * is non-zero. Since this is redundant for FT reassoc
2304 * failure, decrement bRefAssocStartCnt.
2305 */
2306 pSession->bRefAssocStartCnt--;
2307 }
2308
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 if ( (pSession == NULL) ||
2310 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2311 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002312 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 return eHAL_STATUS_FAILURE;
2314 }
2315
2316 if(NULL != pSession->callback)
2317 {
2318 if( pRoamInfo )
2319 {
2320 pRoamInfo->sessionId = (tANI_U8)sessionId;
2321 }
2322
2323 /* avoid holding the global lock when making the roaming callback , original change came
2324 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2325 is possible on other OS ports where the callback may need to take locks to protect
2326 HDD state
2327 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2328 that may actually depend on the lock being held */
2329 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2330 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2331 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2332 }
2333 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2334 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2335#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2336 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2337 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2338 {
2339 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2340 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2341 if(NULL != pRoamInfo->pBssDesc)
2342 {
2343 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2344 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2347 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2348 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2349 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2350 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2351 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2354 {
2355 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2356 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2357 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 if(eCSR_ROAM_RESULT_FORCED == u2)
2360 {
2361 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2362 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2363 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2366 {
2367 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2368 connectionStatus.reason = eCSR_REASON_DISASSOC;
2369 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2372 {
2373 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2374 connectionStatus.reason = eCSR_REASON_DEAUTH;
2375 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002377#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2378
2379 return (status);
2380}
Jeff Johnson295189b2012-06-20 16:38:30 -07002381// Returns whether handoff is currently in progress or not
2382tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2383{
2384#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2385 return csrNeighborRoamIsHandoffInProgress(pMac);
2386#else
2387 return eANI_BOOLEAN_FALSE;
2388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002389}
Jeff Johnson295189b2012-06-20 16:38:30 -07002390eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2391 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2392{
2393 eHalStatus status = eHAL_STATUS_SUCCESS;
2394 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2395 tANI_U16 reasonCode;
2396 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002397
2398 if(!pSession)
2399 {
2400 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2401 return eHAL_STATUS_FAILURE;
2402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002403
2404 //Restore AC weight in case we change it
2405 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2406 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002407 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 -07002408 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2409 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2410 }
2411
2412 if ( fMICFailure )
2413 {
2414 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2415 }
2416 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2417 {
2418 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002419 }
2420 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 {
2422 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002424#ifdef WLAN_FEATURE_VOWIFI_11R
2425 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2426 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2427 {
2428 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2429 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002430 }
2431 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002432#endif
2433 if(pSession->pConnectBssDesc)
2434 {
2435 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2436 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002437
Jeff Johnson295189b2012-06-20 16:38:30 -07002438
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002439 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2440 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2441 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2442
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2444
2445 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2446
2447 if(HAL_STATUS_SUCCESS(status))
2448 {
2449 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002450#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2451 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2452 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2453 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002454 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2456 }
2457#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002458 }
2459 else
2460 {
2461 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2462 }
2463
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 return (status);
2465}
Jeff Johnson295189b2012-06-20 16:38:30 -07002466
Jeff Johnson295189b2012-06-20 16:38:30 -07002467/* ---------------------------------------------------------------------------
2468 \fn csrRoamIssueDisassociateStaCmd
2469 \brief csr function that HDD calls to disassociate a associated station
2470 \param sessionId - session Id for Soft AP
2471 \param pPeerMacAddr - MAC of associated station to delete
2472 \param reason - reason code, be one of the tSirMacReasonCodes
2473 \return eHalStatus
2474 ---------------------------------------------------------------------------*/
2475eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2476 tANI_U32 sessionId,
2477 tANI_U8 *pPeerMacAddr,
2478 tANI_U32 reason)
2479{
2480 eHalStatus status = eHAL_STATUS_SUCCESS;
2481 tSmeCmd *pCommand;
2482
2483 do
2484 {
2485 pCommand = csrGetCommandBuffer( pMac );
2486 if ( !pCommand )
2487 {
2488 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2489 status = eHAL_STATUS_RESOURCES;
2490 break;
2491 }
2492 pCommand->command = eSmeCommandRoam;
2493 pCommand->sessionId = (tANI_U8)sessionId;
2494 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2495 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2496 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2497 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2498 if( !HAL_STATUS_SUCCESS( status ) )
2499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002500 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 csrReleaseCommandRoam( pMac, pCommand );
2502 }
2503 }while(0);
2504
2505 return status;
2506}
2507
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509/* ---------------------------------------------------------------------------
2510 \fn csrRoamIssueDeauthSta
2511 \brief csr function that HDD calls to delete a associated station
2512 \param sessionId - session Id for Soft AP
2513 \param pPeerMacAddr - MAC of associated station to delete
2514 \param reason - reason code, be one of the tSirMacReasonCodes
2515 \return eHalStatus
2516 ---------------------------------------------------------------------------*/
2517eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2518 tANI_U32 sessionId,
2519 tANI_U8 *pPeerMacAddr,
2520 tANI_U32 reason)
2521{
2522 eHalStatus status = eHAL_STATUS_SUCCESS;
2523 tSmeCmd *pCommand;
2524
2525 do
2526 {
2527 pCommand = csrGetCommandBuffer( pMac );
2528 if ( !pCommand )
2529 {
2530 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2531 status = eHAL_STATUS_RESOURCES;
2532 break;
2533 }
2534 pCommand->command = eSmeCommandRoam;
2535 pCommand->sessionId = (tANI_U8)sessionId;
2536 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2537 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2538 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2539 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2540 if( !HAL_STATUS_SUCCESS( status ) )
2541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002542 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 csrReleaseCommandRoam( pMac, pCommand );
2544 }
2545 }while(0);
2546
2547 return status;
2548}
Jeff Johnson295189b2012-06-20 16:38:30 -07002549eHalStatus
2550csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2551 tANI_BOOLEAN bEnable )
2552{
2553 eHalStatus status = eHAL_STATUS_FAILURE;
2554 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2555 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 if (!pSession)
2557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002558 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 return (status);
2560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 if (pSession->pConnectBssDesc)
2562 {
2563 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2564 }
2565 else
2566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002567 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 return (status);
2569 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002570 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2572 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2574 return (status);
2575}
Jeff Johnson295189b2012-06-20 16:38:30 -07002576eHalStatus
2577csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2578 VOS_MODULE_ID modId, void *pUsrContext,
2579 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2580{
2581 eHalStatus status = eHAL_STATUS_SUCCESS;
2582 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2583 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 if (!pSession)
2585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002586 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002587 return (status);
2588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 if(pSession->pConnectBssDesc)
2590 {
2591 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2592 }
2593 else
2594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002595 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 return (status);
2597 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002598 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2600 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2602 return (status);
2603}
Jeff Johnson295189b2012-06-20 16:38:30 -07002604eHalStatus
2605csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2606 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2607{
2608 eHalStatus status = eHAL_STATUS_SUCCESS;
2609 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2610 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2611
2612 if (!pSession)
2613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002614 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 return (status);
2616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 if(pSession->pConnectBssDesc)
2618 {
2619 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2620 }
2621 else
2622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002623 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 return (status);
2625 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002626 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2628 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2629
2630 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2631
2632 return (status);
2633}
Jeff Johnson295189b2012-06-20 16:38:30 -07002634eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2635{
2636 eHalStatus status = eHAL_STATUS_SUCCESS;
2637 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2638 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002639
2640 if (!pSession)
2641 {
2642 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2643 return eHAL_STATUS_FAILURE;
2644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002645
2646 if(pSession->pConnectBssDesc)
2647 {
2648 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2649 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002650 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2652 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2654
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302655 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002656 if(!HAL_STATUS_SUCCESS(status))
2657 {
2658 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2659 }
2660
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 return (status);
2662}
2663
Jeff Johnson295189b2012-06-20 16:38:30 -07002664eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2665{
2666 eHalStatus status = eHAL_STATUS_SUCCESS;
2667 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2668 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002669
2670 if(!pSession)
2671 {
2672 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2673 return eHAL_STATUS_FAILURE;
2674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002675
2676 // If no BSS description was found in this connection (happens with start IBSS), then
2677 // nix the BSS description that we keep around for the connected BSS) and get out...
2678 if(NULL == pBssDesc)
2679 {
2680 csrFreeConnectBssDesc(pMac, sessionId);
2681 }
2682 else
2683 {
2684 size = pBssDesc->length + sizeof( pBssDesc->length );
2685 if(NULL != pSession->pConnectBssDesc)
2686 {
2687 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2688 {
2689 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2690 csrFreeConnectBssDesc(pMac, sessionId);
2691 }
2692 }
2693 if(NULL == pSession->pConnectBssDesc)
2694 {
2695 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2696 }
2697 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2698 {
2699 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2700 }
2701 }
2702
2703 return (status);
2704}
2705
Jeff Johnson295189b2012-06-20 16:38:30 -07002706eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2707 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2708 tDot11fBeaconIEs *pIes)
2709{
2710 eHalStatus status = eHAL_STATUS_SUCCESS;
2711 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302713 if (pIes == NULL)
2714 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002715
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 do
2717 {
2718 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2719 //get qos
2720 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2721 //get SSID
2722 if(pIes->SSID.present)
2723 {
2724 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2725 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2726 }
2727 else
2728 pBssConfig->SSID.length = 0;
2729 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002731 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 //Return failed if profile doesn't have an SSID either.
2733 if(pProfile->SSIDs.numOfSSIDs == 0)
2734 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002735 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 status = eHAL_STATUS_FAILURE;
2737 break;
2738 }
2739 }
2740 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2741 {
2742 pBssConfig->eBand = eCSR_BAND_5G;
2743 }
2744 else
2745 {
2746 pBssConfig->eBand = eCSR_BAND_24;
2747 }
2748 //phymode
2749 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2750 {
2751 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2752 }
2753 else
2754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002755 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 //force it
2757 if(eCSR_BAND_24 == pBssConfig->eBand)
2758 {
2759 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2760 }
2761 else
2762 {
2763 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2764 }
2765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 //Qos
2767 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2768 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2769 {
2770 //Joining BSS is not 11n capable and WMM is disabled on client.
2771 //Disable QoS and WMM
2772 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2773 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302774
2775 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302776 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302777 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2778 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2779 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2780 {
2781 //Joining BSS is 11n capable and WMM is disabled on AP.
2782 //Assume all HT AP's are QOS AP's and enable WMM
2783 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2784 }
2785
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 //auth type
2787 switch( pProfile->negotiatedAuthType )
2788 {
2789 default:
2790 case eCSR_AUTH_TYPE_WPA:
2791 case eCSR_AUTH_TYPE_WPA_PSK:
2792 case eCSR_AUTH_TYPE_WPA_NONE:
2793 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2794 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 case eCSR_AUTH_TYPE_SHARED_KEY:
2797 pBssConfig->authType = eSIR_SHARED_KEY;
2798 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 case eCSR_AUTH_TYPE_AUTOSWITCH:
2800 pBssConfig->authType = eSIR_AUTO_SWITCH;
2801 break;
2802 }
2803 //short slot time
2804 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2805 {
2806 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2807 }
2808 else
2809 {
2810 pBssConfig->uShortSlotTime = 0;
2811 }
2812 if(pBssConfig->BssCap.ibss)
2813 {
2814 //We don't support 11h on IBSS
2815 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2816 }
2817 else
2818 {
2819 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2820 }
2821 //power constraint
2822 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2823 //heartbeat
2824 if ( CSR_IS_11A_BSS( pBssDesc ) )
2825 {
2826 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2827 }
2828 else
2829 {
2830 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2831 }
2832 //Join timeout
2833 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002834 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 if ( pBssDesc->beaconInterval )
2836 {
2837 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002838 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 }
2840 else
2841 {
2842 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2843 }
2844 //validate CB
2845 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2846 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 return (status);
2848}
2849
Jeff Johnson295189b2012-06-20 16:38:30 -07002850static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2851 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2852{
2853 eHalStatus status = eHAL_STATUS_SUCCESS;
2854 tANI_U8 operationChannel = 0;
2855 tANI_U8 qAPisEnabled = FALSE;
2856 //SSID
2857 pBssConfig->SSID.length = 0;
2858 if(pProfile->SSIDs.numOfSSIDs)
2859 {
2860 //only use the first one
2861 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2862 }
2863 else
2864 {
2865 //SSID must present
2866 return eHAL_STATUS_FAILURE;
2867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 //Settomg up the capabilities
2869 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2870 {
2871 pBssConfig->BssCap.ibss = 1;
2872 }
2873 else
2874 {
2875 pBssConfig->BssCap.ess = 1;
2876 }
2877 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2878 {
2879 pBssConfig->BssCap.privacy = 1;
2880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 pBssConfig->eBand = pMac->roam.configParam.eBand;
2882 //phymode
2883 if(pProfile->ChannelInfo.ChannelList)
2884 {
2885 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2888 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 //QOS
2890 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 if ( pBssConfig->BssCap.ess == 1 )
2892 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 /*For Softap case enable WMM*/
2894 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2895 qAPisEnabled = TRUE;
2896 }
2897 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2899 qAPisEnabled = TRUE;
2900 } else {
2901 qAPisEnabled = FALSE;
2902 }
2903 } else {
2904 qAPisEnabled = TRUE;
2905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2907 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2908 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2909 )
2910 {
2911 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2912 } else {
2913 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2914 }
2915
2916 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002917 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 {
2919 default:
2920 case eCSR_AUTH_TYPE_WPA:
2921 case eCSR_AUTH_TYPE_WPA_PSK:
2922 case eCSR_AUTH_TYPE_WPA_NONE:
2923 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2924 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2925 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 case eCSR_AUTH_TYPE_SHARED_KEY:
2927 pBssConfig->authType = eSIR_SHARED_KEY;
2928 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 case eCSR_AUTH_TYPE_AUTOSWITCH:
2930 pBssConfig->authType = eSIR_AUTO_SWITCH;
2931 break;
2932 }
2933 //short slot time
2934 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2935 {
2936 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2937 }
2938 else
2939 {
2940 pBssConfig->uShortSlotTime = 0;
2941 }
2942 //power constraint. We don't support 11h on IBSS
2943 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2944 pBssConfig->uPowerLimit = 0;
2945 //heartbeat
2946 if ( eCSR_BAND_5G == pBssConfig->eBand )
2947 {
2948 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2949 }
2950 else
2951 {
2952 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2953 }
2954 //Join timeout
2955 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002956
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 return (status);
2958}
Jeff Johnson295189b2012-06-20 16:38:30 -07002959static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2960{
2961 eHalStatus status = eHAL_STATUS_FAILURE;
2962 tDot11fBeaconIEs *pIes = NULL;
2963
2964 do
2965 {
2966 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2967 {
2968 //err msg
2969 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002970 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 break;
2972 }
2973 //check if the AP is QAP & it supports APSD
2974 if( CSR_IS_QOS_BSS(pIes) )
2975 {
2976 return eHAL_STATUS_SUCCESS;
2977 }
2978 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 return status;
2980}
2981
Jeff Johnson295189b2012-06-20 16:38:30 -07002982void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2983{
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2985 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2986 // See !!Note: below in this function...
2987 tANI_U32 PrivacyEnabled = 0;
2988 tANI_U32 RsnEnabled = 0;
2989 tANI_U32 WepDefaultKeyId = 0;
2990 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2991 tANI_U32 Key0Length = 0;
2992 tANI_U32 Key1Length = 0;
2993 tANI_U32 Key2Length = 0;
2994 tANI_U32 Key3Length = 0;
2995
2996 // Reserve for the biggest key
2997 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2998 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2999 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3000 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3001
3002 switch ( pProfile->negotiatedUCEncryptionType )
3003 {
3004 case eCSR_ENCRYPT_TYPE_NONE:
3005
3006 // for NO encryption, turn off Privacy and Rsn.
3007 PrivacyEnabled = 0;
3008 RsnEnabled = 0;
3009
3010 // WEP key length and Wep Default Key ID don't matter in this case....
3011
3012 // clear out the WEP keys that may be hanging around.
3013 Key0Length = 0;
3014 Key1Length = 0;
3015 Key2Length = 0;
3016 Key3Length = 0;
3017
3018 break;
3019
3020 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303021 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003022
3023 // Privacy is ON. NO RSN for Wep40 static key.
3024 PrivacyEnabled = 1;
3025 RsnEnabled = 0;
3026
3027 // Set the Wep default key ID.
3028 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 // Wep key size if 5 bytes (40 bits).
3030 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3031
3032 // set encryption keys in the CFG database or clear those that are not present in this profile.
3033 if ( pProfile->Keys.KeyLength[0] )
3034 {
3035 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3036 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3037 }
3038 else
3039 {
3040 Key0Length = 0;
3041 }
3042
3043 if ( pProfile->Keys.KeyLength[1] )
3044 {
3045 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3046 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3047 }
3048 else
3049 {
3050 Key1Length = 0;
3051 }
3052
3053 if ( pProfile->Keys.KeyLength[2] )
3054 {
3055 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3056 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3057 }
3058 else
3059 {
3060 Key2Length = 0;
3061 }
3062
3063 if ( pProfile->Keys.KeyLength[3] )
3064 {
3065 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3066 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3067 }
3068 else
3069 {
3070 Key3Length = 0;
3071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 break;
3073
3074 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303075 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003076
3077 // Privacy is ON. NO RSN for Wep40 static key.
3078 PrivacyEnabled = 1;
3079 RsnEnabled = 0;
3080
3081 // Set the Wep default key ID.
3082 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3083
3084 // Wep key size if 13 bytes (104 bits).
3085 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3086
3087 // set encryption keys in the CFG database or clear those that are not present in this profile.
3088 if ( pProfile->Keys.KeyLength[0] )
3089 {
3090 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3091 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3092 }
3093 else
3094 {
3095 Key0Length = 0;
3096 }
3097
3098 if ( pProfile->Keys.KeyLength[1] )
3099 {
3100 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3101 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3102 }
3103 else
3104 {
3105 Key1Length = 0;
3106 }
3107
3108 if ( pProfile->Keys.KeyLength[2] )
3109 {
3110 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3111 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3112 }
3113 else
3114 {
3115 Key2Length = 0;
3116 }
3117
3118 if ( pProfile->Keys.KeyLength[3] )
3119 {
3120 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3121 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3122 }
3123 else
3124 {
3125 Key3Length = 0;
3126 }
3127
3128 break;
3129
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 case eCSR_ENCRYPT_TYPE_TKIP:
3131 case eCSR_ENCRYPT_TYPE_AES:
3132#ifdef FEATURE_WLAN_WAPI
3133 case eCSR_ENCRYPT_TYPE_WPI:
3134#endif /* FEATURE_WLAN_WAPI */
3135 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3136 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3137 PrivacyEnabled = (0 != fPrivacy);
3138
3139 // turn on RSN enabled for WPA associations
3140 RsnEnabled = 1;
3141
3142 // WEP key length and Wep Default Key ID don't matter in this case....
3143
3144 // clear out the static WEP keys that may be hanging around.
3145 Key0Length = 0;
3146 Key1Length = 0;
3147 Key2Length = 0;
3148 Key3Length = 0;
3149
3150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 default:
3152 PrivacyEnabled = 0;
3153 RsnEnabled = 0;
3154 break;
3155 }
3156
3157 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3158 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3159 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3160 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3161 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3162 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3163 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3164 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3165}
3166
Jeff Johnson295189b2012-06-20 16:38:30 -07003167static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3168{
3169 tANI_U32 len = 0;
3170 if(pSSID->length <= WNI_CFG_SSID_LEN)
3171 {
3172 len = pSSID->length;
3173 }
3174 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3175}
3176
Jeff Johnson295189b2012-06-20 16:38:30 -07003177eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3178{
3179 eHalStatus status = eHAL_STATUS_SUCCESS;
3180 tANI_U32 QoSEnabled;
3181 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 // set the CFG enable/disable variables based on the qosType being configured...
3183 switch( qosType )
3184 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3186 QoSEnabled = FALSE;
3187 WmeEnabled = TRUE;
3188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3190 QoSEnabled = FALSE;
3191 WmeEnabled = TRUE;
3192 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3194 QoSEnabled = FALSE;
3195 WmeEnabled = TRUE;
3196 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3198 QoSEnabled = TRUE;
3199 WmeEnabled = FALSE;
3200 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 case eCSR_MEDIUM_ACCESS_11e_HCF:
3202 QoSEnabled = TRUE;
3203 WmeEnabled = FALSE;
3204 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 default:
3206 case eCSR_MEDIUM_ACCESS_DCF:
3207 QoSEnabled = FALSE;
3208 WmeEnabled = FALSE;
3209 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 }
3211 //save the WMM setting for later use
3212 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3214 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 return (status);
3216}
Jeff Johnson295189b2012-06-20 16:38:30 -07003217static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3218 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3219{
3220 eHalStatus status = eHAL_STATUS_FAILURE;
3221 int i;
3222 eCsrCfgDot11Mode cfgDot11Mode;
3223 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3225 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003227
3228 if( NULL != pIes )
3229 {
3230 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 // Originally, we thought that for 11a networks, the 11a rates are always
3232 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3233 // appear in the Operational Rate set. Consequently, in either case, we
3234 // would blindly put the rates we support into our Operational Rate set
3235 // (including the basic rates, which we have already verified are
3236 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 // However, it turns out that this is not always the case. Some AP's
3238 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3239 // too. Now, we're a little more careful:
3240 pDstRate = pOpRateSet->rate;
3241 if(pIes->SuppRates.present)
3242 {
3243 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3244 {
3245 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3246 {
3247 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003248 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 }
3250 }
3251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3253 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3254 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3255 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3256 {
3257 // If there are Extended Rates in the beacon, we will reflect those
3258 // extended rates that we support in out Extended Operational Rate
3259 // set:
3260 pDstRate = pExRateSet->rate;
3261 if(pIes->ExtSuppRates.present)
3262 {
3263 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3264 {
3265 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3266 {
3267 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3268 pExRateSet->numRates++;
3269 }
3270 }
3271 }
3272 }
3273 }//Parsing BSSDesc
3274 else
3275 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003276 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 }
3278 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3279 return status;
3280}
3281
3282static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3283 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3284{
3285 int i;
3286 tANI_U8 *pDstRate;
3287 eCsrCfgDot11Mode cfgDot11Mode;
3288 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3289 tANI_U32 OperationalRatesLength = 0;
3290 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3291 tANI_U32 ExtendedOperationalRatesLength = 0;
3292 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3293 tANI_U32 ProprietaryOperationalRatesLength = 0;
3294 tANI_U32 PropRatesEnable = 0;
3295 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3296 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 if( NULL != pIes )
3299 {
3300 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 // Originally, we thought that for 11a networks, the 11a rates are always
3302 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3303 // appear in the Operational Rate set. Consequently, in either case, we
3304 // would blindly put the rates we support into our Operational Rate set
3305 // (including the basic rates, which we have already verified are
3306 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 // However, it turns out that this is not always the case. Some AP's
3308 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3309 // too. Now, we're a little more careful:
3310 pDstRate = OperationalRates;
3311 if(pIes->SuppRates.present)
3312 {
3313 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3314 {
3315 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3316 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3317 {
3318 *pDstRate++ = pIes->SuppRates.rates[ i ];
3319 OperationalRatesLength++;
3320 }
3321 }
3322 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3324 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3325 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3326 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3327 {
3328 // If there are Extended Rates in the beacon, we will reflect those
3329 // extended rates that we support in out Extended Operational Rate
3330 // set:
3331 pDstRate = ExtendedOperationalRates;
3332 if(pIes->ExtSuppRates.present)
3333 {
3334 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3335 {
3336 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3337 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3338 {
3339 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3340 ExtendedOperationalRatesLength++;
3341 }
3342 }
3343 }
3344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 // Enable proprietary MAC features if peer node is Airgo node and STA
3346 // user wants to use them
3347 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3348 {
3349 PropRatesEnable = 1;
3350 }
3351 else
3352 {
3353 PropRatesEnable = 0;
3354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 // For ANI network companions, we need to populate the proprietary rate
3356 // set with any proprietary rates we found in the beacon, only if user
3357 // allows them...
3358 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3359 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3360 {
3361 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3362 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3363 {
3364 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3365 }
3366 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3367 }
3368 else {
3369 // No proprietary modes...
3370 ProprietaryOperationalRatesLength = 0;
3371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 /* Get MCS Rate */
3373 pDstRate = MCSRateIdxSet;
3374 if ( pIes->HTCaps.present )
3375 {
3376 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3377 {
3378 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3379 {
3380 MCSRateLength++;
3381 *pDstRate++ = i;
3382 }
3383 }
3384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 // Set the operational rate set CFG variables...
3386 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3387 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3388 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3389 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3390 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3391 ProprietaryOperationalRates,
3392 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3393 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3394 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3395 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3396 }//Parsing BSSDesc
3397 else
3398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003399 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 }
3401}
3402
Jeff Johnson295189b2012-06-20 16:38:30 -07003403static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3404 tCsrRoamProfile *pProfile )
3405{
3406 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3407 { 8,
3408 { SIR_MAC_RATE_6,
3409 SIR_MAC_RATE_9,
3410 SIR_MAC_RATE_12,
3411 SIR_MAC_RATE_18,
3412 SIR_MAC_RATE_24,
3413 SIR_MAC_RATE_36,
3414 SIR_MAC_RATE_48,
3415 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3417 { 4,
3418 { SIR_MAC_RATE_1,
3419 SIR_MAC_RATE_2,
3420 SIR_MAC_RATE_5_5,
3421 SIR_MAC_RATE_11 } } };
3422
3423
3424 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3425 { SIR_MAC_RATE_72,
3426 SIR_MAC_RATE_96,
3427 SIR_MAC_RATE_108 } };
3428 eCsrCfgDot11Mode cfgDot11Mode;
3429 eCsrBand eBand;
3430 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3431 tANI_U32 OperationalRatesLength = 0;
3432 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3433 tANI_U32 ExtendedOperationalRatesLength = 0;
3434 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3435 tANI_U32 ProprietaryOperationalRatesLength = 0;
3436 tANI_U32 PropRatesEnable = 0;
3437 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 if(pProfile->ChannelInfo.ChannelList)
3439 {
3440 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3441 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3444 // networks, the 11b rates appear in the Operational Rate set. In either case,
3445 // we can blindly put the rates we support into our Operational Rate set
3446 // (including the basic rates, which we have already verified are supported
3447 // earlier in the roaming decision).
3448 if ( eCSR_BAND_5G == eBand )
3449 {
3450 // 11a rates into the Operational Rate Set.
3451 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3452 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3453 palCopyMemory( pMac->hHdd, OperationalRates,
3454 DefaultSupportedRates11a.supportedRateSet.rate,
3455 OperationalRatesLength );
3456
3457 // Nothing in the Extended rate set.
3458 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 // populate proprietary rates if user allows them
3460 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3461 {
3462 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3463 sizeof(*DefaultSupportedPropRates.propRate);
3464 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3465 DefaultSupportedPropRates.propRate,
3466 ProprietaryOperationalRatesLength );
3467 }
3468 else
3469 {
3470 // No proprietary modes
3471 ProprietaryOperationalRatesLength = 0;
3472 }
3473 }
3474 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3475 {
3476 // 11b rates into the Operational Rate Set.
3477 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3478 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3479 palCopyMemory( pMac->hHdd, OperationalRates,
3480 DefaultSupportedRates11b.supportedRateSet.rate,
3481 OperationalRatesLength );
3482 // Nothing in the Extended rate set.
3483 ExtendedOperationalRatesLength = 0;
3484 // No proprietary modes
3485 ProprietaryOperationalRatesLength = 0;
3486 }
3487 else
3488 {
3489 // 11G
3490
3491 // 11b rates into the Operational Rate Set.
3492 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3493 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3494 palCopyMemory( pMac->hHdd, OperationalRates,
3495 DefaultSupportedRates11b.supportedRateSet.rate,
3496 OperationalRatesLength );
3497
3498 // 11a rates go in the Extended rate set.
3499 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3500 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3501 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3502 DefaultSupportedRates11a.supportedRateSet.rate,
3503 ExtendedOperationalRatesLength );
3504
3505 // populate proprietary rates if user allows them
3506 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3507 {
3508 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3509 sizeof(*DefaultSupportedPropRates.propRate);
3510 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3511 DefaultSupportedPropRates.propRate,
3512 ProprietaryOperationalRatesLength );
3513 }
3514 else
3515 {
3516 // No proprietary modes
3517 ProprietaryOperationalRatesLength = 0;
3518 }
3519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3521 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3522 {
3523 PropRatesEnable = 1;
3524 }
3525 else
3526 {
3527 PropRatesEnable = 0;
3528 }
3529
3530 // Set the operational rate set CFG variables...
3531 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3532 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3533 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3534 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3535 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3536 ProprietaryOperationalRates,
3537 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3538 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003539}
Jeff Johnson295189b2012-06-20 16:38:30 -07003540void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3541{
3542 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3545 tANI_U32 sessionId;
3546 tSmeCmd *pCommand = NULL;
3547
3548 if(NULL == pEntry)
3549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003550 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 return;
3552 }
3553 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3554 sessionId = pCommand->sessionId;
3555
3556 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3557 {
3558 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3559 }
3560}
3561
Jeff Johnson295189b2012-06-20 16:38:30 -07003562//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3563tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3564{
3565 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3566 {
3567 return (WNI_CFG_PHY_MODE_11B);
3568 }
3569 else
3570 {
3571 if(eCSR_BAND_24 == band)
3572 return (WNI_CFG_PHY_MODE_11G);
3573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 return (WNI_CFG_PHY_MODE_11A);
3575}
Jeff Johnson295189b2012-06-20 16:38:30 -07003576
Jeff Johnsone7245742012-09-05 17:12:55 -07003577
3578#ifdef WLAN_FEATURE_11AC
3579ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3580{
3581 switch ( aniCBMode )
3582 {
3583 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3584 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3585 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3586 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3587 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3588 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3589 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3590 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3591 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003592 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003593 return PHY_SINGLE_CHANNEL_CENTERED;
3594 }
3595}
3596#endif
3597
Jeff Johnson295189b2012-06-20 16:38:30 -07003598//pIes may be NULL
3599eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3600 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3601 tDot11fBeaconIEs *pIes)
3602{
3603 eHalStatus status = eHAL_STATUS_SUCCESS;
3604 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3605 tANI_U8 channel = 0;
3606 //Make sure we have the domain info for the BSS we try to connect to.
3607 //Do we need to worry about sequence for OSs that are not Windows??
3608 if(pBssDesc)
3609 {
3610 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3611 {
3612 //Make sure the 11d info from this BSSDesc can be applied
3613 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3614 csrApplyCountryInformation( pMac, TRUE );
3615 }
Kiran4a17ebe2013-01-31 10:43:43 -08003616 if ((csrIs11dSupported (pMac)) && pIes)
3617 {
3618 if (!pIes->Country.present)
3619 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 //Qos
3623 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3624 //SSID
3625 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3626 //fragment threshold
3627 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3628 //RTS threshold
3629 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3630
3631 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3632
3633 //Auth type
3634 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3635 //encryption type
3636 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3637 //short slot time
3638 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 //11d
3640 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3641 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3642 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 /*//11h
3644 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3645 */
3646 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3647 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003648
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003649 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 {
3651 channel = pProfile->operationChannel;
3652 }
3653 else
3654 {
3655 if(pBssDesc)
3656 {
3657 channel = pBssDesc->channelId;
3658 }
3659 }
3660 if(0 != channel)
3661 {
3662 if(CSR_IS_CHANNEL_24GHZ(channel))
3663 {//for now if we are on 2.4 Ghz, CB will be always disabled
3664 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3665 }
3666 else
3667 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003668 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 }
3670 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003671#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003672 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3673 // in function csrConvertCBIniValueToPhyCBState()
3674 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3675 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003676 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003677 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003678 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003679 }
3680 else
3681 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003682 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003683 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003684 }
3685 else
3686#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3688 //Rate
3689 //Fixed Rate
3690 if(pBssDesc)
3691 {
3692 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3693 }
3694 else
3695 {
3696 csrSetCfgRateSetFromProfile(pMac, pProfile);
3697 }
3698 //Make this the last CFG to set. The callback will trigger a join_req
3699 //Join time out
3700 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3701
3702 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 return (status);
3704}
3705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3707 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3708{
3709 eHalStatus status;
3710 tBssConfigParam *pBssConfig;
3711 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003712
3713 if(!pSession)
3714 {
3715 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3716 return eHAL_STATUS_FAILURE;
3717 }
3718
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3720 if(HAL_STATUS_SUCCESS(status))
3721 {
3722 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3723 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3724 if(HAL_STATUS_SUCCESS(status))
3725 {
3726 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003727 /* This will allow to pass cbMode during join req */
3728 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 //For IBSS, we need to prepare some more information
3730 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 )
3733 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003734 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 }
3736 // If we are in an IBSS, then stop the IBSS...
3737 ////Not worry about WDS connection for now
3738 if ( csrIsConnStateIbss( pMac, sessionId ) )
3739 {
3740 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3741 }
3742 else
3743 {
3744 // if we are in an Infrastructure association....
3745 if ( csrIsConnStateInfra( pMac, sessionId ) )
3746 {
3747 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3748 // across SSIDs (roaming to a new SSID)... //
3749 //Not worry about WDS connection for now
3750 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3751 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3752 {
3753 // then we need to disassociate from the Infrastructure network...
3754 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3755 }
3756 else
3757 {
3758 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3759 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3760 if ( pBssDesc )
3761 {
3762 // Set parameters for this Bss.
3763 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3764 }
3765 }
3766 }
3767 else
3768 {
3769 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3770 // Nothing to stop.
3771 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 )
3774 {
3775 // Set parameters for this Bss.
3776 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3777 }
3778 }
3779 }
3780 }//Success getting BSS config info
3781 palFreeMemory(pMac->hHdd, pBssConfig);
3782 }//Allocate memory
3783
3784 return (status);
3785}
3786
Jeff Johnson295189b2012-06-20 16:38:30 -07003787eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3788 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3789{
3790 eCsrJoinState eRoamState = eCsrContinueRoaming;
3791 eHalStatus status;
3792 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3793 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3794 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003795
3796 if(!pSession)
3797 {
3798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3799 return (eCsrStopRoaming);
3800 }
3801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 if( CSR_IS_WDS_STA( pProfile ) )
3803 {
3804 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3805 if( !HAL_STATUS_SUCCESS( status ) )
3806 {
3807 eRoamState = eCsrStopRoaming;
3808 }
3809 }
3810 else
3811 {
3812 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3813 {
3814 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3815 return (eCsrStopRoaming);
3816 }
3817 if ( csrIsInfraBssDesc( pBssDesc ) )
3818 {
3819 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3820 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3821 // have changed and handle the changes (without disturbing the current association).
3822
3823 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3824 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3825 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3826 )
3827 {
3828 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3829 // with Authenticating first. To force this, stop the current association (Disassociate) and
3830 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3831 // a new Association.
3832 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003834 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3836 {
3837 eRoamState = eCsrReassocToSelfNoCapChange;
3838 }
3839 else
3840 {
3841 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 //The key changes
3843 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3844 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3845 if(HAL_STATUS_SUCCESS(status))
3846 {
3847 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003848 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 //Reapply the config including Keys so reassoc is happening.
3850 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3851 if(!HAL_STATUS_SUCCESS(status))
3852 {
3853 eRoamState = eCsrStopRoaming;
3854 }
3855 }
3856 else
3857 {
3858 eRoamState = eCsrStopRoaming;
3859 }
3860 }//same profile
3861 }
3862 else
3863 {
3864 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3865 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003867 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 eRoamState = eCsrStopRoaming;
3869 }
3870 }
3871 }
3872 else
3873 {
3874 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3875 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3876 // work much better.
3877 //
3878 //
3879 // stop the existing network before attempting to join the new network...
3880 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3881 {
3882 eRoamState = eCsrStopRoaming;
3883 }
3884 }
3885 }//Infra
3886 else
3887 {
3888 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3889 {
3890 eRoamState = eCsrStopRoaming;
3891 }
3892 }
3893 if( pIesLocal && !pScanResult->pvIes )
3894 {
3895 palFreeMemory(pMac->hHdd, pIesLocal);
3896 }
3897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 return( eRoamState );
3899}
3900
Jeff Johnson295189b2012-06-20 16:38:30 -07003901eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3902 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3903{
3904 eHalStatus status = eHAL_STATUS_SUCCESS;
3905 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3907 roamInfo.pBssDesc = pBssDesc;
3908 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3909 return (status);
3910}
Jeff Johnson295189b2012-06-20 16:38:30 -07003911//In case no matching BSS is found, use whatever default we can find
3912static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3913{
3914 //Need to get all negotiated types in place first
3915 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003916 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 {
3918 default:
3919 case eCSR_AUTH_TYPE_WPA:
3920 case eCSR_AUTH_TYPE_WPA_PSK:
3921 case eCSR_AUTH_TYPE_WPA_NONE:
3922 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3923 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3924 break;
3925
3926 case eCSR_AUTH_TYPE_SHARED_KEY:
3927 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3928 break;
3929
3930 case eCSR_AUTH_TYPE_AUTOSWITCH:
3931 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3932 break;
3933 }
3934 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3935 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3936 //In this case, the multicast encryption needs to follow the uncast ones.
3937 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3938 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3939}
3940
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07003941
3942static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3943{
3944 switch(pCommand->u.roamCmd.roamReason)
3945 {
3946 case eCsrLostLink1:
3947 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
3948 break;
3949 case eCsrLostLink2:
3950 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
3951 break;
3952 case eCsrLostLink3:
3953 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
3954 break;
3955 default:
3956 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
3957 pCommand->u.roamCmd.roamReason);
3958 break;
3959 }
3960}
3961
Jeff Johnson295189b2012-06-20 16:38:30 -07003962static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3963{
3964 eHalStatus status;
3965 tCsrScanResult *pScanResult = NULL;
3966 eCsrJoinState eRoamState = eCsrStopRoaming;
3967 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3968 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3969 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3970#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3971 v_U8_t acm_mask = 0;
3972#endif
3973 tANI_U32 sessionId = pCommand->sessionId;
3974 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3975 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3976 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003977
3978 if(!pSession)
3979 {
3980 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3981 return (eCsrStopRoaming);
3982 }
3983
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 do
3985 {
3986 // Check for Cardbus eject condition, before trying to Roam to any BSS
3987 //***if( !balIsCardPresent(pAdapter) ) break;
3988
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07003989 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3990 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 if(NULL != pBSSList)
3992 {
3993 // When handling AP's capability change, continue to associate to
3994 // same BSS and make sure pRoamBssEntry is not Null.
3995 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3996 {
3997 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3998 {
3999 //Try the first BSS
4000 pCommand->u.roamCmd.pLastRoamBss = NULL;
4001 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4002 }
4003 else
4004 {
4005 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4006 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4007 {
4008 //Done with all the BSSs
4009 //In this case, will tell HDD the completion
4010 break;
4011 }
4012 else
4013 {
4014 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004015 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4017 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4018 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4019 pRoamInfo = &roamInfo;
4020 }
4021 }
4022 while(pCommand->u.roamCmd.pRoamBssEntry)
4023 {
4024 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 /*If concurrency enabled take the concurrent connected channel first. */
4026 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004027 if (vos_concurrent_sessions_running() &&
4028 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 {
4030 concurrentChannel =
4031 csrGetConcurrentOperationChannel(pMac);
4032 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004033 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 if ((concurrentChannel) &&
4035 (concurrentChannel ==
4036 pScanResult->Result.BssDescriptor.channelId))
4037 {
4038 //make this 0 because we do not want the
4039 //below check to pass as we don't want to
4040 //connect on other channel
4041 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4042 FL("Concurrent channel match =%d"),
4043 concurrentChannel);
4044 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 }
4046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004047
4048 if (!concurrentChannel)
4049 {
4050
4051 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4052 sessionId, &pScanResult->Result.BssDescriptor,
4053 pCommand->u.roamCmd.roamId)))
4054 {
4055 //Ok to roam this
4056 break;
4057 }
4058 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004059 else
4060 {
4061 eRoamState = eCsrStopRoamingDueToConcurrency;
4062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4064 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4065 {
4066 //Done with all the BSSs
4067 fDone = eANI_BOOLEAN_TRUE;
4068 break;
4069 }
4070 }
4071 if(fDone)
4072 {
4073 break;
4074 }
4075 }
4076 }
4077 //We have something to roam, tell HDD when it is infra.
4078 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4079 //For WDS, the indication is eCSR_ROAM_WDS_IND
4080 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4081 {
4082 if(pRoamInfo)
4083 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004084 if(pSession->bRefAssocStartCnt)
4085 {
4086 pSession->bRefAssocStartCnt--;
4087 //Complete the last association attemp because a new one is about to be tried
4088 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4089 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004091 }
4092 }
4093 /* If the roaming has stopped, not to continue the roaming command*/
4094 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4095 {
4096 //No need to complete roaming here as it already completes
4097 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4098 pCommand->u.roamCmd.roamReason);
4099 eRoamState = eCsrStopRoaming;
4100 csrSetAbortRoamingCommand(pMac, pCommand);
4101 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 }
4103 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4104 if(pScanResult)
4105 {
4106 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004109 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 fDone = eANI_BOOLEAN_TRUE;
4111 eRoamState = eCsrStopRoaming;
4112 break;
4113 }
4114 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4115 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4116 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4117 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4118 CSR_IS_QOS_BSS(pIesLocal) &&
4119 CSR_IS_UAPSD_BSS(pIesLocal) )
4120 {
4121#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4123 pIesLocal);
4124 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4125#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 }
4127 else
4128 {
4129 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4130 }
4131 if( pIesLocal && !pScanResult->Result.pvIes)
4132 {
4133 palFreeMemory(pMac->hHdd, pIesLocal);
4134 }
4135 }
4136 else
4137 {
4138 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4139 }
4140 roamInfo.pProfile = pProfile;
4141 pSession->bRefAssocStartCnt++;
4142 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4143 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4146 {
4147 // If this is a start IBSS profile, then we need to start the IBSS.
4148 if ( CSR_IS_START_IBSS(pProfile) )
4149 {
4150 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 // Attempt to start this IBSS...
4152 csrRoamAssignDefaultParam( pMac, pCommand );
4153 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4154 if(HAL_STATUS_SUCCESS(status))
4155 {
4156 if ( fSameIbss )
4157 {
4158 eRoamState = eCsrStartIbssSameIbss;
4159 }
4160 else
4161 {
4162 eRoamState = eCsrContinueRoaming;
4163 }
4164 }
4165 else
4166 {
4167 //it somehow fail need to stop
4168 eRoamState = eCsrStopRoaming;
4169 }
4170 break;
4171 }
4172 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 )
4175 {
4176 // Attempt to start this WDS...
4177 csrRoamAssignDefaultParam( pMac, pCommand );
4178 /* For AP WDS, we dont have any BSSDescription */
4179 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4180 if(HAL_STATUS_SUCCESS(status))
4181 {
4182 eRoamState = eCsrContinueRoaming;
4183 }
4184 else
4185 {
4186 //it somehow fail need to stop
4187 eRoamState = eCsrStopRoaming;
4188 }
4189 }
4190 else
4191 {
4192 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004193 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 eRoamState = eCsrStopRoaming;
4195 break;
4196 }
4197 }
4198 else //We have BSS
4199 {
4200 //Need to assign these value because they are used in csrIsSameProfile
4201 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4202 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4203 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4204 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4205 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4206 {
4207 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4208 {
4209 eRoamState = eCsrStartIbssSameIbss;
4210 break;
4211 }
4212 }
4213 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4214 {
4215 //trying to connect to the one already connected
4216 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4217 eRoamState = eCsrReassocToSelfNoCapChange;
4218 break;
4219 }
4220 // Attempt to Join this Bss...
4221 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4222 break;
4223 }
4224
4225 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4227 {
4228 //Need to indicate association_completion if association_start has been done
4229 if(pSession->bRefAssocStartCnt > 0)
4230 {
4231 pSession->bRefAssocStartCnt--;
4232 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004233 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4235 eCSR_ROAM_ASSOCIATION_COMPLETION,
4236 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4237 }
4238 }
4239
4240 return( eRoamState );
4241}
4242
Jeff Johnson295189b2012-06-20 16:38:30 -07004243static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4244{
4245 eHalStatus status = eHAL_STATUS_SUCCESS;
4246 eCsrJoinState RoamState;
4247 tANI_U32 sessionId = pCommand->sessionId;
4248
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 //***if( hddIsRadioStateOn( pAdapter ) )
4250 {
4251 // Attept to join a Bss...
4252 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004253
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004255 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 {
4257 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 // and if connected in Infrastructure mode...
4259 if ( csrIsConnStateInfra(pMac, sessionId) )
4260 {
4261 //... then we need to issue a disassociation
4262 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4263 if(!HAL_STATUS_SUCCESS(status))
4264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004265 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 //roam command is completed by caller in the failed case
4267 fComplete = eANI_BOOLEAN_TRUE;
4268 }
4269 }
4270 else if( csrIsConnStateIbss(pMac, sessionId) )
4271 {
4272 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4273 if(!HAL_STATUS_SUCCESS(status))
4274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004275 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 //roam command is completed by caller in the failed case
4277 fComplete = eANI_BOOLEAN_TRUE;
4278 }
4279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4281 {
4282 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4283 if(!HAL_STATUS_SUCCESS(status))
4284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004285 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 //roam command is completed by caller in the failed case
4287 fComplete = eANI_BOOLEAN_TRUE;
4288 }
4289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 else
4291 {
4292 fComplete = eANI_BOOLEAN_TRUE;
4293 }
4294 if(fComplete)
4295 {
4296 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004297 if(eCsrStopRoamingDueToConcurrency == RoamState)
4298 {
4299 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4300 }
4301 else
4302 {
4303 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 }
4306 }
4307 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4308 {
4309 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4310 }
4311 else if ( eCsrStartIbssSameIbss == RoamState )
4312 {
4313 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4314 }
4315 }//hddIsRadioStateOn
4316
4317 return status;
4318}
Jeff Johnson295189b2012-06-20 16:38:30 -07004319eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4320{
4321 tANI_U32 sessionId;
4322 tCsrRoamSession *pSession;
4323 tCsrScanResult *pScanResult = NULL;
4324 tSirBssDescription *pBssDesc = NULL;
4325 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 sessionId = pCommand->sessionId;
4327 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004328
4329 if(!pSession)
4330 {
4331 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4332 return eHAL_STATUS_FAILURE;
4333 }
4334
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4336 {
4337 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004338 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4340 return eHAL_STATUS_FAILURE;
4341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 if (pCommand->u.roamCmd.pRoamBssEntry)
4343 {
4344 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4345 pBssDesc = &pScanResult->Result.BssDescriptor;
4346 }
4347 else
4348 {
4349 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004350 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4352 return eHAL_STATUS_FAILURE;
4353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4355 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4356 return status;
4357}
4358
Jeff Johnson295189b2012-06-20 16:38:30 -07004359eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4360{
4361 eHalStatus status = eHAL_STATUS_SUCCESS;
4362 tCsrRoamInfo roamInfo;
4363 tANI_U32 sessionId = pCommand->sessionId;
4364 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004365
4366 if(!pSession)
4367 {
4368 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4369 return eHAL_STATUS_FAILURE;
4370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004371
4372 switch ( pCommand->u.roamCmd.roamReason )
4373 {
4374 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004376 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 case eCsrSmeIssuedDisassocForHandoff:
4379 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4380#if 0 // TODO : Confirm this change
4381 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4382#else
4383 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4384#endif
4385
4386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004389 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004392 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004393 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 case eCsrHddIssuedReassocToSameAP:
4396 case eCsrSmeIssuedReassocToSameAP:
4397 {
4398 tDot11fBeaconIEs *pIes = NULL;
4399
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 if( pSession->pConnectBssDesc )
4401 {
4402 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4403 if(!HAL_STATUS_SUCCESS(status) )
4404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004405 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 }
4407 else
4408 {
4409 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4410 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4411 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4413 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4414 pSession->bRefAssocStartCnt++;
4415 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4416 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4417
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004418 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004419 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4420 &pCommand->u.roamCmd.roamProfile );
4421 if(!HAL_STATUS_SUCCESS(status))
4422 {
4423 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004424 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004425 }
4426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 palFreeMemory(pMac->hHdd, pIes);
4428 pIes = NULL;
4429 }
4430 }
4431 break;
4432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004434 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4436 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004439 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4441 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 case eCsrStopBss:
4444 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4445 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4446 break;
4447
4448 case eCsrForcedDisassocSta:
4449 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4450 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4451 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4452 pCommand->u.roamCmd.reason);
4453 break;
4454
4455 case eCsrForcedDeauthSta:
4456 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4457 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4458 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4459 pCommand->u.roamCmd.reason);
4460 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004461
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004462 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004463 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004464 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4465 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467
4468 default:
4469 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4470
4471 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4472 {
4473 //Remember the roaming profile
4474 csrFreeRoamProfile(pMac, sessionId);
4475 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4476 {
4477 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4478 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4479 }
4480 }
4481
4482 //At this point, original uapsd_mask is saved in pCurRoamProfile
4483 //uapsd_mask in the pCommand may change from this point on.
4484
4485 // Attempt to roam with the new scan results (if we need to..)
4486 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004487 if(!HAL_STATUS_SUCCESS(status))
4488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004489 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 break;
4492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 return (status);
4494}
4495
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004496void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4497{
4498 pCommand->u.roamCmd.pLastRoamBss = NULL;
4499 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4500 //Because u.roamCmd is union and share with scanCmd and StatusChange
4501 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4502}
4503
Jeff Johnson295189b2012-06-20 16:38:30 -07004504void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4505{
4506 if(pCommand->u.roamCmd.fReleaseBssList)
4507 {
4508 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4509 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4510 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4511 }
4512 if(pCommand->u.roamCmd.fReleaseProfile)
4513 {
4514 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4515 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4516 }
4517 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4518 //Because u.roamCmd is union and share with scanCmd and StatusChange
4519 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4520}
4521
Jeff Johnson295189b2012-06-20 16:38:30 -07004522void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4523{
4524 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4525}
Jeff Johnson295189b2012-06-20 16:38:30 -07004526void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4527{
4528 tListElem *pEntry;
4529 tSmeCmd *pCommand;
4530 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004531 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4533 if ( pEntry )
4534 {
4535 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 // If the head of the queue is Active and it is a ROAM command, remove
4537 // and put this on the Free queue.
4538 if ( eSmeCommandRoam == pCommand->command )
4539 {
4540 //we need to process the result first before removing it from active list because state changes
4541 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4542 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4543 if( fReleaseCommand )
4544 {
4545 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4546 {
4547 csrReleaseCommandRoam( pMac, pCommand );
4548 }
4549 else
4550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004551 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004552 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 }
4554 }
4555 else
4556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004557 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004558 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 }
4560 }
4561 else
4562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004563 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 }
4565 }
4566 else
4567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004568 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 if( fReleaseCommand )
4571 {
4572 smeProcessPendingQueue( pMac );
4573 }
4574}
4575
Jeff Johnson295189b2012-06-20 16:38:30 -07004576void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4577{
4578 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004579 if(!pSession)
4580 {
4581 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4582 return;
4583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4585 pSession->NumPmkidCandidate = 0;
4586}
Jeff Johnson295189b2012-06-20 16:38:30 -07004587#ifdef FEATURE_WLAN_WAPI
4588void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4589{
4590 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004591 if(!pSession)
4592 {
4593 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4594 return;
4595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4597 pSession->NumBkidCandidate = 0;
4598}
4599#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004600extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4601
Jeff Johnson295189b2012-06-20 16:38:30 -07004602static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4603 tSirBssDescription *pSirBssDesc,
4604 tDot11fBeaconIEs *pIes)
4605{
4606 eHalStatus status = eHAL_STATUS_SUCCESS;
4607 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4608 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004609
4610 if(!pSession)
4611 {
4612 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4613 return eHAL_STATUS_FAILURE;
4614 }
4615
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 if((eCSR_AUTH_TYPE_WPA == authType) ||
4617 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4618 (eCSR_AUTH_TYPE_RSN == authType) ||
4619 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4620#if defined WLAN_FEATURE_VOWIFI_11R
4621 ||
4622 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4623 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4624#endif /* FEATURE_WLAN_WAPI */
4625#ifdef FEATURE_WLAN_WAPI
4626 ||
4627 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4628 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4629#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004630#ifdef WLAN_FEATURE_11W
4631 ||
4632 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4633#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 )
4635 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004638 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 }
4640 if( pIesLocal )
4641 {
4642 tANI_U32 nIeLen;
4643 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 if((eCSR_AUTH_TYPE_RSN == authType) ||
4645#if defined WLAN_FEATURE_VOWIFI_11R
4646 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4647 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4648#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004649#if defined WLAN_FEATURE_11W
4650 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4651#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4653 {
4654 if(pIesLocal->RSN.present)
4655 {
4656 //Calculate the actual length
4657 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4658 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4659 + 2 //akm_suite_count
4660 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4661 + 2; //reserved
4662 if( pIesLocal->RSN.pmkid_count )
4663 {
4664 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4665 }
4666 //nIeLen doesn't count EID and length fields
4667 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4668 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004669 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4671 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4672 //copy upto akm_suites
4673 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004674 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4675 pIeBuf += sizeof(pIesLocal->RSN.version);
4676 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4677 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4678 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4679 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 if( pIesLocal->RSN.pwise_cipher_suite_count )
4681 {
4682 //copy pwise_cipher_suites
4683 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4684 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4685 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4686 }
4687 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4688 pIeBuf += 2;
4689 if( pIesLocal->RSN.akm_suite_count )
4690 {
4691 //copy akm_suites
4692 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4693 pIesLocal->RSN.akm_suite_count * 4);
4694 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4695 }
4696 //copy the rest
4697 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4698 pIesLocal->RSN.akm_suite_count * 4,
4699 2 + pIesLocal->RSN.pmkid_count * 4);
4700 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4701 }
4702 }
4703 }
4704 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4705 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4706 {
4707 if(pIesLocal->WPA.present)
4708 {
4709 //Calculate the actual length
4710 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4711 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4712 + 2 //auth_suite_count
4713 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4714 // The WPA capabilities follows the Auth Suite (two octects)--
4715 // this field is optional, and we always "send" zero, so just
4716 // remove it. This is consistent with our assumptions in the
4717 // frames compiler; c.f. bug 15234:
4718 //nIeLen doesn't count EID and length fields
4719 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4720 {
4721 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4722 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4723 pIeBuf = pSession->pWpaRsnRspIE + 2;
4724 //Copy WPA OUI
4725 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4726 pIeBuf += 4;
4727 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4728 pIesLocal->WPA.unicast_cipher_count * 4);
4729 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4730 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4731 pIesLocal->WPA.auth_suite_count * 4);
4732 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4733 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4734 }
4735 }
4736 }
4737#ifdef FEATURE_WLAN_WAPI
4738 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4739 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4740 {
4741 if(pIesLocal->WAPI.present)
4742 {
4743 //Calculate the actual length
4744 nIeLen = 4 //version + akm_suite_count
4745 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4746 + 2 //pwise_cipher_suite_count
4747 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4748 + 6; //gp_cipher_suite + preauth + reserved
4749 if( pIesLocal->WAPI.bkid_count )
4750 {
4751 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4752 }
4753
4754 //nIeLen doesn't count EID and length fields
4755 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4756 {
4757 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4758 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4759 pIeBuf = pSession->pWapiRspIE + 2;
4760 //copy upto akm_suite_count
4761 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4762 pIeBuf += 4;
4763 if( pIesLocal->WAPI.akm_suite_count )
4764 {
4765 //copy akm_suites
4766 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4767 pIesLocal->WAPI.akm_suite_count * 4);
4768 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4769 }
4770 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4771 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4773 {
4774 //copy pwise_cipher_suites
4775 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4776 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4777 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4778 }
4779 //gp_cipher_suite + preauth + reserved + bkid_count
4780 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4781 pIeBuf += 8;
4782 if( pIesLocal->WAPI.bkid_count )
4783 {
4784 //copy akm_suites
4785 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4786 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4787 }
4788 pSession->nWapiRspIeLength = nIeLen + 2;
4789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 }
4791 }
4792#endif /* FEATURE_WLAN_WAPI */
4793 if( !pIes )
4794 {
4795 //locally allocated
4796 palFreeMemory(pMac->hHdd, pIesLocal);
4797 }
4798 }
4799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 return (status);
4801}
4802
Jeff Johnson295189b2012-06-20 16:38:30 -07004803static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4804{
4805 v_U8_t bACWeights[WLANTL_MAX_AC];
4806 v_U8_t paramBk, paramBe, paramVi, paramVo;
4807 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4809 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4810 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4811 //This doesn't address the case where the lower AC needs a real higher weight
4812 if( pIEs->WMMParams.present )
4813 {
4814 //no change to the lowest ones
4815 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4816 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4817 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4818 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4819 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4820 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4821 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4822 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4823 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4824 {
4825 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4826 fWeightChange = VOS_TRUE;
4827 }
4828 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4829 {
4830 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4831 fWeightChange = VOS_TRUE;
4832 }
4833 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4834 {
4835 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4836 fWeightChange = VOS_TRUE;
4837 }
4838 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4839 {
4840 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4841 fWeightChange = VOS_TRUE;
4842 }
4843 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4844 {
4845 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4846 fWeightChange = VOS_TRUE;
4847 }
4848 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4849 {
4850 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4851 fWeightChange = VOS_TRUE;
4852 }
4853 if(fWeightChange)
4854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004855 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 bACWeights[2], bACWeights[3]);
4857 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4858 }
4859 }
4860}
Jeff Johnson295189b2012-06-20 16:38:30 -07004861#ifdef WLAN_FEATURE_VOWIFI_11R
4862//Returns whether the current association is a 11r assoc or not
4863tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4864{
4865#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4866 return csrNeighborRoamIs11rAssoc(pMac);
4867#else
4868 return eANI_BOOLEAN_FALSE;
4869#endif
4870}
4871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004872#ifdef FEATURE_WLAN_CCX
4873//Returns whether the current association is a CCX assoc or not
4874tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4875{
4876#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4877 return csrNeighborRoamIsCCXAssoc(pMac);
4878#else
4879 return eANI_BOOLEAN_FALSE;
4880#endif
4881}
4882#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004883#ifdef FEATURE_WLAN_LFR
4884//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304885tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004886{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304887 tCsrRoamSession *pSession = NULL;
4888
4889 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4890 {
4891 pSession = CSR_GET_SESSION( pMac, sessionId );
4892 if (NULL != pSession->pCurRoamProfile)
4893 {
4894 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4895 {
4896 return eANI_BOOLEAN_FALSE;
4897 }
4898 }
4899 }
4900
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004901 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004902 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004903}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004904#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4905//Returns whether "FW based BG scan" is currently enabled...or not
4906tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
4907{
4908 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
4909}
4910#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004911#endif
4912
Jeff Johnson295189b2012-06-20 16:38:30 -07004913//Return true means the command can be release, else not
4914static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4915 eCsrRoamCompleteResult Result, void *Context )
4916{
4917 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4918 tSirBssDescription *pSirBssDesc = NULL;
4919 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4920 tCsrScanResult *pScanResult = NULL;
4921 tCsrRoamInfo roamInfo;
4922 sme_QosAssocInfo assocInfo;
4923 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4924 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4925 tDot11fBeaconIEs *pIes = NULL;
4926 tANI_U32 sessionId = pCommand->sessionId;
4927 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4928 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4929 eRoamCmdStatus roamStatus;
4930 eCsrRoamResult roamResult;
4931 eHalStatus status;
4932 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004934
Jeff Johnson32d95a32012-09-10 13:15:23 -07004935 if(!pSession)
4936 {
4937 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4938 return eANI_BOOLEAN_FALSE;
4939 }
4940
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004941 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 switch( Result )
4943 {
4944 case eCsrJoinSuccess:
4945 // reset the IDLE timer
4946 // !!
4947 // !! fall through to the next CASE statement here is intentional !!
4948 // !!
4949 case eCsrReassocSuccess:
4950 if(eCsrReassocSuccess == Result)
4951 {
4952 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4953 }
4954 else
4955 {
4956 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4957 }
4958 // Success Join Response from LIM. Tell NDIS we are connected and save the
4959 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004960 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4962 //always free the memory here
4963 if(pSession->pWpaRsnRspIE)
4964 {
4965 pSession->nWpaRsnRspIeLength = 0;
4966 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4967 pSession->pWpaRsnRspIE = NULL;
4968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004969#ifdef FEATURE_WLAN_WAPI
4970 if(pSession->pWapiRspIE)
4971 {
4972 pSession->nWapiRspIeLength = 0;
4973 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4974 pSession->pWapiRspIE = NULL;
4975 }
4976#endif /* FEATURE_WLAN_WAPI */
4977#ifdef FEATURE_WLAN_BTAMP_UT_RF
4978 //Reset counter so no join retry is needed.
4979 pSession->maxRetryCount = 0;
4980 csrRoamStopJoinRetryTimer(pMac, sessionId);
4981#endif
4982 /* This creates problem since we have not saved the connected profile.
4983 So moving this after saving the profile
4984 */
4985 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4986 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4987 {
4988 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4989 }
4990 else
4991 {
4992 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 //Use the last connected bssdesc for reassoc-ing to the same AP.
4995 //NOTE: What to do when reassoc to a different AP???
4996 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4997 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4998 {
4999 pSirBssDesc = pSession->pConnectBssDesc;
5000 if(pSirBssDesc)
5001 {
5002 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5003 }
5004 }
5005 else
5006 {
5007
5008 if(pCommand->u.roamCmd.pRoamBssEntry)
5009 {
5010 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5011 if(pScanResult != NULL)
5012 {
5013 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5014 //this can be NULL
5015 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5016 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5017 }
5018 }
5019 }
5020 if( pSirBssDesc )
5021 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5024 //Save WPA/RSN IE
5025 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5026#ifdef FEATURE_WLAN_CCX
5027 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5028#endif
5029
5030 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5031 // substate change.
5032 // Moving even save profile above so that below mentioned conditon is also met.
5033 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5034 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5036 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5037 // will be dropped for the security context may not be set properly.
5038 //
5039 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5040 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5041 //
5042 // this reordering was done on titan_prod_usb branch and is being replicated here.
5043 //
5044
5045 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5046 !pProfile->bWPSAssociation)
5047 {
5048 // Issue the set Context request to LIM to establish the Unicast STA context
5049 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5050 pProfile->negotiatedUCEncryptionType,
5051 pSirBssDesc, &(pSirBssDesc->bssId),
5052 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5053 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005054 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5056 }
5057 // Issue the set Context request to LIM to establish the Broadcast STA context
5058 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5059 pSirBssDesc, &BroadcastMac,
5060 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5061 }
5062 else
5063 {
5064 //Need to wait for supplicant authtication
5065 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 //Set the subestate to WaitForKey in case authentiation is needed
5067 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5068
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 if(pProfile->bWPSAssociation)
5070 {
5071 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5072 }
5073 else
5074 {
5075 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5076 }
5077
5078 //Save sessionId in case of timeout
5079 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5080 //This time should be long enough for the rest of the process plus setting key
5081 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5082 {
5083 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005084 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5086 }
5087 }
5088
5089 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5090 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 if(Context)
5092 {
5093 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5094 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5096 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5097#ifdef WLAN_FEATURE_VOWIFI_11R
5098 len += pJoinRsp->parsedRicRspLen;
5099#endif /* WLAN_FEATURE_VOWIFI_11R */
5100#ifdef FEATURE_WLAN_CCX
5101 len += pJoinRsp->tspecIeLen;
5102#endif
5103 if(len)
5104 {
5105 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5106 (void **)&pSession->connectedInfo.pbFrames, len)))
5107 {
5108 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5109 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5110 {
5111 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5112 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5113 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5114#ifdef WLAN_FEATURE_VOWIFI_11R
5115 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5116#endif /* WLAN_FEATURE_VOWIFI_11R */
5117#ifdef FEATURE_WLAN_CCX
5118 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5119#endif
5120 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5121 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5122 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5123 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5124 }
5125 else
5126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005127 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005128 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5130 pSession->connectedInfo.pbFrames = NULL;
5131 }
5132 }
5133 }
5134 if(pCommand->u.roamCmd.fReassoc)
5135 {
5136 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5137 }
5138 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5139 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5140 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5141 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5142 }
5143 else
5144 {
5145 if(pCommand->u.roamCmd.fReassoc)
5146 {
5147 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5148 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5149 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5150 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5151 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5152 }
5153 }
5154#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5155 // Indicate SME-QOS with reassoc success event, only after
5156 // copying the frames
5157 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5158#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 roamInfo.pBssDesc = pSirBssDesc;
5160 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5161 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5162#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5163 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5164#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5165 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5167 //It may be better to let QoS do this????
5168 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005170 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5172 pmcStartUapsd( pMac, NULL, NULL );
5173 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305174 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5176 if( pSession->bRefAssocStartCnt > 0 )
5177 {
5178 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005179 //Remove this code once SLM_Sessionization is supported
5180 //BMPS_WORKAROUND_NOT_NEEDED
5181 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005182 {
5183 pMac->roam.configParam.doBMPSWorkaround = 1;
5184 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5186 }
5187
5188 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 // reset the PMKID candidate list
5190 csrResetPMKIDCandidateList( pMac, sessionId );
5191 //Update TL's AC weight base on the current EDCA parameters
5192 //These parameters may change in the course of the connection, that sictuation
5193 //is not taken care here. This change is mainly to address a WIFI WMM test where
5194 //BE has a equal or higher TX priority than VI.
5195 //We only do this for infra link
5196 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5197 {
5198 csrCheckAndUpdateACWeight(pMac, pIes);
5199 }
5200#ifdef FEATURE_WLAN_WAPI
5201 // reset the BKID candidate list
5202 csrResetBKIDCandidateList( pMac, sessionId );
5203#endif /* FEATURE_WLAN_WAPI */
5204 }
5205 else
5206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005207 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 csrScanCancelIdleScan(pMac);
5210 //Not to signal link up because keys are yet to be set.
5211 //The linkup function will overwrite the sub-state that we need to keep at this point.
5212 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5213 {
5214 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5217 //enough to let security and DHCP handshake succeed before entry into BMPS
5218 if (pmcShouldBmpsTimerRun(pMac))
5219 {
5220 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5221 != eHAL_STATUS_SUCCESS)
5222 {
5223 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5224 }
5225 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 break;
5228
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 case eCsrStartBssSuccess:
5230 // on the StartBss Response, LIM is returning the Bss Description that we
5231 // are beaconing. Add this Bss Description to our scan results and
5232 // chain the Profile to this Bss Description. On a Start BSS, there was no
5233 // detected Bss description (no partner) so we issued the Start Bss to
5234 // start the Ibss without any Bss description. Lim was kind enough to return
5235 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005236 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5240 if( CSR_IS_IBSS( pProfile ) )
5241 {
5242 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 else if (CSR_IS_INFRA_AP(pProfile))
5245 {
5246 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5247 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 else
5249 {
5250 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5251 }
5252 if( !CSR_IS_WDS_STA( pProfile ) )
5253 {
5254 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005258 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 roamInfo.pBssDesc = pSirBssDesc;
5260 //We need to associate_complete it first, becasue Associate_start already indicated.
5261 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5262 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5263 break;
5264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 {
5267 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5268 }
5269 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5270 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5271 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5272 if(pSirBssDesc)
5273 {
5274 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5275 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5276 }
5277 //We are doen with the IEs so free it
5278 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005279#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5280 {
5281 vos_log_ibss_pkt_type *pIbssLog;
5282 tANI_U32 bi;
5283
5284 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5285 if(pIbssLog)
5286 {
5287 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5288 {
5289 //We start the IBSS (didn't find any matched IBSS out there)
5290 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5291 }
5292 else
5293 {
5294 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5295 }
5296 if(pSirBssDesc)
5297 {
5298 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5299 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5300 }
5301 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5302 {
5303 //***U8 is not enough for beacon interval
5304 pIbssLog->beaconInterval = (v_U8_t)bi;
5305 }
5306 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5307 }
5308 }
5309#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5310 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5311 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5313 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5315 csrRoamIssueSetContextReq( pMac, sessionId,
5316 pProfile->negotiatedMCEncryptionType,
5317 pSirBssDesc, &BroadcastMac,
5318 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5319 }
5320 }
5321 else
5322 {
5323 //Keep the state to eCSR_ROAMING_STATE_JOINING
5324 //Need to send join_req.
5325 if(pCommand->u.roamCmd.pRoamBssEntry)
5326 {
5327 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5328 {
5329 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5330 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5331 // Set the roaming substate to 'join attempt'...
5332 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005333 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 }
5335 }
5336 else
5337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005338 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 VOS_ASSERT( 0 );
5340 }
5341 }
5342 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5343 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5344 //trigger the connection start indication in Vista
5345 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5346 {
5347 roamStatus = eCSR_ROAM_IBSS_IND;
5348 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5349 if( CSR_IS_WDS( pProfile ) )
5350 {
5351 roamStatus = eCSR_ROAM_WDS_IND;
5352 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 if( CSR_IS_INFRA_AP( pProfile ) )
5355 {
5356 roamStatus = eCSR_ROAM_INFRA_IND;
5357 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005359
5360 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5361 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5362 //trigger the connection start indication in Vista
5363 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5364 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5365 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5366 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5367 {
5368 //We start the IBSS (didn't find any matched IBSS out there)
5369 roamInfo.pBssDesc = pSirBssDesc;
5370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005372 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005373 //Remove this code once SLM_Sessionization is supported
5374 //BMPS_WORKAROUND_NOT_NEEDED
5375 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005376 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005377 {
5378 pMac->roam.configParam.doBMPSWorkaround = 1;
5379 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005380
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5382 }
5383
5384 csrScanCancelIdleScan(pMac);
5385 //Only use this timer for ibss. BAP has its own timer for WDS
5386 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5387 {
5388 //start the join IBSS timer
5389 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5390 pSession->ibss_join_pending = TRUE;
5391 }
5392 if( HAL_STATUS_SUCCESS( status ) )
5393 {
5394 //Already sent join_req for the WDS station
5395 fReleaseCommand = eANI_BOOLEAN_FALSE;
5396 }
5397 else if( CSR_IS_WDS_STA( pProfile ) )
5398 {
5399 //need to send stop BSS because we fail to send join_req
5400 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5401 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5402 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 case eCsrStartBssFailure:
5406#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5407 {
5408 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5410 if(pIbssLog)
5411 {
5412 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5413 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5414 }
5415 }
5416#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 roamStatus = eCSR_ROAM_IBSS_IND;
5418 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5419 if( CSR_IS_WDS( pProfile ) )
5420 {
5421 roamStatus = eCSR_ROAM_WDS_IND;
5422 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 if( CSR_IS_INFRA_AP( pProfile ) )
5425 {
5426 roamStatus = eCSR_ROAM_INFRA_IND;
5427 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 if(Context)
5430 {
5431 pSirBssDesc = (tSirBssDescription *)Context;
5432 }
5433 else
5434 {
5435 pSirBssDesc = NULL;
5436 }
5437 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5438 roamInfo.pBssDesc = pSirBssDesc;
5439 //We need to associate_complete it first, becasue Associate_start already indicated.
5440 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5441 csrSetDefaultDot11Mode( pMac );
5442 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 case eCsrSilentlyStopRoaming:
5444 // We are here because we try to start the same IBSS
5445 //No message to PE
5446 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005447 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5449 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5450 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5451 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5452 if( roamInfo.pBssDesc )
5453 {
5454 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5455 }
5456 //Since there is no change in the current state, simply pass back no result otherwise
5457 //HDD may be mistakenly mark to disconnected state.
5458 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5459 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 case eCsrSilentlyStopRoamingSaveState:
5462 //We are here because we try to connect to the same AP
5463 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005464 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5466
5467 //to aviod resetting the substate to NONE
5468 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5469 //No need to change substate to wai_for_key because there is no state change
5470 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5471 if( roamInfo.pBssDesc )
5472 {
5473 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5476 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5477 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5478 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5479 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5480 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5481 roamInfo.staId = pSession->connectedInfo.staId;
5482 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 pSession->bRefAssocStartCnt--;
5485 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5486 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5487 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 case eCsrReassocFailure:
5490#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5491 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5492#endif
5493 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005494 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 csrFreeConnectBssDesc(pMac, sessionId);
5496 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5497 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5498 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5499 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5500 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5501 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5502 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5503 eCSR_ROAM_WDS_IND,
5504 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5505 //Need to issue stop_bss
5506 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 case eCsrJoinFailure:
5508 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005509 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 default:
5511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005512 smsLog(pMac, LOGW, FL("receives no association indication"));
5513 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005514 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5516 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5517 {
5518 //do not free for the other profiles as we need to send down stop BSS later
5519 csrFreeConnectBssDesc(pMac, sessionId);
5520 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5521 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5522 csrSetDefaultDot11Mode( pMac );
5523 }
5524
5525 switch( pCommand->u.roamCmd.roamReason )
5526 {
5527 // If this transition is because of an 802.11 OID, then we transition
5528 // back to INIT state so we sit waiting for more OIDs to be issued and
5529 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005530 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 case eCsrSmeIssuedAssocToSimilarAP:
5532 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005533 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5535 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5536 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5537 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5538 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005539 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5540
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 /* Defeaturize this later if needed */
5542#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5543 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5544 if (csrRoamIsHandoffInProgress(pMac))
5545 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 /* Should indicate neighbor roam algorithm about the connect failure here */
5547 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005549#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 if(pSession->bRefAssocStartCnt > 0)
5551 {
5552 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005553 if(eCsrJoinFailureDueToConcurrency == Result)
5554 {
5555 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5556 eCSR_ROAM_ASSOCIATION_COMPLETION,
5557 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5558 }
5559 else
5560 {
5561 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 eCSR_ROAM_ASSOCIATION_COMPLETION,
5563 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005566 else
5567 {
5568 /* bRefAssocStartCnt is not incremented when
5569 * eRoamState == eCsrStopRoamingDueToConcurrency
5570 * in csrRoamJoinNextBss API. so handle this in
5571 * else case by sending assoc failure
5572 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005573 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005574 pCommand->u.scanCmd.roamId,
5575 eCSR_ROAM_ASSOCIATION_FAILURE,
5576 eCSR_ROAM_RESULT_FAILURE);
5577 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005578 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005579#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5580 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5581#endif
5582 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5583 csrScanStartIdleScan(pMac);
5584#ifdef FEATURE_WLAN_BTAMP_UT_RF
5585 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5586 //BT activity and not able to recevie WLAN traffic. Retry the join
5587 if( CSR_IS_WDS_STA(pProfile) )
5588 {
5589 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5590 }
5591#endif
5592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 case eCsrHddIssuedReassocToSameAP:
5594 case eCsrSmeIssuedReassocToSameAP:
5595 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5596
5597 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5598#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5599 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5600#endif
5601 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5602 csrScanStartIdleScan(pMac);
5603 break;
5604 case eCsrForcedDisassoc:
5605 case eCsrForcedDeauth:
5606 case eCsrSmeIssuedIbssJoinFailure:
5607 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5608
5609 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5610 {
5611 // Notify HDD that IBSS join failed
5612 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5613 }
5614 else
5615 {
5616 csrRoamCallCallback(pMac, sessionId, NULL,
5617 pCommand->u.roamCmd.roamId,
5618 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5619 }
5620#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5621 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5622#endif
5623 csrRoamLinkDown(pMac, sessionId);
5624 csrScanStartIdleScan(pMac);
5625 break;
5626 case eCsrForcedIbssLeave:
5627 csrRoamCallCallback(pMac, sessionId, NULL,
5628 pCommand->u.roamCmd.roamId,
5629 eCSR_ROAM_IBSS_LEAVE,
5630 eCSR_ROAM_RESULT_IBSS_STOP);
5631 break;
5632 case eCsrForcedDisassocMICFailure:
5633 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5634
5635 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5636#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5637 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5638#endif
5639 csrScanStartIdleScan(pMac);
5640 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 case eCsrStopBss:
5642 csrRoamCallCallback(pMac, sessionId, NULL,
5643 pCommand->u.roamCmd.roamId,
5644 eCSR_ROAM_INFRA_IND,
5645 eCSR_ROAM_RESULT_INFRA_STOPPED);
5646 break;
5647 case eCsrForcedDisassocSta:
5648 case eCsrForcedDeauthSta:
5649 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5650 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5651 {
5652 pSession = CSR_GET_SESSION(pMac, sessionId);
5653 if (!pSession)
5654 break;
5655
5656 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5657 {
5658 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5659 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5660 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5661 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5662 roamInfo.statusCode = eSIR_SME_SUCCESS;
5663 status = csrRoamCallCallback(pMac, sessionId,
5664 &roamInfo, pCommand->u.roamCmd.roamId,
5665 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5666 }
5667 }
5668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 case eCsrLostLink1:
5670 // if lost link roam1 failed, then issue lost link Scan2 ...
5671 csrScanRequestLostLink2(pMac, sessionId);
5672 break;
5673 case eCsrLostLink2:
5674 // if lost link roam2 failed, then issue lost link scan3 ...
5675 csrScanRequestLostLink3(pMac, sessionId);
5676 break;
5677 case eCsrLostLink3:
5678 default:
5679 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5680
5681 //We are done with one round of lostlink roaming here
5682 csrScanHandleFailedLostlink3(pMac, sessionId);
5683 break;
5684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 break;
5686 }
5687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 return ( fReleaseCommand );
5689}
5690
Jeff Johnson295189b2012-06-20 16:38:30 -07005691eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5692{
5693 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 return (status);
5695}
5696
Jeff Johnson295189b2012-06-20 16:38:30 -07005697eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5698{
5699 eHalStatus status = eHAL_STATUS_SUCCESS;
5700 tANI_U32 size = 0;
5701
5702 do
5703 {
5704 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5705 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5706 {
5707 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5708 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5709 if(!HAL_STATUS_SUCCESS(status))
5710 {
5711 break;
5712 }
5713 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5714 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5715 }
5716 if(pSrcProfile->SSIDs.numOfSSIDs)
5717 {
5718 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5719 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5720 if(!HAL_STATUS_SUCCESS(status))
5721 {
5722 break;
5723 }
5724 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5725 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5726 }
5727 if(pSrcProfile->nWPAReqIELength)
5728 {
5729 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5730 if(!HAL_STATUS_SUCCESS(status))
5731 {
5732 break;
5733 }
5734 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5735 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5736 }
5737 if(pSrcProfile->nRSNReqIELength)
5738 {
5739 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5740 if(!HAL_STATUS_SUCCESS(status))
5741 {
5742 break;
5743 }
5744 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5745 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5746 }
5747#ifdef FEATURE_WLAN_WAPI
5748 if(pSrcProfile->nWAPIReqIELength)
5749 {
5750 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5751 if(!HAL_STATUS_SUCCESS(status))
5752 {
5753 break;
5754 }
5755 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5756 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5757 }
5758#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 if(pSrcProfile->nAddIEScanLength)
5760 {
5761 status = palAllocateMemory(pMac->hHdd,
5762 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5763 if(!HAL_STATUS_SUCCESS(status))
5764 {
5765 break;
5766 }
5767 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5768 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5769 pSrcProfile->nAddIEScanLength);
5770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 if(pSrcProfile->nAddIEAssocLength)
5772 {
5773 status = palAllocateMemory(pMac->hHdd,
5774 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5775 if(!HAL_STATUS_SUCCESS(status))
5776 {
5777 break;
5778 }
5779 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5780 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5781 pSrcProfile->nAddIEAssocLength);
5782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 if(pSrcProfile->ChannelInfo.ChannelList)
5784 {
5785 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5786 if(!HAL_STATUS_SUCCESS(status))
5787 {
5788 break;
5789 }
5790 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5791 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 pDstProfile->AuthType = pSrcProfile->AuthType;
5794 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5795 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5796 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5797 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5798 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005799#ifdef WLAN_FEATURE_11W
5800 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5801 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5802 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5803#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 pDstProfile->BSSType = pSrcProfile->BSSType;
5805 pDstProfile->phyMode = pSrcProfile->phyMode;
5806 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5807
5808#ifdef FEATURE_WLAN_WAPI
5809 if(csrIsProfileWapi(pSrcProfile))
5810 {
5811 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5812 {
5813 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5814 }
5815 }
5816#endif /* FEATURE_WLAN_WAPI */
5817 pDstProfile->CBMode = pSrcProfile->CBMode;
5818 /*Save the WPS info*/
5819 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5820 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 pDstProfile->privacy = pSrcProfile->privacy;
5823 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5824 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5825 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5826 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5827 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5828 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5829 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5830 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5831 pDstProfile->wps_state = pSrcProfile->wps_state;
5832 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005834#ifdef WLAN_FEATURE_VOWIFI_11R
5835 if (pSrcProfile->MDID.mdiePresent)
5836 {
5837 pDstProfile->MDID.mdiePresent = 1;
5838 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5839 }
5840#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 }while(0);
5842
5843 if(!HAL_STATUS_SUCCESS(status))
5844 {
5845 csrReleaseProfile(pMac, pDstProfile);
5846 pDstProfile = NULL;
5847 }
5848
5849 return (status);
5850}
Jeff Johnson295189b2012-06-20 16:38:30 -07005851eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5852{
5853 eHalStatus status = eHAL_STATUS_SUCCESS;
5854 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5855 do
5856 {
5857 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5858 if(pSrcProfile->bssid)
5859 {
5860 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5861 if(!HAL_STATUS_SUCCESS(status))
5862 {
5863 break;
5864 }
5865 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5866 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5867 }
5868 if(pSrcProfile->SSID.ssId)
5869 {
5870 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5871 if(!HAL_STATUS_SUCCESS(status))
5872 {
5873 break;
5874 }
5875 pDstProfile->SSIDs.numOfSSIDs = 1;
5876 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5877 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5878 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5879 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005880 if(pSrcProfile->nAddIEAssocLength)
5881 {
5882 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5883 if(!HAL_STATUS_SUCCESS(status))
5884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005885 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005886 break;
5887 }
5888 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5889 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5890 pSrcProfile->nAddIEAssocLength);
5891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5893 if(!HAL_STATUS_SUCCESS(status))
5894 {
5895 break;
5896 }
5897 pDstProfile->ChannelInfo.numOfChannels = 1;
5898 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 pDstProfile->AuthType.numEntries = 1;
5900 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5901 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5902 pDstProfile->EncryptionType.numEntries = 1;
5903 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5904 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5905 pDstProfile->mcEncryptionType.numEntries = 1;
5906 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5907 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5908 pDstProfile->BSSType = pSrcProfile->BSSType;
5909 pDstProfile->CBMode = pSrcProfile->CBMode;
5910 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5911#ifdef WLAN_FEATURE_VOWIFI_11R
5912 if (pSrcProfile->MDID.mdiePresent)
5913 {
5914 pDstProfile->MDID.mdiePresent = 1;
5915 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5916 }
5917#endif
5918
5919 }while(0);
5920
5921 if(!HAL_STATUS_SUCCESS(status))
5922 {
5923 csrReleaseProfile(pMac, pDstProfile);
5924 pDstProfile = NULL;
5925 }
5926
5927 return (status);
5928}
5929
Jeff Johnson295189b2012-06-20 16:38:30 -07005930eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5931 tScanResultHandle hBSSList,
5932 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5933 tANI_BOOLEAN fClearScan)
5934{
5935 eHalStatus status = eHAL_STATUS_SUCCESS;
5936 tSmeCmd *pCommand;
5937
5938 pCommand = csrGetCommandBuffer(pMac);
5939 if(NULL == pCommand)
5940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005941 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 status = eHAL_STATUS_RESOURCES;
5943 }
5944 else
5945 {
5946 if( fClearScan )
5947 {
5948 csrScanCancelIdleScan(pMac);
5949 csrScanAbortMacScanNotForConnect(pMac);
5950 }
5951 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5952 if(NULL == pProfile)
5953 {
5954 //We can roam now
5955 //Since pProfile is NULL, we need to build our own profile, set everything to default
5956 //We can only support open and no encryption
5957 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5958 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5959 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5960 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5961 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5962 }
5963 else
5964 {
5965 //make a copy of the profile
5966 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5967 if(HAL_STATUS_SUCCESS(status))
5968 {
5969 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5970 }
5971 }
5972 pCommand->command = eSmeCommandRoam;
5973 pCommand->sessionId = (tANI_U8)sessionId;
5974 pCommand->u.roamCmd.hBSSList = hBSSList;
5975 pCommand->u.roamCmd.roamId = roamId;
5976 pCommand->u.roamCmd.roamReason = reason;
5977 //We need to free the BssList when the command is done
5978 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5979 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5981 FL("CSR PERSONA=%d"),
5982 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5984 if( !HAL_STATUS_SUCCESS( status ) )
5985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005986 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 csrReleaseCommandRoam( pMac, pCommand );
5988 }
5989 }
5990
5991 return (status);
5992}
Jeff Johnson295189b2012-06-20 16:38:30 -07005993eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5994 tCsrRoamModifyProfileFields *pMmodProfileFields,
5995 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5996{
5997 eHalStatus status = eHAL_STATUS_SUCCESS;
5998 tSmeCmd *pCommand;
5999
6000 pCommand = csrGetCommandBuffer(pMac);
6001 if(NULL == pCommand)
6002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006003 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 status = eHAL_STATUS_RESOURCES;
6005 }
6006 else
6007 {
6008 csrScanCancelIdleScan(pMac);
6009 csrScanAbortMacScanNotForConnect(pMac);
6010 if(pProfile)
6011 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 //This is likely trying to reassoc to different profile
6013 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6014 //make a copy of the profile
6015 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6016 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 }
6018 else
6019 {
6020 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6021 //how to update WPA/WPA2 info in roamProfile??
6022 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 if(HAL_STATUS_SUCCESS(status))
6025 {
6026 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6027 }
6028 pCommand->command = eSmeCommandRoam;
6029 pCommand->sessionId = (tANI_U8)sessionId;
6030 pCommand->u.roamCmd.roamId = roamId;
6031 pCommand->u.roamCmd.roamReason = reason;
6032 //We need to free the BssList when the command is done
6033 //For reassoc there is no BSS list, so the boolean set to false
6034 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6035 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6036 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6038 if( !HAL_STATUS_SUCCESS( status ) )
6039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006040 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6042 csrReleaseCommandRoam( pMac, pCommand );
6043 }
6044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 return (status);
6046}
6047
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006048eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6049 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
6050// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6051{
6052 eHalStatus status = eHAL_STATUS_SUCCESS;
6053 tSmeCmd *pCommand;
6054
6055 pCommand = csrGetCommandBuffer(pMac);
6056 if(NULL == pCommand)
6057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006058 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006059 status = eHAL_STATUS_RESOURCES;
6060 }
6061 else
6062 {
6063 if(pBssDescription)
6064 {
6065 //copy over the parameters we need later
6066 pCommand->command = eSmeCommandRoam;
6067 pCommand->sessionId = (tANI_U8)sessionId;
6068 pCommand->u.roamCmd.roamReason = reason;
6069 //this is the important parameter
6070 //in this case we are using this field for the "next" BSS
6071 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6072 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6073 if( !HAL_STATUS_SUCCESS( status ) )
6074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006075 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006076 csrReleaseCommandPreauth( pMac, pCommand );
6077 }
6078 }
6079 else
6080 {
6081 //Return failure
6082 status = eHAL_STATUS_RESOURCES;
6083 }
6084 }
6085 return (status);
6086}
6087
6088eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6089{
6090 tListElem *pEntry;
6091 tSmeCmd *pCommand;
6092 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6093 if ( pEntry )
6094 {
6095 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6096 if ( (eSmeCommandRoam == pCommand->command) &&
6097 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6098 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006099 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006100 pCommand->command, pCommand->u.roamCmd.roamReason);
6101 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6102 csrReleaseCommandPreauth( pMac, pCommand );
6103 }
6104 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006105 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006106 pCommand->command, pCommand->u.roamCmd.roamReason);
6107 }
6108 }
6109 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006110 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006111 }
6112 smeProcessPendingQueue( pMac );
6113 return eHAL_STATUS_SUCCESS;
6114}
6115
Jeff Johnson295189b2012-06-20 16:38:30 -07006116eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6117 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6118{
6119 eHalStatus status = eHAL_STATUS_FAILURE;
6120 tScanResultHandle hBSSList;
6121 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6123 if(HAL_STATUS_SUCCESS(status))
6124 {
6125 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6126 if(pRoamId)
6127 {
6128 *pRoamId = roamId;
6129 }
6130 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6131 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6132 if(!HAL_STATUS_SUCCESS(status))
6133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006134 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 csrScanResultPurge(pMac, hBSSList);
6136 }
6137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 return (status);
6139}
6140
Jeff Johnson295189b2012-06-20 16:38:30 -07006141eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6142 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6143{
6144 eHalStatus status = eHAL_STATUS_SUCCESS;
6145 tScanResultHandle hBSSList;
6146 tCsrScanResultFilter *pScanFilter;
6147 tANI_U32 roamId = 0;
6148 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6149 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 if (NULL == pProfile)
6151 {
6152 smsLog(pMac, LOGP, FL("No profile specified"));
6153 return eHAL_STATUS_FAILURE;
6154 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006155 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 if( CSR_IS_WDS( pProfile ) &&
6158 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006160 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006161 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 return status;
6163 }
6164 csrRoamCancelRoaming(pMac, sessionId);
6165 csrScanRemoveFreshScanCommand(pMac, sessionId);
6166 csrScanCancelIdleScan(pMac);
6167 //Only abort the scan if it is not used for other roam/connect purpose
6168 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6170 {
6171 csrScanDisable(pMac);
6172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6174 //Check whether ssid changes
6175 if(csrIsConnStateConnected(pMac, sessionId))
6176 {
6177 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6178 {
6179 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6180 }
6181 }
6182#ifdef FEATURE_WLAN_BTAMP_UT_RF
6183 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6184#endif
6185 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006187 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6189 if(pRoamId)
6190 {
6191 roamId = *pRoamId;
6192 }
6193 if(!HAL_STATUS_SUCCESS(status))
6194 {
6195 fCallCallback = eANI_BOOLEAN_TRUE;
6196 }
6197 }
6198 else
6199 {
6200 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6201 if(HAL_STATUS_SUCCESS(status))
6202 {
6203 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6204 //Try to connect to any BSS
6205 if(NULL == pProfile)
6206 {
6207 //No encryption
6208 pScanFilter->EncryptionType.numEntries = 1;
6209 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6210 }//we don't have a profile
6211 else
6212 {
6213 //Here is the profile we need to connect to
6214 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6215 }//We have a profile
6216 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6217 if(pRoamId)
6218 {
6219 *pRoamId = roamId;
6220 }
6221
6222 if(HAL_STATUS_SUCCESS(status))
6223 {
6224 /*Save the WPS info*/
6225 if(NULL != pProfile)
6226 {
6227 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6228 }
6229 else
6230 {
6231 pScanFilter->bWPSAssociation = 0;
6232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 do
6234 {
6235 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 )
6238 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006239 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6241 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6242 if(!HAL_STATUS_SUCCESS(status))
6243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006244 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 fCallCallback = eANI_BOOLEAN_TRUE;
6246 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006247 else
6248 {
6249 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 break;
6252 }
6253 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006254 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 if(HAL_STATUS_SUCCESS(status))
6256 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6258 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6259 if(!HAL_STATUS_SUCCESS(status))
6260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006261 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 csrScanResultPurge(pMac, hBSSList);
6263 fCallCallback = eANI_BOOLEAN_TRUE;
6264 }
6265 }//Have scan result
6266 else if(NULL != pProfile)
6267 {
6268 //Check whether it is for start ibss
6269 if(CSR_IS_START_IBSS(pProfile))
6270 {
6271 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6272 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6273 if(!HAL_STATUS_SUCCESS(status))
6274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006275 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 fCallCallback = eANI_BOOLEAN_TRUE;
6277 }
6278 }
6279 else
6280 {
6281 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006282 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 if(!HAL_STATUS_SUCCESS(status))
6284 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006285 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 fCallCallback = eANI_BOOLEAN_TRUE;
6287 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006288 else
6289 {
6290 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 }
6293 }
6294 else
6295 {
6296 fCallCallback = eANI_BOOLEAN_TRUE;
6297 }
6298 } while (0);
6299 if(NULL != pProfile)
6300 {
6301 //we need to free memory for filter if profile exists
6302 csrFreeScanFilter(pMac, pScanFilter);
6303 }
6304 }//Got the scan filter from profile
6305
6306 palFreeMemory(pMac->hHdd, pScanFilter);
6307 }//allocated memory for pScanFilter
6308 }//No Bsslist coming in
6309 //tell the caller if we fail to trigger a join request
6310 if( fCallCallback )
6311 {
6312 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6313 }
6314
6315 return (status);
6316}
Jeff Johnson295189b2012-06-20 16:38:30 -07006317eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6318 tCsrRoamModifyProfileFields modProfileFields,
6319 tANI_U32 *pRoamId)
6320{
6321 eHalStatus status = eHAL_STATUS_SUCCESS;
6322 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6323 tANI_U32 roamId = 0;
6324 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 if (NULL == pProfile)
6326 {
6327 smsLog(pMac, LOGP, FL("No profile specified"));
6328 return eHAL_STATUS_FAILURE;
6329 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006330 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 csrRoamCancelRoaming(pMac, sessionId);
6332 csrScanRemoveFreshScanCommand(pMac, sessionId);
6333 csrScanCancelIdleScan(pMac);
6334 csrScanAbortMacScanNotForConnect(pMac);
6335 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 if(csrIsConnStateConnected(pMac, sessionId))
6337 {
6338 if(pProfile)
6339 {
6340 if(pProfile->SSIDs.numOfSSIDs &&
6341 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6342 {
6343 fCallCallback = eANI_BOOLEAN_FALSE;
6344 }
6345 else
6346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006347 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 }
6349 }
6350 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6351 &pSession->connectedProfile.modifyProfileFields,
6352 sizeof(tCsrRoamModifyProfileFields)))
6353 {
6354 fCallCallback = eANI_BOOLEAN_FALSE;
6355 }
6356 else
6357 {
6358 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006359 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 }
6361 }
6362 else
6363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006364 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 if(!fCallCallback)
6367 {
6368 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6369 if(pRoamId)
6370 {
6371 *pRoamId = roamId;
6372 }
6373
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6375 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 }
6377 else
6378 {
6379 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6380 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 return status;
6383}
Jeff Johnson295189b2012-06-20 16:38:30 -07006384eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6385{
6386 eHalStatus status = eHAL_STATUS_FAILURE;
6387 tScanResultHandle hBSSList = NULL;
6388 tCsrScanResultFilter *pScanFilter = NULL;
6389 tANI_U32 roamId;
6390 tCsrRoamProfile *pProfile = NULL;
6391 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006392
6393 if(!pSession)
6394 {
6395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6396 return eHAL_STATUS_FAILURE;
6397 }
6398
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 do
6400 {
6401 if(pSession->pCurRoamProfile)
6402 {
6403 csrScanCancelIdleScan(pMac);
6404 csrScanAbortMacScanNotForConnect(pMac);
6405 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6406 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6407 if(!HAL_STATUS_SUCCESS(status))
6408 break;
6409 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6410 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6411 if(!HAL_STATUS_SUCCESS(status))
6412 break;
6413 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6414 if(!HAL_STATUS_SUCCESS(status))
6415 {
6416 break;
6417 }
6418 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6419 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6420 if(!HAL_STATUS_SUCCESS(status))
6421 {
6422 break;
6423 }
6424 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6425 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6426 if(HAL_STATUS_SUCCESS(status))
6427 {
6428 //we want to put the last connected BSS to the very beginning, if possible
6429 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6430 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6431 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6432 if(!HAL_STATUS_SUCCESS(status))
6433 {
6434 csrScanResultPurge(pMac, hBSSList);
6435 break;
6436 }
6437 }
6438 else
6439 {
6440 //Do a scan on this profile
6441 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006442 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 if(!HAL_STATUS_SUCCESS(status))
6444 {
6445 break;
6446 }
6447 }
6448 }//We have a profile
6449 else
6450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006451 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 break;
6453 }
6454 }while(0);
6455 if(pScanFilter)
6456 {
6457 csrFreeScanFilter(pMac, pScanFilter);
6458 palFreeMemory(pMac->hHdd, pScanFilter);
6459 }
6460 if(NULL != pProfile)
6461 {
6462 csrReleaseProfile(pMac, pProfile);
6463 palFreeMemory(pMac->hHdd, pProfile);
6464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 return (status);
6466}
Jeff Johnson295189b2012-06-20 16:38:30 -07006467eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6468{
6469 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 if(csrIsConnStateConnected(pMac, sessionId))
6471 {
6472 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6473 if(HAL_STATUS_SUCCESS(status))
6474 {
6475 status = csrRoamJoinLastProfile(pMac, sessionId);
6476 }
6477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006478 return (status);
6479}
6480
Jeff Johnson295189b2012-06-20 16:38:30 -07006481eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6482{
6483 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006484 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 csrRoamCancelRoaming(pMac, sessionId);
6486 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6487 if(csrIsConnStateDisconnected(pMac, sessionId))
6488 {
6489 status = csrRoamJoinLastProfile(pMac, sessionId);
6490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 return (status);
6492}
6493
Jeff Johnson295189b2012-06-20 16:38:30 -07006494eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6495{
6496 eHalStatus status = eHAL_STATUS_SUCCESS;
6497 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6498 eCsrRoamSubState NewSubstate;
6499 tANI_U32 sessionId = pCommand->sessionId;
6500
6501 // change state to 'Roaming'...
6502 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6503
6504 if ( csrIsConnStateIbss( pMac, sessionId ) )
6505 {
6506 // If we are in an IBSS, then stop the IBSS...
6507 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6508 fComplete = (!HAL_STATUS_SUCCESS(status));
6509 }
6510 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006512 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 -07006513 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6514 //Restore AC weight in case we change it
6515 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6516 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6517 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6518 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6519 {
6520 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6521 }
6522 if( fDisassoc )
6523 {
6524 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6525 }
6526 else
6527 {
6528 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6529 }
6530 fComplete = (!HAL_STATUS_SUCCESS(status));
6531 }
6532 else if ( csrIsConnStateWds( pMac, sessionId ) )
6533 {
6534 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6535 {
6536 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6537 fComplete = (!HAL_STATUS_SUCCESS(status));
6538 }
6539 //This has to be WDS station
6540 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6541 {
6542
6543 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6544 if( fDisassoc )
6545 {
6546 status = csrRoamIssueDisassociate( pMac, sessionId,
6547 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6548 fComplete = (!HAL_STATUS_SUCCESS(status));
6549 }
6550 }
6551 } else {
6552 // we got a dis-assoc request while not connected to any peer
6553 // just complete the command
6554 fComplete = eANI_BOOLEAN_TRUE;
6555 status = eHAL_STATUS_FAILURE;
6556 }
6557 if(fComplete)
6558 {
6559 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6560 }
6561
6562 if(HAL_STATUS_SUCCESS(status))
6563 {
6564 if ( csrIsConnStateInfra( pMac, sessionId ) )
6565 {
6566 //Set the state to disconnect here
6567 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6568 }
6569 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006570 else
6571 {
6572 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 return (status);
6575}
6576
Jeff Johnson295189b2012-06-20 16:38:30 -07006577/* This is been removed from latest code base */
6578/*
6579static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6580{
6581 eHalStatus status;
6582 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6584 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 return ( status );
6586}
6587*/
6588
Jeff Johnson295189b2012-06-20 16:38:30 -07006589eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6590{
6591 eHalStatus status = eHAL_STATUS_SUCCESS;
6592 tSmeCmd *pCommand;
6593 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 do
6595 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006596 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 pCommand = csrGetCommandBuffer( pMac );
6598 if ( !pCommand )
6599 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006600 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 status = eHAL_STATUS_RESOURCES;
6602 break;
6603 }
6604 //Change the substate in case it is wait-for-key
6605 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6606 {
6607 csrRoamStopWaitForKeyTimer( pMac );
6608 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6609 }
6610 pCommand->command = eSmeCommandRoam;
6611 pCommand->sessionId = (tANI_U8)sessionId;
6612 switch ( reason )
6613 {
6614 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6615 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6616 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 case eCSR_DISCONNECT_REASON_DEAUTH:
6618 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6619 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 case eCSR_DISCONNECT_REASON_HANDOFF:
6621 fHighPriority = eANI_BOOLEAN_TRUE;
6622 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6623 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6625 case eCSR_DISCONNECT_REASON_DISASSOC:
6626 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6627 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6629 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6630 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6632 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 default:
6635 break;
6636 }
6637 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6638 if( !HAL_STATUS_SUCCESS( status ) )
6639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006640 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 csrReleaseCommandRoam( pMac, pCommand );
6642 }
6643 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 return( status );
6645}
6646
Jeff Johnson295189b2012-06-20 16:38:30 -07006647eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6648{
6649 eHalStatus status = eHAL_STATUS_SUCCESS;
6650 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 pCommand = csrGetCommandBuffer( pMac );
6652 if ( NULL != pCommand )
6653 {
6654 //Change the substate in case it is wait-for-key
6655 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6656 {
6657 csrRoamStopWaitForKeyTimer( pMac );
6658 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6659 }
6660 pCommand->command = eSmeCommandRoam;
6661 pCommand->sessionId = (tANI_U8)sessionId;
6662 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6663 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6664 if( !HAL_STATUS_SUCCESS( status ) )
6665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006666 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 csrReleaseCommandRoam( pMac, pCommand );
6668 }
6669 }
6670 else
6671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006672 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 status = eHAL_STATUS_RESOURCES;
6674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 return ( status );
6676}
6677
Jeff Johnson295189b2012-06-20 16:38:30 -07006678eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6679{
6680 eHalStatus status = eHAL_STATUS_SUCCESS;
6681 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006682
6683 if(!pSession)
6684 {
6685 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6686 return eHAL_STATUS_FAILURE;
6687 }
6688
Jeff Johnson295189b2012-06-20 16:38:30 -07006689#ifdef FEATURE_WLAN_BTAMP_UT_RF
6690 //Stop te retry
6691 pSession->maxRetryCount = 0;
6692 csrRoamStopJoinRetryTimer(pMac, sessionId);
6693#endif
6694 //Not to call cancel roaming here
6695 //Only issue disconnect when necessary
6696 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6697 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6698 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6699
6700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006701 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 return (status);
6705}
6706
Jeff Johnson295189b2012-06-20 16:38:30 -07006707eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6708{
6709 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006710
6711 if(!pSession)
6712 {
6713 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6714 return eHAL_STATUS_FAILURE;
6715 }
6716
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 csrRoamCancelRoaming(pMac, sessionId);
6718 pSession->ibss_join_pending = FALSE;
6719 csrRoamStopIbssJoinTimer(pMac, sessionId);
6720 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6721
6722 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6723}
6724
Jeff Johnson295189b2012-06-20 16:38:30 -07006725eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6726 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6727{
6728 eHalStatus status = eHAL_STATUS_SUCCESS;
6729 tDot11fBeaconIEs *pIesTemp = pIes;
6730 tANI_U8 index;
6731 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6732 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006733
6734 if(!pSession)
6735 {
6736 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6737 return eHAL_STATUS_FAILURE;
6738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006739
6740 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6741 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6742 pConnectProfile->AuthInfo = pProfile->AuthType;
6743 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6744 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6745 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6746 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6747 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6748 pConnectProfile->BSSType = pProfile->BSSType;
6749 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6750 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006751 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6752
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006754 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6755 if(pProfile->nAddIEAssocLength)
6756 {
6757 status = palAllocateMemory(pMac->hHdd,
6758 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6759 if(!HAL_STATUS_SUCCESS(status))
6760 {
6761 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6762 return eHAL_STATUS_FAILURE;
6763 }
6764 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6765 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6766 pProfile->nAddIEAssocLength);
6767 }
6768
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 //Save bssid
6770 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6771#ifdef WLAN_FEATURE_VOWIFI_11R
6772 if (pSirBssDesc->mdiePresent)
6773 {
6774 pConnectProfile->MDID.mdiePresent = 1;
6775 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6776 }
6777#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006778 if( NULL == pIesTemp )
6779 {
6780 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006782#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006783 if ((csrIsProfileCCX(pProfile) ||
6784 ((pIesTemp->CCXVersion.present)
6785 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6786 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6787 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6788 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006789#ifdef WLAN_FEATURE_11W
6790 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6791#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306792 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006793 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 {
6795 pConnectProfile->isCCXAssoc = 1;
6796 }
6797#endif
6798 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006799 if(HAL_STATUS_SUCCESS(status))
6800 {
6801 if(pIesTemp->SSID.present)
6802 {
6803 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6804 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6805 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6806 }
6807
6808 //Save the bss desc
6809 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306810
6811 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306813 //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 -07006814 pConnectProfile->qap = TRUE;
6815 }
6816 else
6817 {
6818 pConnectProfile->qap = FALSE;
6819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 if ( NULL == pIes )
6821 {
6822 //Free memory if it allocated locally
6823 palFreeMemory(pMac->hHdd, pIesTemp);
6824 }
6825 }
6826 //Save Qos connection
6827 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6828
6829 if(!HAL_STATUS_SUCCESS(status))
6830 {
6831 csrFreeConnectBssDesc(pMac, sessionId);
6832 }
6833 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6834 {
6835 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6836 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6837 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6838 {
6839 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6840 break;
6841 }
6842 pConnectProfile->handoffPermitted = FALSE;
6843 }
6844
6845 return (status);
6846}
6847
Jeff Johnson295189b2012-06-20 16:38:30 -07006848static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6849{
6850 tListElem *pEntry = NULL;
6851 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 //The head of the active list is the request we sent
6853 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6854 if(pEntry)
6855 {
6856 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6859 {
6860 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6861 {
6862#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6863 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6864#endif
6865 }
6866 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6867 }
6868 else
6869 {
6870 tANI_U32 roamId = 0;
6871 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006872 if(!pSession)
6873 {
6874 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6875 return;
6876 }
6877
Jeff Johnson295189b2012-06-20 16:38:30 -07006878
6879 //The head of the active list is the request we sent
6880 //Try to get back the same profile and roam again
6881 if(pCommand)
6882 {
6883 roamId = pCommand->u.roamCmd.roamId;
6884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6886 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006887 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006888#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6889 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6890 if (csrRoamIsHandoffInProgress(pMac))
6891 {
6892 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6893 /* Should indicate neighbor roam algorithm about the connect failure here */
6894 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6895 }
6896#endif
6897 if (pCommand)
6898 {
6899 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6900 {
6901 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6902 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6903 csrRoamReissueRoamCommand(pMac);
6904 }
6905 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6906 {
6907 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6908 }
6909 else
6910 {
6911 csrRoam(pMac, pCommand);
6912 }
6913 }
6914 else
6915 {
6916 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6917 }
6918 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6919}
6920
Jeff Johnson295189b2012-06-20 16:38:30 -07006921eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6922 tDot11fBeaconIEs *pIes,
6923 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6924{
6925 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006926 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6928 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6929
6930 // Set the roaming substate to 'join attempt'...
6931 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006933 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 return (status);
6935}
6936
Jeff Johnson295189b2012-06-20 16:38:30 -07006937static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6938 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6939{
6940 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 // Set the roaming substate to 'join attempt'...
6942 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6943
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006944 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006945
6946 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006947 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006948}
6949
Jeff Johnson295189b2012-06-20 16:38:30 -07006950void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6951{
6952 tListElem *pEntry;
6953 tSmeCmd *pCommand;
6954 tCsrRoamInfo roamInfo;
6955 tANI_U32 sessionId;
6956 tCsrRoamSession *pSession;
6957
6958 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6959 if(pEntry)
6960 {
6961 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6962 if ( eSmeCommandRoam == pCommand->command )
6963 {
6964 sessionId = pCommand->sessionId;
6965 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006966
6967 if(!pSession)
6968 {
6969 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6970 return;
6971 }
6972
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 if( pCommand->u.roamCmd.fStopWds )
6974 {
6975 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6976 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6977 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6978 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6981 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6982 eCSR_ROAM_WDS_IND,
6983 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6985 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6986 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6987 eCSR_ROAM_INFRA_IND,
6988 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6989 }
6990
Jeff Johnson295189b2012-06-20 16:38:30 -07006991
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006994 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6996 }
6997 }
6998 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007000 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7002 }
7003 }
7004 else
7005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007006 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 }
7008 }
7009 else
7010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007011 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 }
7013}
7014
Jeff Johnson295189b2012-06-20 16:38:30 -07007015tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7016{
7017 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7018 tListElem *pEntry;
7019 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 //alwasy lock active list before locking pending list
7021 csrLLLock( &pMac->sme.smeCmdActiveList );
7022 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7023 if(pEntry)
7024 {
7025 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7026 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7027 {
7028 fRet = eANI_BOOLEAN_TRUE;
7029 }
7030 }
7031 if(eANI_BOOLEAN_FALSE == fRet)
7032 {
7033 csrLLLock(&pMac->sme.smeCmdPendingList);
7034 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7035 while(pEntry)
7036 {
7037 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7038 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7039 {
7040 fRet = eANI_BOOLEAN_TRUE;
7041 break;
7042 }
7043 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7044 }
7045 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7046 }
7047 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 return (fRet);
7049}
7050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7052{
7053 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7054 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7056 {
7057 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7058 {
7059 break;
7060 }
7061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 return ( fRet );
7063}
7064
Jeff Johnson295189b2012-06-20 16:38:30 -07007065tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7066{
7067 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 //alwasy lock active list before locking pending list
7069 csrLLLock( &pMac->sme.smeCmdActiveList );
7070 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7071 if(eANI_BOOLEAN_FALSE == fRet)
7072 {
7073 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7074 }
7075 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 return (fRet);
7077}
7078
Jeff Johnson295189b2012-06-20 16:38:30 -07007079tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7080{
7081 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7082 tListElem *pEntry;
7083 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 //alwasy lock active list before locking pending list
7085 csrLLLock( &pMac->sme.smeCmdActiveList );
7086 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7087 if( pEntry )
7088 {
7089 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7090 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7091 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7092 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7093 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7094 {
7095 fRet = eANI_BOOLEAN_TRUE;
7096 }
7097 }
7098 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 return (fRet);
7100}
Jeff Johnson295189b2012-06-20 16:38:30 -07007101eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7102{
7103 eHalStatus status = eHAL_STATUS_SUCCESS;
7104 tSmeCmd *pCommand = NULL;
7105 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7106 tANI_BOOLEAN fRemoveCmd = FALSE;
7107 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 // Delete the old assoc command. All is setup for reassoc to be serialized
7109 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7110 if ( pEntry )
7111 {
7112 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7113 if ( !pCommand )
7114 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007115 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 return eHAL_STATUS_RESOURCES;
7117 }
7118 if ( eSmeCommandRoam == pCommand->command )
7119 {
7120 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7121 {
7122 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7123 }
7124 else
7125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007126 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 }
7128 if (fRemoveCmd == FALSE)
7129 {
7130 // Implies we did not get the serialized assoc command we
7131 // were expecting
7132 pCommand = NULL;
7133 }
7134 }
7135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 if(NULL == pCommand)
7137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007138 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 return eHAL_STATUS_RESOURCES;
7140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 do
7142 {
7143 //Change the substate in case it is wait-for-key
7144 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7145 {
7146 csrRoamStopWaitForKeyTimer( pMac );
7147 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7148 }
7149 pCommand->command = eSmeCommandRoam;
7150 pCommand->sessionId = (tANI_U8)sessionId;
7151 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007152 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7153 if( !HAL_STATUS_SUCCESS( status ) )
7154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007155 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 csrReleaseCommandRoam( pMac, pCommand );
7157 }
7158 } while( 0 );
7159
Jeff Johnson295189b2012-06-20 16:38:30 -07007160 return( status );
7161}
7162static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7163{
7164 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7165 tCsrScanResult *pScanResult = NULL;
7166 tSirBssDescription *pBssDesc = NULL;
7167 tSmeCmd *pCommand = NULL;
7168 tANI_U32 sessionId;
7169 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 if(NULL == pEntry)
7171 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007172 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 return;
7174 }
7175 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7176 sessionId = pCommand->sessionId;
7177 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007178
7179 if(!pSession)
7180 {
7181 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7182 return;
7183 }
7184
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7186 {
7187 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007188 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7190 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007191 /* If the roaming has stopped, not to continue the roaming command*/
7192 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7193 {
7194 //No need to complete roaming here as it already completes
7195 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7196 pCommand->u.roamCmd.roamReason);
7197 csrSetAbortRoamingCommand( pMac, pCommand );
7198 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 else
7201 {
7202 if ( CCM_IS_RESULT_SUCCESS(result) )
7203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007204 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 // Successfully set the configuration parameters for the new Bss. Attempt to
7206 // join the roaming Bss.
7207 if(pCommand->u.roamCmd.pRoamBssEntry)
7208 {
7209 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7210 pBssDesc = &pScanResult->Result.BssDescriptor;
7211 }
7212 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7213 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 )
7216 {
7217 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7218 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7219 pBssDesc, pCommand->u.roamCmd.roamId )))
7220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007221 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 //We need to complete the command
7223 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7224 }
7225 }
7226 else
7227 {
7228 if (!pCommand->u.roamCmd.pRoamBssEntry)
7229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007230 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 //We need to complete the command
7232 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7233 return;
7234 }
7235 // If we are roaming TO an Infrastructure BSS...
7236 VOS_ASSERT(pScanResult != NULL);
7237 if ( csrIsInfraBssDesc( pBssDesc ) )
7238 {
7239 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7241 {
7242 // ..and currently in an Infrastructure connection....
7243 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7244 {
7245 // ...and the SSIDs are equal, then we Reassoc.
7246 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7247 pIesLocal ) )
7248 // ..and currently in an infrastructure connection
7249 {
7250 // then issue a Reassoc.
7251 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7252 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7253 &pCommand->u.roamCmd.roamProfile );
7254 }
7255 else
7256 {
7257
7258 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7259 // previously associated AP.
7260 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7261 pIesLocal,
7262 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7263 {
7264 //try something else
7265 csrRoam( pMac, pCommand );
7266 }
7267 }
7268 }
7269 else
7270 {
7271 eHalStatus status = eHAL_STATUS_SUCCESS;
7272
7273 /* We need to come with other way to figure out that this is because of HO in BMP
7274 The below API will be only available for Android as it uses a different HO algorithm */
7275 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7276 * use join request */
7277#ifdef WLAN_FEATURE_VOWIFI_11R
7278 if (csrRoamIsHandoffInProgress(pMac) &&
7279 csrRoamIs11rAssoc(pMac))
7280 {
7281 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7282 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7283 }
7284 else
7285#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007286#ifdef FEATURE_WLAN_CCX
7287 if (csrRoamIsHandoffInProgress(pMac) &&
7288 csrRoamIsCCXAssoc(pMac))
7289 {
7290 // Now serialize the reassoc command.
7291 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7292 }
7293 else
7294#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007295#ifdef FEATURE_WLAN_LFR
7296 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307297 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007298 {
7299 // Now serialize the reassoc command.
7300 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7301 }
7302 else
7303#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 // else we are not connected and attempting to Join. Issue the
7305 // Join request.
7306 {
7307 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7308 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7309 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7310 }
7311 if(!HAL_STATUS_SUCCESS(status))
7312 {
7313 //try something else
7314 csrRoam( pMac, pCommand );
7315 }
7316 }
7317 if( !pScanResult->Result.pvIes )
7318 {
7319 //Locally allocated
7320 palFreeMemory(pMac->hHdd, pIesLocal);
7321 }
7322 }
7323 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7324 else
7325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007326 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 }
7328 }//else
7329 }//if ( WNI_CFG_SUCCESS == result )
7330 else
7331 {
7332 // In the event the configuration failed, for infra let the roam processor
7333 //attempt to join something else...
7334 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7335 {
7336 csrRoam(pMac, pCommand);
7337 }
7338 else
7339 {
7340 //We need to complete the command
7341 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7342 {
7343 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7344 }
7345 else
7346 {
7347 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7348 }
7349 }
7350 }
7351 }//we have active entry
7352}
7353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7355{
7356 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007357 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007360 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7362 // join the new one...
7363 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7365 }
7366 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007367 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 /***profHandleLostLinkAfterReset(pAdapter);
7369 // In the event the authenticate fails, let the roam processor attempt to join something else...
7370 roamRoam( pAdapter );***/
7371 }
7372}
7373
Jeff Johnson295189b2012-06-20 16:38:30 -07007374static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7375{
7376 eCsrRoamCompleteResult result;
7377 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7378 tCsrRoamInfo roamInfo;
7379 tANI_U32 roamId = 0;
7380
7381 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007383 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 /* Defeaturize this part later if needed */
7386#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7387 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7388 * we need the response contents while processing the result in csrRoamProcessResults() */
7389 if (csrRoamIsHandoffInProgress(pMac))
7390 {
7391 /* Need to dig more on indicating events to SME QoS module */
7392 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7393 csrRoamComplete( pMac, result, pSmeJoinRsp);
7394 }
7395 else
7396#endif
7397 {
7398 csrRoamComplete( pMac, result, NULL );
7399 }
7400 }
7401 /* Should we handle this similar to handling the join failure? Is it ok
7402 * to call csrRoamComplete() with state as CsrJoinFailure */
7403 else
7404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007405 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 result = eCsrReassocFailure;
7407#ifdef WLAN_FEATURE_VOWIFI_11R
7408 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7409 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7410 {
7411 // Inform HDD to turn off FT flag in HDD
7412 if (pNeighborRoamInfo)
7413 {
7414 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7415 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7416 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007417 /*
7418 * Since the above callback sends a disconnect
7419 * to HDD, we should clean-up our state
7420 * machine as well to be in sync with the upper
7421 * layers. There is no need to send a disassoc
7422 * since: 1) we will never reassoc to the current
7423 * AP in LFR, and 2) there is no need to issue a
7424 * disassoc to the AP with which we were trying
7425 * to reassoc.
7426 */
7427 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7428 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 }
7430 }
7431#endif
7432 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7433 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7434 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7435 //The disassoc rsp message will remove the command from active list
7436 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7437 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7438 {
7439 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7440 }
7441 }
7442}
7443
Jeff Johnson295189b2012-06-20 16:38:30 -07007444static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7445{
Jeff Johnson295189b2012-06-20 16:38:30 -07007446#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7447 {
7448 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7450 if(pIbssLog)
7451 {
7452 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7453 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7454 {
7455 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7456 }
7457 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7458 }
7459 }
7460#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7462 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7463 {
7464 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7465 }
7466 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7467 {
7468 csrRoamReissueRoamCommand(pMac);
7469 }
7470}
7471
Jeff Johnson295189b2012-06-20 16:38:30 -07007472void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7473{
7474 tSirResultCodes statusCode;
7475#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7476 tScanResultHandle hBSSList;
7477 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7478 eHalStatus status;
7479 tCsrRoamInfo roamInfo;
7480 tCsrScanResultFilter *pScanFilter = NULL;
7481 tANI_U32 roamId = 0;
7482 tCsrRoamProfile *pCurRoamProfile = NULL;
7483 tListElem *pEntry = NULL;
7484 tSmeCmd *pCommand = NULL;
7485#endif
7486 tANI_U32 sessionId;
7487 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007488
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 tSirSmeDisassocRsp SmeDisassocRsp;
7490
7491 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7492 sessionId = SmeDisassocRsp.sessionId;
7493 statusCode = SmeDisassocRsp.statusCode;
7494
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007495 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007496
7497 if ( csrIsConnStateInfra( pMac, sessionId ) )
7498 {
7499 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007502
7503 if(!pSession)
7504 {
7505 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7506 return;
7507 }
7508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7510 {
7511 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7512 }
7513 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7514 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7515 {
7516 if ( eSIR_SME_SUCCESS == statusCode )
7517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007518 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7520 }
7521 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007523 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007525 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007526#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007527 /*
7528 * First ensure if the roam profile is in the scan cache.
7529 * If not, post a reassoc failure and disconnect.
7530 */
7531 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7532 if(HAL_STATUS_SUCCESS(status))
7533 {
7534 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7535 status = csrRoamPrepareFilterFromProfile(pMac,
7536 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7537 if(!HAL_STATUS_SUCCESS(status))
7538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007539 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007540 __func__, status);
7541 goto POST_ROAM_FAILURE;
7542 }
7543 else
7544 {
7545 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7546 if (!HAL_STATUS_SUCCESS(status))
7547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007548 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007549 __func__, status);
7550 goto POST_ROAM_FAILURE;
7551 }
7552 }
7553 }
7554 else
7555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007556 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007557 __func__, status);
7558 goto POST_ROAM_FAILURE;
7559 }
7560
7561 /*
7562 * After ensuring that the roam profile is in the scan result list,
7563 * dequeue the command from the active list.
7564 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7566 if ( pEntry )
7567 {
7568 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007569 /* If the head of the queue is Active and it is a ROAM command, remove
7570 * and put this on the Free queue.
7571 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 if ( eSmeCommandRoam == pCommand->command )
7573 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007574
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007575 /*
7576 * we need to process the result first before removing it from active list
7577 * because state changes still happening insides roamQProcessRoamResults so
7578 * no other roam command should be issued.
7579 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7581 if(pCommand->u.roamCmd.fReleaseProfile)
7582 {
7583 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7584 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 else
7589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007590 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007591 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 }
7593 }
7594 else
7595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007596 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007597 }
7598 }
7599 else
7600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007601 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007603
7604 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7606
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007607 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7608 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7609 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007610
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007611 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7612 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007613
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007614 /* Copy the connected profile to apply the same for this connection as well */
7615 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7616 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007618 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7619 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7620 //make sure to put it at the head of the cmd queue
7621 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7622 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7623 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7624
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 if(!HAL_STATUS_SUCCESS(status))
7626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007627 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007628 __func__, status);
7629 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 }
7631
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007632 /* Notify sub-modules like QoS etc. that handoff happening */
7633 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007634 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007635 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 csrFreeScanFilter(pMac, pScanFilter);
7637 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007638 return;
7639 }
7640
7641POST_ROAM_FAILURE:
7642 if (pScanFilter)
7643 {
7644 csrFreeScanFilter(pMac, pScanFilter);
7645 palFreeMemory( pMac->hHdd, pScanFilter );
7646 }
7647 if (pCurRoamProfile)
7648 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7649
7650 /* Inform the upper layers that the reassoc failed */
7651 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7652 csrRoamCallCallback(pMac, sessionId,
7653 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7654
7655 /*
7656 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7657 * Upon success, we would re-enter this routine after receiving the disassoc
7658 * response and will fall into the reassoc fail sub-state. And, eventually
7659 * call csrRoamComplete which would remove the roam command from SME active
7660 * queue.
7661 */
7662 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7663 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007665 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007666 __func__, status);
7667 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007669#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007670
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7672 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7673 {
7674 // Disassoc due to Reassoc failure falls into this codepath....
7675 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7676 }
7677 else
7678 {
7679 if ( eSIR_SME_SUCCESS == statusCode )
7680 {
7681 // Successfully disassociated from the 'old' Bss...
7682 //
7683 // We get Disassociate response in three conditions.
7684 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7685 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7686 // Infrastructure network.
7687 // - Third is where we are doing an Infra to Infra roam between networks with different
7688 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7689
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007690 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 }
7692 else
7693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007694 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 }
7696 //We are not done yet. Get the data and continue roaming
7697 csrRoamReissueRoamCommand(pMac);
7698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007699}
7700
Jeff Johnson295189b2012-06-20 16:38:30 -07007701static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7702{
7703 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007705 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7707 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7708 {
7709 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7710 }
7711 else
7712 {
7713 if ( eSIR_SME_SUCCESS == statusCode )
7714 {
7715 // Successfully deauth from the 'old' Bss...
7716 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007717 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 }
7719 else
7720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007721 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 }
7723 //We are not done yet. Get the data and continue roaming
7724 csrRoamReissueRoamCommand(pMac);
7725 }
7726}
7727
Jeff Johnson295189b2012-06-20 16:38:30 -07007728static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7729{
7730 eCsrRoamCompleteResult result;
7731
7732 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007734 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 result = eCsrStartBssSuccess;
7736 }
7737 else
7738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007739 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 //Let csrRoamComplete decide what to do
7741 result = eCsrStartBssFailure;
7742 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007744}
7745
Jeff Johnson295189b2012-06-20 16:38:30 -07007746/*
7747 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7748 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7749 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7750 For the messages where sender allocates memory for specific structures, then it can be
7751 cast accordingly.
7752*/
7753void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7754{
7755 tSirSmeRsp *pSmeRsp;
7756 tSmeIbssPeerInd *pIbssPeerInd;
7757 tCsrRoamInfo roamInfo;
7758 // TODO Session Id need to be acquired in this function
7759 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007761 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 pSmeRsp->messageType, pSmeRsp->messageType,
7763 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 pSmeRsp->messageType = (pSmeRsp->messageType);
7765 pSmeRsp->length = (pSmeRsp->length);
7766 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 switch (pSmeRsp->messageType)
7768 {
7769
7770 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7771 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7772 {
7773 //We sent a JOIN_REQ
7774 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7775 }
7776 break;
7777
7778 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7779 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7780 {
7781 //We sent a AUTH_REQ
7782 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7783 }
7784 break;
7785
7786 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7787 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7788 {
7789 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7790 }
7791 break;
7792
7793 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7794 {
7795 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7796 }
7797 break;
7798
7799 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7800 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7801 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7802 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7803 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7804 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7805//HO
7806 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007808 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7810 }
7811 break;
7812
7813 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7814 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7815 {
7816 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7817 }
7818 break;
7819
7820 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7821 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7822 {
7823 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7824 }
7825 break;
7826
7827 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7828 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7829 {
7830 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7834 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7835 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007836 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7838 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7839 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7840 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7841 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7842 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7843 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7844 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7845 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007847 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 pSmeRsp->messageType, pSmeRsp->messageType,
7849 pMac->roam.curSubState[pSmeRsp->sessionId] );
7850
7851 //If we are connected, check the link status change
7852 if(!csrIsConnStateDisconnected(pMac, sessionId))
7853 {
7854 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7855 }
7856 break;
7857 }
7858}
7859
Jeff Johnson295189b2012-06-20 16:38:30 -07007860void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7861{
7862 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 switch (pSirMsg->messageType)
7864 {
7865 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007866 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007867 csrRoamStatsRspProcessor( pMac, pSirMsg );
7868 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7870 {
7871 tCsrRoamSession *pSession;
7872 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7873 tCsrRoamInfo roamInfo;
7874 tCsrRoamInfo *pRoamInfo = NULL;
7875 tANI_U32 sessionId;
7876 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007877 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7879 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7881 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7882 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007883
7884 if(!pSession)
7885 {
7886 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7887 return;
7888 }
7889
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7891 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7893 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7894 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7896 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7898 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007899 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7901 {
7902 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7903 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7904 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7905 }
7906 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7907 {
7908 vos_sleep( 100 );
7909 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7910 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7911 }
7912
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 }
7914 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007915 default:
7916 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7917 break;
7918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007919}
7920
Jeff Johnson295189b2012-06-20 16:38:30 -07007921eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7922 tSirBssDescription *pBssDescription,
7923 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7924 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7925 tANI_U8 keyId, tANI_U16 keyLength,
7926 tANI_U8 *pKey, tANI_U8 paeRole )
7927{
7928 eHalStatus status = eHAL_STATUS_SUCCESS;
7929 tAniEdType edType;
7930
7931 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7932 {
7933 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7934 }
7935
7936 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7937
7938 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7939 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7940 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7941 addKey )
7942 {
7943 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 setKey.encType = EncryptType;
7945 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7946 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7947 setKey.paeRole = paeRole; //0 for supplicant
7948 setKey.keyId = keyId; // Kye index
7949 setKey.keyLength = keyLength;
7950 if( keyLength )
7951 {
7952 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7953 }
7954 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 return (status);
7957}
7958
Jeff Johnson295189b2012-06-20 16:38:30 -07007959static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7960 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7961{
7962 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7963 tSmeCmd *pCommand = NULL;
7964#ifdef FEATURE_WLAN_CCX
7965 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7966#endif /* FEATURE_WLAN_CCX */
7967
7968 do
7969 {
7970 pCommand = csrGetCommandBuffer(pMac);
7971 if(NULL == pCommand)
7972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007973 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 status = eHAL_STATUS_RESOURCES;
7975 break;
7976 }
7977 pCommand->command = eSmeCommandSetKey;
7978 pCommand->sessionId = (tANI_U8)sessionId;
7979 // validate the key length, Adjust if too long...
7980 // for static WEP the keys are not set thru' SetContextReq
7981 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7982 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7983 {
7984 //KeyLength maybe 0 for static WEP
7985 if( pSetKey->keyLength )
7986 {
7987 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007989 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 break;
7991 }
7992
7993 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7994 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7995 }
7996 }
7997 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7998 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7999 {
8000 //KeyLength maybe 0 for static WEP
8001 if( pSetKey->keyLength )
8002 {
8003 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8004 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008005 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 break;
8007 }
8008
8009 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8010 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8011 }
8012 }
8013 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8014 {
8015 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8016 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008017 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 break;
8019 }
8020 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8021 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8022 }
8023 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8024 {
8025 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008027 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 break;
8029 }
8030 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8031 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8032 }
8033#ifdef FEATURE_WLAN_WAPI
8034 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8035 {
8036 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008038 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 break;
8040 }
8041 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8042 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8043 }
8044#endif /* FEATURE_WLAN_WAPI */
8045#ifdef FEATURE_WLAN_CCX
8046 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8047 {
8048 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008050 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 break;
8052 }
8053 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8054 pSession->ccxCckmInfo.reassoc_req_num=1;
8055 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8056 status = eHAL_STATUS_SUCCESS;
8057 break;
8058 }
8059#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008060
Jeff Johnson295189b2012-06-20 16:38:30 -07008061#ifdef WLAN_FEATURE_11W
8062 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008063 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008065 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008067 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 break;
8069 }
8070 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008071 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 }
8073#endif
8074 status = eHAL_STATUS_SUCCESS;
8075 pCommand->u.setKeyCmd.roamId = roamId;
8076 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8077 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8078 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8079 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8080 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8081 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8082 //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
8083
8084 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8085 if( !HAL_STATUS_SUCCESS( status ) )
8086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008087 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 }
8089 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 // Free the command if there has been a failure, or it is a
8091 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008092 if ( ( NULL != pCommand ) &&
8093 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008094#ifdef FEATURE_WLAN_CCX
8095 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8096#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008097 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 {
8099 csrReleaseCommandSetKey( pMac, pCommand );
8100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 return( status );
8102}
8103
Jeff Johnson295189b2012-06-20 16:38:30 -07008104eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8105 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8106{
8107 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8108 tSmeCmd *pCommand = NULL;
8109 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008110 do
8111 {
8112 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008114 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 status = eHAL_STATUS_CSR_WRONG_STATE;
8116 break;
8117 }
8118 pCommand = csrGetCommandBuffer(pMac);
8119 if(NULL == pCommand)
8120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008121 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 status = eHAL_STATUS_RESOURCES;
8123 break;
8124 }
8125 pCommand->command = eSmeCommandRemoveKey;
8126 pCommand->sessionId = (tANI_U8)sessionId;
8127 pCommand->u.removeKeyCmd.roamId = roamId;
8128 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8129 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8130 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8131 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8132 {
8133 //in this case, put it to the end of the Q incase there is a set key pending.
8134 fImediate = eANI_BOOLEAN_FALSE;
8135 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008136 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008137 pRemoveKey->encType, pRemoveKey->keyId,
8138 pCommand->u.removeKeyCmd.peerMac[0],
8139 pCommand->u.removeKeyCmd.peerMac[1],
8140 pCommand->u.removeKeyCmd.peerMac[2],
8141 pCommand->u.removeKeyCmd.peerMac[3],
8142 pCommand->u.removeKeyCmd.peerMac[4],
8143 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8145 if( !HAL_STATUS_SUCCESS( status ) )
8146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008147 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 break;
8149 }
8150 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8152 {
8153 csrReleaseCommandRemoveKey( pMac, pCommand );
8154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 return (status );
8156}
8157
Jeff Johnson295189b2012-06-20 16:38:30 -07008158eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8159{
8160 eHalStatus status;
8161 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8162 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8163 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8164 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008165#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8167 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8169 {
8170 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8171 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8172 {
8173 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8174 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8175 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8176 }
8177 else
8178 {
8179 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8180 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8181 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8182 }
8183 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8184 if(CSR_IS_ENC_TYPE_STATIC(edType))
8185 {
8186 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 //It has to be static WEP here
8188 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8189 {
8190 setKeyEvent.keyId = (v_U8_t)defKeyId;
8191 }
8192 }
8193 else
8194 {
8195 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8196 }
8197 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8198 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8199 }
8200#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 if( csrIsSetKeyAllowed(pMac, sessionId) )
8202 {
8203 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8204 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8205 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8206 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8207 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8208 pCommand->u.setKeyCmd.keyRsc);
8209 }
8210 else
8211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008212 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 //Set this status so the error handling take care of the case.
8214 status = eHAL_STATUS_CSR_WRONG_STATE;
8215 }
8216 if( !HAL_STATUS_SUCCESS(status) )
8217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008218 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008220#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8221 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8222 {
8223 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8224 {
8225 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8226 }
8227 else
8228 {
8229 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8230 }
8231 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8232 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8233 }
8234#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 return ( status );
8237}
8238
Jeff Johnson295189b2012-06-20 16:38:30 -07008239eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8240{
8241 eHalStatus status;
8242 tpSirSmeRemoveKeyReq pMsg = NULL;
8243 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8244 tANI_U8 *p;
8245 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008246#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8247 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8248 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8250 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8251 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8252 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8253 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8254 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8255 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8256 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8257#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 if( csrIsSetKeyAllowed(pMac, sessionId) )
8259 {
8260 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8261 }
8262 else
8263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008264 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 //Set the error status so error handling kicks in below
8266 status = eHAL_STATUS_CSR_WRONG_STATE;
8267 }
8268 if( HAL_STATUS_SUCCESS( status ) )
8269 {
8270 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8271 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8272 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 pMsg->sessionId = (tANI_U8)sessionId;
8274 pMsg->transactionId = 0;
8275 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8276 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8277 // bssId - copy from session Info
8278 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8279 p += sizeof(tSirMacAddr);
8280 // peerMacAddr
8281 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8282 p += sizeof(tSirMacAddr);
8283 // edType
8284 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8285 p++;
8286 // weptype
8287 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8288 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8289 {
8290 *p = (tANI_U8)eSIR_WEP_STATIC;
8291 }
8292 else
8293 {
8294 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8295 }
8296 p++;
8297 //keyid
8298 *p = pCommand->u.removeKeyCmd.keyId;
8299 p++;
8300 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 status = palSendMBMessage(pMac->hHdd, pMsg);
8302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 if( !HAL_STATUS_SUCCESS( status ) )
8304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008305 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008306#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8307 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008308 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8310#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 return ( status );
8314}
8315
Jeff Johnson295189b2012-06-20 16:38:30 -07008316eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8317{
8318 eHalStatus status;
8319
8320 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8321 {
8322 status = eHAL_STATUS_CSR_WRONG_STATE;
8323 }
8324 else
8325 {
8326 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 return ( status );
8329}
8330
Jeff Johnson295189b2012-06-20 16:38:30 -07008331/*
8332 Prepare a filter base on a profile for parsing the scan results.
8333 Upon successful return, caller MUST call csrFreeScanFilter on
8334 pScanFilter when it is done with the filter.
8335*/
8336eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8337 tCsrScanResultFilter *pScanFilter)
8338{
8339 eHalStatus status = eHAL_STATUS_SUCCESS;
8340 tANI_U32 size = 0;
8341 tANI_U8 index = 0;
8342
8343 do
8344 {
8345 if(pProfile->BSSIDs.numOfBSSIDs)
8346 {
8347 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8348 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8349 if(!HAL_STATUS_SUCCESS(status))
8350 {
8351 break;
8352 }
8353 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8354 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8355 }
8356 if(pProfile->SSIDs.numOfSSIDs)
8357 {
8358 if( !CSR_IS_WDS_STA( pProfile ) )
8359 {
8360 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8361 }
8362 else
8363 {
8364 //For WDS station
8365 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8366 pScanFilter->SSIDs.numOfSSIDs = 1;
8367 }
8368 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8369 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8370 if(!HAL_STATUS_SUCCESS(status))
8371 {
8372 break;
8373 }
8374 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8375 }
8376 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8377 {
8378 pScanFilter->ChannelInfo.numOfChannels = 0;
8379 pScanFilter->ChannelInfo.ChannelList = NULL;
8380 }
8381 else if(pProfile->ChannelInfo.numOfChannels)
8382 {
8383 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8384 pScanFilter->ChannelInfo.numOfChannels = 0;
8385 if(HAL_STATUS_SUCCESS(status))
8386 {
8387 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8388 {
8389 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8390 {
8391 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8392 = pProfile->ChannelInfo.ChannelList[index];
8393 pScanFilter->ChannelInfo.numOfChannels++;
8394 }
8395 else
8396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008397 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 }
8400 }
8401 else
8402 {
8403 break;
8404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 }
8406 else
8407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008408 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 status = eHAL_STATUS_FAILURE;
8410 break;
8411 }
8412 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8413 pScanFilter->authType = pProfile->AuthType;
8414 pScanFilter->EncryptionType = pProfile->EncryptionType;
8415 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8416 pScanFilter->BSSType = pProfile->BSSType;
8417 pScanFilter->phyMode = pProfile->phyMode;
8418#ifdef FEATURE_WLAN_WAPI
8419 //check if user asked for WAPI with 11n or auto mode, in that case modify
8420 //the phymode to 11g
8421 if(csrIsProfileWapi(pProfile))
8422 {
8423 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8424 {
8425 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8426 }
8427 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8428 {
8429 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8430 }
8431 if(!pScanFilter->phyMode)
8432 {
8433 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8434 }
8435 }
8436#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 /*Save the WPS info*/
8438 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 if( pProfile->countryCode[0] )
8440 {
8441 //This causes the matching function to use countryCode as one of the criteria.
8442 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8443 WNI_CFG_COUNTRY_CODE_LEN );
8444 }
8445#ifdef WLAN_FEATURE_VOWIFI_11R
8446 if (pProfile->MDID.mdiePresent)
8447 {
8448 pScanFilter->MDID.mdiePresent = 1;
8449 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8450 }
8451#endif
8452
8453 }while(0);
8454
8455 if(!HAL_STATUS_SUCCESS(status))
8456 {
8457 csrFreeScanFilter(pMac, pScanFilter);
8458 }
8459
8460 return(status);
8461}
8462
Jeff Johnson295189b2012-06-20 16:38:30 -07008463tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8464 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8465{
8466 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8467 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 do
8469 {
8470 // Validate the type is ok...
8471 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8472 pCommand = csrGetCommandBuffer( pMac );
8473 if ( !pCommand )
8474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008475 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 break;
8477 }
8478 //Change the substate in case it is waiting for key
8479 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8480 {
8481 csrRoamStopWaitForKeyTimer( pMac );
8482 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8483 }
8484 pCommand->command = eSmeCommandWmStatusChange;
8485 pCommand->sessionId = (tANI_U8)sessionId;
8486 pCommand->u.wmStatusChangeCmd.Type = Type;
8487 if ( eCsrDisassociated == Type )
8488 {
8489 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8490 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8491 }
8492 else
8493 {
8494 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8495 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8496 }
8497 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8498 {
8499 fCommandQueued = eANI_BOOLEAN_TRUE;
8500 }
8501 else
8502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008503 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 csrReleaseCommandWmStatusChange( pMac, pCommand );
8505 }
8506
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8508 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 return( fCommandQueued );
8511}
8512
Jeff Johnson295189b2012-06-20 16:38:30 -07008513static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8514{
8515 v_S7_t rssi = 0;
8516 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8517 if(pGetRssiReq)
8518 {
8519 if(NULL != pGetRssiReq->pVosContext)
8520 {
8521 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8522 }
8523 else
8524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008525 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 return;
8527 }
8528
8529 if(NULL != pGetRssiReq->rssiCallback)
8530 {
8531 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8532 }
8533 else
8534 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008535 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 return;
8537 }
8538 }
8539 else
8540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008541 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 }
8543 return;
8544}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008545#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8546void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8547{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008548 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8549
Jeff Johnson36d483b2013-04-08 11:08:53 -07008550 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008551 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008552 /* Get roam Rssi request is backed up and passed back to the response,
8553 Extract the request message to fetch callback */
8554 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8555 v_S7_t rssi = pRoamRssiRsp->rssi;
8556
8557 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008558 {
8559 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8560 reqBkp->rssiCallback = NULL;
8561 vos_mem_free(reqBkp);
8562 }
8563 else
8564 {
8565 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8566 if (NULL != reqBkp)
8567 {
8568 vos_mem_free(reqBkp);
8569 }
8570 }
8571 }
8572 else
8573 {
8574 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8575 }
8576 return;
8577}
8578#endif
8579
Jeff Johnsone7245742012-09-05 17:12:55 -07008580static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8581{
8582 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8583 if(pTlRssiInd)
8584 {
8585 if(NULL != pTlRssiInd->tlCallback)
8586 {
8587 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008588 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008589 }
8590 else
8591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008592 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008593 }
8594 }
8595 else
8596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008597 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008598 }
8599 return;
8600}
Jeff Johnson295189b2012-06-20 16:38:30 -07008601
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308602eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8603{
8604 tpSirResetAPCapsChange pMsg;
8605 tANI_U16 len;
8606 eHalStatus status = eHAL_STATUS_SUCCESS;
8607
8608 /* Create the message and send to lim */
8609 len = sizeof(tSirResetAPCapsChange);
8610 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8611 if (HAL_STATUS_SUCCESS(status))
8612 {
8613 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8614 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8615 pMsg->length = len;
8616 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8617 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8618 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8619 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8620 status = palSendMBMessage(pMac->hHdd, pMsg);
8621 }
8622 else
8623 {
8624 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8625 }
8626 return status;
8627}
8628
Jeff Johnson295189b2012-06-20 16:38:30 -07008629void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8630{
8631 tSirSmeAssocInd *pAssocInd;
8632 tSirSmeDisassocInd *pDisassocInd;
8633 tSirSmeDeauthInd *pDeauthInd;
8634 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8635 tSirSmeNewBssInfo *pNewBss;
8636 tSmeIbssPeerInd *pIbssPeerInd;
8637 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8638 tSirSmeApNewCaps *pApNewCaps;
8639 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8640 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8641 tCsrRoamInfo *pRoamInfo = NULL;
8642 tCsrRoamInfo roamInfo;
8643 eHalStatus status;
8644 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8645 tCsrRoamSession *pSession = NULL;
8646 tpSirSmeSwitchChannelInd pSwitchChnInd;
8647 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008648 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 pSirMsg->messageType = (pSirMsg->messageType);
8650 pSirMsg->length = (pSirMsg->length);
8651 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 switch( pSirMsg->messageType )
8654 {
8655 case eWNI_SME_ASSOC_IND:
8656 {
8657 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008658 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008659 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8660 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8661 if( HAL_STATUS_SUCCESS( status ) )
8662 {
8663 pSession = CSR_GET_SESSION(pMac, sessionId);
8664
Jeff Johnson32d95a32012-09-10 13:15:23 -07008665 if(!pSession)
8666 {
8667 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8668 return;
8669 }
8670
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 pRoamInfo = &roamInfo;
8672
8673 // Required for indicating the frames to upper layer
8674 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8675 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8676
8677 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8678 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8679 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8680 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8681
8682 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8683 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8684 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8685
8686 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8687 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8689 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8691 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008692 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8694 {
8695 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8696 {
8697 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8698 pSession->pConnectBssDesc,
8699 &(pRoamInfo->peerMac),
8700 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8701 pRoamInfo->fAuthRequired = FALSE;
8702 }
8703 else
8704 {
8705 pRoamInfo->fAuthRequired = TRUE;
8706 }
8707 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8708 if (!HAL_STATUS_SUCCESS(status))
8709 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 /* Send Association completion message to PE */
8712 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8713
8714 /* send a message to CSR itself just to avoid the EAPOL frames going
8715 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8717 {
8718 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8721 {
8722 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8723 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8724 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 }
8727 }
8728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008730 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 // Check if AP dis-associated us because of MIC failure. If so,
8732 // then we need to take action immediately and not wait till the
8733 // the WmStatusChange requests is pushed and processed
8734 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8735 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8736 if( HAL_STATUS_SUCCESS( status ) )
8737 {
8738 // If we are in neighbor preauth done state then on receiving
8739 // disassoc or deauth we dont roam instead we just disassoc
8740 // from current ap and then go to disconnected state
8741 // This happens for CCX and 11r FT connections ONLY.
8742#ifdef WLAN_FEATURE_VOWIFI_11R
8743 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8744 {
8745 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8746 }
8747#endif
8748#ifdef FEATURE_WLAN_CCX
8749 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8750 {
8751 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8752 }
8753#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008754#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308755 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008756 {
8757 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8758 }
8759#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 pSession = CSR_GET_SESSION( pMac, sessionId );
8761
Jeff Johnson32d95a32012-09-10 13:15:23 -07008762 if(!pSession)
8763 {
8764 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8765 return;
8766 }
8767
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 if ( csrIsConnStateInfra( pMac, sessionId ) )
8769 {
8770 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008772#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8773 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8774#endif
8775 csrRoamLinkDown(pMac, sessionId);
8776 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8778 {
8779
8780 pRoamInfo = &roamInfo;
8781
8782 pRoamInfo->statusCode = pDisassocInd->statusCode;
8783 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8784
8785 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8786
8787 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8788 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8789
8790 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008791
8792 /*
8793 * STA/P2P client got disassociated so remove any pending deauth
8794 * commands in sme pending list
8795 */
8796 pCommand.command = eSmeCommandRoam;
8797 pCommand.sessionId = (tANI_U8)sessionId;
8798 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8799 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8800 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 }
8803 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008805 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8807 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8808 if( HAL_STATUS_SUCCESS( status ) )
8809 {
8810 // If we are in neighbor preauth done state then on receiving
8811 // disassoc or deauth we dont roam instead we just disassoc
8812 // from current ap and then go to disconnected state
8813 // This happens for CCX and 11r FT connections ONLY.
8814#ifdef WLAN_FEATURE_VOWIFI_11R
8815 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8816 {
8817 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8818 }
8819#endif
8820#ifdef FEATURE_WLAN_CCX
8821 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8822 {
8823 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8824 }
8825#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008826#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308827 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008828 {
8829 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8830 }
8831#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 pSession = CSR_GET_SESSION( pMac, sessionId );
8833
Jeff Johnson32d95a32012-09-10 13:15:23 -07008834 if(!pSession)
8835 {
8836 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8837 return;
8838 }
8839
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 if ( csrIsConnStateInfra( pMac, sessionId ) )
8841 {
8842 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008844#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8845 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8846#endif
8847 csrRoamLinkDown(pMac, sessionId);
8848 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8850 {
8851
8852 pRoamInfo = &roamInfo;
8853
8854 pRoamInfo->statusCode = pDeauthInd->statusCode;
8855 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8856
8857 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8858
8859 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8860 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8861
8862 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008864 }
8865 break;
8866
8867 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008868 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8870 //Update with the new channel id.
8871 //The channel id is hidden in the statusCode.
8872 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8873 if( HAL_STATUS_SUCCESS( status ) )
8874 {
8875 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008876 if(!pSession)
8877 {
8878 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8879 return;
8880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8882 if(pSession->pConnectBssDesc)
8883 {
8884 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8885 }
8886 }
8887 break;
8888
8889 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008890 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 {
8892 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8893 sessionId = pDeauthRsp->sessionId;
8894 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8895 {
8896 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008897 if(!pSession)
8898 {
8899 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8900 return;
8901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8903 {
8904 pRoamInfo = &roamInfo;
8905 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8906 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8907 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8908 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8909 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8910 }
8911 }
8912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 break;
8914
8915 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008916 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008917 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 {
8919 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8920 sessionId = pDisassocRsp->sessionId;
8921 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8922 {
8923 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008924 if(!pSession)
8925 {
8926 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8927 return;
8928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8930 {
8931 pRoamInfo = &roamInfo;
8932 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8933 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8934 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8935 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8936 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8937 }
8938 }
8939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 case eWNI_SME_MIC_FAILURE_IND:
8942 {
8943 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8944 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8945 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008946#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8947 {
8948 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008949 if(!pSession)
8950 {
8951 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8952 return;
8953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8955 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8956 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8957 secEvent.encryptionModeMulticast =
8958 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8959 secEvent.encryptionModeUnicast =
8960 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8961 secEvent.authMode =
8962 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8963 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8964 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8965 }
8966#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8968 if( HAL_STATUS_SUCCESS( status ) )
8969 {
8970 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8971 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8972 pRoamInfo = &roamInfo;
8973 if(pMicInd->info.multicast)
8974 {
8975 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8976 }
8977 else
8978 {
8979 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8980 }
8981 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8982 }
8983 }
8984 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8986 {
8987 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8988 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008989 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008990
8991 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8992 if( HAL_STATUS_SUCCESS( status ) )
8993 {
8994 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8995 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8996 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8997 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8998 }
8999 }
9000 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009001
Jeff Johnson295189b2012-06-20 16:38:30 -07009002 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9003 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9004 switch( pStatusChangeMsg->statusChangeCode )
9005 {
9006 case eSIR_SME_IBSS_ACTIVE:
9007 sessionId = csrFindIbssSession( pMac );
9008 if( CSR_SESSION_ID_INVALID != sessionId )
9009 {
9010 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009011 if(!pSession)
9012 {
9013 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9014 return;
9015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009016 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9017 if(pSession->pConnectBssDesc)
9018 {
9019 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9020 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9021 pRoamInfo = &roamInfo;
9022 }
9023 else
9024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009025 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 }
9027 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9028 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9029 }
9030 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 case eSIR_SME_IBSS_INACTIVE:
9032 sessionId = csrFindIbssSession( pMac );
9033 if( CSR_SESSION_ID_INVALID != sessionId )
9034 {
9035 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009036 if(!pSession)
9037 {
9038 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9039 return;
9040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9042 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9043 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9044 }
9045 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9047 sessionId = csrFindIbssSession( pMac );
9048 if( CSR_SESSION_ID_INVALID != sessionId )
9049 {
9050 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009051 if(!pSession)
9052 {
9053 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9054 return;
9055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 // update the connection state information
9057 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009058#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9059 {
9060 vos_log_ibss_pkt_type *pIbssLog;
9061 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9063 if(pIbssLog)
9064 {
9065 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9066 if(pNewBss)
9067 {
9068 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9069 if(pNewBss->ssId.length)
9070 {
9071 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9072 }
9073 pIbssLog->operatingChannel = pNewBss->channelNumber;
9074 }
9075 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9076 {
9077 //***U8 is not enough for beacon interval
9078 pIbssLog->beaconInterval = (v_U8_t)bi;
9079 }
9080 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9081 }
9082 }
9083#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009085
9086 if ((eCSR_ENCRYPT_TYPE_NONE ==
9087 pSession->connectedProfile.EncryptionType ))
9088 {
9089 csrRoamIssueSetContextReq( pMac, sessionId,
9090 pSession->connectedProfile.EncryptionType,
9091 pSession->pConnectBssDesc,
9092 &Broadcastaddr,
9093 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009095 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9096 roamStatus = eCSR_ROAM_IBSS_IND;
9097 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9098 pRoamInfo = &roamInfo;
9099 //This BSSID is th ereal BSSID, let's save it
9100 if(pSession->pConnectBssDesc)
9101 {
9102 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9103 }
9104 // Stop the join IBSS timer in case of join, for
9105 // genuine merge do nothing
9106 if(pSession->ibss_join_pending)
9107 {
9108 pSession->ibss_join_pending = FALSE;
9109 csrRoamStopIbssJoinTimer(pMac, sessionId);
9110 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9111 }
9112 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009113 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 // detection by LIM that the capabilities of the associated AP have changed.
9116 case eSIR_SME_AP_CAPS_CHANGED:
9117 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009118 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9120 if( HAL_STATUS_SUCCESS( status ) )
9121 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009122 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9123 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309124 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009125 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9126 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9127 )
9128 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309129 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9130 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009131 }
9132 else
9133 {
9134 smsLog(pMac, LOGW,
9135 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009136 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009137 pMac->roam.curState[sessionId],
9138 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309139 /* We ignore the caps change event if CSR is not in full connected state.
9140 * Send one event to PE to reset limSentCapsChangeNtf
9141 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9142 * otherwise lim cannot send any CAPS change events to SME */
9143 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009145 }
9146 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309147
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 default:
9149 roamStatus = eCSR_ROAM_FAILED;
9150 result = eCSR_ROAM_RESULT_NONE;
9151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 } // end switch on statusChangeCode
9153 if(eCSR_ROAM_RESULT_NONE != result)
9154 {
9155 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9156 }
9157 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 case eWNI_SME_IBSS_NEW_PEER_IND:
9159 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009160#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9161 {
9162 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9164 if(pIbssLog)
9165 {
9166 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9167 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9168 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9169 }
9170 }
9171#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009172 sessionId = csrFindIbssSession( pMac );
9173 if( CSR_SESSION_ID_INVALID != sessionId )
9174 {
9175 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009176
9177 if(!pSession)
9178 {
9179 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9180 return;
9181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9183 if(pSession->pConnectBssDesc)
9184 {
9185 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9186 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9187 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9188 {
9189 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9190 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9191 if(HAL_STATUS_SUCCESS(status))
9192 {
9193 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9194 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9195 roamInfo.nBeaconLength);
9196 }
9197 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9198 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9199 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9200 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9201 pSession->pConnectBssDesc->length);
9202 if(HAL_STATUS_SUCCESS(status))
9203 {
9204 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9205 pSession->pConnectBssDesc->length);
9206 }
9207 if(HAL_STATUS_SUCCESS(status))
9208 {
9209 pRoamInfo = &roamInfo;
9210 }
9211 else
9212 {
9213 if(roamInfo.pbFrames)
9214 {
9215 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9216 }
9217 if(roamInfo.pBssDesc)
9218 {
9219 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9220 }
9221 }
9222 }
9223 else
9224 {
9225 pRoamInfo = &roamInfo;
9226 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009227 if ((eCSR_ENCRYPT_TYPE_NONE ==
9228 pSession->connectedProfile.EncryptionType ))
9229 {
9230 csrRoamIssueSetContextReq( pMac, sessionId,
9231 pSession->connectedProfile.EncryptionType,
9232 pSession->pConnectBssDesc,
9233 &(pIbssPeerInd->peerAddr),
9234 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 }
9237 else
9238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009239 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 }
9241 //send up the sec type for the new peer
9242 if (pRoamInfo)
9243 {
9244 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9245 }
9246 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9247 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9248 if(pRoamInfo)
9249 {
9250 if(roamInfo.pbFrames)
9251 {
9252 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9253 }
9254 if(roamInfo.pBssDesc)
9255 {
9256 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9257 }
9258 }
9259 }
9260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009261 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9262 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9263 sessionId = csrFindIbssSession( pMac );
9264 if( CSR_SESSION_ID_INVALID != sessionId )
9265 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009266#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9267 {
9268 vos_log_ibss_pkt_type *pIbssLog;
9269
9270 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9271 if(pIbssLog)
9272 {
9273 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9274 if(pIbssPeerInd)
9275 {
9276 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9277 }
9278 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9279 }
9280 }
9281#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009282 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009283 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9284 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9285 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9286 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9287 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9288 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9289 }
9290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 case eWNI_SME_SETCONTEXT_RSP:
9292 {
9293 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9294 tListElem *pEntry;
9295 tSmeCmd *pCommand;
9296
9297 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9298 if ( pEntry )
9299 {
9300 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9301 if ( eSmeCommandSetKey == pCommand->command )
9302 {
9303 sessionId = pCommand->sessionId;
9304 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009305
9306 if(!pSession)
9307 {
9308 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9309 return;
9310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009311
9312#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9313 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9314 {
9315 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9316 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9317 if( pRsp->peerMacAddr[0] & 0x01 )
9318 {
9319 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9320 }
9321 else
9322 {
9323 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9324 }
9325 setKeyEvent.encryptionModeMulticast =
9326 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9327 setKeyEvent.encryptionModeUnicast =
9328 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9329 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9330 setKeyEvent.authMode =
9331 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9332 if( eSIR_SUCCESS != pRsp->statusCode )
9333 {
9334 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9335 }
9336 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9337 }
9338#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9339 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9340 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009341 csrRoamStopWaitForKeyTimer( pMac );
9342
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 //We are done with authentication, whethere succeed or not
9344 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 //We do it here because this linkup function is not called after association
9346 //when a key needs to be set.
9347 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9348 {
9349 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9350 }
9351 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009352 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009353 {
9354 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009355 //Make sure we install the GTK before indicating to HDD as authenticated
9356 //This is to prevent broadcast packets go out after PTK and before GTK.
9357 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9358 sizeof(tSirMacAddr) ) )
9359 {
Yathish9f22e662012-12-10 14:21:35 -08009360#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9361 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9362 {
9363 tpSirSetActiveModeSetBncFilterReq pMsg;
9364 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9365 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9366 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9367 pMsg->seesionId = sessionId;
9368 status = palSendMBMessage(pMac->hHdd, pMsg );
9369 }
9370#endif
9371 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009372 }
9373 else
9374 {
9375 result = eCSR_ROAM_RESULT_NONE;
9376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 pRoamInfo = &roamInfo;
9378 }
9379 else
9380 {
9381 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009382 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9384 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9385 }
9386 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9387 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009388 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9389 // can go ahead and initiate the TSPEC if any are pending
9390 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009391#ifdef FEATURE_WLAN_CCX
9392 //Send Adjacent AP repot to new AP.
9393 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9394 pSession->isPrevApInfoValid &&
9395 pSession->connectedProfile.isCCXAssoc)
9396 {
9397#ifdef WLAN_FEATURE_VOWIFI
9398 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9399#endif
9400 pSession->isPrevApInfoValid = FALSE;
9401 }
9402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9404 {
9405 csrReleaseCommandSetKey( pMac, pCommand );
9406 }
9407 }
9408 else
9409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009410 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009411 }
9412 }
9413 else
9414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009415 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 smeProcessPendingQueue( pMac );
9418 }
9419 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 case eWNI_SME_REMOVEKEY_RSP:
9421 {
9422 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9423 tListElem *pEntry;
9424 tSmeCmd *pCommand;
9425
9426 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9427 if ( pEntry )
9428 {
9429 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9430 if ( eSmeCommandRemoveKey == pCommand->command )
9431 {
9432 sessionId = pCommand->sessionId;
9433 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009434
9435 if(!pSession)
9436 {
9437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9438 return;
9439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009440#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9441 {
9442 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9443 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9444 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9445 removeKeyEvent.encryptionModeMulticast =
9446 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9447 removeKeyEvent.encryptionModeUnicast =
9448 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9449 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9450 removeKeyEvent.authMode =
9451 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9452 if( eSIR_SUCCESS != pRsp->statusCode )
9453 {
9454 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9455 }
9456 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9457 }
9458#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009459 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 {
9461 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9462 result = eCSR_ROAM_RESULT_NONE;
9463 pRoamInfo = &roamInfo;
9464 }
9465 else
9466 {
9467 result = eCSR_ROAM_RESULT_FAILURE;
9468 }
9469 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9470 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9471 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9472 {
9473 csrReleaseCommandRemoveKey( pMac, pCommand );
9474 }
9475 }
9476 else
9477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009478 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 }
9480 }
9481 else
9482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009483 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 smeProcessPendingQueue( pMac );
9486 }
9487 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009489 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 csrRoamStatsRspProcessor( pMac, pSirMsg );
9491 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009492#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9493 case eWNI_SME_GET_ROAM_RSSI_RSP:
9494 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9495 csrRoamRssiRspProcessor( pMac, pSirMsg );
9496 break;
9497#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009499 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 csrUpdateRssi( pMac, pSirMsg );
9501 break;
9502
Jeff Johnson295189b2012-06-20 16:38:30 -07009503#ifdef WLAN_FEATURE_VOWIFI_11R
9504 case eWNI_SME_FT_PRE_AUTH_RSP:
9505 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9506 break;
9507#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009508 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9509 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009510 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 sessionId = pSmeMaxAssocInd->sessionId;
9512 roamInfo.sessionId = sessionId;
9513 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9514 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9515 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9516 break;
9517
9518 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009519 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009520 btampEstablishLogLinkHdlr( pSirMsg );
9521 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009522 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009523 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009524 csrRoamRssiIndHdlr( pMac, pSirMsg );
9525 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009526#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9527 case eWNI_SME_CANDIDATE_FOUND_IND:
9528 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9529 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9530 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009531 case eWNI_SME_HANDOFF_REQ:
9532 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9533 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9534 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009536
9537 default:
9538 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009540}
9541
Jeff Johnson295189b2012-06-20 16:38:30 -07009542void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9543 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9544{
9545 if(pSession)
9546 {
9547 if(pSession->bRefAssocStartCnt)
9548 {
9549 pSession->bRefAssocStartCnt--;
9550 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9551 //Need to call association_completion because there is an assoc_start pending.
9552 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9553 eCSR_ROAM_ASSOCIATION_COMPLETION,
9554 eCSR_ROAM_RESULT_FAILURE);
9555 }
9556 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9557 }
9558 else
9559 {
9560 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9561 }
9562}
9563
9564
9565eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9566{
9567 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9569 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9570 {
9571 status = csrScanRequestLostLink1( pMac, sessionId );
9572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 return(status);
9574}
9575
Jeff Johnson295189b2012-06-20 16:38:30 -07009576//return a boolean to indicate whether roaming completed or continue.
9577tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9578 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9579{
9580 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9581 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9582 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9583 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009584 if(!pSession)
9585 {
9586 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9587 return eANI_BOOLEAN_FALSE;
9588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 //Check whether time is up
9590 if(pSession->fCancelRoaming || fForce ||
9591 ((curTime - pSession->roamingStartTime) > roamTime) ||
9592 eCsrReassocRoaming == pSession->roamingReason ||
9593 eCsrDynamicRoaming == pSession->roamingReason)
9594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009595 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9597 {
9598 //roaming is cancelled, tell HDD to indicate disconnect
9599 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9600 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9601 //to be eSIR_BEACON_MISSED
9602 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9603 {
9604 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9605 }
9606 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9607 {
9608 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9609 }
9610 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9611 {
9612 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9613 }
9614 else
9615 {
9616 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9617 }
9618 }
9619 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9620 pSession->roamingReason = eCsrNotRoaming;
9621 }
9622 else
9623 {
9624 pSession->roamResult = roamResult;
9625 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9626 {
9627 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9628 pSession->roamingReason = eCsrNotRoaming;
9629 }
9630 else
9631 {
9632 fCompleted = eANI_BOOLEAN_FALSE;
9633 }
9634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 return(fCompleted);
9636}
9637
Jeff Johnson295189b2012-06-20 16:38:30 -07009638void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9639{
9640 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009641
9642 if(!pSession)
9643 {
9644 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9645 return;
9646 }
9647
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 if(CSR_IS_ROAMING(pSession))
9649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009650 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9652 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9653 {
9654 //No need to do anything in here because the handler takes care of it
9655 }
9656 else
9657 {
9658 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9659 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9660 //Roaming is stopped after here
9661 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9662 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9663 csrScanAbortMacScan(pMac);
9664 csrRoamStopRoamingTimer(pMac, sessionId);
9665 }
9666 }
9667}
9668
Jeff Johnson295189b2012-06-20 16:38:30 -07009669void csrRoamRoamingTimerHandler(void *pv)
9670{
9671 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9672 tpAniSirGlobal pMac = pInfo->pMac;
9673 tANI_U32 sessionId = pInfo->sessionId;
9674 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009675
9676 if(!pSession)
9677 {
9678 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9679 return;
9680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009681
9682 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9683 {
9684 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9685 {
9686 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9687 pSession->roamingReason = eCsrNotRoaming;
9688 }
9689 }
9690}
9691
Jeff Johnson295189b2012-06-20 16:38:30 -07009692eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9693{
9694 eHalStatus status;
9695 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009696
9697 if(!pSession)
9698 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009699 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009700 return eHAL_STATUS_FAILURE;
9701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009702
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009703 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9705 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9706
9707 return (status);
9708}
9709
Jeff Johnson295189b2012-06-20 16:38:30 -07009710eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9711{
9712 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9713}
9714
Jeff Johnson295189b2012-06-20 16:38:30 -07009715void csrRoamWaitForKeyTimeOutHandler(void *pv)
9716{
9717 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9718 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009719 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9720
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009721 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009722 pMac->roam.neighborRoamInfo.neighborRoamState,
9723 pMac->roam.curSubState[pInfo->sessionId]);
9724
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9726 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009727#ifdef FEATURE_WLAN_LFR
9728 if (csrNeighborRoamIsHandoffInProgress(pMac))
9729 {
9730 /*
9731 * Enable heartbeat timer when hand-off is in progress
9732 * and Key Wait timer expired.
9733 */
9734 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009735 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009736 pMac->roam.configParam.HeartbeatThresh24);
9737 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9738 pMac->roam.configParam.HeartbeatThresh24,
9739 NULL, eANI_BOOLEAN_FALSE);
9740 }
9741#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009742 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 //Change the substate so command queue is unblocked.
9744 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009745 if (pSession)
9746 {
9747 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9748 {
9749 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9750 smeProcessPendingQueue(pMac);
9751 }
9752 else
9753 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009754 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009755 __func__);
9756 }
9757 }
9758 else
9759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009760 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 }
9763
9764}
9765
Jeff Johnson295189b2012-06-20 16:38:30 -07009766eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9767{
9768 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009769#ifdef FEATURE_WLAN_LFR
9770 if (csrNeighborRoamIsHandoffInProgress(pMac))
9771 {
9772 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009773 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009774 __func__,
9775 pMac->roam.neighborRoamInfo.neighborRoamState,
9776 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9777 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9778 }
9779#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009780 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9782
9783 return (status);
9784}
9785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9787{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009788 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009789 pMac->roam.neighborRoamInfo.neighborRoamState,
9790 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9791#ifdef FEATURE_WLAN_LFR
9792 if (csrNeighborRoamIsHandoffInProgress(pMac))
9793 {
9794 /*
9795 * Enable heartbeat timer when hand-off is in progress
9796 * and Key Wait timer got stopped for some reason
9797 */
9798 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009799 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009800 pMac->roam.configParam.HeartbeatThresh24);
9801 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9802 pMac->roam.configParam.HeartbeatThresh24,
9803 NULL, eANI_BOOLEAN_FALSE);
9804 }
9805#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9807}
9808
Jeff Johnson295189b2012-06-20 16:38:30 -07009809void csrRoamIbssJoinTimerHandler(void *pv)
9810{
9811 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9812 tpAniSirGlobal pMac = pInfo->pMac;
9813 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9814 tANI_U32 sessionId = pInfo->sessionId;
9815 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009816
9817 if(!pSession)
9818 {
9819 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9820 return;
9821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009822
9823 pSession->ibss_join_pending = FALSE;
9824 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9825 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9826 // Send an IBSS stop request to PE
9827 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009828}
Jeff Johnson295189b2012-06-20 16:38:30 -07009829eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9830{
9831 eHalStatus status;
9832 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009833
9834 if(!pSession)
9835 {
9836 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9837 return eHAL_STATUS_FAILURE;
9838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009839
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009840 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9842 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9843
9844 return (status);
9845}
Jeff Johnson295189b2012-06-20 16:38:30 -07009846eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9847{
9848 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9849}
Jeff Johnson295189b2012-06-20 16:38:30 -07009850void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9851 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9852{
9853 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9854 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009855 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9856 /* To silence the KW tool Null chaeck is added */
9857 if(!pSession)
9858 {
9859 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9860 return;
9861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009862
9863 if(pCommand)
9864 {
9865 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9869 {
9870 //if success, force roaming completion
9871 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9872 }
9873 else
9874 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009875 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009876 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9878 }
9879}
9880
Jeff Johnson295189b2012-06-20 16:38:30 -07009881eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9882{
9883 eHalStatus status = eHAL_STATUS_SUCCESS;
9884 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9885 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9886 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9887 tCsrRoamInfo *pRoamInfo = NULL;
9888 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009889 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009890 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009891 /* To silence the KW tool Null chaeck is added */
9892 if(!pSession)
9893 {
9894 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9895 return eHAL_STATUS_FAILURE;
9896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009898 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9900 if ( eWNI_SME_DISASSOC_IND == type )
9901 {
9902 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9903 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9904 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009905 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 }
9907 else if ( eWNI_SME_DEAUTH_IND == type )
9908 {
9909 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9910 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9911 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009912 /* Convert into proper reason code */
9913 pSession->joinFailStatusCode.reasonCode =
9914 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309915 0 : pDeauthIndMsg->reasonCode;
9916 /* cfg layer expects 0 as reason code if
9917 the driver dosent know the reason code
9918 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 }
9920 else
9921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009922 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009924 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 }
9926
9927 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009929 {
9930 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9931 }
9932
9933 if ( eWNI_SME_DISASSOC_IND == type )
9934 {
9935 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9936 }
9937 else if ( eWNI_SME_DEAUTH_IND == type )
9938 {
9939 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 if(!HAL_STATUS_SUCCESS(status))
9942 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009943 //If fail to send confirmation to PE, not to trigger roaming
9944 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 }
9946
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009947 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9949 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9950 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 if( eWNI_SME_DISASSOC_IND == type)
9952 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009953 //staMacAddr
9954 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9955 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9956 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 else if( eWNI_SME_DEAUTH_IND == type )
9958 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009959 //staMacAddr
9960 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9961 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9962 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009963 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009964
9965 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9966 that we are roaming. But if we cannot possibly roam, or if we are unable to
9967 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 if(fToRoam)
9969 {
9970 //Only remove the connected BSS in infrastructure mode
9971 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9972 //Not to do anying for lostlink with WDS
9973 if( pMac->roam.configParam.nRoamingTime )
9974 {
9975 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9976 ( eWNI_SME_DEAUTH_IND == type ) ?
9977 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9978 {
9979 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9980 //For IBSS, we need to give some more info to HDD
9981 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9982 {
9983 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9984 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9985 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9986 }
9987 else
9988 {
9989 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9990 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009991 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9993 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9994 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9995 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9996 }
9997 else
9998 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009999 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 fToRoam = eANI_BOOLEAN_FALSE;
10001 }
10002 }
10003 else
10004 {
10005 //We are told not to roam, indicate lostlink
10006 fToRoam = eANI_BOOLEAN_FALSE;
10007 }
10008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 if(!fToRoam)
10010 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010011 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010012 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010013 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010014 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10015 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10016 * csrRoamCheckForLinkStatusChange API.
10017 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010018 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10019 }
10020
10021 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 Still enable idle scan for polling in case concurrent sessions are running */
10023 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10024 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010025 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010026 }
10027 }
10028
10029 return (status);
10030}
10031
Jeff Johnson295189b2012-06-20 16:38:30 -070010032eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10033{
10034 eHalStatus status = eHAL_STATUS_SUCCESS;
10035 tListElem *pEntry = NULL;
10036 tSmeCmd *pCommand = NULL;
10037 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010038
10039 if(!pSession)
10040 {
10041 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10042 return eHAL_STATUS_FAILURE;
10043 }
10044
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 //Only remove the connected BSS in infrastructure mode
10047 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10048 if(pMac->roam.configParam.nRoamingTime)
10049 {
10050 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10051 {
10052 //before starting the lost link logic release the roam command for handoff
10053 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10054 if(pEntry)
10055 {
10056 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10057 }
10058 if(pCommand)
10059 {
10060 if (( eSmeCommandRoam == pCommand->command ) &&
10061 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10062 {
10063 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10064 {
10065 csrReleaseCommandRoam( pMac, pCommand );
10066 }
10067 }
10068 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010069 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010070 }
10071 }
10072 else
10073 {
10074 //We are told not to roam, indicate lostlink
10075 status = eHAL_STATUS_FAILURE;
10076 }
10077
10078 return (status);
10079}
Jeff Johnson295189b2012-06-20 16:38:30 -070010080void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10081{
10082 tListElem *pEntry;
10083 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010084 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10085 if ( pEntry )
10086 {
10087 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10088 if ( eSmeCommandWmStatusChange == pCommand->command )
10089 {
10090 // Nothing to process in a Lost Link completion.... It just kicks off a
10091 // roaming sequence.
10092 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10093 {
10094 csrReleaseCommandWmStatusChange( pMac, pCommand );
10095 }
10096 else
10097 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010098 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 }
10100
10101 }
10102 else
10103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010104 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010105 }
10106 }
10107 else
10108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010109 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 smeProcessPendingQueue( pMac );
10112}
10113
Jeff Johnson295189b2012-06-20 16:38:30 -070010114void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10115{
10116 eHalStatus status = eHAL_STATUS_FAILURE;
10117 tSirSmeRsp *pSirSmeMsg;
10118 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010119
10120 if(!pSession)
10121 {
10122 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10123 return;
10124 }
10125
Jeff Johnson295189b2012-06-20 16:38:30 -070010126 switch ( pCommand->u.wmStatusChangeCmd.Type )
10127 {
10128 case eCsrDisassociated:
10129 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10130 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 case eCsrDeauthenticated:
10133 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10134 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10135 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010137 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 break;
10139 }
10140 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10141 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10142 {
10143 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10144 {
10145 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010146 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010147 }
10148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010149 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10150 // command here since there is nothing else to do.
10151 csrRoamWmStatusChangeComplete( pMac );
10152}
10153
Jeff Johnson295189b2012-06-20 16:38:30 -070010154//This function returns band and mode information.
10155//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10156//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010157static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10158 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010159{
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10161 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10162 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010164
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 //If the global setting for dot11Mode is set to auto/abg, we overwrite the setting in the profile.
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10167 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10168 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10169 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010170 {
10171 switch( pMac->roam.configParam.uCfgDot11Mode )
10172 {
10173 case eCSR_CFG_DOT11_MODE_11A:
10174 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10175 eBand = eCSR_BAND_5G;
10176 break;
10177 case eCSR_CFG_DOT11_MODE_11B:
10178 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10179 eBand = eCSR_BAND_24;
10180 break;
10181 case eCSR_CFG_DOT11_MODE_11G:
10182 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10183 eBand = eCSR_BAND_24;
10184 break;
10185 case eCSR_CFG_DOT11_MODE_11N:
10186 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10187 eBand = eCSR_BAND_24;
10188 break;
10189 //case eCSR_CFG_DOT11_MODE_BEST:
10190 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
10191 // eBand = eCSR_BAND_24;
10192 // break;
10193 default:
10194 // Global dot11 Mode setting is 11a/b/g.
10195 // use the channel number to determine the Mode setting.
10196 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10197 {
10198 eBand = pMac->roam.configParam.eBand;
10199 if(eCSR_BAND_24 == eBand)
10200 {
10201 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10202 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10203 }
10204 else
10205 {
10206 //prefer 5GHz
10207 eBand = eCSR_BAND_5G;
10208 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10209 }
10210 }
10211 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10212 {
10213 // channel is a 2.4GHz channel. Set mode to 11g.
10214 //
10215 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
10216 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
10217 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
10218 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
10219 // the IBSS network in 11b mode instead of 11g mode.
10220 //
10221 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
10222 // then start the IBSS in b mode.
10223 //
10224 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
10225 // the user will have to set the do11Mode in the property page to 11g to force it.
10226 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10227 eBand = eCSR_BAND_24;
10228 }
10229 else
10230 {
10231 // else, it's a 5.0GHz channel. Set mode to 11a.
10232 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10233 eBand = eCSR_BAND_5G;
10234 }
10235 break;
10236 }//switch
10237 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10238 else
10239 {
10240 //dot11 mode is set, lets pick the band
10241 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10242 {
10243 // channel is Auto also.
10244 eBand = pMac->roam.configParam.eBand;
10245 if(eCSR_BAND_ALL == eBand)
10246 {
10247 //prefer 5GHz
10248 eBand = eCSR_BAND_5G;
10249 }
10250 }
10251 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10252 {
10253 eBand = eCSR_BAND_24;
10254 }
10255 else
10256 {
10257 eBand = eCSR_BAND_5G;
10258 }
10259 }
10260 if(pBand)
10261 {
10262 *pBand = eBand;
10263 }
10264
10265 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010266 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10268 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010269
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010270 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10271 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 -070010272 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010273#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010274 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010275#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010276 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10277 {
10278 //We cannot do 11n here
10279 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10280 {
10281 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10282 }
10283 else
10284 {
10285 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10286 }
10287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 return( cfgDot11Mode );
10289}
10290
Jeff Johnson295189b2012-06-20 16:38:30 -070010291eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10292{
10293 eHalStatus status;
10294 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010295
10296 if(!pSession)
10297 {
10298 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10299 return eHAL_STATUS_FAILURE;
10300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010301
10302#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10303 {
10304 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010305 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10306 if(pIbssLog)
10307 {
10308 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10309 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10310 }
10311 }
10312#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010313 pSession->ibss_join_pending = FALSE;
10314 csrRoamStopIbssJoinTimer(pMac, sessionId );
10315 // Set the roaming substate to 'stop Bss request'...
10316 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10317
10318 // attempt to stop the Bss (reason code is ignored...)
10319 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010320 if(!HAL_STATUS_SUCCESS(status))
10321 {
10322 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 return (status);
10325}
10326
Jeff Johnson295189b2012-06-20 16:38:30 -070010327//pNumChan is a caller allocated space with the sizeof pChannels
10328eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10329{
10330
10331 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10332 (tANI_U8 *)pChannels,
10333 pNumChan));
10334}
10335
Kiran4a17ebe2013-01-31 10:43:43 -080010336tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10337{
10338 tANI_U32 cfgLength = 0;
10339 tANI_U16 cfgId = 0;
10340 tPowerdBm maxTxPwr = 0;
10341 tANI_U8 *pCountryInfo = NULL;
10342 eHalStatus status;
10343 tANI_U8 count = 0;
10344 tANI_U8 firstChannel;
10345 tANI_U8 maxChannels;
10346
10347 if (CSR_IS_CHANNEL_5GHZ(channel))
10348 {
10349 cfgId = WNI_CFG_MAX_TX_POWER_5;
10350 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10351 }
10352 else if (CSR_IS_CHANNEL_24GHZ(channel))
10353 {
10354 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10355 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10356 }
10357 else
10358 return maxTxPwr;
10359
10360 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10361 if (status != eHAL_STATUS_SUCCESS)
10362 {
10363 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10364 FL("%s: palAllocateMemory() failed, status = %d"),
10365 __FUNCTION__, status);
10366 goto error;
10367 }
10368 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10369 if (status != eHAL_STATUS_SUCCESS)
10370 {
10371 goto error;
10372 }
10373 /* Identify the channel and maxtxpower */
10374 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10375 {
10376 firstChannel = pCountryInfo[count++];
10377 maxChannels = pCountryInfo[count++];
10378 maxTxPwr = pCountryInfo[count++];
10379
10380 if ((channel >= firstChannel) &&
10381 (channel < (firstChannel + maxChannels)))
10382 {
10383 break;
10384 }
10385 }
10386
10387error:
10388 if (NULL != pCountryInfo)
10389 palFreeMemory(pMac->hHdd, pCountryInfo);
10390
10391 return maxTxPwr;
10392}
10393
10394
Jeff Johnson295189b2012-06-20 16:38:30 -070010395tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10396{
10397 tANI_BOOLEAN fValid = FALSE;
10398 tANI_U32 idxValidChannels;
10399 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10400
10401 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10402 {
10403 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10404 {
10405 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10406 {
10407 fValid = TRUE;
10408 break;
10409 }
10410 }
10411 }
10412 pMac->roam.numValidChannels = len;
10413 return fValid;
10414}
10415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10417{
10418 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10419 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10421 {
10422 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10423 {
10424 fValid = eANI_BOOLEAN_TRUE;
10425 break;
10426 }
10427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 return (fValid);
10429}
10430
Jeff Johnson295189b2012-06-20 16:38:30 -070010431//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010432 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010433{
Jeff Johnsone7245742012-09-05 17:12:55 -070010434 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010435 tANI_U8 centerChn;
10436 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10438 {
10439 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10440 }
10441 else
10442 {
10443 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10444 }
10445 //Figure what the other side's CB mode
10446 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10447 {
10448 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10449 {
10450 if(pIes->HTInfo.present)
10451 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010452 /* This is called during INFRA STA/CLIENT and should use the merged value of
10453 * supported channel width and recommended tx width as per standard
10454 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010455 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010456 pIes->HTCaps.supportedChannelWidthSet,
10457 pIes->HTInfo.recommendedTxWidthSet,
10458 pIes->HTInfo.secondaryChannelOffset);
10459
10460 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10461 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010463 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10464 switch (eRet) {
10465 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10466 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10467 break;
10468 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10469 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10470 break;
10471 case PHY_SINGLE_CHANNEL_CENTERED:
10472 default:
10473 centerChn = primaryChn;
10474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010476 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010478 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010479 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 }
10481 }
10482 }
10483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010484 return eRet;
10485}
Jeff Johnson295189b2012-06-20 16:38:30 -070010486tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10487{
10488 tANI_BOOLEAN fFound = FALSE;
10489 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10491 {
10492 if( pCipherList->encryptionType[idx] == encryptionType )
10493 {
10494 fFound = TRUE;
10495 break;
10496 }
10497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 return fFound;
10499}
Jeff Johnson295189b2012-06-20 16:38:30 -070010500tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10501{
10502 tANI_BOOLEAN fFound = FALSE;
10503 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10505 {
10506 if( pAuthList->authType[idx] == authType )
10507 {
10508 fFound = TRUE;
10509 break;
10510 }
10511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010512 return fFound;
10513}
Jeff Johnson295189b2012-06-20 16:38:30 -070010514tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10515{
10516 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10517 tCsrScanResultFilter *pScanFilter = NULL;
10518 eHalStatus status = eHAL_STATUS_SUCCESS;
10519
10520 if(pProfile1 && pProfile2)
10521 {
10522 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10523 if(HAL_STATUS_SUCCESS(status))
10524 {
10525 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10526 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10527 if(HAL_STATUS_SUCCESS(status))
10528 {
10529 fCheck = eANI_BOOLEAN_FALSE;
10530 do
10531 {
10532 tANI_U32 i;
10533 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10534 {
10535 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10536 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10537 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10538 if ( fCheck ) break;
10539 }
10540 if(!fCheck)
10541 {
10542 break;
10543 }
10544 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10545 || pProfile2->BSSType != pProfile1->BSSType
10546 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10547 )
10548 {
10549 fCheck = eANI_BOOLEAN_FALSE;
10550 break;
10551 }
10552#ifdef WLAN_FEATURE_VOWIFI_11R
10553 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10554 {
10555 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10556 {
10557 fCheck = eANI_BOOLEAN_FALSE;
10558 break;
10559 }
10560 }
10561#endif
10562 //Match found
10563 fCheck = eANI_BOOLEAN_TRUE;
10564 }while(0);
10565 csrFreeScanFilter(pMac, pScanFilter);
10566 }
10567 palFreeMemory(pMac->hHdd, pScanFilter);
10568 }
10569 }
10570
10571 return (fCheck);
10572}
10573
Jeff Johnson295189b2012-06-20 16:38:30 -070010574tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10575{
10576 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10577 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 do
10579 {
10580 //Only check for static WEP
10581 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10582 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10583 {
10584 fCheck = eANI_BOOLEAN_TRUE;
10585 break;
10586 }
10587 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10588 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10589 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10590 {
10591 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10592 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10593 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10594 {
10595 break;
10596 }
10597 }
10598 if( i == CSR_MAX_NUM_KEY)
10599 {
10600 fCheck = eANI_BOOLEAN_TRUE;
10601 }
10602 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 return (fCheck);
10604}
10605
Jeff Johnson295189b2012-06-20 16:38:30 -070010606//IBSS
10607
Jeff Johnson295189b2012-06-20 16:38:30 -070010608tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10609{
10610 tANI_U8 channel = 0;
10611 tANI_U32 idx;
10612 tANI_U32 idxValidChannels;
10613 tANI_BOOLEAN fFound = FALSE;
10614 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10615
10616 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10617 {
10618 channel = pMac->roam.configParam.AdHocChannel5G;
10619 if(!csrRoamIsChannelValid(pMac, channel))
10620 {
10621 channel = 0;
10622 }
10623 }
10624 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10625 {
10626 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10627 {
10628 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10629 {
10630 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10631 {
10632 fFound = TRUE;
10633 channel = csrStartIbssChannels50[ idx ];
10634 }
10635 }
10636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10638 if (!fFound)
10639 {
10640 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10641 {
10642 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10643 {
10644 channel = csrStartIbssChannels50[ idx ];
10645 break;
10646 }
10647 }
10648 }
10649 }//if
10650
10651 return( channel );
10652}
10653
Jeff Johnson295189b2012-06-20 16:38:30 -070010654tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10655{
10656 tANI_U8 channel = 1;
10657 tANI_U32 idx;
10658 tANI_U32 idxValidChannels;
10659 tANI_BOOLEAN fFound = FALSE;
10660 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10661
10662 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10663 {
10664 channel = pMac->roam.configParam.AdHocChannel24;
10665 if(!csrRoamIsChannelValid(pMac, channel))
10666 {
10667 channel = 0;
10668 }
10669 }
10670
10671 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10672 {
10673 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10674 {
10675 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10676 {
10677 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10678 {
10679 fFound = TRUE;
10680 channel = csrStartIbssChannels24[ idx ];
10681 }
10682 }
10683 }
10684 }
10685
10686 return( channel );
10687}
10688
Jeff Johnson295189b2012-06-20 16:38:30 -070010689static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10690 tCsrRoamStartBssParams *pParam )
10691{
10692 eCsrCfgDot11Mode cfgDot11Mode;
10693 eCsrBand eBand;
10694 tANI_U8 channel = 0;
10695 tSirNwType nwType;
10696 tANI_U8 operationChannel = 0;
10697
10698 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10699 {
10700 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10701 }
10702
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010704
Jeff Johnson295189b2012-06-20 16:38:30 -070010705 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10706 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10707 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10708 )
10709 {
10710 /* This should never happen */
10711 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010712 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010713 pProfile->csrPersona);
10714 VOS_ASSERT(0);
10715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010716 switch( cfgDot11Mode )
10717 {
10718 case eCSR_CFG_DOT11_MODE_11G:
10719 nwType = eSIR_11G_NW_TYPE;
10720 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 case eCSR_CFG_DOT11_MODE_11B:
10722 nwType = eSIR_11B_NW_TYPE;
10723 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010724 case eCSR_CFG_DOT11_MODE_11A:
10725 nwType = eSIR_11A_NW_TYPE;
10726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010727 default:
10728 case eCSR_CFG_DOT11_MODE_11N:
10729 case eCSR_CFG_DOT11_MODE_TAURUS:
10730 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10731 if(eCSR_BAND_24 == eBand)
10732 {
10733 nwType = eSIR_11G_NW_TYPE;
10734 }
10735 else
10736 {
10737 nwType = eSIR_11A_NW_TYPE;
10738 }
10739 break;
10740 }
10741
10742 pParam->extendedRateSet.numRates = 0;
10743
10744 switch ( nwType )
10745 {
10746 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010747 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 case eSIR_11A_NW_TYPE:
10749
10750 pParam->operationalRateSet.numRates = 8;
10751
10752 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10753 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10754 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10755 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10756 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10757 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10758 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10759 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10760
10761 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10762 {
10763 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10764 if( 0 == channel &&
10765 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10766 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10767 )
10768 {
10769 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10770 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10771 nwType = eSIR_11B_NW_TYPE;
10772 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10773 pParam->operationalRateSet.numRates = 4;
10774 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10775 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10776 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10777 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10778 }
10779 }
10780 else
10781 {
10782 channel = operationChannel;
10783 }
10784 break;
10785
10786 case eSIR_11B_NW_TYPE:
10787 pParam->operationalRateSet.numRates = 4;
10788 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10789 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10790 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10791 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010792 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10793 {
10794 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10795 }
10796 else
10797 {
10798 channel = operationChannel;
10799 }
10800
10801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010803 /* For P2P Client and P2P GO, disable 11b rates */
10804 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10805 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10806 )
10807 {
10808 pParam->operationalRateSet.numRates = 8;
10809
10810 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10811 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10812 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10813 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10814 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10815 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10816 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10817 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10818 }
10819 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010820 {
10821 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010822 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10823 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10824 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10825 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10826
10827 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10829 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10830 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10831 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10832 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10833 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10834 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10835 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10836 }
10837
10838 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10839 {
10840 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10841 }
10842 else
10843 {
10844 channel = operationChannel;
10845 }
10846
10847 break;
10848 }
10849 pParam->operationChn = channel;
10850 pParam->sirNwType = nwType;
10851}
10852
Jeff Johnson295189b2012-06-20 16:38:30 -070010853static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10854 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10855{
10856
10857 if( pParam )
10858 {
10859 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010860 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010861 pParam->operationChn = pBssDesc->channelId;
10862 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10863
10864 if( pIes )
10865 {
10866 if(pIes->SuppRates.present)
10867 {
10868 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10869 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010871 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 pIes->SuppRates.num_rates);
10873 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10874 }
10875 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10876 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10877 }
10878 if( pIes->SSID.present )
10879 {
10880 pParam->ssId.length = pIes->SSID.num_ssid;
10881 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10882 }
10883 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010884 }
10885 else
10886 {
10887 pParam->ssId.length = 0;
10888 pParam->operationalRateSet.numRates = 0;
10889 }
10890 }
10891}
10892
Jeff Johnson295189b2012-06-20 16:38:30 -070010893static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10894{
10895 tANI_U8 MaxRate = 0;
10896 tANI_U32 i;
10897 tANI_U8 *pRate;
10898
10899 pRate = pSirRateSet->rate;
10900 for ( i = 0; i < pSirRateSet->numRates; i++ )
10901 {
10902 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10903 }
10904
10905 // Save the max rate in the connected state information...
10906
10907 // modify LastRates variable as well
10908
10909 return;
10910}
10911
Jeff Johnson295189b2012-06-20 16:38:30 -070010912eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10913 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10914{
10915 eHalStatus status = eHAL_STATUS_SUCCESS;
10916 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 // Set the roaming substate to 'Start BSS attempt'...
10918 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010919#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10920 //Need to figure out whether we need to log WDS???
10921 if( CSR_IS_IBSS( pProfile ) )
10922 {
10923 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10925 if(pIbssLog)
10926 {
10927 if(pBssDesc)
10928 {
10929 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10930 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10931 }
10932 else
10933 {
10934 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10935 }
10936 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10937 pParam->ssId.length);
10938 if(pProfile->ChannelInfo.numOfChannels == 0)
10939 {
10940 pIbssLog->channelSetting = AUTO_PICK;
10941 }
10942 else
10943 {
10944 pIbssLog->channelSetting = SPECIFIED;
10945 }
10946 pIbssLog->operatingChannel = pParam->operationChn;
10947 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10948 }
10949 }
10950#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10951 //Put RSN information in for Starting BSS
10952 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10953 pParam->pRSNIE = pProfile->pRSNReqIE;
10954
Jeff Johnson295189b2012-06-20 16:38:30 -070010955 pParam->privacy = pProfile->privacy;
10956 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10957 pParam->authType = pProfile->csr80211AuthType;
10958 pParam->beaconInterval = pProfile->beaconInterval;
10959 pParam->dtimPeriod = pProfile->dtimPeriod;
10960 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10961 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10962 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10963 {
10964 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10965 {
10966 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10967 }
10968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 pParam->protEnabled = pProfile->protEnabled;
10970 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10971 pParam->ht_protection = pProfile->cfg_protection;
10972 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010973
Jeff Johnson295189b2012-06-20 16:38:30 -070010974 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10975 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 pParam->bssPersona = pProfile->csrPersona;
10977 // When starting an IBSS, start on the channel from the Profile.
10978 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 return (status);
10980}
10981
Jeff Johnson295189b2012-06-20 16:38:30 -070010982static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010983 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010984{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070010985 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070010986 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010988
10989 if(!pSession)
10990 {
10991 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10992 return;
10993 }
10994
Jeff Johnson295189b2012-06-20 16:38:30 -070010995 if( pBssDesc )
10996 {
10997 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10998 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10999 //The following code has to be do after that.
11000 //For WDS station, use selfMac as the self BSSID
11001 if( CSR_IS_WDS_STA( pProfile ) )
11002 {
11003 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11004 }
11005 }
11006 else
11007 {
11008 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011009 //Use the first SSID
11010 if(pProfile->SSIDs.numOfSSIDs)
11011 {
11012 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11013 }
11014 //For WDS station, use selfMac as the self BSSID
11015 if( CSR_IS_WDS_STA( pProfile ) )
11016 {
11017 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11018 }
11019 //Use the first BSSID
11020 else if( pProfile->BSSIDs.numOfBSSIDs )
11021 {
11022 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11023 }
11024 else
11025 {
11026 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11027 }
11028 }
11029 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011030 //Set operating channel in pProfile which will be used
11031 //in csrRoamSetBssConfigCfg() to determine channel bonding
11032 //mode and will be configured in CFG later
11033 pProfile->operationChannel = Channel;
11034
11035 if(Channel == 0)
11036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011037 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 }
11039 else
11040 {
11041
11042 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011043 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011044 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011045 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011046 {
11047 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11048 }
11049 else
11050 {
11051 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11052 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011053 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011054 pBssConfig->cbMode = cbMode;
11055 pSession->bssParams.cbMode = cbMode;
11056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011057 }
11058}
11059
Jeff Johnson295189b2012-06-20 16:38:30 -070011060static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11061 tANI_BOOLEAN *pfSameIbss )
11062{
11063 eHalStatus status = eHAL_STATUS_SUCCESS;
11064 tANI_BOOLEAN fSameIbss = FALSE;
11065
11066 if ( csrIsConnStateIbss( pMac, sessionId ) )
11067 {
11068 // Check if any profile parameter has changed ? If any profile parameter
11069 // has changed then stop old BSS and start a new one with new parameters
11070 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11071 {
11072 fSameIbss = TRUE;
11073 }
11074 else
11075 {
11076 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11077 }
11078 }
11079 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11080 {
11081 // Disassociate from the connected Infrastructure network...
11082 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11083 }
11084 else
11085 {
11086 tBssConfigParam *pBssConfig;
11087
11088 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11089 if(HAL_STATUS_SUCCESS(status))
11090 {
11091 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11092 // there is no Bss description before we start an IBSS so we need to adopt
11093 // all Bss configuration parameters from the Profile.
11094 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11095 if(HAL_STATUS_SUCCESS(status))
11096 {
11097 //save dotMode
11098 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11099 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011100 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11102 }
11103
11104 palFreeMemory(pMac->hHdd, pBssConfig);
11105 }//Allocate memory
11106 }
11107
11108 if(pfSameIbss)
11109 {
11110 *pfSameIbss = fSameIbss;
11111 }
11112 return( status );
11113}
11114
Jeff Johnson295189b2012-06-20 16:38:30 -070011115static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11116 tSirSmeNewBssInfo *pNewBss )
11117{
11118 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011119
11120 if(!pSession)
11121 {
11122 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11123 return;
11124 }
11125
Jeff Johnson295189b2012-06-20 16:38:30 -070011126 if( pNewBss )
11127 {
11128 // Set the operating channel.
11129 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11130 // move the BSSId from the BSS description into the connected state information.
11131 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11132 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 return;
11135}
11136
Jeff Johnson295189b2012-06-20 16:38:30 -070011137#ifdef FEATURE_WLAN_WAPI
11138eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11139 tANI_U32 numItems )
11140{
11141 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11142 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011145 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 return status;
11147 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011148 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 pSession = CSR_GET_SESSION( pMac, sessionId );
11150 if(numItems <= CSR_MAX_BKID_ALLOWED)
11151 {
11152 status = eHAL_STATUS_SUCCESS;
11153 //numItems may be 0 to clear the cache
11154 pSession->NumBkidCache = (tANI_U16)numItems;
11155 if(numItems && pBKIDCache)
11156 {
11157 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11158 sizeof(tBkidCacheInfo) * numItems );
11159 }
11160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011161 return (status);
11162}
Jeff Johnson295189b2012-06-20 16:38:30 -070011163eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11164 tBkidCacheInfo *pBkidCache)
11165{
11166 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11167 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011170 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011171 return status;
11172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011173 pSession = CSR_GET_SESSION( pMac, sessionId );
11174 if(pNum && pBkidCache)
11175 {
11176 if(pSession->NumBkidCache == 0)
11177 {
11178 *pNum = 0;
11179 status = eHAL_STATUS_SUCCESS;
11180 }
11181 else if(*pNum >= pSession->NumBkidCache)
11182 {
11183 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011185 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 pSession->NumBkidCache);
11187 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11188 }
11189 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11190 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11191 *pNum = pSession->NumBkidCache;
11192 status = eHAL_STATUS_SUCCESS;
11193 }
11194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011196}
Jeff Johnson295189b2012-06-20 16:38:30 -070011197tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11198{
11199 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011200}
11201#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011202eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11203 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11204{
11205 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11206 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011207
11208 if(!pSession)
11209 {
11210 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11211 return eHAL_STATUS_FAILURE;
11212 }
11213
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011214 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011215 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11216 {
11217#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11218 {
11219 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11220 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11221 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11222 secEvent.encryptionModeMulticast =
11223 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11224 secEvent.encryptionModeUnicast =
11225 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11226 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11227 secEvent.authMode =
11228 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11229 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11230 }
11231#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 status = eHAL_STATUS_SUCCESS;
11233 //numItems may be 0 to clear the cache
11234 pSession->NumPmkidCache = (tANI_U16)numItems;
11235 if(numItems && pPMKIDCache)
11236 {
11237 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11238 sizeof(tPmkidCacheInfo) * numItems );
11239 }
11240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011241 return (status);
11242}
11243
Jeff Johnson295189b2012-06-20 16:38:30 -070011244tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11245{
11246 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11247}
11248
Jeff Johnson295189b2012-06-20 16:38:30 -070011249eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11250{
11251 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011253
11254 if(!pSession)
11255 {
11256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11257 return eHAL_STATUS_FAILURE;
11258 }
11259
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 if(pNum && pPmkidCache)
11261 {
11262 if(pSession->NumPmkidCache == 0)
11263 {
11264 *pNum = 0;
11265 status = eHAL_STATUS_SUCCESS;
11266 }
11267 else if(*pNum >= pSession->NumPmkidCache)
11268 {
11269 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011271 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 pSession->NumPmkidCache);
11273 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11274 }
11275 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11276 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11277 *pNum = pSession->NumPmkidCache;
11278 status = eHAL_STATUS_SUCCESS;
11279 }
11280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 return (status);
11282}
11283
Jeff Johnson295189b2012-06-20 16:38:30 -070011284eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11285{
11286 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11287 tANI_U32 len;
11288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011289
11290 if(!pSession)
11291 {
11292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11293 return eHAL_STATUS_FAILURE;
11294 }
11295
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 if(pLen)
11297 {
11298 len = *pLen;
11299 *pLen = pSession->nWpaRsnReqIeLength;
11300 if(pBuf)
11301 {
11302 if(len >= pSession->nWpaRsnReqIeLength)
11303 {
11304 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11305 }
11306 }
11307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 return (status);
11309}
11310
Jeff Johnson295189b2012-06-20 16:38:30 -070011311eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11312{
11313 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11314 tANI_U32 len;
11315 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011316
11317 if(!pSession)
11318 {
11319 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11320 return eHAL_STATUS_FAILURE;
11321 }
11322
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 if(pLen)
11324 {
11325 len = *pLen;
11326 *pLen = pSession->nWpaRsnRspIeLength;
11327 if(pBuf)
11328 {
11329 if(len >= pSession->nWpaRsnRspIeLength)
11330 {
11331 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11332 }
11333 }
11334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 return (status);
11336}
Jeff Johnson295189b2012-06-20 16:38:30 -070011337#ifdef FEATURE_WLAN_WAPI
11338eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11339{
11340 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11341 tANI_U32 len;
11342 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011343
11344 if(!pSession)
11345 {
11346 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11347 return eHAL_STATUS_FAILURE;
11348 }
11349
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 if(pLen)
11351 {
11352 len = *pLen;
11353 *pLen = pSession->nWapiReqIeLength;
11354 if(pBuf)
11355 {
11356 if(len >= pSession->nWapiReqIeLength)
11357 {
11358 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11359 }
11360 }
11361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 return (status);
11363}
Jeff Johnson295189b2012-06-20 16:38:30 -070011364eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11365{
11366 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11367 tANI_U32 len;
11368 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011369
11370 if(!pSession)
11371 {
11372 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11373 return eHAL_STATUS_FAILURE;
11374 }
11375
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 if(pLen)
11377 {
11378 len = *pLen;
11379 *pLen = pSession->nWapiRspIeLength;
11380 if(pBuf)
11381 {
11382 if(len >= pSession->nWapiRspIeLength)
11383 {
11384 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11385 }
11386 }
11387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 return (status);
11389}
11390#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011391eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11392{
11393 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11394 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011395
11396 if(!pSession)
11397 {
11398 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11399 return (retStatus);
11400 }
11401
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 if(CSR_IS_ROAMING(pSession))
11403 {
11404 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11405 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011407 return (retStatus);
11408}
11409
Jeff Johnson295189b2012-06-20 16:38:30 -070011410//This function remove the connected BSS from te cached scan result
11411eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11412 tCsrRoamConnectedProfile *pConnProfile)
11413{
11414 eHalStatus status = eHAL_STATUS_FAILURE;
11415 tCsrScanResultFilter *pScanFilter = NULL;
11416 tListElem *pEntry;
11417 tCsrScanResult *pResult;
11418 tDot11fBeaconIEs *pIes;
11419 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11421 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11422 {
11423 do
11424 {
11425 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11426 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11427 if(!HAL_STATUS_SUCCESS(status)) break;
11428 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11429 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11430 if(!HAL_STATUS_SUCCESS(status)) break;
11431 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11432 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11433 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11434 {
11435 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11436 if(!HAL_STATUS_SUCCESS(status)) break;
11437 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11438 }
11439 pScanFilter->authType.numEntries = 1;
11440 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11441 pScanFilter->BSSType = pConnProfile->BSSType;
11442 pScanFilter->EncryptionType.numEntries = 1;
11443 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11444 pScanFilter->mcEncryptionType.numEntries = 1;
11445 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11446 //We ignore the channel for now, BSSID should be enough
11447 pScanFilter->ChannelInfo.numOfChannels = 0;
11448 //Also ignore the following fields
11449 pScanFilter->uapsd_mask = 0;
11450 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11451 pScanFilter->countryCode[0] = 0;
11452 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 csrLLLock(&pMac->scan.scanResultList);
11454 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11455 while( pEntry )
11456 {
11457 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11458 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11459 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11460 pScanFilter, NULL, NULL, NULL, &pIes);
11461 //Release the IEs allocated by csrMatchBSS is needed
11462 if( !pResult->Result.pvIes )
11463 {
11464 //need to free the IEs since it is allocated by csrMatchBSS
11465 palFreeMemory(pMac->hHdd, pIes);
11466 }
11467 if(fMatch)
11468 {
11469 //We found the one
11470 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11471 {
11472 //Free the memory
11473 csrFreeScanResultEntry( pMac, pResult );
11474 }
11475 break;
11476 }
11477 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11478 }//while
11479 csrLLUnlock(&pMac->scan.scanResultList);
11480 }while(0);
11481 if(pScanFilter)
11482 {
11483 csrFreeScanFilter(pMac, pScanFilter);
11484 palFreeMemory(pMac->hHdd, pScanFilter);
11485 }
11486 }
11487 return (status);
11488}
11489
Jeff Johnson295189b2012-06-20 16:38:30 -070011490//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011491eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11492{
11493 eHalStatus status = eHAL_STATUS_SUCCESS;
11494 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11496 {
11497 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11498 {
11499 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11500 {
11501 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011502 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011503 status = eHAL_STATUS_CSR_WRONG_STATE;
11504 break;
11505 }
11506 if( csrIsConnStateInfra( pMac, sessionId ) )
11507 {
11508 if( chnId &&
11509 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011511 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11513 status = eHAL_STATUS_CSR_WRONG_STATE;
11514 break;
11515 }
11516 }
11517 }
11518 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 return ( status );
11520}
11521
Jeff Johnson295189b2012-06-20 16:38:30 -070011522static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11523{
11524 eHalStatus status = eHAL_STATUS_SUCCESS;
11525 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11526 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011527
11528 if(!pSession)
11529 {
11530 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11531 return eHAL_STATUS_FAILURE;
11532 }
11533
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 if ( csrIsConnStateIbss( pMac, sessionId ) )
11535 {
11536 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11537 }
11538 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11539 {
11540 // Disassociate from the connected Infrastructure network...
11541 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11542 }
11543 else
11544 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011545 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11546 //Otherwise we need to add code to handle the
11547 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11548 //send stop_bss to PE, before we can continue.
11549 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11551 /* Assume HDD provide bssid in profile */
11552 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11553 // there is no Bss description before we start an WDS so we need
11554 // to adopt all Bss configuration parameters from the Profile.
11555 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11556 if(HAL_STATUS_SUCCESS(status))
11557 {
11558 //Save profile for late use
11559 csrFreeRoamProfile( pMac, sessionId );
11560 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11561 (void **)&pSession->pCurRoamProfile,
11562 sizeof(tCsrRoamProfile))))
11563 {
11564 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11565 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011568 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11570 }
11571 }
11572
11573 return( status );
11574}
11575
Jeff Johnson295189b2012-06-20 16:38:30 -070011576////////////////////Mail box
11577
Jeff Johnson295189b2012-06-20 16:38:30 -070011578//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11579//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11580static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11581 tSirBssDescription *pBssDescription,
11582 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11583{
11584 tCsrChannelSet channelGroup;
11585 tSirMacCapabilityInfo *pAP_capabilityInfo;
11586 tAniBool fTmp;
11587 tANI_BOOLEAN found = FALSE;
11588 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011589 tANI_S8 pwrLimit = 0;
11590 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11592 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11593 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11594 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011595 // 802.11h
11596 //We can do this because it is in HOST CPU order for now.
11597 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011598 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11599 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11600 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 fTmp = (tAniBool)pal_cpu_to_be32(1);
11602 }
11603 else
11604 fTmp = (tAniBool)0;
11605
11606 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11607 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11608 pBuf += sizeof(tAniBool);
11609 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011610 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 // This is required for 11k test VoWiFi Ent: Test 2.
11612 // We need the power capabilities for Assoc Req.
11613 // This macro is provided by the halPhyCfg.h. We pick our
11614 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011615 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11616 if (0 != pwrLimit)
11617 {
11618 *pBuf++ = pwrLimit;
11619 }
11620 else
11621 {
11622 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 size = sizeof(pMac->roam.validChannelList);
11625 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11626 {
11627 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11628 for ( i = 0; i < size; i++)
11629 {
11630 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11631
11632 }
11633 }
11634 else
11635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011636 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 *pBuf++ = 0; //tSirSupChnl->numChnl
11638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 //Check whether it is ok to enter UAPSD
11640#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11641 if( btcIsReadyForUapsd(pMac) )
11642#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11643 {
11644 *pBuf++ = uapsdMask;
11645 }
11646#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11647 else
11648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011649 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 *pBuf++ = 0;
11651 }
11652#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11653
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 // move the entire BssDescription into the join request.
11655 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11656 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11658}
11659
Jeff Johnson295189b2012-06-20 16:38:30 -070011660/*
11661 * The communication between HDD and LIM is thru mailbox (MB).
11662 * Both sides will access the data structure "tSirSmeJoinReq".
11663 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11664 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11665 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11666 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11667 */
11668eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011669 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011670{
11671 eHalStatus status = eHAL_STATUS_SUCCESS;
11672 tSirSmeJoinReq *pMsg;
11673 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011674 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011675 tANI_U16 msgLen, wTmp, ieLen;
11676 tSirMacRateSet OpRateSet;
11677 tSirMacRateSet ExRateSet;
11678 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11679 tANI_U32 dwTmp;
11680 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011681
11682 if(!pSession)
11683 {
11684 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11685 return eHAL_STATUS_FAILURE;
11686 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011687 /* To satisfy klockworks */
11688 if (NULL == pBssDescription)
11689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011690 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011691 return eHAL_STATUS_FAILURE;
11692 }
11693
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 do {
11695 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11696 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011697 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011698 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11699 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11700 // IE fields, but the length field in the bssDescription needs to be interpreted to
11701 // determine length of the IE fields.
11702 //
11703 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11704 // add in the length from the bssDescription (then add the size of the 'length' field
11705 // itself because that is NOT included in the length field).
11706 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11707 pBssDescription->length + sizeof( pBssDescription->length ) +
11708 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 -070011709 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11710 if ( !HAL_STATUS_SUCCESS(status) ) break;
11711 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011712 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 pMsg->length = pal_cpu_to_be16(msgLen);
11714 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 // sessionId
11716 *pBuf = (tANI_U8)sessionId;
11717 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 // transactionId
11719 *pBuf = 0;
11720 *( pBuf + 1 ) = 0;
11721 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 // ssId
11723 if( pIes->SSID.present && pIes->SSID.num_ssid )
11724 {
11725 // ssId len
11726 *pBuf = pIes->SSID.num_ssid;
11727 pBuf++;
11728 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11729 pBuf += pIes->SSID.num_ssid;
11730 }
11731 else
11732 {
11733 *pBuf = 0;
11734 pBuf++;
11735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 // selfMacAddr
11737 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11738 pBuf += sizeof(tSirMacAddr);
11739 // bsstype
11740 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11741 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11742 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11743 pBuf += sizeof(tSirBssType);
11744 // dot11mode
11745 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11746 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 //Persona
11748 *pBuf = (tANI_U8)pProfile->csrPersona;
11749 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011750 //CBMode
11751 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11752 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011753
11754 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011755 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11756
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 // uapsdPerAcBitmask
11758 *pBuf = pProfile->uapsd_mask;
11759 pBuf++;
11760
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011761
11762
Jeff Johnson295189b2012-06-20 16:38:30 -070011763 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011764 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 {
11766 // OperationalRateSet
11767 if (OpRateSet.numRates) {
11768 *pBuf++ = OpRateSet.numRates;
11769 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11770 pBuf += OpRateSet.numRates;
11771 } else *pBuf++ = 0;
11772 // ExtendedRateSet
11773 if (ExRateSet.numRates) {
11774 *pBuf++ = ExRateSet.numRates;
11775 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11776 pBuf += ExRateSet.numRates;
11777 } else *pBuf++ = 0;
11778 }
11779 else
11780 {
11781 *pBuf++ = 0;
11782 *pBuf++ = 0;
11783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 // rsnIE
11785 if ( csrIsProfileWpa( pProfile ) )
11786 {
11787 // Insert the Wpa IE into the join request
11788 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11789 (tCsrWpaIe *)( wpaRsnIE ) );
11790 }
11791 else if( csrIsProfileRSN( pProfile ) )
11792 {
11793 // Insert the RSN IE into the join request
11794 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11795 (tCsrRSNIe *)( wpaRsnIE ) );
11796 }
11797#ifdef FEATURE_WLAN_WAPI
11798 else if( csrIsProfileWapi( pProfile ) )
11799 {
11800 // Insert the WAPI IE into the join request
11801 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11802 (tCsrWapiIe *)( wpaRsnIE ) );
11803 }
11804#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 else
11806 {
11807 ieLen = 0;
11808 }
11809 //remember the IE for future use
11810 if( ieLen )
11811 {
11812 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011814 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"), ieLen, DOT11F_IE_RSN_MAX_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070011815 ieLen = DOT11F_IE_RSN_MAX_LEN;
11816 }
11817#ifdef FEATURE_WLAN_WAPI
11818 if( csrIsProfileWapi( pProfile ) )
11819 {
11820 //Check whether we need to allocate more memory
11821 if(ieLen > pSession->nWapiReqIeLength)
11822 {
11823 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11824 {
11825 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11826 }
11827 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11828 if(!HAL_STATUS_SUCCESS(status)) break;
11829 }
11830 pSession->nWapiReqIeLength = ieLen;
11831 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11832 wTmp = pal_cpu_to_be16( ieLen );
11833 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11834 pBuf += sizeof(tANI_U16);
11835 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11836 pBuf += ieLen;
11837 }
11838 else//should be WPA/WPA2 otherwise
11839#endif /* FEATURE_WLAN_WAPI */
11840 {
11841 //Check whether we need to allocate more memory
11842 if(ieLen > pSession->nWpaRsnReqIeLength)
11843 {
11844 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11845 {
11846 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11847 }
11848 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11849 if(!HAL_STATUS_SUCCESS(status)) break;
11850 }
11851 pSession->nWpaRsnReqIeLength = ieLen;
11852 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11853 wTmp = pal_cpu_to_be16( ieLen );
11854 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11855 pBuf += sizeof(tANI_U16);
11856 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11857 pBuf += ieLen;
11858 }
11859 }
11860 else
11861 {
11862 //free whatever old info
11863 pSession->nWpaRsnReqIeLength = 0;
11864 if(pSession->pWpaRsnReqIE)
11865 {
11866 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11867 pSession->pWpaRsnReqIE = NULL;
11868 }
11869#ifdef FEATURE_WLAN_WAPI
11870 pSession->nWapiReqIeLength = 0;
11871 if(pSession->pWapiReqIE)
11872 {
11873 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11874 pSession->pWapiReqIE = NULL;
11875 }
11876#endif /* FEATURE_WLAN_WAPI */
11877 //length is two bytes
11878 *pBuf = 0;
11879 *(pBuf + 1) = 0;
11880 pBuf += 2;
11881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011882#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011883 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011884 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011885 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011886 //length is two bytes
11887 *pBuf = 0;
11888 *(pBuf + 1) = 0;
11889 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011890 }
11891 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011893 // cckmIE
11894 if( csrIsProfileCCX( pProfile ) )
11895 {
11896 // Insert the CCKM IE into the join request
11897 ieLen = csrConstructCcxCckmIe( pMac,
11898 pSession,
11899 pProfile,
11900 pBssDescription,
11901 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011902 pSession->nWpaRsnReqIeLength,
11903 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011904 }
11905 else
11906 {
11907 ieLen = 0;
11908 }
11909 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11910 if( ieLen )
11911 {
11912 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11913 wTmp = pal_cpu_to_be16( ieLen );
11914 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11915 pBuf += sizeof(tANI_U16);
11916 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11917 pBuf += ieLen;
11918 }
11919 else
11920 {
11921 //Indicate you have no CCKM IE
11922 //length is two bytes
11923 *pBuf = 0;
11924 *(pBuf + 1) = 0;
11925 pBuf += 2;
11926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 }
11928#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011929 // addIEScan
11930 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11931 {
11932 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 if(ieLen > pSession->nAddIEScanLength)
11934 {
11935 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11936 {
11937 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11938 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011939 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 (void **)&pSession->pAddIEScan, ieLen);
11941 if(!HAL_STATUS_SUCCESS(status)) break;
11942 }
11943 pSession->nAddIEScanLength = ieLen;
11944 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11945 pProfile->pAddIEScan, ieLen);
11946 wTmp = pal_cpu_to_be16( ieLen );
11947 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11948 pBuf += sizeof(tANI_U16);
11949 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11950 pBuf += ieLen;
11951 }
11952 else
11953 {
11954 pSession->nAddIEScanLength = 0;
11955 if(pSession->pAddIEScan)
11956 {
11957 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11958 pSession->pAddIEScan = NULL;
11959 }
11960 *pBuf = 0;
11961 *(pBuf + 1) = 0;
11962 pBuf += 2;
11963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 // addIEAssoc
11965 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11966 {
11967 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 if(ieLen > pSession->nAddIEAssocLength)
11969 {
11970 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11971 {
11972 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11973 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011974 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 (void **)&pSession->pAddIEAssoc, ieLen);
11976 if(!HAL_STATUS_SUCCESS(status)) break;
11977 }
11978 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011979 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011980 pProfile->pAddIEAssoc, ieLen);
11981 wTmp = pal_cpu_to_be16( ieLen );
11982 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11983 pBuf += sizeof(tANI_U16);
11984 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11985 pBuf += ieLen;
11986 }
11987 else
11988 {
11989 pSession->nAddIEAssocLength = 0;
11990 if(pSession->pAddIEAssoc)
11991 {
11992 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11993 pSession->pAddIEAssoc = NULL;
11994 }
11995 *pBuf = 0;
11996 *(pBuf + 1) = 0;
11997 pBuf += 2;
11998 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011999
12000 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012002 //Unmask any AC in reassoc that is ACM-set
12003 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12004 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012006 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12007 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012008#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012009 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012010#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012011 uapsd_mask &= ~(acm_mask);
12012 }
12013 else
12014 {
12015 uapsd_mask = 0;
12016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 }
12018 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012019
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12021 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012022 pBuf += sizeof(tANI_U32);
12023
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12025 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012026 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012027#ifdef WLAN_FEATURE_11W
12028 //MgmtEncryption
12029 if (pProfile->MFPEnabled)
12030 {
12031 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12032 }
12033 else
12034 {
12035 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12036 }
12037 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12038 pBuf += sizeof(tANI_U32);
12039#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012040#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012041 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012042 if (csrIsProfile11r( pProfile )
12043#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012044 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12045 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012046#endif
12047 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012048 {
12049 // is11Rconnection;
12050 dwTmp = pal_cpu_to_be32(TRUE);
12051 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12052 pBuf += sizeof(tAniBool);
12053 }
12054 else
12055 {
12056 // is11Rconnection;
12057 dwTmp = pal_cpu_to_be32(FALSE);
12058 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12059 pBuf += sizeof(tAniBool);
12060 }
12061#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012062#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012063 /* A profile can not be both CCX and 11R. But an 802.11R AP
12064 * may be advertising support for CCX as well. So if we are
12065 * associating Open or explicitly CCX then we will get CCX.
12066 * If we are associating explictly 11R only then we will get
12067 * 11R.
12068 */
12069 if ((csrIsProfileCCX(pProfile) ||
12070 ((pIes->CCXVersion.present)
12071 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012072 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12073 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12074 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012075#ifdef WLAN_FEATURE_11W
12076 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12077#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012078 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012079 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12080 {
12081 // isCCXconnection;
12082 dwTmp = pal_cpu_to_be32(TRUE);
12083 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12084 pBuf += sizeof(tAniBool);
12085 }
12086 else
12087 {
12088 //isCCXconnection;
12089 dwTmp = pal_cpu_to_be32(FALSE);
12090 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12091 pBuf += sizeof(tAniBool);
12092 }
12093
12094 if (eWNI_SME_JOIN_REQ == messageType)
12095 {
12096 tCCXTspecInfo ccxTspec;
12097 // CCX-Tspec IEs in the ASSOC request is presently not supported
12098 // so nullify the TSPEC parameters
12099 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12100 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12101 pBuf += sizeof(tCCXTspecInfo);
12102 }
12103 else if (eWNI_SME_REASSOC_REQ == messageType)
12104 {
12105 if ((csrIsProfileCCX(pProfile) ||
12106 ((pIes->CCXVersion.present)
12107 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012108 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12109 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12110 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012111#ifdef WLAN_FEATURE_11W
12112 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12113#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012114 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012115 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 {
12117 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 // CCX Tspec information
12119 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12120 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12121 *pBuf = ccxTspec.numTspecs;
12122 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 // Copy the TSPEC information only if present
12124 if (ccxTspec.numTspecs) {
12125 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12126 }
12127 pBuf += sizeof(ccxTspec.tspec);
12128 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012129 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 tCCXTspecInfo ccxTspec;
12132 // CCX-Tspec IEs in the ASSOC request is presently not supported
12133 // so nullify the TSPEC parameters
12134 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12135 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12136 pBuf += sizeof(tCCXTspecInfo);
12137 }
12138 }
12139#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012140#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012141 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012142 if (pMac->roam.configParam.isFastTransitionEnabled
12143#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012144 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012145#endif
12146 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012148 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012150 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 }
12152 else
12153 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012154 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012156 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 }
12158#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012159#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012160 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012161 {
12162 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012163 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012164 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012165 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012166 }
12167 else
12168 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012169 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012170 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012171 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012172 }
12173#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012174
12175 // txLdpcIniFeatureEnabled
12176 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12177 pBuf++;
12178
Kiran4a17ebe2013-01-31 10:43:43 -080012179 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12180 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12181 {
12182 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12183 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12184 csrApplyPower2Current(pMac);
12185 }
12186
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012187#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012188 // txBFIniFeatureEnabled
12189 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12190 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012191
12192 // txBFCsnValue
12193 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12194 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012195#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012196 //BssDesc
12197 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12198 (tANI_U8)pProfile->uapsd_mask);
12199 status = palSendMBMessage(pMac->hHdd, pMsg );
12200 if(!HAL_STATUS_SUCCESS(status))
12201 {
12202 break;
12203 }
12204 else
12205 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012206#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012207 if (eWNI_SME_JOIN_REQ == messageType)
12208 {
12209 //Tush-QoS: notify QoS module that join happening
12210 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12211 }
12212 else if (eWNI_SME_REASSOC_REQ == messageType)
12213 {
12214 //Tush-QoS: notify QoS module that reassoc happening
12215 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012217#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012221}
12222
Jeff Johnson295189b2012-06-20 16:38:30 -070012223//
12224eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12225{
12226 eHalStatus status = eHAL_STATUS_SUCCESS;
12227 tSirSmeDisassocReq *pMsg;
12228 tANI_U8 *pBuf;
12229 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012230 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12231 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12232 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 do {
12234 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12235 if ( !HAL_STATUS_SUCCESS(status) ) break;
12236 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12237 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12238 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 pBuf = &pMsg->sessionId;
12240 // sessionId
12241 *pBuf++ = (tANI_U8)sessionId;
12242 // transactionId
12243 *pBuf = 0;
12244 *( pBuf + 1 ) = 0;
12245 pBuf += sizeof(tANI_U16);
12246
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012247 if ( (pSession->pCurRoamProfile != NULL) &&
12248 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12249 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 {
12251 // Set the bssid address before sending the message to LIM
12252 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12253 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 // Set the peer MAC address before sending the message to LIM
12255 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12256 pBuf = pBuf + sizeof ( tSirMacAddr );
12257 }
12258 else
12259 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012260 // Set the peer MAC address before sending the message to LIM
12261 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12262 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012263 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12264 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012266 if(!HAL_STATUS_SUCCESS(status))
12267 {
12268 palFreeMemory(pMac->hHdd, pMsg);
12269 break;
12270 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 // reasonCode
12272 wTmp = pal_cpu_to_be16(reasonCode);
12273 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12274 if(!HAL_STATUS_SUCCESS(status))
12275 {
12276 palFreeMemory(pMac->hHdd, pMsg);
12277 break;
12278 }
12279 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12281 Here we should not send the disassoc over the air to the AP */
12282 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12283#ifdef WLAN_FEATURE_VOWIFI_11R
12284 && csrRoamIs11rAssoc(pMac)
12285#endif
12286 )
12287 {
12288 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12289 }
12290 pBuf += sizeof(tANI_U8);
12291 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012293 return( status );
12294}
Jeff Johnson295189b2012-06-20 16:38:30 -070012295eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12296{
12297 eHalStatus status = eHAL_STATUS_SUCCESS;
12298 tSirSmeTkipCntrMeasReq *pMsg;
12299 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 do
12301 {
12302 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12303 if ( !HAL_STATUS_SUCCESS(status) ) break;
12304 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12305 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12306 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 pBuf = &pMsg->sessionId;
12308 // sessionId
12309 *pBuf++ = (tANI_U8)sessionId;
12310 // transactionId
12311 *pBuf = 0;
12312 *( pBuf + 1 ) = 0;
12313 pBuf += sizeof(tANI_U16);
12314 // bssid
12315 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12316 pBuf = pBuf + sizeof ( tSirMacAddr );
12317 // bEnable
12318 *pBuf = (tANI_BOOLEAN)bEnable;
12319 if(!HAL_STATUS_SUCCESS(status))
12320 {
12321 palFreeMemory(pMac->hHdd, pMsg);
12322 break;
12323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 return( status );
12327}
Jeff Johnson295189b2012-06-20 16:38:30 -070012328eHalStatus
12329csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12330 VOS_MODULE_ID modId, tSirMacAddr bssId,
12331 void *pUsrContext, void *pfnSapEventCallback,
12332 tANI_U8 *pAssocStasBuf )
12333{
12334 eHalStatus status = eHAL_STATUS_SUCCESS;
12335 tSirSmeGetAssocSTAsReq *pMsg;
12336 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12337 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012338 do
12339 {
12340 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12341 if (!HAL_STATUS_SUCCESS(status)) break;
12342 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12343 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 pBuf = (tANI_U8 *)&pMsg->bssId;
12345 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 // bssId
12347 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12348 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 // modId
12350 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12351 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12352 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 // pUsrContext
12354 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12355 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12356 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012357 // pfnSapEventCallback
12358 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12359 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12360 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 // pAssocStasBuf
12362 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12363 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12364 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 status = palSendMBMessage( pMac->hHdd, pMsg );
12367 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 return( status );
12369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012370eHalStatus
12371csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12372 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12373 {
12374 eHalStatus status = eHAL_STATUS_SUCCESS;
12375 tSirSmeGetWPSPBCSessionsReq *pMsg;
12376 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12377 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 do
12379 {
12380 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12381 if (!HAL_STATUS_SUCCESS(status)) break;
12382 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12383 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12385 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 // pUsrContext
12387 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12388 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12389 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 // pSapEventCallback
12391 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12392 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12393 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 // bssId
12395 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12396 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 // MAC Address of STA in WPS session
12398 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12399 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012401 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 return( status );
12404}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012405
12406eHalStatus
12407csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12408{
12409 tpSirChangeBIParams pMsg;
12410 tANI_U16 len = 0;
12411 eHalStatus status = eHAL_STATUS_SUCCESS;
12412 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12413
12414 if(!pSession)
12415 {
12416 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12417 return eHAL_STATUS_FAILURE;
12418 }
12419
12420 //NO need to update the Beacon Params if update beacon parameter flag is not set
12421 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12422 return eHAL_STATUS_SUCCESS;
12423
12424 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12425
12426 /* Create the message and send to lim */
12427 len = sizeof(tSirChangeBIParams);
12428 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12429 if(HAL_STATUS_SUCCESS(status))
12430 {
12431 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12432 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12433 pMsg->length = len;
12434
12435 // bssId
12436 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012437 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012438 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12439 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12440 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012441 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012442 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12443 status = palSendMBMessage(pMac->hHdd, pMsg);
12444 }
12445 return status;
12446}
12447
Jeff Johnson295189b2012-06-20 16:38:30 -070012448eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12449{
12450 eHalStatus status = eHAL_STATUS_SUCCESS;
12451 tSirSmeDeauthReq *pMsg;
12452 tANI_U8 *pBuf;
12453 tANI_U16 wTmp;
12454 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12455 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12456 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 do {
12458 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12459 if ( !HAL_STATUS_SUCCESS(status) ) break;
12460 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12461 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12462 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12463 //sessionId
12464 pBuf = &pMsg->sessionId;
12465 *pBuf++ = (tANI_U8)sessionId;
12466
12467 //tansactionId
12468 *pBuf = 0;
12469 *(pBuf + 1 ) = 0;
12470 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12474 // Set the BSSID before sending the message to LIM
12475 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12476 pBuf = pBuf + sizeof(tSirMacAddr);
12477 }
12478 else
12479 {
12480 // Set the BSSID before sending the message to LIM
12481 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12482 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 }
12484 if(!HAL_STATUS_SUCCESS(status))
12485 {
12486 palFreeMemory(pMac->hHdd, pMsg);
12487 break;
12488 }
12489 // Set the peer MAC address before sending the message to LIM
12490 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12491 pBuf = pBuf + sizeof(tSirMacAddr);
12492 if(!HAL_STATUS_SUCCESS(status))
12493 {
12494 palFreeMemory(pMac->hHdd, pMsg);
12495 break;
12496 }
12497 wTmp = pal_cpu_to_be16(reasonCode);
12498 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12499 if(!HAL_STATUS_SUCCESS(status))
12500 {
12501 palFreeMemory(pMac->hHdd, pMsg);
12502 break;
12503 }
12504 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 return( status );
12507}
12508
Jeff Johnson295189b2012-06-20 16:38:30 -070012509eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12510{
12511 eHalStatus status = eHAL_STATUS_SUCCESS;
12512 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 do {
12514 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12515 if ( !HAL_STATUS_SUCCESS(status) ) break;
12516 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12517 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12518 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12519 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12520 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12521 if(!HAL_STATUS_SUCCESS(status))
12522 {
12523 palFreeMemory(pMac->hHdd, pMsg);
12524 break;
12525 }
12526//To test reconn
12527 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12528 if(!HAL_STATUS_SUCCESS(status))
12529 {
12530 palFreeMemory(pMac->hHdd, pMsg);
12531 break;
12532 }
12533//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012535 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 return( status );
12537}
12538
Jeff Johnson295189b2012-06-20 16:38:30 -070012539eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12540{
12541 eHalStatus status = eHAL_STATUS_SUCCESS;
12542 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 do {
12544 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12545 if ( !HAL_STATUS_SUCCESS(status) ) break;
12546 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12547 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12548 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12549 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12550 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12551 if(!HAL_STATUS_SUCCESS(status))
12552 {
12553 palFreeMemory(pMac->hHdd, pMsg);
12554 break;
12555 }
12556 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12557 if(!HAL_STATUS_SUCCESS(status))
12558 {
12559 palFreeMemory(pMac->hHdd, pMsg);
12560 break;
12561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 return( status );
12565}
Jeff Johnson295189b2012-06-20 16:38:30 -070012566eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12567{
12568 eHalStatus status = eHAL_STATUS_SUCCESS;
12569 tSirSmeAssocCnf *pMsg;
12570 tANI_U8 *pBuf;
12571 tSirResultCodes statusCode;
12572 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 do {
12574 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12575 if ( !HAL_STATUS_SUCCESS(status) ) break;
12576 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12577 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12578 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 pBuf = (tANI_U8 *)&pMsg->statusCode;
12580 if(HAL_STATUS_SUCCESS(Halstatus))
12581 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12582 else
12583 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12584 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12585 pBuf += sizeof(tSirResultCodes);
12586 // bssId
12587 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12588 pBuf += sizeof (tSirMacAddr);
12589 // peerMacAddr
12590 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12591 pBuf += sizeof (tSirMacAddr);
12592 // aid
12593 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12594 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12595 pBuf += sizeof (tANI_U16);
12596 // alternateBssId
12597 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12598 pBuf += sizeof (tSirMacAddr);
12599 // alternateChannelId
12600 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 status = palSendMBMessage( pMac->hHdd, pMsg );
12602 if(!HAL_STATUS_SUCCESS(status))
12603 {
12604 //pMsg is freed by palSendMBMessage
12605 break;
12606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 return( status );
12609}
Jeff Johnson295189b2012-06-20 16:38:30 -070012610eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12611 tpSirSmeAssocInd pAssocInd,
12612 eHalStatus Halstatus,
12613 tANI_U8 sessionId)
12614{
12615 tSirMsgQ msgQ;
12616 eHalStatus status = eHAL_STATUS_SUCCESS;
12617 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12618 tANI_U8 *pBuf;
12619 tSirResultCodes statusCode;
12620 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012621 do {
12622 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12623 if ( !HAL_STATUS_SUCCESS(status) ) break;
12624 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012625
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12627 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12628
12629 pMsg->sessionId = sessionId;
12630
12631 pBuf = (tANI_U8 *)&pMsg->statusCode;
12632 if(HAL_STATUS_SUCCESS(Halstatus))
12633 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12634 else
12635 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12636 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12637 pBuf += sizeof(tSirResultCodes);
12638 // bssId
12639 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12640 pBuf += sizeof (tSirMacAddr);
12641 // peerMacAddr
12642 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12643 pBuf += sizeof (tSirMacAddr);
12644 // StaId
12645 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12646 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12647 pBuf += sizeof (tANI_U16);
12648 // alternateBssId
12649 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12650 pBuf += sizeof (tSirMacAddr);
12651 // alternateChannelId
12652 *pBuf = 11;
12653 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12655 //Wmm
12656 *pBuf = pAssocInd->wmmEnabledSta;
12657 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 //RSN IE
12659 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12660 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 //Additional IE
12662 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12663 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 //reassocReq
12665 *pBuf = pAssocInd->reassocReq;
12666 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012667 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12668 msgQ.bodyptr = pMsg;
12669 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 return( status );
12673}
Jeff Johnson295189b2012-06-20 16:38:30 -070012674
Jeff Johnson295189b2012-06-20 16:38:30 -070012675eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12676 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12677 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12678 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12679 tANI_U8 *pKeyRsc )
12680{
12681 tSirSmeSetContextReq *pMsg;
12682 tANI_U16 msgLen;
12683 eHalStatus status = eHAL_STATUS_FAILURE;
12684 tAniEdType tmpEdType;
12685 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012686 tANI_U8 *pBuf = NULL;
12687 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12692 // key set. Since we only support upto one key, we always allocate memory for 1 key
12693 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12694 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12695 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12696 ( sizeof( pMsg->keyMaterial.key ) );
12697
12698 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12699 if ( !HAL_STATUS_SUCCESS(status) ) break;
12700 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12701 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12702 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 //sessionId
12704 pBuf = &pMsg->sessionId;
12705 *pBuf = (tANI_U8)sessionId;
12706 pBuf++;
12707 // transactionId
12708 *pBuf = 0;
12709 *(pBuf + 1) = 0;
12710 pBuf += sizeof(tANI_U16);
12711 // peerMacAddr
12712 palCopyMemory( pMac->hHdd, pBuf,
12713 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12714
12715 pBuf += sizeof(tSirMacAddr);
12716
12717 // bssId
12718 palCopyMemory( pMac->hHdd, pBuf,
12719 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12720
12721 pBuf += sizeof(tSirMacAddr);
12722
12723 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12725 // in the tSirKeyMaterial keyMaterial; field).
12726 //
12727 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12728 // shorter than this max size. Is LIM interpreting this ok ?
12729 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 -070012730 // set pMsg->keyMaterial.edType
12731 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12732 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12733 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 // set the pMsg->keyMaterial.numKeys field
12735 *p = numKeys;
12736 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 // set pSirKey->keyId = keyId;
12738 *p = keyId;
12739 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 // set pSirKey->unicast = (tANI_U8)fUnicast;
12741 *p = (tANI_U8)fUnicast;
12742 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 // set pSirKey->keyDirection = aniKeyDirection;
12744 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12745 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12746 p += sizeof(tAniKeyDirection);
12747 // pSirKey->keyRsc = ;;
12748 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12749 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 // set pSirKey->paeRole
12751 *p = paeRole; // 0 is Supplicant
12752 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 // set pSirKey->keyLength = keyLength;
12754 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 if ( keyLength && pKey )
12756 {
12757 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12758 if(keyLength == 16)
12759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012760 smsLog(pMac, LOG1, " SME Set keyIdx (%d) encType(%d) key = %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X",
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12762 pKey[5], pKey[6], pKey[7], pKey[8],
12763 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12764 }
12765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012767 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 return( status );
12769}
12770
Jeff Johnson295189b2012-06-20 16:38:30 -070012771eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12772 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12773{
12774 eHalStatus status;
12775 tSirSmeStartBssReq *pMsg;
12776 tANI_U8 *pBuf = NULL;
12777 tANI_U8 *wTmpBuf = NULL;
12778 tANI_U16 msgLen, wTmp;
12779 tANI_U32 dwTmp;
12780 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012781 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012784
12785 if(!pSession)
12786 {
12787 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12788 return eHAL_STATUS_FAILURE;
12789 }
12790
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 do {
12792 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12793 pSession->joinFailStatusCode.reasonCode = 0;
12794 msgLen = sizeof(tSirSmeStartBssReq);
12795 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12796 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12798 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012800 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 //sessionId
12802 *pBuf = (tANI_U8)sessionId;
12803 pBuf++;
12804 // transactionId
12805 *pBuf = 0;
12806 *(pBuf + 1) = 0;
12807 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 // bssid
12809 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12810 pBuf += sizeof(tSirMacAddr);
12811 // selfMacAddr
12812 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12813 pBuf += sizeof(tSirMacAddr);
12814 // beaconInterval
12815 if( pBssDesc && pBssDesc->beaconInterval )
12816 {
12817 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 else if(pParam->beaconInterval)
12820 {
12821 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12822 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 else
12824 {
12825 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12826 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012827 if(csrIsconcurrentsessionValid (pMac, sessionId,
12828 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012829 == eHAL_STATUS_SUCCESS )
12830 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012831 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012832 pParam->bssPersona);
12833 //Update the beacon Interval
12834 pParam->beaconInterval = wTmp;
12835 }
12836 else
12837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012838 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012839 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070012840 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070012841 return status;
12842 }
12843
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12845 pBuf += sizeof(tANI_U16);
12846 // dot11mode
12847 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12848 pBuf += 1;
12849 // bssType
12850 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12851 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12852 pBuf += sizeof(tSirBssType);
12853 // ssId
12854 if( pParam->ssId.length )
12855 {
12856 // ssId len
12857 *pBuf = pParam->ssId.length;
12858 pBuf++;
12859 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12860 pBuf += pParam->ssId.length;
12861 }
12862 else
12863 {
12864 *pBuf = 0;
12865 pBuf++;
12866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 // set the channel Id
12868 *pBuf = pParam->operationChn;
12869 pBuf++;
12870 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012871 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12872 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12873 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012874
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 // Set privacy
12876 *pBuf = pParam->privacy;
12877 pBuf++;
12878
12879 //Set Uapsd
12880 *pBuf = pParam->ApUapsdEnable;
12881 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012882 //Set SSID hidden
12883 *pBuf = pParam->ssidHidden;
12884 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12886 pBuf++;
12887
12888 //Ht protection Enable/Disable
12889 *pBuf = (tANI_U8)pParam->protEnabled;
12890 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 //Enable Beacons to Receive for OBSS protection Enable/Disable
12892 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12893 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012894 //set cfg related to protection
12895 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12896 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12897 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 // Set Auth type
12899 authType = pal_cpu_to_be32(pParam->authType);
12900 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12901 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 // Set DTIM
12903 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12904 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12905 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 // Set wps_state
12907 *pBuf = pParam->wps_state;
12908 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012909 //Persona
12910 *pBuf = (tANI_U8)pParam->bssPersona;
12911 pBuf++;
12912
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012913 //txLdpcIniFeatureEnabled
12914 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12915 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012916
Jeff Johnson295189b2012-06-20 16:38:30 -070012917
12918 // set RSN IE
12919 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12920 {
12921 status = eHAL_STATUS_INVALID_PARAMETER;
12922 palFreeMemory( pMac->hHdd, pMsg );
12923 break;
12924 }
12925 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12926 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12927 pBuf += sizeof(tANI_U16);
12928 if( wTmp )
12929 {
12930 wTmp = pParam->nRSNIELength;
12931 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12932 pBuf += wTmp;
12933 }
12934 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12935 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12936 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12938 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12940 pBuf += pParam->operationalRateSet.numRates ;
12941 *pBuf++ = pParam->extendedRateSet.numRates;
12942 if(0 != pParam->extendedRateSet.numRates)
12943 {
12944 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12945 pBuf += pParam->extendedRateSet.numRates;
12946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12948 pMsg->length = pal_cpu_to_be16(msgLen);
12949
12950 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012952 return( status );
12953}
12954
Jeff Johnson295189b2012-06-20 16:38:30 -070012955eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12956{
12957 eHalStatus status = eHAL_STATUS_FAILURE;
12958 tSirSmeStopBssReq *pMsg;
12959 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12960 tANI_U8 *pBuf;
12961 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012962
12963 if(!pSession)
12964 {
12965 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12966 return eHAL_STATUS_FAILURE;
12967 }
12968
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 do {
12970 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12971 if ( !HAL_STATUS_SUCCESS(status) ) break;
12972 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12973 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12974 pBuf = &pMsg->sessionId;
12975 //sessionId
12976 *pBuf = (tANI_U8)sessionId;
12977 pBuf++;
12978 // transactionId
12979 *pBuf = 0;
12980 pBuf += sizeof(tANI_U16);
12981 //reason code
12982 *pBuf = 0;
12983 pBuf += sizeof(tSirResultCodes);
12984 // bssid
12985 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12986 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12987 {
12988 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12989 }
12990 else
12991 {
12992 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12993 }
12994 pBuf += sizeof(tSirMacAddr);
12995 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12996 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 status = palSendMBMessage( pMac->hHdd, pMsg );
12998#if 0
12999 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13000 if ( !HAL_STATUS_SUCCESS(status) ) break;
13001 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13002 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13003 pMsg->reasonCode = 0;
13004 // bssid
13005 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13006 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13007 {
13008 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13009 }
13010 else
13011 {
13012 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13013 }
13014 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13015 pMsg->transactionId = 0;
13016 pMsg->sessionId = (tANI_U8)sessionId;
13017 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13018 status = palSendMBMessage( pMac->hHdd, pMsg );
13019#endif
13020 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 return( status );
13022}
13023
Jeff Johnson295189b2012-06-20 16:38:30 -070013024eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13025 tCsrRoamModifyProfileFields *pModProfileFields,
13026 tANI_U32 *pRoamId, v_BOOL_t fForce)
13027{
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 eHalStatus status = eHAL_STATUS_FAILURE;
13029 tANI_U32 roamId = 0;
13030 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 if((csrIsConnStateConnected(pMac, sessionId)) &&
13032 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13033 &pSession->connectedProfile.modifyProfileFields,
13034 sizeof(tCsrRoamModifyProfileFields)))) )
13035 {
13036 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13037 if(pRoamId)
13038 {
13039 *pRoamId = roamId;
13040 }
13041
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13043 eCsrSmeIssuedReassocToSameAP, roamId,
13044 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 return status;
13047}
Jeff Johnson295189b2012-06-20 16:38:30 -070013048static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13049{
13050 eHalStatus status = eHAL_STATUS_SUCCESS;
13051 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13053 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13054 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13055 return (status);
13056}
Jeff Johnson295189b2012-06-20 16:38:30 -070013057eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13058{
13059 eHalStatus status = eHAL_STATUS_SUCCESS;
13060 tListElem *pEntry = NULL;
13061 tSmeCmd *pCommand = NULL;
13062 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 do
13064 {
13065 if(pMsg == NULL)
13066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013067 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 status = eHAL_STATUS_FAILURE;
13069 break;
13070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13072 if(pEntry)
13073 {
13074 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13075 if(eSmeCommandAddStaSession == pCommand->command)
13076 {
13077 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013078 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 //Remove this command out of the active list
13082 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13083 {
13084 //Now put this command back on the avilable command list
13085 csrReleaseCommand(pMac, pCommand);
13086 }
13087 smeProcessPendingQueue( pMac );
13088 }
13089 else
13090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013091 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013092 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 status = eHAL_STATUS_FAILURE;
13094 break;
13095 }
13096 }
13097 else
13098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013099 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013100 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 status = eHAL_STATUS_FAILURE;
13102 break;
13103 }
13104 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013106}
Jeff Johnson295189b2012-06-20 16:38:30 -070013107eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13108{
13109 tSirSmeAddStaSelfReq *pMsg;
13110 tANI_U16 msgLen;
13111 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13114 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13116 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13119 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 // self station address
13121 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013122 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 pMsg->selfMacAddr[0],
13124 pMsg->selfMacAddr[1],
13125 pMsg->selfMacAddr[2],
13126 pMsg->selfMacAddr[3],
13127 pMsg->selfMacAddr[4],
13128 pMsg->selfMacAddr[5]);
13129 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013130 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 return( status );
13132}
Jeff Johnson295189b2012-06-20 16:38:30 -070013133eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
13134{
13135 eHalStatus status = eHAL_STATUS_SUCCESS;
13136 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 pCommand = csrGetCommandBuffer(pMac);
13138 if(NULL == pCommand)
13139 {
13140 status = eHAL_STATUS_RESOURCES;
13141 }
13142 else
13143 {
13144 pCommand->command = eSmeCommandAddStaSession;
13145 pCommand->sessionId = (tANI_U8)sessionId;
13146 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13148 if( !HAL_STATUS_SUCCESS( status ) )
13149 {
13150 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013151 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013152 }
13153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 return (status);
13155}
Jeff Johnson295189b2012-06-20 16:38:30 -070013156eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13157{
13158 return csrSendMBAddSelfStaReqMsg( pMac,
13159 pCommand->u.addStaSessionCmd.selfMacAddr );
13160}
Jeff Johnson295189b2012-06-20 16:38:30 -070013161eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
13162 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
13163{
13164 eHalStatus status = eHAL_STATUS_SUCCESS;
13165 tANI_U32 i;
13166 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 *pbSessionId = CSR_SESSION_ID_INVALID;
13168 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13169 {
13170 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13171 {
13172 pSession = CSR_GET_SESSION( pMac, i );
13173 status = eHAL_STATUS_SUCCESS;
13174 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13175 pSession->sessionId = (tANI_U8)i;
13176 pSession->callback = callback;
13177 pSession->pContext = pContext;
13178 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13179 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13181 &pSession->roamingTimerInfo);
13182 if(!HAL_STATUS_SUCCESS(status))
13183 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013184 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 break;
13186 }
13187#ifdef FEATURE_WLAN_BTAMP_UT_RF
13188 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13189 &pSession->joinRetryTimerInfo);
13190 if(!HAL_STATUS_SUCCESS(status))
13191 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013192 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 break;
13194 }
13195#endif
13196 pSession->ibssJoinTimerInfo.pMac = pMac;
13197 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13199 &pSession->ibssJoinTimerInfo);
13200 if(!HAL_STATUS_SUCCESS(status))
13201 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013202 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 break;
13204 }
13205 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13206 break;
13207 }
13208 }
13209 if( CSR_ROAM_SESSION_MAX == i )
13210 {
13211 //No session is available
13212 status = eHAL_STATUS_RESOURCES;
13213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 return ( status );
13215}
Jeff Johnson295189b2012-06-20 16:38:30 -070013216eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13217{
13218 eHalStatus status = eHAL_STATUS_SUCCESS;
13219 tListElem *pEntry = NULL;
13220 tSmeCmd *pCommand = NULL;
13221 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 do
13223 {
13224 if(pMsg == NULL)
13225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013226 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 status = eHAL_STATUS_FAILURE;
13228 break;
13229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13231 if(pEntry)
13232 {
13233 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13234 if(eSmeCommandDelStaSession == pCommand->command)
13235 {
13236 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013238 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 //This session is done.
13240 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 if(pCommand->u.delStaSessionCmd.callback)
13242 {
13243
13244 status = sme_ReleaseGlobalLock( &pMac->sme );
13245 if ( HAL_STATUS_SUCCESS( status ) )
13246 {
13247 pCommand->u.delStaSessionCmd.callback(
13248 pCommand->u.delStaSessionCmd.pContext);
13249 status = sme_AcquireGlobalLock( &pMac->sme );
13250 if (! HAL_STATUS_SUCCESS( status ) )
13251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013252 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 return status;
13254 }
13255 }
13256 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013257 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 }
13259 }
13260
13261 //Remove this command out of the active list
13262 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13263 {
13264 //Now put this command back on the avilable command list
13265 csrReleaseCommand(pMac, pCommand);
13266 }
13267 smeProcessPendingQueue( pMac );
13268 }
13269 else
13270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013271 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013272 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 status = eHAL_STATUS_FAILURE;
13274 break;
13275 }
13276 }
13277 else
13278 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013279 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013280 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 status = eHAL_STATUS_FAILURE;
13282 break;
13283 }
13284 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013286}
Jeff Johnson295189b2012-06-20 16:38:30 -070013287eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13288{
13289 tSirSmeDelStaSelfReq *pMsg;
13290 tANI_U16 msgLen;
13291 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13294 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13296 if ( !HAL_STATUS_SUCCESS(status) ) break;
13297
13298 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13300 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 // self station address
13302 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 return( status );
13306}
Jeff Johnson295189b2012-06-20 16:38:30 -070013307eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13308 tSirMacAddr sessionMacAddr,
13309 csrRoamSessionCloseCallback callback,
13310 void *pContext)
13311{
13312 eHalStatus status = eHAL_STATUS_SUCCESS;
13313 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 pCommand = csrGetCommandBuffer(pMac);
13315 if(NULL == pCommand)
13316 {
13317 status = eHAL_STATUS_RESOURCES;
13318 }
13319 else
13320 {
13321 pCommand->command = eSmeCommandDelStaSession;
13322 pCommand->sessionId = (tANI_U8)sessionId;
13323 pCommand->u.delStaSessionCmd.callback = callback;
13324 pCommand->u.delStaSessionCmd.pContext = pContext;
13325 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13327 if( !HAL_STATUS_SUCCESS( status ) )
13328 {
13329 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013330 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 }
13332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 return (status);
13334}
Jeff Johnson295189b2012-06-20 16:38:30 -070013335eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13336{
13337 return csrSendMBDelSelfStaReqMsg( pMac,
13338 pCommand->u.delStaSessionCmd.selfMacAddr );
13339}
Jeff Johnson295189b2012-06-20 16:38:30 -070013340static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13341{
13342 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13343 tListElem *pEntry, *pNext;
13344 tSmeCmd *pCommand;
13345 tDblLinkList localList;
13346
13347 vos_mem_zero(&localList, sizeof(tDblLinkList));
13348 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13349 {
13350 smsLog(pMac, LOGE, FL(" failed to open list"));
13351 return;
13352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 csrLLLock(pList);
13354 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13355 while(pEntry != NULL)
13356 {
13357 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13358 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13359 if(pCommand->sessionId == sessionId)
13360 {
13361 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13362 {
13363 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13364 }
13365 }
13366 pEntry = pNext;
13367 }
13368 csrLLUnlock(pList);
13369
13370 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13371 {
13372 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13373 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13374 }
13375 csrLLClose(&localList);
13376}
13377
Jeff Johnson295189b2012-06-20 16:38:30 -070013378void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13379{
13380 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13381 {
13382 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 csrRoamStop(pMac, sessionId);
13384 csrFreeConnectBssDesc(pMac, sessionId);
13385 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13386 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13387 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13388#ifdef FEATURE_WLAN_BTAMP_UT_RF
13389 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13390#endif
13391 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13392 purgeSmeSessionCmdList(pMac, sessionId);
13393 purgeCsrSessionCmdList(pMac, sessionId);
13394 csrInitSession(pMac, sessionId);
13395 }
13396}
13397
Jeff Johnson295189b2012-06-20 16:38:30 -070013398eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13399 tANI_BOOLEAN fSync,
13400 csrRoamSessionCloseCallback callback,
13401 void *pContext )
13402{
13403 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13405 {
13406 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13407 if(fSync)
13408 {
13409 csrCleanupSession(pMac, sessionId);
13410 }
13411 else
13412 {
13413 purgeSmeSessionCmdList(pMac, sessionId);
13414 purgeCsrSessionCmdList(pMac, sessionId);
13415 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13416 pSession->selfMacAddr, callback, pContext);
13417 }
13418 }
13419 else
13420 {
13421 status = eHAL_STATUS_INVALID_PARAMETER;
13422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 return ( status );
13424}
13425
Jeff Johnson295189b2012-06-20 16:38:30 -070013426static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13427{
13428 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013429
13430 if(!pSession)
13431 {
13432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13433 return;
13434 }
13435
Jeff Johnson295189b2012-06-20 16:38:30 -070013436 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13437 pSession->sessionId = CSR_SESSION_ID_INVALID;
13438 pSession->callback = NULL;
13439 pSession->pContext = NULL;
13440 pSession->ibss_join_pending = FALSE;
13441 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13442 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13443 csrFreeRoamProfile( pMac, sessionId );
13444 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13445 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13446 csrFreeConnectBssDesc(pMac, sessionId);
13447 csrScanEnable(pMac);
13448 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13449 if(pSession->pWpaRsnReqIE)
13450 {
13451 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13452 pSession->pWpaRsnReqIE = NULL;
13453 }
13454 pSession->nWpaRsnReqIeLength = 0;
13455 if(pSession->pWpaRsnRspIE)
13456 {
13457 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13458 pSession->pWpaRsnRspIE = NULL;
13459 }
13460 pSession->nWpaRsnRspIeLength = 0;
13461#ifdef FEATURE_WLAN_WAPI
13462 if(pSession->pWapiReqIE)
13463 {
13464 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13465 pSession->pWapiReqIE = NULL;
13466 }
13467 pSession->nWapiReqIeLength = 0;
13468 if(pSession->pWapiRspIE)
13469 {
13470 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13471 pSession->pWapiRspIE = NULL;
13472 }
13473 pSession->nWapiRspIeLength = 0;
13474#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 if(pSession->pAddIEScan)
13476 {
13477 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13478 pSession->pAddIEScan = NULL;
13479 }
13480 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 if(pSession->pAddIEAssoc)
13482 {
13483 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13484 pSession->pAddIEAssoc = NULL;
13485}
13486 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013487}
13488
Jeff Johnson295189b2012-06-20 16:38:30 -070013489eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13490{
13491 eHalStatus status = eHAL_STATUS_FAILURE;
13492 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13494 {
13495 if( CSR_IS_SESSION_VALID( pMac, i ) )
13496 {
13497 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13498 {
13499 //Found it
13500 status = eHAL_STATUS_SUCCESS;
13501 *pSessionId = i;
13502 break;
13503 }
13504 }
13505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 return( status );
13507}
13508
Jeff Johnson295189b2012-06-20 16:38:30 -070013509//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13510//session because for IBSS, the bssid changes.
13511static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13512{
13513 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13514 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13516 {
13517 if( CSR_IS_SESSION_VALID( pMac, i ) )
13518 {
13519 pSession = CSR_GET_SESSION( pMac, i );
13520 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13521 {
13522 //Found it
13523 nRet = i;
13524 break;
13525 }
13526 }
13527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 return (nRet);
13529}
Jeff Johnson295189b2012-06-20 16:38:30 -070013530static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13531{
13532 /* Update the current BSS info in ho control block based on connected
13533 profile info from pmac global structure */
13534
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013535 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13537 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 /* Check for user misconfig of RSSI trigger threshold */
13539 pMac->roam.configParam.vccRssiThreshold =
13540 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13541 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13542 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 /* Check for user misconfig of UL MAC Loss trigger threshold */
13544 pMac->roam.configParam.vccUlMacLossThreshold =
13545 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13546 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013547#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13548 {
13549 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 /* Indicate the neighbor roal algorithm about the connect indication */
13551 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13552 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13553 }
13554#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013555}
13556
Jeff Johnson295189b2012-06-20 16:38:30 -070013557static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13558{
13559 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013560
13561 if(!pSession)
13562 {
13563 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13564 return;
13565 }
13566
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 //Only to handle the case for Handover on infra link
13568 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13569 {
13570 return;
13571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13573 csrRoamDeregStatisticsReq(pMac);
13574 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13575#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13576 /* Indicate the neighbor roal algorithm about the disconnect indication */
13577 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13578#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013579
13580 //Remove this code once SLM_Sessionization is supported
13581 //BMPS_WORKAROUND_NOT_NEEDED
13582 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013583 csrIsInfraApStarted( pMac ) &&
13584 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013585 {
13586 pMac->roam.configParam.doBMPSWorkaround = 0;
13587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013588}
13589
Jeff Johnson295189b2012-06-20 16:38:30 -070013590void csrRoamTlStatsTimerHandler(void *pv)
13591{
13592 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13593 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13595
Jeff Johnsone7245742012-09-05 17:12:55 -070013596 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13597
Jeff Johnson295189b2012-06-20 16:38:30 -070013598#if 0
13599 // TODO Persession .???
13600 //req TL for stats
13601 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013603 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 }
13605 else
13606 {
13607 //save in SME
13608 csrRoamSaveStatsFromTl(pMac, tlStats);
13609 }
13610#endif
13611 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13612 {
13613 if(pMac->roam.tlStatsReqInfo.periodicity)
13614 {
13615 //start timer
13616 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13617 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13618 if(!HAL_STATUS_SUCCESS(status))
13619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013620 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 return;
13622 }
13623 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13624 }
13625 }
13626}
Jeff Johnson295189b2012-06-20 16:38:30 -070013627void csrRoamPeStatsTimerHandler(void *pv)
13628{
13629 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13630 eHalStatus status;
13631 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13632 VOS_STATUS vosStatus;
13633 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 pPeStatsReqListEntry->timerRunning = FALSE;
13635 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13636 {
13637 // If we entered here, meaning the timer could not be successfully
13638 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13639
13640 /* Destroy the timer */
13641 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13642 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013644 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 }
13646
13647 // Free the entry
13648 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13649 pPeStatsReqListEntry = NULL;
13650 }
13651 else
13652 {
13653 if(!pPeStatsReqListEntry->rspPending)
13654 {
13655 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13656 pPeStatsReqListEntry->staId);
13657 if(!HAL_STATUS_SUCCESS(status))
13658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013659 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 }
13661 else
13662 {
13663 pPeStatsReqListEntry->rspPending = TRUE;
13664 }
13665 }
13666
13667 //send down a req
13668 if(pPeStatsReqListEntry->periodicity &&
13669 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13670 {
13671 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13672 if(ePMC_FULL_POWER == powerState)
13673 {
13674 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13675 {
13676 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13677 }
13678 }
13679 else
13680 {
13681 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13682 {
13683 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13684 }
13685 }
13686 //start timer
13687 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13688 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013690 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 return;
13692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 pPeStatsReqListEntry->timerRunning = TRUE;
13694
13695 }
13696
13697 }
13698}
Jeff Johnson295189b2012-06-20 16:38:30 -070013699void csrRoamStatsClientTimerHandler(void *pv)
13700{
13701 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13703 {
13704#if 0
13705 // TODO Stats fix for multisession
13706 //start the timer
13707 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13708
13709 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013711 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 }
13713#endif
13714 }
13715#if 0
13716 //send up the stats report
13717 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13718 pStaEntry->staId, pStaEntry->pContext);
13719#endif
13720}
13721
13722
13723
Jeff Johnson295189b2012-06-20 16:38:30 -070013724eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13725{
13726 tAniGetPEStatsReq *pMsg;
13727 eHalStatus status = eHAL_STATUS_SUCCESS;
13728 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13729 if ( !HAL_STATUS_SUCCESS(status) )
13730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013731 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 return status;
13733 }
13734 // need to initiate a stats request to PE
13735 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13736 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13737 pMsg->staId = staId;
13738 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 if(!HAL_STATUS_SUCCESS(status))
13741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013742 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 return status;
13745}
Jeff Johnson295189b2012-06-20 16:38:30 -070013746void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13747{
13748 tAniGetPEStatsRsp *pSmeStatsRsp;
13749 eHalStatus status = eHAL_STATUS_FAILURE;
13750 tListElem *pEntry = NULL;
13751 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13752 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13753 tANI_U32 tempMask = 0;
13754 tANI_U8 counter = 0;
13755 tANI_U8 *pStats = NULL;
13756 tANI_U32 length = 0;
13757 v_PVOID_t pvosGCtx;
13758 v_S7_t rssi = 0;
13759 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13761 if(pSmeStatsRsp->rc)
13762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013763 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 goto post_update;
13765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 tempMask = pSmeStatsRsp->statsMask;
13767 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 /* subtract all statistics from this length, and after processing the entire
13769 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13770 * in this 'stats' message.
13771 */
13772 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 //new stats info from PE, fill up the stats strucutres in PMAC
13774 while(tempMask)
13775 {
13776 if(tempMask & 1)
13777 {
13778 switch(counter)
13779 {
13780 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013781 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13783 pStats, sizeof(tCsrSummaryStatsInfo));
13784 if(!HAL_STATUS_SUCCESS(status))
13785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013786 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013787 }
13788 pStats += sizeof(tCsrSummaryStatsInfo);
13789 length -= sizeof(tCsrSummaryStatsInfo);
13790 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013792 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13794 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13795 if(!HAL_STATUS_SUCCESS(status))
13796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013797 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 }
13799 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13800 length -= sizeof(tCsrGlobalClassAStatsInfo);
13801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013803 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13805 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13806 if(!HAL_STATUS_SUCCESS(status))
13807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013808 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 }
13810 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13811 length -= sizeof(tCsrGlobalClassBStatsInfo);
13812 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013814 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13816 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13817 if(!HAL_STATUS_SUCCESS(status))
13818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013819 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 }
13821 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13822 length -= sizeof(tCsrGlobalClassCStatsInfo);
13823 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013825 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13827 {
13828 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13829 pStats, sizeof(tCsrPerStaStatsInfo));
13830 }
13831 else
13832 {
13833 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013834 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 VOS_ASSERT( 0 );
13836 }
13837 if(!HAL_STATUS_SUCCESS(status))
13838 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013839 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 }
13841 pStats += sizeof(tCsrPerStaStatsInfo);
13842 length -= sizeof(tCsrPerStaStatsInfo);
13843 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013845 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 }
13848 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 tempMask >>=1;
13850 counter++;
13851 }
13852 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13853 if (length != 0)
13854 {
13855 pRssi = (tANI_U32*)pStats;
13856 rssi = (v_S7_t)*pRssi;
13857 }
13858 else
13859 {
13860 /* If riva is not sending rssi, continue to use the hack */
13861 rssi = RSSI_HACK_BMPS;
13862 }
13863 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013864post_update:
13865 //make sure to update the pe stats req list
13866 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13867 if(pEntry)
13868 {
13869 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13870 pPeStaEntry->rspPending = FALSE;
13871
13872 }
13873 //check the one timer cases
13874 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13875 if(pEntry)
13876 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 if(pTempStaEntry->timerExpired)
13879 {
13880 //send up the stats report
13881 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13882 pTempStaEntry->staId, pTempStaEntry->pContext);
13883 //also remove from the client list
13884 csrRoamRemoveStatListEntry(pMac, pEntry);
13885 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 }
13887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013888}
Jeff Johnson295189b2012-06-20 16:38:30 -070013889tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13890{
13891 tListElem *pEntry = NULL;
13892 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 if(!pEntry)
13895 {
13896 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013897 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013898 return NULL;
13899 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 while( pEntry )
13901 {
13902 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 if(pTempStaEntry->statsMask == statsMask)
13904 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013905 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 break;
13907 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13909 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 return pEntry;
13911}
13912
Jeff Johnson295189b2012-06-20 16:38:30 -070013913tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13914 tANI_BOOLEAN update)
13915{
13916 tListElem *pEntry;
13917 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 if(!pEntry)
13920 {
13921 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013922 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013923 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 return NULL;
13925 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 while( pEntry )
13927 {
13928 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13930 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13931 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013932 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 if(update)
13934 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013935 pTempStaEntry->periodicity = pStaEntry->periodicity;
13936 pTempStaEntry->callback = pStaEntry->callback;
13937 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 }
13939 break;
13940 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 return pEntry;
13944}
Jeff Johnson295189b2012-06-20 16:38:30 -070013945tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13946{
13947 tListElem *pEntry;
13948 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 if(!pEntry)
13951 {
13952 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013953 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013954 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 return NULL;
13956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 while( pEntry )
13958 {
13959 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013962 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 break;
13964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 return pEntry;
13968}
Jeff Johnson295189b2012-06-20 16:38:30 -070013969eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13970 csrRoamLinkQualityIndCallback callback,
13971 void *pContext)
13972{
13973 pMac->roam.linkQualityIndInfo.callback = callback;
13974 pMac->roam.linkQualityIndInfo.context = pContext;
13975 if( NULL == callback )
13976 {
13977 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13978 }
13979 else
13980 {
13981 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 /* do we need to invoke the callback to notify client of initial value ?? */
13983 }
13984 return eHAL_STATUS_SUCCESS;
13985}
Jeff Johnson295189b2012-06-20 16:38:30 -070013986void csrRoamVccTrigger(tpAniSirGlobal pMac)
13987{
13988 eCsrRoamLinkQualityInd newVccLinkQuality;
13989 tANI_U32 ul_mac_loss = 0;
13990 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13992 /*-------------------------------------------------------------------------
13993 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 Check for a change in link quality and notify client if necessary
13995 -------------------------------------------------------------------------*/
13996 ul_mac_loss_trigger_threshold =
13997 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013999 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014003 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14005 }
14006 else
14007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014008 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14012 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014015 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014018 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 newVccLinkQuality );
14020
14021 /* we now invoke the callback once to notify client of initial value */
14022 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14023 pMac->roam.linkQualityIndInfo.context );
14024 //event: EVENT_WLAN_VCC
14025 }
14026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pMac->roam.vccLinkQuality = newVccLinkQuality;
14028
Jeff Johnson295189b2012-06-20 16:38:30 -070014029}
Jeff Johnson295189b2012-06-20 16:38:30 -070014030VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14031 v_U8_t rssiNotification,
14032 void * context)
14033{
14034 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14035 eCsrRoamLinkQualityInd newVccLinkQuality;
14036 // TODO : Session info unavailable
14037 tANI_U32 sessionId = 0;
14038 VOS_STATUS status = VOS_STATUS_SUCCESS;
14039 /*-------------------------------------------------------------------------
14040 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 Check for a change in link quality and notify client if necessary
14042 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014043 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 pMac->roam.configParam.vccRssiThreshold);
14045 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014047 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014048 return VOS_STATUS_SUCCESS;
14049 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014050 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014052 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14054 }
14055 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014057 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014058 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14059 }
14060 else
14061 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014062 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 //Set to this so the code below won't do anything
14064 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014065 VOS_ASSERT(0);
14066 }
14067
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014070 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014073 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 /* we now invoke the callback once to notify client of initial value */
14076 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14077 pMac->roam.linkQualityIndInfo.context );
14078 //event: EVENT_WLAN_VCC
14079 }
14080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 return status;
14083}
Jeff Johnson295189b2012-06-20 16:38:30 -070014084tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14085 tDblLinkList *pStaList,
14086 tCsrStatsClientReqInfo *pStaEntry)
14087{
14088 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 //if same entity requested for same set of stats with different periodicity &
14091 // callback update it
14092 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14093 {
14094
14095 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14096 if (!HAL_STATUS_SUCCESS(status))
14097 {
14098 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014099 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 return NULL;
14101 }
14102
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 pNewStaEntry->callback = pStaEntry->callback;
14104 pNewStaEntry->pContext = pStaEntry->pContext;
14105 pNewStaEntry->periodicity = pStaEntry->periodicity;
14106 pNewStaEntry->requesterId = pStaEntry->requesterId;
14107 pNewStaEntry->statsMask = pStaEntry->statsMask;
14108 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14109 pNewStaEntry->pMac = pStaEntry->pMac;
14110 pNewStaEntry->staId = pStaEntry->staId;
14111 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14112
14113 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14114 }
14115 return pNewStaEntry;
14116}
14117
Jeff Johnson295189b2012-06-20 16:38:30 -070014118tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14119 tDblLinkList *pStaList,
14120 tCsrPeStatsReqInfo *pStaEntry)
14121{
14122 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14125 if (!HAL_STATUS_SUCCESS(status))
14126 {
14127 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014128 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 return NULL;
14130 }
14131
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14133 pNewStaEntry->numClient = pStaEntry->numClient;
14134 pNewStaEntry->periodicity = pStaEntry->periodicity;
14135 pNewStaEntry->statsMask = pStaEntry->statsMask;
14136 pNewStaEntry->pMac = pStaEntry->pMac;
14137 pNewStaEntry->staId = pStaEntry->staId;
14138 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14139 pNewStaEntry->rspPending = pStaEntry->rspPending;
14140
14141 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 return pNewStaEntry;
14143}
Jeff Johnson295189b2012-06-20 16:38:30 -070014144eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14145 tCsrRssiCallback callback,
14146 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14147{
14148 eHalStatus status = eHAL_STATUS_SUCCESS;
14149 vos_msg_t msg;
14150 tANI_U32 sessionId;
14151
14152 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014153 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14155 if ( !HAL_STATUS_SUCCESS(status) )
14156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014157 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 return status;
14159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014160 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14161
14162 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14163 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14164 pMsg->sessionId = sessionId;
14165 pMsg->staId = staId;
14166 pMsg->rssiCallback = callback;
14167 pMsg->pDevContext = pContext;
14168 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 msg.type = eWNI_SME_GET_RSSI_REQ;
14170 msg.bodyptr = pMsg;
14171 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014174 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 palFreeMemory(pMac->hHdd, (void *)pMsg);
14176 status = eHAL_STATUS_FAILURE;
14177 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014178 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014179 return status;
14180}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014181
14182#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14183eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14184 tCsrRssiCallback callback,
14185 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14186{
14187 eHalStatus status = eHAL_STATUS_SUCCESS;
14188 tAniGetRssiReq *pMsg;
14189
14190 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14191 if ( !HAL_STATUS_SUCCESS(status) )
14192 {
14193 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14194 return status;
14195 }
14196 // need to initiate a stats request to PE
14197 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14198 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14199 pMsg->staId = staId;
14200 pMsg->rssiCallback = callback;
14201 pMsg->pDevContext = pContext;
14202 pMsg->pVosContext = pVosContext;
14203 status = palSendMBMessage(pMac->hHdd, pMsg );
14204 if(!HAL_STATUS_SUCCESS(status))
14205 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014206 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14207 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014208 status = eHAL_STATUS_FAILURE;
14209 }
14210 return status;
14211}
14212#endif
14213
Jeff Johnson295189b2012-06-20 16:38:30 -070014214eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14215 tANI_U32 statsMask,
14216 tCsrStatsCallback callback,
14217 tANI_U32 periodicity, tANI_BOOLEAN cache,
14218 tANI_U8 staId, void *pContext)
14219{
14220 tCsrStatsClientReqInfo staEntry;
14221 tCsrStatsClientReqInfo *pStaEntry = NULL;
14222 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14223 tListElem *pEntry = NULL;
14224 tANI_BOOLEAN found = FALSE;
14225 eHalStatus status = eHAL_STATUS_SUCCESS;
14226 tANI_BOOLEAN insertInClientList = FALSE;
14227 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014228 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014229
14230 if( csrIsAllSessionDisconnected(pMac) )
14231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014232 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 return eHAL_STATUS_FAILURE;
14234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 if((!statsMask) && (!callback))
14236 {
14237 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014238 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 return eHAL_STATUS_FAILURE;
14240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 //for the search list method for deregister
14242 staEntry.requesterId = requesterId;
14243 staEntry.statsMask = statsMask;
14244 //requester wants to deregister or just an error
14245 if((statsMask) && (!callback))
14246 {
14247 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14248 if(!pEntry)
14249 {
14250 //msg
14251 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014252 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 return eHAL_STATUS_FAILURE;
14254 }
14255 else
14256 {
14257 //clean up & return
14258 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014259 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014261 pStaEntry->pPeStaEntry->numClient--;
14262 //check if we need to delete the entry from peStatsReqList too
14263 if(!pStaEntry->pPeStaEntry->numClient)
14264 {
14265 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014267 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014268
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 //check if we need to stop the tl stats timer too
14270 pMac->roam.tlStatsReqInfo.numClient--;
14271 if(!pMac->roam.tlStatsReqInfo.numClient)
14272 {
14273 if(pMac->roam.tlStatsReqInfo.timerRunning)
14274 {
14275 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14276 if(!HAL_STATUS_SUCCESS(status))
14277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014278 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014279 return eHAL_STATUS_FAILURE;
14280 }
14281 }
14282 pMac->roam.tlStatsReqInfo.periodicity = 0;
14283 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14284 }
14285 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 // Destroy the vos timer...
14287 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14288 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014290 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 csrRoamRemoveStatListEntry(pMac, pEntry);
14293 pStaEntry = NULL;
14294 return eHAL_STATUS_SUCCESS;
14295 }
14296 }
14297
14298 if(cache && !periodicity)
14299 {
14300 //return the cached stats
14301 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14302 }
14303 else
14304 {
14305 //add the request in the client req list
14306 staEntry.callback = callback;
14307 staEntry.pContext = pContext;
14308 staEntry.periodicity = periodicity;
14309 staEntry.pPeStaEntry = NULL;
14310 staEntry.staId = staId;
14311 staEntry.pMac = pMac;
14312 staEntry.timerExpired = FALSE;
14313
14314
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 //if periodic report requested with non cached result from PE/TL
14316 if(periodicity)
14317 {
14318
14319 //if looking for stats from PE
14320 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14321 {
14322
14323 //check if same request made already & waiting for rsp
14324 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14325 periodicity, &found, staId);
14326 if(!pPeStaEntry)
14327 {
14328 //bail out, maxed out on number of req for PE
14329 return eHAL_STATUS_FAILURE;
14330 }
14331 else
14332 {
14333 staEntry.pPeStaEntry = pPeStaEntry;
14334 }
14335
14336 }
14337 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14338 if(statsMask & (1 << eCsrGlobalClassDStats))
14339 {
14340 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014342 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 }
14344 else
14345 {
14346
14347 //update periodicity
14348 if(pMac->roam.tlStatsReqInfo.periodicity)
14349 {
14350 pMac->roam.tlStatsReqInfo.periodicity =
14351 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14352 }
14353 else
14354 {
14355 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14356 }
14357 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14358 {
14359 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14360 }
14361
14362 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14363 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014364 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14365 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014367 //req TL for class D stats
14368 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014370 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014371 }
14372 else
14373 {
14374 //save in SME
14375 csrRoamSaveStatsFromTl(pMac, pTlStats);
14376 }
14377 vos_mem_free(pTlStats);
14378 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 }
14380 else
14381 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014382 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014383 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014384
Jeff Johnson295189b2012-06-20 16:38:30 -070014385 if(pMac->roam.tlStatsReqInfo.periodicity)
14386 {
14387 //start timer
14388 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14389 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14390 if(!HAL_STATUS_SUCCESS(status))
14391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014392 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014393 return eHAL_STATUS_FAILURE;
14394 }
14395 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14396 }
14397 }
14398 }
14399 pMac->roam.tlStatsReqInfo.numClient++;
14400 }
14401
14402 insertInClientList = TRUE;
14403 }
14404 //if one time report requested with non cached result from PE/TL
14405 else if(!cache && !periodicity)
14406 {
14407 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14408 {
14409 //send down a req
14410 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14411 if(!HAL_STATUS_SUCCESS(status))
14412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014413 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014414 }
14415 //so that when the stats rsp comes back from PE we respond to upper layer
14416 //right away
14417 staEntry.timerExpired = TRUE;
14418 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014419 }
14420 if(statsMask & (1 << eCsrGlobalClassDStats))
14421 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014422 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14423 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014424 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014425 //req TL for class D stats
14426 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014428 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014429 }
14430 else
14431 {
14432 //save in SME
14433 csrRoamSaveStatsFromTl(pMac, pTlStats);
14434 }
14435 vos_mem_free(pTlStats);
14436 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 }
14438 else
14439 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014440 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014442
14443 }
14444 //if looking for stats from TL only
14445 if(!insertInClientList)
14446 {
14447 //return the stats
14448 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 if(insertInClientList)
14452 {
14453 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14454 if(!pStaEntry)
14455 {
14456 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014457 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 return eHAL_STATUS_FAILURE;
14459 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014460 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014461 //Init & start timer if needed
14462 if(periodicity)
14463 {
14464 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14465 csrRoamStatsClientTimerHandler, pStaEntry );
14466 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014468 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014469 return eHAL_STATUS_FAILURE;
14470 }
14471 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14472 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014474 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 return eHAL_STATUS_FAILURE;
14476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014479 }
14480 return eHAL_STATUS_SUCCESS;
14481}
14482
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014483#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14484
14485static tSirRetStatus
14486csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14487 tANI_U8* pBD,
14488 tANI_U8 type,
14489 tANI_U8 subType,
14490 tSirMacAddr peerAddr,
14491 tSirMacAddr selfMacAddr)
14492{
14493 tSirRetStatus statusCode = eSIR_SUCCESS;
14494 tpSirMacMgmtHdr pMacHdr;
14495
14496 /* Prepare MAC management header */
14497 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14498
14499 /* Prepare FC */
14500 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14501 pMacHdr->fc.type = type;
14502 pMacHdr->fc.subType = subType;
14503
14504 /* Prepare Address 1 */
14505 palCopyMemory( pMac->hHdd,
14506 (tANI_U8 *) pMacHdr->da,
14507 (tANI_U8 *) peerAddr,
14508 sizeof( tSirMacAddr ));
14509
14510 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14511
14512 /* Prepare Address 3 */
14513 palCopyMemory( pMac->hHdd,
14514 (tANI_U8 *) pMacHdr->bssId,
14515 (tANI_U8 *) peerAddr,
14516 sizeof( tSirMacAddr ));
14517 return statusCode;
14518} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14519
14520static tSirRetStatus
14521csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14522 tANI_U8 nChannelNum,
14523 tANI_U32 dot11mode,
14524 tSirMacAddr selfMacAddr,
14525 tANI_U8 *pFrame,
14526 tANI_U16 *pusLen)
14527{
14528 tDot11fProbeRequest pr;
14529 tANI_U32 nStatus, nBytes, nPayload;
14530 tSirRetStatus nSirStatus;
14531 /*Bcast tx*/
14532 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14533 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14534
14535
14536 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14537
14538 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14539
14540 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14541 {
14542 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14543 }
14544
14545
14546 if (IS_DOT11_MODE_HT(dot11mode))
14547 {
14548 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14549 }
14550
14551
14552 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14553 if ( DOT11F_FAILED( nStatus ) )
14554 {
14555 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14556 "Failed to calculate the packed size f"
14557 "or a Probe Request (0x%08x).\n", nStatus );
14558
14559
14560 nPayload = sizeof( tDot11fProbeRequest );
14561 }
14562 else if ( DOT11F_WARNED( nStatus ) )
14563 {
14564 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14565 "There were warnings while calculating"
14566 "the packed size for a Probe Request ("
14567 "0x%08x).\n", nStatus );
14568 }
14569
14570 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14571
14572 /* Prepare outgoing frame*/
14573 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14574
14575
14576 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
14577 SIR_MAC_MGMT_PROBE_REQ, bssId ,selfMacAddr);
14578
14579 if ( eSIR_SUCCESS != nSirStatus )
14580 {
14581 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14582 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14583 nSirStatus );
14584 return nSirStatus;
14585 }
14586
14587
14588 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14589 sizeof( tSirMacMgmtHdr ),
14590 nPayload, &nPayload );
14591 if ( DOT11F_FAILED( nStatus ) )
14592 {
14593 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14594 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14595 return eSIR_FAILURE;
14596 }
14597 else if ( DOT11F_WARNED( nStatus ) )
14598 {
14599 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14600 "There were warnings while packing a Probe Request (0x%08x).\n" );
14601 }
14602
14603 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14604 return eSIR_SUCCESS;
14605}
14606
14607eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14608{
14609 vos_msg_t msg;
14610 tSirRoamOffloadScanReq *pRequestBuf;
14611 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14612 tCsrRoamSession *pSession;
14613 tANI_U8 i,num_channels = 0, ucDot11Mode;
14614 tANI_U8 *ChannelList = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014615 tANI_U8 MaxDwellPeriod;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014616 tANI_U32 sessionId;
14617 eHalStatus status = eHAL_STATUS_SUCCESS;
14618 tpCsrChannelInfo currChannelListInfo;
14619 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14620
14621 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
14622 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014623 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set \n");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014624 return eHAL_STATUS_FAILURE;
14625 }
14626 status = csrRoamGetSessionIdFromBSSID(pMac,
14627 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14628 &sessionId);
14629 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14630 * It is important to ensure that the command is passed down to the FW only
14631 * if the Infra Station is in a connected state.A connected station could also be
14632 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14633 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14634 * irrespective of whichever state we are in.*/
14635 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14636 (command != ROAM_SCAN_OFFLOAD_STOP))
14637 {
14638 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14639 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14640 return eHAL_STATUS_FAILURE;
14641 }
14642
14643 if ( !HAL_STATUS_SUCCESS( status ) )
14644 {
14645 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14646 return eHAL_STATUS_FAILURE;
14647 }
14648 pSession = CSR_GET_SESSION( pMac, sessionId );
14649 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14650 if (NULL == pRequestBuf)
14651 {
14652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14653 return eHAL_STATUS_FAILED_ALLOC;
14654 }
14655
14656 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14657 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14658 * host driver reloads, but Riva still up and running*/
14659 if(command == ROAM_SCAN_OFFLOAD_STOP)
14660 pRequestBuf->RoamScanOffloadEnabled = 0;
14661 else
14662 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14663 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14664 sizeof(tCsrBssid));
14665 pRequestBuf->ConnectedNetwork.ssId.length =
14666 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14667 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14668 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14669 pRequestBuf->ConnectedNetwork.ssId.length);
14670 pRequestBuf->ConnectedNetwork.authentication =
14671 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14672 pRequestBuf->ConnectedNetwork.encryption =
14673 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14674 pRequestBuf->ConnectedNetwork.mcencryption =
14675 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14676 pRequestBuf->LookupThreshold =
14677 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14678 pRequestBuf->RoamRssiDiff =
14679 pMac->roam.configParam.RoamRssiDiff;
14680 pRequestBuf->Command = command;
14681 pRequestBuf->StartScanReason = reason;
14682 pRequestBuf->NeighborScanTimerPeriod =
14683 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14684 pRequestBuf->NeighborRoamScanRefreshPeriod =
14685 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14686 pRequestBuf->NeighborScanChannelMinTime =
14687 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14688 pRequestBuf->NeighborScanChannelMaxTime =
14689 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14690 pRequestBuf->EmptyRefreshScanPeriod =
14691 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14692#ifdef FEATURE_WLAN_CCX
14693 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14694#endif
14695 if (
14696#ifdef FEATURE_WLAN_CCX
14697 ((pNeighborRoamInfo->isCCXAssoc) &&
14698 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14699 eANI_BOOLEAN_FALSE)) ||
14700 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14701#endif // CCX
14702 currChannelListInfo->numOfChannels == 0)
14703 {
14704
14705 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14706 * Give Preference to INI Channels.*/
14707 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14708 {
14709 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14710 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14711 {
14712 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14713 {
14714 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14715 }
14716 ChannelList++;
14717 }
14718 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14719 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14720 }
14721 else{
14722 ChannelList = pMac->scan.occupiedChannels.channelList;
14723 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14724 {
14725 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14726 {
14727 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14728 }
14729 ChannelList++;
14730 }
14731 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14732 /* If the profile changes as to what it was earlier, inform the FW through
14733 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14734 * for the earlier profile and try to learn them afresh.*/
14735 if (reason == REASON_FLUSH_CHANNEL_LIST)
14736 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14737 else {
14738 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14739 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14740 else
14741 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14742 }
14743 }
14744 }
14745#ifdef FEATURE_WLAN_CCX
14746 else
14747 {
14748 /* If CCX is enabled, and a neighbor Report is received,then
14749 * Ignore the INI Channels or the Occupied Channel List. Consider
14750 * the channels in the neighbor list sent by the CCX AP.*/
14751 if (currChannelListInfo->numOfChannels != 0)
14752 {
14753 ChannelList = currChannelListInfo->ChannelList;
14754 for (i=0;i<currChannelListInfo->numOfChannels;i++)
14755 {
14756 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14757 {
14758 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14759 }
14760 ChannelList++;
14761 }
14762 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14763 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14764 }
14765 }
14766#endif
14767 num_channels = 0;
14768 ChannelList = NULL;
14769
14770 /* Maintain the Valid Channels List*/
14771 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
14772 {
14773 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
14774 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
14775 {
14776 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14777 {
14778 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14779 }
14780 ChannelList++;
14781 }
14782 pRequestBuf->ValidChannelCount = num_channels;
14783 } else {
14784 ChannelList = pMac->roam.validChannelList;
14785 for(i=0; i<pMac->roam.numValidChannels; i++)
14786 {
14787 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14788 {
14789 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14790 }
14791 ChannelList++;
14792 }
14793 pRequestBuf->ValidChannelCount = num_channels;
14794 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014795 pRequestBuf->MDID.mdiePresent =
14796 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
14797 pRequestBuf->MDID.mobilityDomain =
14798 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
14799 /*Ensure that the nProbes does not fall below its MIN Value which is 2*/
14800 if(pMac->roam.configParam.nProbes < 2)
14801 pRequestBuf->nProbes = 2;
14802 else
14803 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
14804
14805 /*Max Dwell Period is calculated here to ensure that,
14806 * Home Away Time is atleast equal to (MaxDwellPeriod +
14807 * (2*SRF)), where SRF is the RF Switching time.The RF
14808 * switching time is considered twice to consider the
14809 * time to go off channel and return to the home channel.*/
14810 MaxDwellPeriod = pRequestBuf->NeighborScanChannelMaxTime/pRequestBuf->nProbes;
14811 if(MaxDwellPeriod < 1)
14812 MaxDwellPeriod = 1;
14813 if(pMac->roam.configParam.nRoamScanHomeAwayTime <
14814 (MaxDwellPeriod + (2 * SIR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
14815 {
14816 pRequestBuf->HomeAwayTime = MaxDwellPeriod + (2 * SIR_ROAM_SCAN_CHANNEL_SWITCH_TIME);
14817 } else {
14818 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
14819 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014820 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
14821 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
14822 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
14823 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14824 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
14825
14826 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14827 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014828 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014829 msg.reserved = 0;
14830 msg.bodyptr = pRequestBuf;
14831 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
14832 {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014833 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014834 vos_mem_free(pRequestBuf);
14835 return eHAL_STATUS_FAILURE;
14836 }
14837
14838 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
14839 return status;
14840}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014841
14842eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
14843{
14844 switch(reason)
14845 {
14846 case 0:
14847 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
14848 break;
14849 case REASON_OS_REQUESTED_ROAMING_NOW:
14850 csrNeighborRoamProceedWithHandoffReq(pMac);
14851 break;
14852 default:
14853 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with unknown Reason %d", reason);
14854 }
14855 return eHAL_STATUS_SUCCESS;
14856}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014857#endif
14858
Jeff Johnson295189b2012-06-20 16:38:30 -070014859tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14860 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14861{
14862 tANI_BOOLEAN found = FALSE;
14863 eHalStatus status = eHAL_STATUS_SUCCESS;
14864 tCsrPeStatsReqInfo staEntry;
14865 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14866 tListElem *pStaEntry = NULL;
14867 VOS_STATUS vosStatus;
14868 tPmcPowerState powerState;
14869 *pFound = FALSE;
14870
14871 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14872 if(pStaEntry)
14873 {
14874 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14875 if(pTempStaEntry->periodicity)
14876 {
14877 pTempStaEntry->periodicity =
14878 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14879 }
14880 else
14881 {
14882 pTempStaEntry->periodicity = periodicity;
14883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014884 pTempStaEntry->numClient++;
14885 found = TRUE;
14886 }
14887 else
14888 {
14889 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14890 staEntry.numClient = 1;
14891 staEntry.periodicity = periodicity;
14892 staEntry.pMac = pMac;
14893 staEntry.rspPending = FALSE;
14894 staEntry.staId = staId;
14895 staEntry.statsMask = statsMask;
14896 staEntry.timerRunning = FALSE;
14897 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14898 if(!pTempStaEntry)
14899 {
14900 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014901 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 return NULL;
14903 }
14904 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14906 if(ePMC_FULL_POWER == powerState)
14907 {
14908 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14909 {
14910 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14911 }
14912 }
14913 else
14914 {
14915 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14916 {
14917 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14918 }
14919 }
14920 if(!pTempStaEntry->timerRunning)
14921 {
14922 //send down a req in case of one time req, for periodic ones wait for timer to expire
14923 if(!pTempStaEntry->rspPending &&
14924 !pTempStaEntry->periodicity)
14925 {
14926 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14927 if(!HAL_STATUS_SUCCESS(status))
14928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014929 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 }
14931 else
14932 {
14933 pTempStaEntry->rspPending = TRUE;
14934 }
14935 }
14936 if(pTempStaEntry->periodicity)
14937 {
14938 if(!found)
14939 {
14940
14941 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14942 csrRoamPeStatsTimerHandler, pTempStaEntry );
14943 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014945 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 return NULL;
14947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 }
14949 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014950 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14952 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14953 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014954 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 return NULL;
14956 }
14957 pTempStaEntry->timerRunning = TRUE;
14958 }
14959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 *pFound = found;
14961 return pTempStaEntry;
14962}
14963
Jeff Johnson295189b2012-06-20 16:38:30 -070014964/*
14965 pStaEntry is no longer invalid upon the return of this function.
14966*/
14967static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14968{
14969 if(pEntry)
14970 {
14971 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14972 {
14973 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 }
14976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014977
14978void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14979{
14980 tListElem *pEntry;
14981 tCsrPeStatsReqInfo *pTempStaEntry;
14982 VOS_STATUS vosStatus;
14983 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 if(!pEntry)
14985 {
14986 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014987 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 return;
14989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 while( pEntry )
14991 {
14992 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014995 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 if(pTempStaEntry->timerRunning)
14997 {
14998 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14999 /* If we are not able to stop the timer here, just remove
15000 * the entry from the linked list. Destroy the timer object
15001 * and free the memory in the timer CB
15002 */
15003 if( vosStatus == VOS_STATUS_SUCCESS )
15004 {
15005 /* the timer is successfully stopped */
15006 pTempStaEntry->timerRunning = FALSE;
15007
15008 /* Destroy the timer */
15009 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15010 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015012 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 }
15014 }
15015 else
15016 {
15017 // the timer could not be stopped. Hence destroy and free the
15018 // memory for the PE stat entry in the timer CB.
15019 pTempStaEntry->timerStopFailed = TRUE;
15020 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015021 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015022
15023 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15024 {
15025 // Only free the memory if we could stop the timer successfully
15026 if(!pTempStaEntry->timerStopFailed)
15027 {
15028 palFreeMemory(pMac->hHdd, pTempStaEntry);
15029 pTempStaEntry = NULL;
15030 }
15031 break;
15032 }
15033
15034 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15035 }
15036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 return;
15038}
15039
15040
Jeff Johnsone7245742012-09-05 17:12:55 -070015041void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015042{
15043
Jeff Johnsone7245742012-09-05 17:12:55 -070015044 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15045 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15046 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15047 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15048 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15049 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15050 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015052 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15053 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15054 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15055 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15056 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15057 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015058 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015059 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15060 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015061
15062}
15063
Jeff Johnson295189b2012-06-20 16:38:30 -070015064void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15065 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15066{
15067 tANI_U8 stats[500];
15068 tANI_U8 *pStats = NULL;
15069 tANI_U32 tempMask = 0;
15070 tANI_U8 counter = 0;
15071 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015072 if(!callback)
15073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015074 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 return;
15076 }
15077 if(!statsMask)
15078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015079 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015080 return;
15081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 while(tempMask)
15085 {
15086 if(tempMask & 1)
15087 {
15088 //new stats info from PE, fill up the stats strucutres in PMAC
15089 switch(counter)
15090 {
15091 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015092 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015093 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15094 sizeof(tCsrSummaryStatsInfo));
15095 if(!HAL_STATUS_SUCCESS(status))
15096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015097 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015098 }
15099 pStats += sizeof(tCsrSummaryStatsInfo);
15100 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015102 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15104 sizeof(tCsrGlobalClassAStatsInfo));
15105 if(!HAL_STATUS_SUCCESS(status))
15106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015107 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 }
15109 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015112 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15114 sizeof(tCsrGlobalClassBStatsInfo));
15115 if(!HAL_STATUS_SUCCESS(status))
15116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015117 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 }
15119 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015120 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015121 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015122 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15124 sizeof(tCsrGlobalClassCStatsInfo));
15125 if(!HAL_STATUS_SUCCESS(status))
15126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015127 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015128 }
15129 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015132 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15134 sizeof(tCsrGlobalClassDStatsInfo));
15135 if(!HAL_STATUS_SUCCESS(status))
15136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015137 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015138 }
15139 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015142 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15144 sizeof(tCsrPerStaStatsInfo));
15145 if(!HAL_STATUS_SUCCESS(status))
15146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015147 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 }
15149 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015152 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 }
15155 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 tempMask >>=1;
15157 counter++;
15158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015160}
15161
Jeff Johnson295189b2012-06-20 16:38:30 -070015162eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15163{
15164 tListElem *pEntry = NULL;
15165 tListElem *pPrevEntry = NULL;
15166 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15167 eHalStatus status = eHAL_STATUS_SUCCESS;
15168 VOS_STATUS vosStatus;
15169 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 if(!pEntry)
15171 {
15172 //list empty
15173 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015174 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 return status;
15176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 while( pEntry )
15178 {
15179 if(pPrevEntry)
15180 {
15181 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15182 //send up the stats report
15183 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15184 pTempStaEntry->staId, pTempStaEntry->pContext);
15185 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15189 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015190 pTempStaEntry->pPeStaEntry->numClient--;
15191 //check if we need to delete the entry from peStatsReqList too
15192 if(!pTempStaEntry->pPeStaEntry->numClient)
15193 {
15194 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 //check if we need to stop the tl stats timer too
15198 pMac->roam.tlStatsReqInfo.numClient--;
15199 if(!pMac->roam.tlStatsReqInfo.numClient)
15200 {
15201 if(pMac->roam.tlStatsReqInfo.timerRunning)
15202 {
15203 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15204 if(!HAL_STATUS_SUCCESS(status))
15205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015206 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015207 //we will continue
15208 }
15209 }
15210 pMac->roam.tlStatsReqInfo.periodicity = 0;
15211 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 if (pTempStaEntry->periodicity)
15214 {
15215 //While creating StaEntry in csrGetStatistics,
15216 //Initializing and starting timer only when periodicity is set.
15217 //So Stop and Destroy timer only when periodicity is set.
15218
Jeff Johnsone7245742012-09-05 17:12:55 -070015219 vos_timer_stop( &pTempStaEntry->timer );
15220 // Destroy the vos timer...
15221 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15222 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015224 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015225 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015227
Jeff Johnson295189b2012-06-20 16:38:30 -070015228
15229 pPrevEntry = pEntry;
15230 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15231 }
15232 //the last one
15233 if(pPrevEntry)
15234 {
15235 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15236 //send up the stats report
15237 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15238 pTempStaEntry->staId, pTempStaEntry->pContext);
15239 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 return status;
15242
15243}
15244
Jeff Johnson295189b2012-06-20 16:38:30 -070015245eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15246 tRequestFullPowerReason *pReason,
15247 tANI_BOOLEAN *pfNeedPower )
15248{
15249 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15250 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15251 tPmcState pmcState;
15252 eHalStatus status = eHAL_STATUS_SUCCESS;
15253 // TODO : Session info unavailable
15254 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 if( pfNeedPower )
15256 {
15257 *pfNeedPower = eANI_BOOLEAN_FALSE;
15258 }
15259 //We only handle CSR commands
15260 if( !(eSmeCsrCommandMask & pCommand->command) )
15261 {
15262 return eHAL_STATUS_SUCCESS;
15263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015264 //Check PMC state first
15265 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015266 switch( pmcState )
15267 {
15268 case REQUEST_IMPS:
15269 case IMPS:
15270 if( eSmeCommandScan == pCommand->command )
15271 {
15272 switch( pCommand->u.scanCmd.reason )
15273 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015274#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15275 case eCsrScanGetLfrResult:
15276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 case eCsrScanGetResult:
15278 case eCsrScanBGScanAbort:
15279 case eCsrScanBGScanEnable:
15280 case eCsrScanGetScanChnInfo:
15281 //Internal process, no need for full power
15282 fNeedFullPower = eANI_BOOLEAN_FALSE;
15283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 default:
15285 //Other scans are real scan, ask for power
15286 fNeedFullPower = eANI_BOOLEAN_TRUE;
15287 break;
15288 } //switch
15289 }
15290 else
15291 {
15292 //ask for power for roam and status change
15293 fNeedFullPower = eANI_BOOLEAN_TRUE;
15294 }
15295 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015296 case REQUEST_BMPS:
15297 case BMPS:
15298 case REQUEST_START_UAPSD:
15299 case UAPSD:
15300 //We treat WOWL same as BMPS
15301 case REQUEST_ENTER_WOWL:
15302 case WOWL:
15303 if( eSmeCommandRoam == pCommand->command )
15304 {
15305 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15306 tCsrScanResult *pScanResult;
15307 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015308 switch ( pCommand->u.roamCmd.roamReason )
15309 {
15310 case eCsrForcedDisassoc:
15311 case eCsrForcedDisassocMICFailure:
15312 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15313 fNeedFullPower = eANI_BOOLEAN_TRUE;
15314 break;
15315 case eCsrSmeIssuedDisassocForHandoff:
15316 case eCsrForcedDeauth:
15317 case eCsrHddIssuedReassocToSameAP:
15318 case eCsrSmeIssuedReassocToSameAP:
15319 fNeedFullPower = eANI_BOOLEAN_TRUE;
15320 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 case eCsrCapsChange:
15322 fNeedFullPower = eANI_BOOLEAN_TRUE;
15323 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 default:
15325 //Check whether the profile is already connected. If so, no need for full power
15326 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15327 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15328 {
15329 //Only need to check the first one
15330 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15331 if( pEntry )
15332 {
15333 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15334#if 0
15335 // TODO : Session Specific info pConnectBssDesc
15336 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15337 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15338 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15339 {
15340 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15341 // with Authenticating first. To force this, stop the current association (Disassociate) and
15342 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15343 // a new Association.
15344 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15345 {
15346 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15347 {
15348 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15349 //No need for full power
15350 //Set the flag so the code later can avoid to do the above
15351 //check again.
15352 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15353 break;
15354 }
15355 }
15356 }
15357#endif
15358 }
15359 }
15360 //If we are here, full power is needed
15361 fNeedFullPower = eANI_BOOLEAN_TRUE;
15362 break;
15363 }
15364 }
15365 else if( eSmeCommandWmStatusChange == pCommand->command )
15366 {
15367 //need full power for all
15368 fNeedFullPower = eANI_BOOLEAN_TRUE;
15369 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15370 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015371#ifdef FEATURE_WLAN_TDLS
15372 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15373 {
15374 //TDLS link is getting established. need full power
15375 fNeedFullPower = eANI_BOOLEAN_TRUE;
15376 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15377 }
15378#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 case REQUEST_STOP_UAPSD:
15381 case REQUEST_EXIT_WOWL:
15382 if( eSmeCommandRoam == pCommand->command )
15383 {
15384 fNeedFullPower = eANI_BOOLEAN_TRUE;
15385 switch ( pCommand->u.roamCmd.roamReason )
15386 {
15387 case eCsrForcedDisassoc:
15388 case eCsrForcedDisassocMICFailure:
15389 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15390 break;
15391 default:
15392 break;
15393 }
15394 }
15395 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 case STOPPED:
15397 case REQUEST_STANDBY:
15398 case STANDBY:
15399 case LOW_POWER:
15400 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015401 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015402 status = eHAL_STATUS_FAILURE;
15403 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 case FULL_POWER:
15405 case REQUEST_FULL_POWER:
15406 default:
15407 //No need to ask for full power. This has to be FULL_POWER state
15408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 if( pReason )
15411 {
15412 *pReason = reason;
15413 }
15414 if( pfNeedPower )
15415 {
15416 *pfNeedPower = fNeedFullPower;
15417 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 return ( status );
15419}
15420
Jeff Johnson295189b2012-06-20 16:38:30 -070015421static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15422{
15423 eHalStatus status = eHAL_STATUS_SUCCESS;
15424 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15425 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015427 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15428 {
15429 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15430 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 return ( status );
15432}
15433
Jeff Johnson295189b2012-06-20 16:38:30 -070015434tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15435{
15436 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 if( pCmd )
15438 {
15439 pMac->roam.sPendingCommands++;
15440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 return ( pCmd );
15442}
15443
Jeff Johnson295189b2012-06-20 16:38:30 -070015444void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15445{
15446 if (pMac->roam.sPendingCommands > 0)
15447 {
15448 //All command allocated through csrGetCommandBuffer need to
15449 //decrement the pending count when releasing.
15450 pMac->roam.sPendingCommands--;
15451 smeReleaseCommand( pMac, pCommand );
15452 }
15453 else
15454 {
15455 smsLog(pMac, LOGE, FL( "no pending commands"));
15456 VOS_ASSERT(0);
15457 }
15458}
15459
Jeff Johnson295189b2012-06-20 16:38:30 -070015460//Return SUCCESS is the command is queued, failed
15461eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15462{
15463 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15465 {
15466 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15467 pCommand->u.scanCmd.reason);
15468 return eHAL_STATUS_CSR_WRONG_STATE;
15469 }
15470
15471 //We can call request full power first before putting the command into pending Q
15472 //because we are holding SME lock at this point.
15473 status = csrRequestFullPower( pMac, pCommand );
15474 if( HAL_STATUS_SUCCESS( status ) )
15475 {
15476 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015477 //make sure roamCmdPendingList is not empty first
15478 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15479 if( fNoCmdPending )
15480 {
15481 smePushCommand( pMac, pCommand, fHighPriority );
15482 }
15483 else
15484 {
15485 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15486 //no list lock is needed since SME lock is held
15487 if( !fHighPriority )
15488 {
15489 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15490 }
15491 else {
15492 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15493 }
15494 }
15495 }
15496 else if( eHAL_STATUS_PMC_PENDING == status )
15497 {
15498 //no list lock is needed since SME lock is held
15499 if( !fHighPriority )
15500 {
15501 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15502 }
15503 else {
15504 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15505 }
15506 //Let caller know the command is queue
15507 status = eHAL_STATUS_SUCCESS;
15508 }
15509 else
15510 {
15511 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15512 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015513 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015516}
Jeff Johnson295189b2012-06-20 16:38:30 -070015517eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15518{
15519 eHalStatus status = eHAL_STATUS_SUCCESS;
15520 tSirUpdateAPWPSIEsReq *pMsg;
15521 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15522
15523 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15524 if (NULL == pSession)
15525 {
15526 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15527 return eHAL_STATUS_FAILURE;
15528 }
15529
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 do
15531 {
15532 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15533 if (!HAL_STATUS_SUCCESS(status)) break;
15534 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15535 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15536
15537 pBuf = (tANI_U8 *)&pMsg->transactionId;
15538 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 // transactionId
15540 *pBuf = 0;
15541 *( pBuf + 1 ) = 0;
15542 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 // bssId
15544 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15545 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 //sessionId
15547 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 // APWPSIEs
15549 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15550 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 return ( status );
15555}
Jeff Johnson295189b2012-06-20 16:38:30 -070015556eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15557{
15558 eHalStatus status = eHAL_STATUS_SUCCESS;
15559 tSirUpdateAPWPARSNIEsReq *pMsg;
15560 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015561 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15562 if (NULL == pSession)
15563 {
15564 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15565 return eHAL_STATUS_FAILURE;
15566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015567 do
15568 {
15569 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15570 if (!HAL_STATUS_SUCCESS(status)) break;
15571 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15572 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 pBuf = (tANI_U8 *)&pMsg->transactionId;
15574 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015575 // transactionId
15576 *pBuf = 0;
15577 *( pBuf + 1 ) = 0;
15578 pBuf += sizeof(tANI_U16);
15579
15580 // bssId
15581 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15582 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 // sessionId
15584 *pBuf++ = (tANI_U8)sessionId;
15585
15586 // APWPARSNIEs
15587 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15588 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015589 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015591 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015592 return ( status );
15593}
Jeff Johnson295189b2012-06-20 16:38:30 -070015594
15595#ifdef WLAN_FEATURE_VOWIFI_11R
15596//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15597eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15598{
15599 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15600 tpSirFTPreAuthReq pftPreAuthReq;
15601 tANI_U16 auth_req_len = 0;
15602 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 auth_req_len = sizeof(tSirFTPreAuthReq);
15604 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15605 if (pftPreAuthReq == NULL)
15606 {
15607 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15608 return eHAL_STATUS_RESOURCES;
15609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015610 // Save the SME Session ID here. We need it while processing the preauth response
15611 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 vos_mem_zero(pftPreAuthReq, auth_req_len);
15613
15614 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15615 sizeof(pBssDescription->length) + pBssDescription->length);
15616
15617 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15618
15619 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15620
Jeff Johnson295189b2012-06-20 16:38:30 -070015621 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15623
Jeff Johnson295189b2012-06-20 16:38:30 -070015624#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015625 if (csrRoamIs11rAssoc(pMac) &&
15626 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 {
15628 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15629 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15630 pMac->ft.ftSmeContext.auth_ft_ies_length);
15631 }
15632 else
15633#endif
15634 {
15635 pftPreAuthReq->ft_ies_length = 0;
15636 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015637 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15638 sizeof(pBssDescription->length) + pBssDescription->length);
15639 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15641}
Jeff Johnson295189b2012-06-20 16:38:30 -070015642/*--------------------------------------------------------------------------
15643 * This will receive and process the FT Pre Auth Rsp from the current
15644 * associated ap.
15645 *
15646 * This will invoke the hdd call back. This is so that hdd can now
15647 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15648 ------------------------------------------------------------------------*/
15649void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15650{
15651 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15652 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015653#ifdef FEATURE_WLAN_LFR
15654 tCsrRoamInfo roamInfo;
15655#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015656
15657#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015658 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015659#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015660#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015661 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015662 if (status != eHAL_STATUS_SUCCESS) {
15663 /*
15664 * Bail out if pre-auth was not even processed.
15665 */
15666 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15667 return;
15668 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015669#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15671 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15672 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015673 // Implies a success
15674 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015675 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15676 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15677 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015678 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15679 * actual transition from the current to handoff AP is triggered */
15680 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15681 60 * PAL_TIMER_TO_MS_UNIT,
15682 eANI_BOOLEAN_FALSE);
15683 if (eHAL_STATUS_SUCCESS != status)
15684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015685 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 return;
15687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015688 // Save the received response
15689 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15690 if (csrRoamIs11rAssoc(pMac))
15691 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15692 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15693
15694 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015695#ifdef FEATURE_WLAN_LFR
15696 // If Legacy Fast Roaming is enabled, signal the supplicant
15697 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015698 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015699 {
15700 // Save the bssid from the received response
15701 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15702 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15703 }
15704
15705#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015706
15707 // Done with it, init it.
15708 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15709}
15710#endif
15711#ifdef FEATURE_WLAN_BTAMP_UT_RF
15712void csrRoamJoinRetryTimerHandler(void *pv)
15713{
15714 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15715 tpAniSirGlobal pMac = pInfo->pMac;
15716 tANI_U32 sessionId = pInfo->sessionId;
15717 tCsrRoamSession *pSession;
15718
15719 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015721 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015722 pSession = CSR_GET_SESSION( pMac, sessionId );
15723 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15724 {
15725 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015727 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015728 }
15729 }
15730 }
15731}
Jeff Johnson295189b2012-06-20 16:38:30 -070015732eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15733{
15734 eHalStatus status = eHAL_STATUS_FAILURE;
15735 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15736
15737 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015739 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015740 pSession->maxRetryCount--;
15741 pSession->joinRetryTimerInfo.pMac = pMac;
15742 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15743 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15744 if(!HAL_STATUS_SUCCESS(status))
15745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015746 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 }
15748 }
15749 else
15750 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015751 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015752 pSession->maxRetryCount);
15753 }
15754
15755 return (status);
15756}
Jeff Johnson295189b2012-06-20 16:38:30 -070015757eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15758{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015759 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015760 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15761 {
15762 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15763 }
15764
15765 return eHAL_STATUS_SUCCESS;
15766}
15767#endif
15768
15769
15770/*
15771 pBuf points to the beginning of the message
15772 LIM packs disassoc rsp as below,
15773 messageType - 2 bytes
15774 messageLength - 2 bytes
15775 sessionId - 1 byte
15776 transactionId - 2 bytes (tANI_U16)
15777 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15778 peerMacAddr - 6 bytes
15779 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15780*/
15781static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15782{
15783 if(pBuf && pRsp)
15784 {
15785 pBuf += 4; //skip type and length
15786 pRsp->sessionId = *pBuf++;
15787 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15788 pBuf += 2;
15789 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15790 pBuf += 4;
15791 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15792 }
15793}
15794
Jeff Johnsond13512a2012-07-17 11:42:19 -070015795eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15796{
15797 static uNvTables nvTables;
15798 eHalStatus status = eHAL_STATUS_SUCCESS;
15799 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15800
15801 /* read the country code from NV and use it */
15802 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15803 {
15804 palCopyMemory( pMac->hHdd, pCountry,
15805 nvTables.defaultCountryTable.countryCode,
15806 WNI_CFG_COUNTRY_CODE_LEN );
15807 return status;
15808 }
15809 else
15810 {
15811 palCopyMemory( pMac->hHdd, pCountry,
15812 "XXX",
15813 WNI_CFG_COUNTRY_CODE_LEN );
15814 status = eHAL_STATUS_FAILURE;
15815 return status;
15816 }
15817}
15818
15819eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15820{
15821 palCopyMemory( pMac->hHdd, pCountry,
15822 pMac->scan.countryCode11d,
15823 WNI_CFG_COUNTRY_CODE_LEN );
15824 return eHAL_STATUS_SUCCESS;
15825}
schang86c22c42013-03-13 18:41:24 -070015826
15827eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
15828{
15829 tSirSetTxPowerReq *pMsg = NULL;
15830 eHalStatus status = eHAL_STATUS_SUCCESS;
15831 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15832
15833 if (!pSession)
15834 {
15835 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15836 return eHAL_STATUS_FAILURE;
15837 }
15838
15839 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
15840 if (HAL_STATUS_SUCCESS(status))
15841 {
15842 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
15843 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
15844 pMsg->length = sizeof(tSirSetTxPowerReq);
15845 pMsg->mwPower = mW;
15846 palCopyMemory( pMac->hHdd,
15847 (tSirMacAddr *)pMsg->bssId,
15848 &pSession->selfMacAddr,
15849 sizeof(tSirMacAddr) );
15850 status = palSendMBMessage(pMac->hHdd, pMsg);
15851 if (!HAL_STATUS_SUCCESS(status))
15852 {
15853 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015854 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070015855 }
15856 }
15857 return status;
15858}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015859
15860/* Returns whether a session is in VOS_STA_MODE...or not */
15861tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
15862{
15863 tCsrRoamSession *pSession = NULL;
15864 pSession = CSR_GET_SESSION ( pMac, sessionId );
15865 if(!pSession)
15866 {
15867 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
15868 return eANI_BOOLEAN_FALSE;
15869 }
15870 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
15871 {
15872 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
15873 return eANI_BOOLEAN_FALSE;
15874 }
15875 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15876 {
15877 return eANI_BOOLEAN_FALSE;
15878 }
15879 /* There is a possibility that the above check may fail,because
15880 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
15881 * when it is connected.So,we may sneak through the above check even
15882 * if we are not a STA mode INFRA station. So, if we sneak through
15883 * the above condition, we can use the following check if we are
15884 * really in STA Mode.*/
15885
15886 if ( NULL != pSession->pCurRoamProfile )
15887 {
15888 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
15889 {
15890 return eANI_BOOLEAN_TRUE;
15891 } else {
15892 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
15893 return eANI_BOOLEAN_FALSE;
15894 }
15895 }
15896
15897 return eANI_BOOLEAN_FALSE;
15898}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015899
15900#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15901eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
15902 tCsrHandoffRequest *pHandoffInfo)
15903{
15904 eHalStatus status = eHAL_STATUS_SUCCESS;
15905 vos_msg_t msg;
15906
15907 tAniHandoffReq *pMsg;
15908 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
15909 if ( !HAL_STATUS_SUCCESS(status) )
15910 {
15911 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
15912 return status;
15913 }
15914 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
15915 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
15916 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
15917 pMsg->channel = pHandoffInfo->channel;
15918 palCopyMemory(pMac->hHdd, pMsg->bssid,
15919 pHandoffInfo->bssid,
15920 6);
15921 msg.type = eWNI_SME_HANDOFF_REQ;
15922 msg.bodyptr = pMsg;
15923 msg.reserved = 0;
15924 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15925 {
15926 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
15927 palFreeMemory(pMac->hHdd, (void *)pMsg);
15928 status = eHAL_STATUS_FAILURE;
15929 }
15930 return status;
15931}
15932#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */