blob: a4d580d36427d4ed50dd29a5a82f0b4ac5ad687f [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;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010187 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10188 break;
10189#ifdef WLAN_FEATURE_11AC
10190 case eCSR_CFG_DOT11_MODE_11AC:
10191 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10192 {
10193 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10194 eBand = eCSR_BAND_5G;
10195 }
10196 else
10197 {
10198 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10199 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10200 }
10201 break;
10202 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10203 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10204 {
10205 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10206 eBand = eCSR_BAND_5G;
10207 }
10208 else
10209 {
10210 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10211 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10212 }
10213 break;
10214#endif
10215 case eCSR_CFG_DOT11_MODE_AUTO:
10216 eBand = pMac->roam.configParam.eBand;
10217 if (eCSR_BAND_24 == eBand)
10218 {
10219 // WiFi tests require IBSS networks to start in 11b mode
10220 // without any change to the default parameter settings
10221 // on the adapter. We use ACU to start an IBSS through
10222 // creation of a startIBSS profile. This startIBSS profile
10223 // has Auto MACProtocol and the adapter property setting
10224 // for dot11Mode is also AUTO. So in this case, let's
10225 // start the IBSS network in 11b mode instead of 11g mode.
10226 // So this is for Auto=profile->MacProtocol && Auto=Global.
10227 // dot11Mode && profile->channel is < 14, then start the IBSS
10228 // in b mode.
10229 //
10230 // Note: we used to have this start as an 11g IBSS for best
10231 // performance... now to specify that the user will have to
10232 // set the do11Mode in the property page to 11g to force it.
10233 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10234 }
10235 else
10236 {
10237#ifdef WLAN_FEATURE_11AC
10238 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10239 {
10240 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10241 eBand = eCSR_BAND_5G;
10242 }
10243 else
10244 {
10245 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10246 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10247 }
10248#else
10249 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10250 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10251#endif
10252 }
10253 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 default:
10255 // Global dot11 Mode setting is 11a/b/g.
10256 // use the channel number to determine the Mode setting.
10257 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10258 {
10259 eBand = pMac->roam.configParam.eBand;
10260 if(eCSR_BAND_24 == eBand)
10261 {
10262 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10263 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10264 }
10265 else
10266 {
10267 //prefer 5GHz
10268 eBand = eCSR_BAND_5G;
10269 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10270 }
10271 }
10272 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10273 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010274 // WiFi tests require IBSS networks to start in 11b mode
10275 // without any change to the default parameter settings
10276 // on the adapter. We use ACU to start an IBSS through
10277 // creation of a startIBSS profile. This startIBSS profile
10278 // has Auto MACProtocol and the adapter property setting
10279 // for dot11Mode is also AUTO. So in this case, let's
10280 // start the IBSS network in 11b mode instead of 11g mode.
10281 // So this is for Auto=profile->MacProtocol && Auto=Global.
10282 // dot11Mode && profile->channel is < 14, then start the IBSS
10283 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010284 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010285 // Note: we used to have this start as an 11g IBSS for best
10286 // performance... now to specify that the user will have to
10287 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10289 eBand = eCSR_BAND_24;
10290 }
10291 else
10292 {
10293 // else, it's a 5.0GHz channel. Set mode to 11a.
10294 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10295 eBand = eCSR_BAND_5G;
10296 }
10297 break;
10298 }//switch
10299 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10300 else
10301 {
10302 //dot11 mode is set, lets pick the band
10303 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10304 {
10305 // channel is Auto also.
10306 eBand = pMac->roam.configParam.eBand;
10307 if(eCSR_BAND_ALL == eBand)
10308 {
10309 //prefer 5GHz
10310 eBand = eCSR_BAND_5G;
10311 }
10312 }
10313 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10314 {
10315 eBand = eCSR_BAND_24;
10316 }
10317 else
10318 {
10319 eBand = eCSR_BAND_5G;
10320 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 if(pBand)
10323 {
10324 *pBand = eBand;
10325 }
10326
10327 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010328 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010329 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10330 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010331
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010332 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10333 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 -070010334 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010335#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010336 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010337#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010338 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10339 {
10340 //We cannot do 11n here
10341 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10342 {
10343 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10344 }
10345 else
10346 {
10347 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10348 }
10349 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 return( cfgDot11Mode );
10351}
10352
Jeff Johnson295189b2012-06-20 16:38:30 -070010353eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10354{
10355 eHalStatus status;
10356 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010357
10358 if(!pSession)
10359 {
10360 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10361 return eHAL_STATUS_FAILURE;
10362 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010363
10364#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10365 {
10366 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10368 if(pIbssLog)
10369 {
10370 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10371 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10372 }
10373 }
10374#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010375 pSession->ibss_join_pending = FALSE;
10376 csrRoamStopIbssJoinTimer(pMac, sessionId );
10377 // Set the roaming substate to 'stop Bss request'...
10378 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10379
10380 // attempt to stop the Bss (reason code is ignored...)
10381 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010382 if(!HAL_STATUS_SUCCESS(status))
10383 {
10384 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010386 return (status);
10387}
10388
Jeff Johnson295189b2012-06-20 16:38:30 -070010389//pNumChan is a caller allocated space with the sizeof pChannels
10390eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10391{
10392
10393 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10394 (tANI_U8 *)pChannels,
10395 pNumChan));
10396}
10397
Kiran4a17ebe2013-01-31 10:43:43 -080010398tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10399{
10400 tANI_U32 cfgLength = 0;
10401 tANI_U16 cfgId = 0;
10402 tPowerdBm maxTxPwr = 0;
10403 tANI_U8 *pCountryInfo = NULL;
10404 eHalStatus status;
10405 tANI_U8 count = 0;
10406 tANI_U8 firstChannel;
10407 tANI_U8 maxChannels;
10408
10409 if (CSR_IS_CHANNEL_5GHZ(channel))
10410 {
10411 cfgId = WNI_CFG_MAX_TX_POWER_5;
10412 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10413 }
10414 else if (CSR_IS_CHANNEL_24GHZ(channel))
10415 {
10416 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10417 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10418 }
10419 else
10420 return maxTxPwr;
10421
10422 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10423 if (status != eHAL_STATUS_SUCCESS)
10424 {
10425 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10426 FL("%s: palAllocateMemory() failed, status = %d"),
10427 __FUNCTION__, status);
10428 goto error;
10429 }
10430 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10431 if (status != eHAL_STATUS_SUCCESS)
10432 {
10433 goto error;
10434 }
10435 /* Identify the channel and maxtxpower */
10436 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10437 {
10438 firstChannel = pCountryInfo[count++];
10439 maxChannels = pCountryInfo[count++];
10440 maxTxPwr = pCountryInfo[count++];
10441
10442 if ((channel >= firstChannel) &&
10443 (channel < (firstChannel + maxChannels)))
10444 {
10445 break;
10446 }
10447 }
10448
10449error:
10450 if (NULL != pCountryInfo)
10451 palFreeMemory(pMac->hHdd, pCountryInfo);
10452
10453 return maxTxPwr;
10454}
10455
10456
Jeff Johnson295189b2012-06-20 16:38:30 -070010457tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10458{
10459 tANI_BOOLEAN fValid = FALSE;
10460 tANI_U32 idxValidChannels;
10461 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10462
10463 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10464 {
10465 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10466 {
10467 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10468 {
10469 fValid = TRUE;
10470 break;
10471 }
10472 }
10473 }
10474 pMac->roam.numValidChannels = len;
10475 return fValid;
10476}
10477
Jeff Johnson295189b2012-06-20 16:38:30 -070010478tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10479{
10480 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10481 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010482 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10483 {
10484 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10485 {
10486 fValid = eANI_BOOLEAN_TRUE;
10487 break;
10488 }
10489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 return (fValid);
10491}
10492
Jeff Johnson295189b2012-06-20 16:38:30 -070010493//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010494 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010495{
Jeff Johnsone7245742012-09-05 17:12:55 -070010496 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 tANI_U8 centerChn;
10498 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10500 {
10501 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10502 }
10503 else
10504 {
10505 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10506 }
10507 //Figure what the other side's CB mode
10508 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10509 {
10510 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10511 {
10512 if(pIes->HTInfo.present)
10513 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010514 /* This is called during INFRA STA/CLIENT and should use the merged value of
10515 * supported channel width and recommended tx width as per standard
10516 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010517 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010518 pIes->HTCaps.supportedChannelWidthSet,
10519 pIes->HTInfo.recommendedTxWidthSet,
10520 pIes->HTInfo.secondaryChannelOffset);
10521
10522 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10523 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010525 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10526 switch (eRet) {
10527 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10528 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10529 break;
10530 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10531 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10532 break;
10533 case PHY_SINGLE_CHANNEL_CENTERED:
10534 default:
10535 centerChn = primaryChn;
10536 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010537 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010538 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010540 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010541 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 }
10543 }
10544 }
10545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 return eRet;
10547}
Jeff Johnson295189b2012-06-20 16:38:30 -070010548tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10549{
10550 tANI_BOOLEAN fFound = FALSE;
10551 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010552 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10553 {
10554 if( pCipherList->encryptionType[idx] == encryptionType )
10555 {
10556 fFound = TRUE;
10557 break;
10558 }
10559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 return fFound;
10561}
Jeff Johnson295189b2012-06-20 16:38:30 -070010562tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10563{
10564 tANI_BOOLEAN fFound = FALSE;
10565 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10567 {
10568 if( pAuthList->authType[idx] == authType )
10569 {
10570 fFound = TRUE;
10571 break;
10572 }
10573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 return fFound;
10575}
Jeff Johnson295189b2012-06-20 16:38:30 -070010576tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10577{
10578 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10579 tCsrScanResultFilter *pScanFilter = NULL;
10580 eHalStatus status = eHAL_STATUS_SUCCESS;
10581
10582 if(pProfile1 && pProfile2)
10583 {
10584 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10585 if(HAL_STATUS_SUCCESS(status))
10586 {
10587 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10588 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10589 if(HAL_STATUS_SUCCESS(status))
10590 {
10591 fCheck = eANI_BOOLEAN_FALSE;
10592 do
10593 {
10594 tANI_U32 i;
10595 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10596 {
10597 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10598 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10599 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10600 if ( fCheck ) break;
10601 }
10602 if(!fCheck)
10603 {
10604 break;
10605 }
10606 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10607 || pProfile2->BSSType != pProfile1->BSSType
10608 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10609 )
10610 {
10611 fCheck = eANI_BOOLEAN_FALSE;
10612 break;
10613 }
10614#ifdef WLAN_FEATURE_VOWIFI_11R
10615 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10616 {
10617 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10618 {
10619 fCheck = eANI_BOOLEAN_FALSE;
10620 break;
10621 }
10622 }
10623#endif
10624 //Match found
10625 fCheck = eANI_BOOLEAN_TRUE;
10626 }while(0);
10627 csrFreeScanFilter(pMac, pScanFilter);
10628 }
10629 palFreeMemory(pMac->hHdd, pScanFilter);
10630 }
10631 }
10632
10633 return (fCheck);
10634}
10635
Jeff Johnson295189b2012-06-20 16:38:30 -070010636tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10637{
10638 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10639 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 do
10641 {
10642 //Only check for static WEP
10643 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10644 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10645 {
10646 fCheck = eANI_BOOLEAN_TRUE;
10647 break;
10648 }
10649 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10650 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10651 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10652 {
10653 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10654 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10655 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10656 {
10657 break;
10658 }
10659 }
10660 if( i == CSR_MAX_NUM_KEY)
10661 {
10662 fCheck = eANI_BOOLEAN_TRUE;
10663 }
10664 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 return (fCheck);
10666}
10667
Jeff Johnson295189b2012-06-20 16:38:30 -070010668//IBSS
10669
Jeff Johnson295189b2012-06-20 16:38:30 -070010670tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10671{
10672 tANI_U8 channel = 0;
10673 tANI_U32 idx;
10674 tANI_U32 idxValidChannels;
10675 tANI_BOOLEAN fFound = FALSE;
10676 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10677
10678 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10679 {
10680 channel = pMac->roam.configParam.AdHocChannel5G;
10681 if(!csrRoamIsChannelValid(pMac, channel))
10682 {
10683 channel = 0;
10684 }
10685 }
10686 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10687 {
10688 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10689 {
10690 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10691 {
10692 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10693 {
10694 fFound = TRUE;
10695 channel = csrStartIbssChannels50[ idx ];
10696 }
10697 }
10698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10700 if (!fFound)
10701 {
10702 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10703 {
10704 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10705 {
10706 channel = csrStartIbssChannels50[ idx ];
10707 break;
10708 }
10709 }
10710 }
10711 }//if
10712
10713 return( channel );
10714}
10715
Jeff Johnson295189b2012-06-20 16:38:30 -070010716tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10717{
10718 tANI_U8 channel = 1;
10719 tANI_U32 idx;
10720 tANI_U32 idxValidChannels;
10721 tANI_BOOLEAN fFound = FALSE;
10722 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10723
10724 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10725 {
10726 channel = pMac->roam.configParam.AdHocChannel24;
10727 if(!csrRoamIsChannelValid(pMac, channel))
10728 {
10729 channel = 0;
10730 }
10731 }
10732
10733 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10734 {
10735 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10736 {
10737 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10738 {
10739 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10740 {
10741 fFound = TRUE;
10742 channel = csrStartIbssChannels24[ idx ];
10743 }
10744 }
10745 }
10746 }
10747
10748 return( channel );
10749}
10750
Jeff Johnson295189b2012-06-20 16:38:30 -070010751static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10752 tCsrRoamStartBssParams *pParam )
10753{
10754 eCsrCfgDot11Mode cfgDot11Mode;
10755 eCsrBand eBand;
10756 tANI_U8 channel = 0;
10757 tSirNwType nwType;
10758 tANI_U8 operationChannel = 0;
10759
10760 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10761 {
10762 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10763 }
10764
Jeff Johnson295189b2012-06-20 16:38:30 -070010765 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010766
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10768 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10769 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10770 )
10771 {
10772 /* This should never happen */
10773 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010774 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 pProfile->csrPersona);
10776 VOS_ASSERT(0);
10777 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 switch( cfgDot11Mode )
10779 {
10780 case eCSR_CFG_DOT11_MODE_11G:
10781 nwType = eSIR_11G_NW_TYPE;
10782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010783 case eCSR_CFG_DOT11_MODE_11B:
10784 nwType = eSIR_11B_NW_TYPE;
10785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010786 case eCSR_CFG_DOT11_MODE_11A:
10787 nwType = eSIR_11A_NW_TYPE;
10788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 default:
10790 case eCSR_CFG_DOT11_MODE_11N:
10791 case eCSR_CFG_DOT11_MODE_TAURUS:
10792 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10793 if(eCSR_BAND_24 == eBand)
10794 {
10795 nwType = eSIR_11G_NW_TYPE;
10796 }
10797 else
10798 {
10799 nwType = eSIR_11A_NW_TYPE;
10800 }
10801 break;
10802 }
10803
10804 pParam->extendedRateSet.numRates = 0;
10805
10806 switch ( nwType )
10807 {
10808 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010809 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 case eSIR_11A_NW_TYPE:
10811
10812 pParam->operationalRateSet.numRates = 8;
10813
10814 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10815 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10816 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10817 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10818 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10819 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10820 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10821 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10822
10823 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10824 {
10825 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10826 if( 0 == channel &&
10827 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10828 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10829 )
10830 {
10831 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10832 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10833 nwType = eSIR_11B_NW_TYPE;
10834 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10835 pParam->operationalRateSet.numRates = 4;
10836 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10837 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10838 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10839 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10840 }
10841 }
10842 else
10843 {
10844 channel = operationChannel;
10845 }
10846 break;
10847
10848 case eSIR_11B_NW_TYPE:
10849 pParam->operationalRateSet.numRates = 4;
10850 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10851 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10852 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10853 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10855 {
10856 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10857 }
10858 else
10859 {
10860 channel = operationChannel;
10861 }
10862
10863 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010864 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 /* For P2P Client and P2P GO, disable 11b rates */
10866 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10867 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10868 )
10869 {
10870 pParam->operationalRateSet.numRates = 8;
10871
10872 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10873 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10874 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10875 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10876 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10877 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10878 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10879 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10880 }
10881 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 {
10883 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010884 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10885 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10886 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10887 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10888
10889 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010890 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10891 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10892 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10893 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10894 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10895 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10896 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10897 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10898 }
10899
10900 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10901 {
10902 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10903 }
10904 else
10905 {
10906 channel = operationChannel;
10907 }
10908
10909 break;
10910 }
10911 pParam->operationChn = channel;
10912 pParam->sirNwType = nwType;
10913}
10914
Jeff Johnson295189b2012-06-20 16:38:30 -070010915static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10916 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10917{
10918
10919 if( pParam )
10920 {
10921 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010922 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010923 pParam->operationChn = pBssDesc->channelId;
10924 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10925
10926 if( pIes )
10927 {
10928 if(pIes->SuppRates.present)
10929 {
10930 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10931 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010933 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 -070010934 pIes->SuppRates.num_rates);
10935 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10936 }
10937 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10938 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10939 }
10940 if( pIes->SSID.present )
10941 {
10942 pParam->ssId.length = pIes->SSID.num_ssid;
10943 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10944 }
10945 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 }
10947 else
10948 {
10949 pParam->ssId.length = 0;
10950 pParam->operationalRateSet.numRates = 0;
10951 }
10952 }
10953}
10954
Jeff Johnson295189b2012-06-20 16:38:30 -070010955static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10956{
10957 tANI_U8 MaxRate = 0;
10958 tANI_U32 i;
10959 tANI_U8 *pRate;
10960
10961 pRate = pSirRateSet->rate;
10962 for ( i = 0; i < pSirRateSet->numRates; i++ )
10963 {
10964 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10965 }
10966
10967 // Save the max rate in the connected state information...
10968
10969 // modify LastRates variable as well
10970
10971 return;
10972}
10973
Jeff Johnson295189b2012-06-20 16:38:30 -070010974eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10975 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10976{
10977 eHalStatus status = eHAL_STATUS_SUCCESS;
10978 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 // Set the roaming substate to 'Start BSS attempt'...
10980 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010981#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10982 //Need to figure out whether we need to log WDS???
10983 if( CSR_IS_IBSS( pProfile ) )
10984 {
10985 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010986 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10987 if(pIbssLog)
10988 {
10989 if(pBssDesc)
10990 {
10991 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10992 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10993 }
10994 else
10995 {
10996 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10997 }
10998 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10999 pParam->ssId.length);
11000 if(pProfile->ChannelInfo.numOfChannels == 0)
11001 {
11002 pIbssLog->channelSetting = AUTO_PICK;
11003 }
11004 else
11005 {
11006 pIbssLog->channelSetting = SPECIFIED;
11007 }
11008 pIbssLog->operatingChannel = pParam->operationChn;
11009 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11010 }
11011 }
11012#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11013 //Put RSN information in for Starting BSS
11014 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11015 pParam->pRSNIE = pProfile->pRSNReqIE;
11016
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 pParam->privacy = pProfile->privacy;
11018 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11019 pParam->authType = pProfile->csr80211AuthType;
11020 pParam->beaconInterval = pProfile->beaconInterval;
11021 pParam->dtimPeriod = pProfile->dtimPeriod;
11022 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11023 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11024 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11025 {
11026 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11027 {
11028 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11029 }
11030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 pParam->protEnabled = pProfile->protEnabled;
11032 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11033 pParam->ht_protection = pProfile->cfg_protection;
11034 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011035
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11037 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 pParam->bssPersona = pProfile->csrPersona;
11039 // When starting an IBSS, start on the channel from the Profile.
11040 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 return (status);
11042}
11043
Jeff Johnson295189b2012-06-20 16:38:30 -070011044static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011045 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011046{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011047 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011048 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011049 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011050
11051 if(!pSession)
11052 {
11053 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11054 return;
11055 }
11056
Jeff Johnson295189b2012-06-20 16:38:30 -070011057 if( pBssDesc )
11058 {
11059 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11060 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11061 //The following code has to be do after that.
11062 //For WDS station, use selfMac as the self BSSID
11063 if( CSR_IS_WDS_STA( pProfile ) )
11064 {
11065 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11066 }
11067 }
11068 else
11069 {
11070 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011071 //Use the first SSID
11072 if(pProfile->SSIDs.numOfSSIDs)
11073 {
11074 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11075 }
11076 //For WDS station, use selfMac as the self BSSID
11077 if( CSR_IS_WDS_STA( pProfile ) )
11078 {
11079 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11080 }
11081 //Use the first BSSID
11082 else if( pProfile->BSSIDs.numOfBSSIDs )
11083 {
11084 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11085 }
11086 else
11087 {
11088 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11089 }
11090 }
11091 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011092 //Set operating channel in pProfile which will be used
11093 //in csrRoamSetBssConfigCfg() to determine channel bonding
11094 //mode and will be configured in CFG later
11095 pProfile->operationChannel = Channel;
11096
11097 if(Channel == 0)
11098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011099 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 }
11101 else
11102 {
11103
11104 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011105 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011106 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011107 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011108 {
11109 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11110 }
11111 else
11112 {
11113 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11114 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011115 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011116 pBssConfig->cbMode = cbMode;
11117 pSession->bssParams.cbMode = cbMode;
11118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 }
11120}
11121
Jeff Johnson295189b2012-06-20 16:38:30 -070011122static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11123 tANI_BOOLEAN *pfSameIbss )
11124{
11125 eHalStatus status = eHAL_STATUS_SUCCESS;
11126 tANI_BOOLEAN fSameIbss = FALSE;
11127
11128 if ( csrIsConnStateIbss( pMac, sessionId ) )
11129 {
11130 // Check if any profile parameter has changed ? If any profile parameter
11131 // has changed then stop old BSS and start a new one with new parameters
11132 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11133 {
11134 fSameIbss = TRUE;
11135 }
11136 else
11137 {
11138 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11139 }
11140 }
11141 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11142 {
11143 // Disassociate from the connected Infrastructure network...
11144 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11145 }
11146 else
11147 {
11148 tBssConfigParam *pBssConfig;
11149
11150 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11151 if(HAL_STATUS_SUCCESS(status))
11152 {
11153 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11154 // there is no Bss description before we start an IBSS so we need to adopt
11155 // all Bss configuration parameters from the Profile.
11156 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11157 if(HAL_STATUS_SUCCESS(status))
11158 {
11159 //save dotMode
11160 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11161 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011162 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11164 }
11165
11166 palFreeMemory(pMac->hHdd, pBssConfig);
11167 }//Allocate memory
11168 }
11169
11170 if(pfSameIbss)
11171 {
11172 *pfSameIbss = fSameIbss;
11173 }
11174 return( status );
11175}
11176
Jeff Johnson295189b2012-06-20 16:38:30 -070011177static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11178 tSirSmeNewBssInfo *pNewBss )
11179{
11180 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011181
11182 if(!pSession)
11183 {
11184 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11185 return;
11186 }
11187
Jeff Johnson295189b2012-06-20 16:38:30 -070011188 if( pNewBss )
11189 {
11190 // Set the operating channel.
11191 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11192 // move the BSSId from the BSS description into the connected state information.
11193 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11194 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 return;
11197}
11198
Jeff Johnson295189b2012-06-20 16:38:30 -070011199#ifdef FEATURE_WLAN_WAPI
11200eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11201 tANI_U32 numItems )
11202{
11203 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11204 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011205 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011207 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 return status;
11209 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011210 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011211 pSession = CSR_GET_SESSION( pMac, sessionId );
11212 if(numItems <= CSR_MAX_BKID_ALLOWED)
11213 {
11214 status = eHAL_STATUS_SUCCESS;
11215 //numItems may be 0 to clear the cache
11216 pSession->NumBkidCache = (tANI_U16)numItems;
11217 if(numItems && pBKIDCache)
11218 {
11219 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11220 sizeof(tBkidCacheInfo) * numItems );
11221 }
11222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011223 return (status);
11224}
Jeff Johnson295189b2012-06-20 16:38:30 -070011225eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11226 tBkidCacheInfo *pBkidCache)
11227{
11228 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11229 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011232 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 return status;
11234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 pSession = CSR_GET_SESSION( pMac, sessionId );
11236 if(pNum && pBkidCache)
11237 {
11238 if(pSession->NumBkidCache == 0)
11239 {
11240 *pNum = 0;
11241 status = eHAL_STATUS_SUCCESS;
11242 }
11243 else if(*pNum >= pSession->NumBkidCache)
11244 {
11245 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011247 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 -070011248 pSession->NumBkidCache);
11249 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11250 }
11251 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11252 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11253 *pNum = pSession->NumBkidCache;
11254 status = eHAL_STATUS_SUCCESS;
11255 }
11256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011258}
Jeff Johnson295189b2012-06-20 16:38:30 -070011259tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11260{
11261 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011262}
11263#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011264eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11265 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11266{
11267 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11268 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011269
11270 if(!pSession)
11271 {
11272 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11273 return eHAL_STATUS_FAILURE;
11274 }
11275
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011276 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011277 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11278 {
11279#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11280 {
11281 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11282 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11283 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11284 secEvent.encryptionModeMulticast =
11285 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11286 secEvent.encryptionModeUnicast =
11287 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11288 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11289 secEvent.authMode =
11290 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11291 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11292 }
11293#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 status = eHAL_STATUS_SUCCESS;
11295 //numItems may be 0 to clear the cache
11296 pSession->NumPmkidCache = (tANI_U16)numItems;
11297 if(numItems && pPMKIDCache)
11298 {
11299 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11300 sizeof(tPmkidCacheInfo) * numItems );
11301 }
11302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 return (status);
11304}
11305
Jeff Johnson295189b2012-06-20 16:38:30 -070011306tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11307{
11308 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11309}
11310
Jeff Johnson295189b2012-06-20 16:38:30 -070011311eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11312{
11313 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11314 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011315
11316 if(!pSession)
11317 {
11318 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11319 return eHAL_STATUS_FAILURE;
11320 }
11321
Jeff Johnson295189b2012-06-20 16:38:30 -070011322 if(pNum && pPmkidCache)
11323 {
11324 if(pSession->NumPmkidCache == 0)
11325 {
11326 *pNum = 0;
11327 status = eHAL_STATUS_SUCCESS;
11328 }
11329 else if(*pNum >= pSession->NumPmkidCache)
11330 {
11331 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011333 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 -070011334 pSession->NumPmkidCache);
11335 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11336 }
11337 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11338 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11339 *pNum = pSession->NumPmkidCache;
11340 status = eHAL_STATUS_SUCCESS;
11341 }
11342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 return (status);
11344}
11345
Jeff Johnson295189b2012-06-20 16:38:30 -070011346eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11347{
11348 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11349 tANI_U32 len;
11350 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011351
11352 if(!pSession)
11353 {
11354 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11355 return eHAL_STATUS_FAILURE;
11356 }
11357
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 if(pLen)
11359 {
11360 len = *pLen;
11361 *pLen = pSession->nWpaRsnReqIeLength;
11362 if(pBuf)
11363 {
11364 if(len >= pSession->nWpaRsnReqIeLength)
11365 {
11366 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11367 }
11368 }
11369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011370 return (status);
11371}
11372
Jeff Johnson295189b2012-06-20 16:38:30 -070011373eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11374{
11375 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11376 tANI_U32 len;
11377 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011378
11379 if(!pSession)
11380 {
11381 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11382 return eHAL_STATUS_FAILURE;
11383 }
11384
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 if(pLen)
11386 {
11387 len = *pLen;
11388 *pLen = pSession->nWpaRsnRspIeLength;
11389 if(pBuf)
11390 {
11391 if(len >= pSession->nWpaRsnRspIeLength)
11392 {
11393 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11394 }
11395 }
11396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 return (status);
11398}
Jeff Johnson295189b2012-06-20 16:38:30 -070011399#ifdef FEATURE_WLAN_WAPI
11400eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11401{
11402 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11403 tANI_U32 len;
11404 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011405
11406 if(!pSession)
11407 {
11408 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11409 return eHAL_STATUS_FAILURE;
11410 }
11411
Jeff Johnson295189b2012-06-20 16:38:30 -070011412 if(pLen)
11413 {
11414 len = *pLen;
11415 *pLen = pSession->nWapiReqIeLength;
11416 if(pBuf)
11417 {
11418 if(len >= pSession->nWapiReqIeLength)
11419 {
11420 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11421 }
11422 }
11423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 return (status);
11425}
Jeff Johnson295189b2012-06-20 16:38:30 -070011426eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11427{
11428 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11429 tANI_U32 len;
11430 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011431
11432 if(!pSession)
11433 {
11434 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11435 return eHAL_STATUS_FAILURE;
11436 }
11437
Jeff Johnson295189b2012-06-20 16:38:30 -070011438 if(pLen)
11439 {
11440 len = *pLen;
11441 *pLen = pSession->nWapiRspIeLength;
11442 if(pBuf)
11443 {
11444 if(len >= pSession->nWapiRspIeLength)
11445 {
11446 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11447 }
11448 }
11449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 return (status);
11451}
11452#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011453eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11454{
11455 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11456 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011457
11458 if(!pSession)
11459 {
11460 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11461 return (retStatus);
11462 }
11463
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 if(CSR_IS_ROAMING(pSession))
11465 {
11466 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11467 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 return (retStatus);
11470}
11471
Jeff Johnson295189b2012-06-20 16:38:30 -070011472//This function remove the connected BSS from te cached scan result
11473eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11474 tCsrRoamConnectedProfile *pConnProfile)
11475{
11476 eHalStatus status = eHAL_STATUS_FAILURE;
11477 tCsrScanResultFilter *pScanFilter = NULL;
11478 tListElem *pEntry;
11479 tCsrScanResult *pResult;
11480 tDot11fBeaconIEs *pIes;
11481 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11483 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11484 {
11485 do
11486 {
11487 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11488 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11489 if(!HAL_STATUS_SUCCESS(status)) break;
11490 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11491 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11492 if(!HAL_STATUS_SUCCESS(status)) break;
11493 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11494 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11495 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11496 {
11497 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11498 if(!HAL_STATUS_SUCCESS(status)) break;
11499 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11500 }
11501 pScanFilter->authType.numEntries = 1;
11502 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11503 pScanFilter->BSSType = pConnProfile->BSSType;
11504 pScanFilter->EncryptionType.numEntries = 1;
11505 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11506 pScanFilter->mcEncryptionType.numEntries = 1;
11507 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11508 //We ignore the channel for now, BSSID should be enough
11509 pScanFilter->ChannelInfo.numOfChannels = 0;
11510 //Also ignore the following fields
11511 pScanFilter->uapsd_mask = 0;
11512 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11513 pScanFilter->countryCode[0] = 0;
11514 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 csrLLLock(&pMac->scan.scanResultList);
11516 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11517 while( pEntry )
11518 {
11519 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11520 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11521 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11522 pScanFilter, NULL, NULL, NULL, &pIes);
11523 //Release the IEs allocated by csrMatchBSS is needed
11524 if( !pResult->Result.pvIes )
11525 {
11526 //need to free the IEs since it is allocated by csrMatchBSS
11527 palFreeMemory(pMac->hHdd, pIes);
11528 }
11529 if(fMatch)
11530 {
11531 //We found the one
11532 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11533 {
11534 //Free the memory
11535 csrFreeScanResultEntry( pMac, pResult );
11536 }
11537 break;
11538 }
11539 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11540 }//while
11541 csrLLUnlock(&pMac->scan.scanResultList);
11542 }while(0);
11543 if(pScanFilter)
11544 {
11545 csrFreeScanFilter(pMac, pScanFilter);
11546 palFreeMemory(pMac->hHdd, pScanFilter);
11547 }
11548 }
11549 return (status);
11550}
11551
Jeff Johnson295189b2012-06-20 16:38:30 -070011552//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011553eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11554{
11555 eHalStatus status = eHAL_STATUS_SUCCESS;
11556 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11558 {
11559 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11560 {
11561 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11562 {
11563 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011564 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 status = eHAL_STATUS_CSR_WRONG_STATE;
11566 break;
11567 }
11568 if( csrIsConnStateInfra( pMac, sessionId ) )
11569 {
11570 if( chnId &&
11571 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011573 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11575 status = eHAL_STATUS_CSR_WRONG_STATE;
11576 break;
11577 }
11578 }
11579 }
11580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 return ( status );
11582}
11583
Jeff Johnson295189b2012-06-20 16:38:30 -070011584static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11585{
11586 eHalStatus status = eHAL_STATUS_SUCCESS;
11587 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11588 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011589
11590 if(!pSession)
11591 {
11592 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11593 return eHAL_STATUS_FAILURE;
11594 }
11595
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 if ( csrIsConnStateIbss( pMac, sessionId ) )
11597 {
11598 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11599 }
11600 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11601 {
11602 // Disassociate from the connected Infrastructure network...
11603 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11604 }
11605 else
11606 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11608 //Otherwise we need to add code to handle the
11609 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11610 //send stop_bss to PE, before we can continue.
11611 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11613 /* Assume HDD provide bssid in profile */
11614 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11615 // there is no Bss description before we start an WDS so we need
11616 // to adopt all Bss configuration parameters from the Profile.
11617 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11618 if(HAL_STATUS_SUCCESS(status))
11619 {
11620 //Save profile for late use
11621 csrFreeRoamProfile( pMac, sessionId );
11622 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11623 (void **)&pSession->pCurRoamProfile,
11624 sizeof(tCsrRoamProfile))))
11625 {
11626 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11627 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11628 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011630 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11632 }
11633 }
11634
11635 return( status );
11636}
11637
Jeff Johnson295189b2012-06-20 16:38:30 -070011638////////////////////Mail box
11639
Jeff Johnson295189b2012-06-20 16:38:30 -070011640//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11641//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11642static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11643 tSirBssDescription *pBssDescription,
11644 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11645{
11646 tCsrChannelSet channelGroup;
11647 tSirMacCapabilityInfo *pAP_capabilityInfo;
11648 tAniBool fTmp;
11649 tANI_BOOLEAN found = FALSE;
11650 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011651 tANI_S8 pwrLimit = 0;
11652 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011653 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11654 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11655 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11656 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 // 802.11h
11658 //We can do this because it is in HOST CPU order for now.
11659 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011660 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11661 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11662 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011663 fTmp = (tAniBool)pal_cpu_to_be32(1);
11664 }
11665 else
11666 fTmp = (tAniBool)0;
11667
11668 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11669 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11670 pBuf += sizeof(tAniBool);
11671 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011672 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 // This is required for 11k test VoWiFi Ent: Test 2.
11674 // We need the power capabilities for Assoc Req.
11675 // This macro is provided by the halPhyCfg.h. We pick our
11676 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011677 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11678 if (0 != pwrLimit)
11679 {
11680 *pBuf++ = pwrLimit;
11681 }
11682 else
11683 {
11684 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 size = sizeof(pMac->roam.validChannelList);
11687 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11688 {
11689 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11690 for ( i = 0; i < size; i++)
11691 {
11692 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11693
11694 }
11695 }
11696 else
11697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011698 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 *pBuf++ = 0; //tSirSupChnl->numChnl
11700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 //Check whether it is ok to enter UAPSD
11702#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11703 if( btcIsReadyForUapsd(pMac) )
11704#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11705 {
11706 *pBuf++ = uapsdMask;
11707 }
11708#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11709 else
11710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011711 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 *pBuf++ = 0;
11713 }
11714#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11715
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 // move the entire BssDescription into the join request.
11717 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11718 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011719 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11720}
11721
Jeff Johnson295189b2012-06-20 16:38:30 -070011722/*
11723 * The communication between HDD and LIM is thru mailbox (MB).
11724 * Both sides will access the data structure "tSirSmeJoinReq".
11725 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11726 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11727 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11728 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11729 */
11730eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011731 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011732{
11733 eHalStatus status = eHAL_STATUS_SUCCESS;
11734 tSirSmeJoinReq *pMsg;
11735 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011736 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 tANI_U16 msgLen, wTmp, ieLen;
11738 tSirMacRateSet OpRateSet;
11739 tSirMacRateSet ExRateSet;
11740 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11741 tANI_U32 dwTmp;
11742 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011743
11744 if(!pSession)
11745 {
11746 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11747 return eHAL_STATUS_FAILURE;
11748 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011749 /* To satisfy klockworks */
11750 if (NULL == pBssDescription)
11751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011752 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011753 return eHAL_STATUS_FAILURE;
11754 }
11755
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 do {
11757 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11758 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011759 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11761 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11762 // IE fields, but the length field in the bssDescription needs to be interpreted to
11763 // determine length of the IE fields.
11764 //
11765 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11766 // add in the length from the bssDescription (then add the size of the 'length' field
11767 // itself because that is NOT included in the length field).
11768 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11769 pBssDescription->length + sizeof( pBssDescription->length ) +
11770 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 -070011771 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11772 if ( !HAL_STATUS_SUCCESS(status) ) break;
11773 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011774 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 pMsg->length = pal_cpu_to_be16(msgLen);
11776 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 // sessionId
11778 *pBuf = (tANI_U8)sessionId;
11779 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 // transactionId
11781 *pBuf = 0;
11782 *( pBuf + 1 ) = 0;
11783 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 // ssId
11785 if( pIes->SSID.present && pIes->SSID.num_ssid )
11786 {
11787 // ssId len
11788 *pBuf = pIes->SSID.num_ssid;
11789 pBuf++;
11790 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11791 pBuf += pIes->SSID.num_ssid;
11792 }
11793 else
11794 {
11795 *pBuf = 0;
11796 pBuf++;
11797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 // selfMacAddr
11799 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11800 pBuf += sizeof(tSirMacAddr);
11801 // bsstype
11802 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11803 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11804 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11805 pBuf += sizeof(tSirBssType);
11806 // dot11mode
11807 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11808 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 //Persona
11810 *pBuf = (tANI_U8)pProfile->csrPersona;
11811 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011812 //CBMode
11813 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11814 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011815
11816 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011817 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11818
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 // uapsdPerAcBitmask
11820 *pBuf = pProfile->uapsd_mask;
11821 pBuf++;
11822
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011823
11824
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011826 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011827 {
11828 // OperationalRateSet
11829 if (OpRateSet.numRates) {
11830 *pBuf++ = OpRateSet.numRates;
11831 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11832 pBuf += OpRateSet.numRates;
11833 } else *pBuf++ = 0;
11834 // ExtendedRateSet
11835 if (ExRateSet.numRates) {
11836 *pBuf++ = ExRateSet.numRates;
11837 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11838 pBuf += ExRateSet.numRates;
11839 } else *pBuf++ = 0;
11840 }
11841 else
11842 {
11843 *pBuf++ = 0;
11844 *pBuf++ = 0;
11845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011846 // rsnIE
11847 if ( csrIsProfileWpa( pProfile ) )
11848 {
11849 // Insert the Wpa IE into the join request
11850 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11851 (tCsrWpaIe *)( wpaRsnIE ) );
11852 }
11853 else if( csrIsProfileRSN( pProfile ) )
11854 {
11855 // Insert the RSN IE into the join request
11856 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11857 (tCsrRSNIe *)( wpaRsnIE ) );
11858 }
11859#ifdef FEATURE_WLAN_WAPI
11860 else if( csrIsProfileWapi( pProfile ) )
11861 {
11862 // Insert the WAPI IE into the join request
11863 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11864 (tCsrWapiIe *)( wpaRsnIE ) );
11865 }
11866#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 else
11868 {
11869 ieLen = 0;
11870 }
11871 //remember the IE for future use
11872 if( ieLen )
11873 {
11874 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011876 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 -070011877 ieLen = DOT11F_IE_RSN_MAX_LEN;
11878 }
11879#ifdef FEATURE_WLAN_WAPI
11880 if( csrIsProfileWapi( pProfile ) )
11881 {
11882 //Check whether we need to allocate more memory
11883 if(ieLen > pSession->nWapiReqIeLength)
11884 {
11885 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11886 {
11887 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11888 }
11889 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11890 if(!HAL_STATUS_SUCCESS(status)) break;
11891 }
11892 pSession->nWapiReqIeLength = ieLen;
11893 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11894 wTmp = pal_cpu_to_be16( ieLen );
11895 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11896 pBuf += sizeof(tANI_U16);
11897 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11898 pBuf += ieLen;
11899 }
11900 else//should be WPA/WPA2 otherwise
11901#endif /* FEATURE_WLAN_WAPI */
11902 {
11903 //Check whether we need to allocate more memory
11904 if(ieLen > pSession->nWpaRsnReqIeLength)
11905 {
11906 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11907 {
11908 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11909 }
11910 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11911 if(!HAL_STATUS_SUCCESS(status)) break;
11912 }
11913 pSession->nWpaRsnReqIeLength = ieLen;
11914 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11915 wTmp = pal_cpu_to_be16( ieLen );
11916 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11917 pBuf += sizeof(tANI_U16);
11918 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11919 pBuf += ieLen;
11920 }
11921 }
11922 else
11923 {
11924 //free whatever old info
11925 pSession->nWpaRsnReqIeLength = 0;
11926 if(pSession->pWpaRsnReqIE)
11927 {
11928 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11929 pSession->pWpaRsnReqIE = NULL;
11930 }
11931#ifdef FEATURE_WLAN_WAPI
11932 pSession->nWapiReqIeLength = 0;
11933 if(pSession->pWapiReqIE)
11934 {
11935 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11936 pSession->pWapiReqIE = NULL;
11937 }
11938#endif /* FEATURE_WLAN_WAPI */
11939 //length is two bytes
11940 *pBuf = 0;
11941 *(pBuf + 1) = 0;
11942 pBuf += 2;
11943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011944#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011945 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011946 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011947 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 //length is two bytes
11949 *pBuf = 0;
11950 *(pBuf + 1) = 0;
11951 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011952 }
11953 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011955 // cckmIE
11956 if( csrIsProfileCCX( pProfile ) )
11957 {
11958 // Insert the CCKM IE into the join request
11959 ieLen = csrConstructCcxCckmIe( pMac,
11960 pSession,
11961 pProfile,
11962 pBssDescription,
11963 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 pSession->nWpaRsnReqIeLength,
11965 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011966 }
11967 else
11968 {
11969 ieLen = 0;
11970 }
11971 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11972 if( ieLen )
11973 {
11974 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11975 wTmp = pal_cpu_to_be16( ieLen );
11976 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11977 pBuf += sizeof(tANI_U16);
11978 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11979 pBuf += ieLen;
11980 }
11981 else
11982 {
11983 //Indicate you have no CCKM IE
11984 //length is two bytes
11985 *pBuf = 0;
11986 *(pBuf + 1) = 0;
11987 pBuf += 2;
11988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 }
11990#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011991 // addIEScan
11992 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11993 {
11994 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011995 if(ieLen > pSession->nAddIEScanLength)
11996 {
11997 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11998 {
11999 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12000 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012001 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012002 (void **)&pSession->pAddIEScan, ieLen);
12003 if(!HAL_STATUS_SUCCESS(status)) break;
12004 }
12005 pSession->nAddIEScanLength = ieLen;
12006 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12007 pProfile->pAddIEScan, ieLen);
12008 wTmp = pal_cpu_to_be16( ieLen );
12009 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12010 pBuf += sizeof(tANI_U16);
12011 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12012 pBuf += ieLen;
12013 }
12014 else
12015 {
12016 pSession->nAddIEScanLength = 0;
12017 if(pSession->pAddIEScan)
12018 {
12019 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12020 pSession->pAddIEScan = NULL;
12021 }
12022 *pBuf = 0;
12023 *(pBuf + 1) = 0;
12024 pBuf += 2;
12025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 // addIEAssoc
12027 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12028 {
12029 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 if(ieLen > pSession->nAddIEAssocLength)
12031 {
12032 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12033 {
12034 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12035 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012036 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 (void **)&pSession->pAddIEAssoc, ieLen);
12038 if(!HAL_STATUS_SUCCESS(status)) break;
12039 }
12040 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012041 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 pProfile->pAddIEAssoc, ieLen);
12043 wTmp = pal_cpu_to_be16( ieLen );
12044 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12045 pBuf += sizeof(tANI_U16);
12046 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12047 pBuf += ieLen;
12048 }
12049 else
12050 {
12051 pSession->nAddIEAssocLength = 0;
12052 if(pSession->pAddIEAssoc)
12053 {
12054 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12055 pSession->pAddIEAssoc = NULL;
12056 }
12057 *pBuf = 0;
12058 *(pBuf + 1) = 0;
12059 pBuf += 2;
12060 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012061
12062 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012064 //Unmask any AC in reassoc that is ACM-set
12065 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12066 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012068 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12069 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012070#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012071 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012072#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012073 uapsd_mask &= ~(acm_mask);
12074 }
12075 else
12076 {
12077 uapsd_mask = 0;
12078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 }
12080 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012081
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12083 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012084 pBuf += sizeof(tANI_U32);
12085
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12087 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012088 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012089#ifdef WLAN_FEATURE_11W
12090 //MgmtEncryption
12091 if (pProfile->MFPEnabled)
12092 {
12093 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12094 }
12095 else
12096 {
12097 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12098 }
12099 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12100 pBuf += sizeof(tANI_U32);
12101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012102#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012103 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012104 if (csrIsProfile11r( pProfile )
12105#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012106 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12107 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012108#endif
12109 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012110 {
12111 // is11Rconnection;
12112 dwTmp = pal_cpu_to_be32(TRUE);
12113 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12114 pBuf += sizeof(tAniBool);
12115 }
12116 else
12117 {
12118 // is11Rconnection;
12119 dwTmp = pal_cpu_to_be32(FALSE);
12120 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12121 pBuf += sizeof(tAniBool);
12122 }
12123#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012124#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012125 /* A profile can not be both CCX and 11R. But an 802.11R AP
12126 * may be advertising support for CCX as well. So if we are
12127 * associating Open or explicitly CCX then we will get CCX.
12128 * If we are associating explictly 11R only then we will get
12129 * 11R.
12130 */
12131 if ((csrIsProfileCCX(pProfile) ||
12132 ((pIes->CCXVersion.present)
12133 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012134 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12135 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12136 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012137#ifdef WLAN_FEATURE_11W
12138 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12139#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012140 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012141 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12142 {
12143 // isCCXconnection;
12144 dwTmp = pal_cpu_to_be32(TRUE);
12145 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12146 pBuf += sizeof(tAniBool);
12147 }
12148 else
12149 {
12150 //isCCXconnection;
12151 dwTmp = pal_cpu_to_be32(FALSE);
12152 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12153 pBuf += sizeof(tAniBool);
12154 }
12155
12156 if (eWNI_SME_JOIN_REQ == messageType)
12157 {
12158 tCCXTspecInfo ccxTspec;
12159 // CCX-Tspec IEs in the ASSOC request is presently not supported
12160 // so nullify the TSPEC parameters
12161 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12162 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12163 pBuf += sizeof(tCCXTspecInfo);
12164 }
12165 else if (eWNI_SME_REASSOC_REQ == messageType)
12166 {
12167 if ((csrIsProfileCCX(pProfile) ||
12168 ((pIes->CCXVersion.present)
12169 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012170 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12171 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12172 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012173#ifdef WLAN_FEATURE_11W
12174 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12175#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012176 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012177 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012178 {
12179 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 // CCX Tspec information
12181 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12182 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12183 *pBuf = ccxTspec.numTspecs;
12184 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 // Copy the TSPEC information only if present
12186 if (ccxTspec.numTspecs) {
12187 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12188 }
12189 pBuf += sizeof(ccxTspec.tspec);
12190 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012191 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012193 tCCXTspecInfo ccxTspec;
12194 // CCX-Tspec IEs in the ASSOC request is presently not supported
12195 // so nullify the TSPEC parameters
12196 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12197 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12198 pBuf += sizeof(tCCXTspecInfo);
12199 }
12200 }
12201#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012202#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012204 if (pMac->roam.configParam.isFastTransitionEnabled
12205#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012206 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012207#endif
12208 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012210 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012212 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 }
12214 else
12215 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012216 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012218 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 }
12220#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012221#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012222 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012223 {
12224 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012225 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012226 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012227 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012228 }
12229 else
12230 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012231 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012232 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012233 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012234 }
12235#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012236
12237 // txLdpcIniFeatureEnabled
12238 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12239 pBuf++;
12240
Kiran4a17ebe2013-01-31 10:43:43 -080012241 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12242 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12243 {
12244 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12245 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12246 csrApplyPower2Current(pMac);
12247 }
12248
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012249#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012250 // txBFIniFeatureEnabled
12251 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12252 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012253
12254 // txBFCsnValue
12255 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12256 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012257#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012258 //BssDesc
12259 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12260 (tANI_U8)pProfile->uapsd_mask);
12261 status = palSendMBMessage(pMac->hHdd, pMsg );
12262 if(!HAL_STATUS_SUCCESS(status))
12263 {
12264 break;
12265 }
12266 else
12267 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012268#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012269 if (eWNI_SME_JOIN_REQ == messageType)
12270 {
12271 //Tush-QoS: notify QoS module that join happening
12272 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12273 }
12274 else if (eWNI_SME_REASSOC_REQ == messageType)
12275 {
12276 //Tush-QoS: notify QoS module that reassoc happening
12277 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012279#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012281 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012282 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012283}
12284
Jeff Johnson295189b2012-06-20 16:38:30 -070012285//
12286eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12287{
12288 eHalStatus status = eHAL_STATUS_SUCCESS;
12289 tSirSmeDisassocReq *pMsg;
12290 tANI_U8 *pBuf;
12291 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12293 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12294 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 do {
12296 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12297 if ( !HAL_STATUS_SUCCESS(status) ) break;
12298 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12299 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12300 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 pBuf = &pMsg->sessionId;
12302 // sessionId
12303 *pBuf++ = (tANI_U8)sessionId;
12304 // transactionId
12305 *pBuf = 0;
12306 *( pBuf + 1 ) = 0;
12307 pBuf += sizeof(tANI_U16);
12308
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012309 if ( (pSession->pCurRoamProfile != NULL) &&
12310 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12311 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 {
12313 // Set the bssid address before sending the message to LIM
12314 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12315 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 // Set the peer MAC address before sending the message to LIM
12317 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12318 pBuf = pBuf + sizeof ( tSirMacAddr );
12319 }
12320 else
12321 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 // Set the peer MAC address before sending the message to LIM
12323 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12324 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12326 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012328 if(!HAL_STATUS_SUCCESS(status))
12329 {
12330 palFreeMemory(pMac->hHdd, pMsg);
12331 break;
12332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012333 // reasonCode
12334 wTmp = pal_cpu_to_be16(reasonCode);
12335 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12336 if(!HAL_STATUS_SUCCESS(status))
12337 {
12338 palFreeMemory(pMac->hHdd, pMsg);
12339 break;
12340 }
12341 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12343 Here we should not send the disassoc over the air to the AP */
12344 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12345#ifdef WLAN_FEATURE_VOWIFI_11R
12346 && csrRoamIs11rAssoc(pMac)
12347#endif
12348 )
12349 {
12350 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12351 }
12352 pBuf += sizeof(tANI_U8);
12353 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 return( status );
12356}
Jeff Johnson295189b2012-06-20 16:38:30 -070012357eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12358{
12359 eHalStatus status = eHAL_STATUS_SUCCESS;
12360 tSirSmeTkipCntrMeasReq *pMsg;
12361 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012362 do
12363 {
12364 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12365 if ( !HAL_STATUS_SUCCESS(status) ) break;
12366 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12367 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12368 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012369 pBuf = &pMsg->sessionId;
12370 // sessionId
12371 *pBuf++ = (tANI_U8)sessionId;
12372 // transactionId
12373 *pBuf = 0;
12374 *( pBuf + 1 ) = 0;
12375 pBuf += sizeof(tANI_U16);
12376 // bssid
12377 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12378 pBuf = pBuf + sizeof ( tSirMacAddr );
12379 // bEnable
12380 *pBuf = (tANI_BOOLEAN)bEnable;
12381 if(!HAL_STATUS_SUCCESS(status))
12382 {
12383 palFreeMemory(pMac->hHdd, pMsg);
12384 break;
12385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 return( status );
12389}
Jeff Johnson295189b2012-06-20 16:38:30 -070012390eHalStatus
12391csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12392 VOS_MODULE_ID modId, tSirMacAddr bssId,
12393 void *pUsrContext, void *pfnSapEventCallback,
12394 tANI_U8 *pAssocStasBuf )
12395{
12396 eHalStatus status = eHAL_STATUS_SUCCESS;
12397 tSirSmeGetAssocSTAsReq *pMsg;
12398 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12399 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 do
12401 {
12402 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12403 if (!HAL_STATUS_SUCCESS(status)) break;
12404 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12405 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 pBuf = (tANI_U8 *)&pMsg->bssId;
12407 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 // bssId
12409 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12410 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012411 // modId
12412 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12413 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12414 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 // pUsrContext
12416 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12417 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12418 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 // pfnSapEventCallback
12420 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12421 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12422 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 // pAssocStasBuf
12424 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12425 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12426 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 status = palSendMBMessage( pMac->hHdd, pMsg );
12429 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 return( status );
12431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012432eHalStatus
12433csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12434 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12435 {
12436 eHalStatus status = eHAL_STATUS_SUCCESS;
12437 tSirSmeGetWPSPBCSessionsReq *pMsg;
12438 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12439 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 do
12441 {
12442 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12443 if (!HAL_STATUS_SUCCESS(status)) break;
12444 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12445 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12447 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 // pUsrContext
12449 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12450 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12451 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 // pSapEventCallback
12453 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12454 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12455 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 // bssId
12457 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12458 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 // MAC Address of STA in WPS session
12460 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12461 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 return( status );
12466}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012467
12468eHalStatus
12469csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12470{
12471 tpSirChangeBIParams pMsg;
12472 tANI_U16 len = 0;
12473 eHalStatus status = eHAL_STATUS_SUCCESS;
12474 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12475
12476 if(!pSession)
12477 {
12478 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12479 return eHAL_STATUS_FAILURE;
12480 }
12481
12482 //NO need to update the Beacon Params if update beacon parameter flag is not set
12483 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12484 return eHAL_STATUS_SUCCESS;
12485
12486 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12487
12488 /* Create the message and send to lim */
12489 len = sizeof(tSirChangeBIParams);
12490 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12491 if(HAL_STATUS_SUCCESS(status))
12492 {
12493 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12494 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12495 pMsg->length = len;
12496
12497 // bssId
12498 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012499 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 -080012500 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12501 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12502 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012503 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012504 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12505 status = palSendMBMessage(pMac->hHdd, pMsg);
12506 }
12507 return status;
12508}
12509
Jeff Johnson295189b2012-06-20 16:38:30 -070012510eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12511{
12512 eHalStatus status = eHAL_STATUS_SUCCESS;
12513 tSirSmeDeauthReq *pMsg;
12514 tANI_U8 *pBuf;
12515 tANI_U16 wTmp;
12516 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12517 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12518 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 do {
12520 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12521 if ( !HAL_STATUS_SUCCESS(status) ) break;
12522 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12523 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12524 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12525 //sessionId
12526 pBuf = &pMsg->sessionId;
12527 *pBuf++ = (tANI_U8)sessionId;
12528
12529 //tansactionId
12530 *pBuf = 0;
12531 *(pBuf + 1 ) = 0;
12532 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012535 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12536 // Set the BSSID before sending the message to LIM
12537 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12538 pBuf = pBuf + sizeof(tSirMacAddr);
12539 }
12540 else
12541 {
12542 // Set the BSSID before sending the message to LIM
12543 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12544 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 }
12546 if(!HAL_STATUS_SUCCESS(status))
12547 {
12548 palFreeMemory(pMac->hHdd, pMsg);
12549 break;
12550 }
12551 // Set the peer MAC address before sending the message to LIM
12552 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12553 pBuf = pBuf + sizeof(tSirMacAddr);
12554 if(!HAL_STATUS_SUCCESS(status))
12555 {
12556 palFreeMemory(pMac->hHdd, pMsg);
12557 break;
12558 }
12559 wTmp = pal_cpu_to_be16(reasonCode);
12560 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12561 if(!HAL_STATUS_SUCCESS(status))
12562 {
12563 palFreeMemory(pMac->hHdd, pMsg);
12564 break;
12565 }
12566 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 return( status );
12569}
12570
Jeff Johnson295189b2012-06-20 16:38:30 -070012571eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12572{
12573 eHalStatus status = eHAL_STATUS_SUCCESS;
12574 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 do {
12576 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12577 if ( !HAL_STATUS_SUCCESS(status) ) break;
12578 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12579 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12580 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12581 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12582 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12583 if(!HAL_STATUS_SUCCESS(status))
12584 {
12585 palFreeMemory(pMac->hHdd, pMsg);
12586 break;
12587 }
12588//To test reconn
12589 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12590 if(!HAL_STATUS_SUCCESS(status))
12591 {
12592 palFreeMemory(pMac->hHdd, pMsg);
12593 break;
12594 }
12595//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 return( status );
12599}
12600
Jeff Johnson295189b2012-06-20 16:38:30 -070012601eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12602{
12603 eHalStatus status = eHAL_STATUS_SUCCESS;
12604 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 do {
12606 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12607 if ( !HAL_STATUS_SUCCESS(status) ) break;
12608 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12609 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12610 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12611 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12612 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12613 if(!HAL_STATUS_SUCCESS(status))
12614 {
12615 palFreeMemory(pMac->hHdd, pMsg);
12616 break;
12617 }
12618 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12619 if(!HAL_STATUS_SUCCESS(status))
12620 {
12621 palFreeMemory(pMac->hHdd, pMsg);
12622 break;
12623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 return( status );
12627}
Jeff Johnson295189b2012-06-20 16:38:30 -070012628eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12629{
12630 eHalStatus status = eHAL_STATUS_SUCCESS;
12631 tSirSmeAssocCnf *pMsg;
12632 tANI_U8 *pBuf;
12633 tSirResultCodes statusCode;
12634 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 do {
12636 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12637 if ( !HAL_STATUS_SUCCESS(status) ) break;
12638 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12639 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12640 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 pBuf = (tANI_U8 *)&pMsg->statusCode;
12642 if(HAL_STATUS_SUCCESS(Halstatus))
12643 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12644 else
12645 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12646 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12647 pBuf += sizeof(tSirResultCodes);
12648 // bssId
12649 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12650 pBuf += sizeof (tSirMacAddr);
12651 // peerMacAddr
12652 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12653 pBuf += sizeof (tSirMacAddr);
12654 // aid
12655 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12656 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12657 pBuf += sizeof (tANI_U16);
12658 // alternateBssId
12659 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12660 pBuf += sizeof (tSirMacAddr);
12661 // alternateChannelId
12662 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 status = palSendMBMessage( pMac->hHdd, pMsg );
12664 if(!HAL_STATUS_SUCCESS(status))
12665 {
12666 //pMsg is freed by palSendMBMessage
12667 break;
12668 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012669 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 return( status );
12671}
Jeff Johnson295189b2012-06-20 16:38:30 -070012672eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12673 tpSirSmeAssocInd pAssocInd,
12674 eHalStatus Halstatus,
12675 tANI_U8 sessionId)
12676{
12677 tSirMsgQ msgQ;
12678 eHalStatus status = eHAL_STATUS_SUCCESS;
12679 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12680 tANI_U8 *pBuf;
12681 tSirResultCodes statusCode;
12682 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 do {
12684 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12685 if ( !HAL_STATUS_SUCCESS(status) ) break;
12686 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012687
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12689 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12690
12691 pMsg->sessionId = sessionId;
12692
12693 pBuf = (tANI_U8 *)&pMsg->statusCode;
12694 if(HAL_STATUS_SUCCESS(Halstatus))
12695 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12696 else
12697 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12698 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12699 pBuf += sizeof(tSirResultCodes);
12700 // bssId
12701 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12702 pBuf += sizeof (tSirMacAddr);
12703 // peerMacAddr
12704 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12705 pBuf += sizeof (tSirMacAddr);
12706 // StaId
12707 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12708 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12709 pBuf += sizeof (tANI_U16);
12710 // alternateBssId
12711 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12712 pBuf += sizeof (tSirMacAddr);
12713 // alternateChannelId
12714 *pBuf = 11;
12715 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12717 //Wmm
12718 *pBuf = pAssocInd->wmmEnabledSta;
12719 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 //RSN IE
12721 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12722 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 //Additional IE
12724 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12725 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 //reassocReq
12727 *pBuf = pAssocInd->reassocReq;
12728 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12730 msgQ.bodyptr = pMsg;
12731 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 return( status );
12735}
Jeff Johnson295189b2012-06-20 16:38:30 -070012736
Jeff Johnson295189b2012-06-20 16:38:30 -070012737eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12738 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12739 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12740 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12741 tANI_U8 *pKeyRsc )
12742{
12743 tSirSmeSetContextReq *pMsg;
12744 tANI_U16 msgLen;
12745 eHalStatus status = eHAL_STATUS_FAILURE;
12746 tAniEdType tmpEdType;
12747 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012748 tANI_U8 *pBuf = NULL;
12749 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12754 // key set. Since we only support upto one key, we always allocate memory for 1 key
12755 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12756 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12757 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12758 ( sizeof( pMsg->keyMaterial.key ) );
12759
12760 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12761 if ( !HAL_STATUS_SUCCESS(status) ) break;
12762 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12763 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12764 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 //sessionId
12766 pBuf = &pMsg->sessionId;
12767 *pBuf = (tANI_U8)sessionId;
12768 pBuf++;
12769 // transactionId
12770 *pBuf = 0;
12771 *(pBuf + 1) = 0;
12772 pBuf += sizeof(tANI_U16);
12773 // peerMacAddr
12774 palCopyMemory( pMac->hHdd, pBuf,
12775 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12776
12777 pBuf += sizeof(tSirMacAddr);
12778
12779 // bssId
12780 palCopyMemory( pMac->hHdd, pBuf,
12781 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12782
12783 pBuf += sizeof(tSirMacAddr);
12784
12785 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12787 // in the tSirKeyMaterial keyMaterial; field).
12788 //
12789 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12790 // shorter than this max size. Is LIM interpreting this ok ?
12791 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 -070012792 // set pMsg->keyMaterial.edType
12793 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12794 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12795 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 // set the pMsg->keyMaterial.numKeys field
12797 *p = numKeys;
12798 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 // set pSirKey->keyId = keyId;
12800 *p = keyId;
12801 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 // set pSirKey->unicast = (tANI_U8)fUnicast;
12803 *p = (tANI_U8)fUnicast;
12804 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 // set pSirKey->keyDirection = aniKeyDirection;
12806 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12807 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12808 p += sizeof(tAniKeyDirection);
12809 // pSirKey->keyRsc = ;;
12810 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12811 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 // set pSirKey->paeRole
12813 *p = paeRole; // 0 is Supplicant
12814 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 // set pSirKey->keyLength = keyLength;
12816 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 if ( keyLength && pKey )
12818 {
12819 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12820 if(keyLength == 16)
12821 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012822 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 -070012823 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12824 pKey[5], pKey[6], pKey[7], pKey[8],
12825 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12826 }
12827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 return( status );
12831}
12832
Jeff Johnson295189b2012-06-20 16:38:30 -070012833eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12834 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12835{
12836 eHalStatus status;
12837 tSirSmeStartBssReq *pMsg;
12838 tANI_U8 *pBuf = NULL;
12839 tANI_U8 *wTmpBuf = NULL;
12840 tANI_U16 msgLen, wTmp;
12841 tANI_U32 dwTmp;
12842 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012843 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012846
12847 if(!pSession)
12848 {
12849 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12850 return eHAL_STATUS_FAILURE;
12851 }
12852
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 do {
12854 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12855 pSession->joinFailStatusCode.reasonCode = 0;
12856 msgLen = sizeof(tSirSmeStartBssReq);
12857 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12858 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12860 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 //sessionId
12864 *pBuf = (tANI_U8)sessionId;
12865 pBuf++;
12866 // transactionId
12867 *pBuf = 0;
12868 *(pBuf + 1) = 0;
12869 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 // bssid
12871 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12872 pBuf += sizeof(tSirMacAddr);
12873 // selfMacAddr
12874 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12875 pBuf += sizeof(tSirMacAddr);
12876 // beaconInterval
12877 if( pBssDesc && pBssDesc->beaconInterval )
12878 {
12879 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12880 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 else if(pParam->beaconInterval)
12882 {
12883 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 else
12886 {
12887 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12888 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070012889 if(csrIsconcurrentsessionValid (pMac, sessionId,
12890 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070012891 == eHAL_STATUS_SUCCESS )
12892 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012893 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012894 pParam->bssPersona);
12895 //Update the beacon Interval
12896 pParam->beaconInterval = wTmp;
12897 }
12898 else
12899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012900 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012901 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070012902 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070012903 return status;
12904 }
12905
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12907 pBuf += sizeof(tANI_U16);
12908 // dot11mode
12909 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12910 pBuf += 1;
12911 // bssType
12912 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12913 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12914 pBuf += sizeof(tSirBssType);
12915 // ssId
12916 if( pParam->ssId.length )
12917 {
12918 // ssId len
12919 *pBuf = pParam->ssId.length;
12920 pBuf++;
12921 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12922 pBuf += pParam->ssId.length;
12923 }
12924 else
12925 {
12926 *pBuf = 0;
12927 pBuf++;
12928 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012929 // set the channel Id
12930 *pBuf = pParam->operationChn;
12931 pBuf++;
12932 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012933 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12934 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12935 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012936
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 // Set privacy
12938 *pBuf = pParam->privacy;
12939 pBuf++;
12940
12941 //Set Uapsd
12942 *pBuf = pParam->ApUapsdEnable;
12943 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 //Set SSID hidden
12945 *pBuf = pParam->ssidHidden;
12946 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12948 pBuf++;
12949
12950 //Ht protection Enable/Disable
12951 *pBuf = (tANI_U8)pParam->protEnabled;
12952 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 //Enable Beacons to Receive for OBSS protection Enable/Disable
12954 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12955 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 //set cfg related to protection
12957 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12958 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12959 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 // Set Auth type
12961 authType = pal_cpu_to_be32(pParam->authType);
12962 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12963 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 // Set DTIM
12965 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12966 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12967 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 // Set wps_state
12969 *pBuf = pParam->wps_state;
12970 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 //Persona
12972 *pBuf = (tANI_U8)pParam->bssPersona;
12973 pBuf++;
12974
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012975 //txLdpcIniFeatureEnabled
12976 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12977 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012978
Jeff Johnson295189b2012-06-20 16:38:30 -070012979
12980 // set RSN IE
12981 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12982 {
12983 status = eHAL_STATUS_INVALID_PARAMETER;
12984 palFreeMemory( pMac->hHdd, pMsg );
12985 break;
12986 }
12987 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12988 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12989 pBuf += sizeof(tANI_U16);
12990 if( wTmp )
12991 {
12992 wTmp = pParam->nRSNIELength;
12993 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12994 pBuf += wTmp;
12995 }
12996 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12997 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12998 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13000 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13002 pBuf += pParam->operationalRateSet.numRates ;
13003 *pBuf++ = pParam->extendedRateSet.numRates;
13004 if(0 != pParam->extendedRateSet.numRates)
13005 {
13006 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13007 pBuf += pParam->extendedRateSet.numRates;
13008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13010 pMsg->length = pal_cpu_to_be16(msgLen);
13011
13012 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 return( status );
13015}
13016
Jeff Johnson295189b2012-06-20 16:38:30 -070013017eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13018{
13019 eHalStatus status = eHAL_STATUS_FAILURE;
13020 tSirSmeStopBssReq *pMsg;
13021 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13022 tANI_U8 *pBuf;
13023 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013024
13025 if(!pSession)
13026 {
13027 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13028 return eHAL_STATUS_FAILURE;
13029 }
13030
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 do {
13032 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13033 if ( !HAL_STATUS_SUCCESS(status) ) break;
13034 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13035 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13036 pBuf = &pMsg->sessionId;
13037 //sessionId
13038 *pBuf = (tANI_U8)sessionId;
13039 pBuf++;
13040 // transactionId
13041 *pBuf = 0;
13042 pBuf += sizeof(tANI_U16);
13043 //reason code
13044 *pBuf = 0;
13045 pBuf += sizeof(tSirResultCodes);
13046 // bssid
13047 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13048 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13049 {
13050 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13051 }
13052 else
13053 {
13054 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13055 }
13056 pBuf += sizeof(tSirMacAddr);
13057 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13058 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 status = palSendMBMessage( pMac->hHdd, pMsg );
13060#if 0
13061 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13062 if ( !HAL_STATUS_SUCCESS(status) ) break;
13063 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13064 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13065 pMsg->reasonCode = 0;
13066 // bssid
13067 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13068 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13069 {
13070 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13071 }
13072 else
13073 {
13074 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13075 }
13076 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13077 pMsg->transactionId = 0;
13078 pMsg->sessionId = (tANI_U8)sessionId;
13079 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13080 status = palSendMBMessage( pMac->hHdd, pMsg );
13081#endif
13082 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 return( status );
13084}
13085
Jeff Johnson295189b2012-06-20 16:38:30 -070013086eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13087 tCsrRoamModifyProfileFields *pModProfileFields,
13088 tANI_U32 *pRoamId, v_BOOL_t fForce)
13089{
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 eHalStatus status = eHAL_STATUS_FAILURE;
13091 tANI_U32 roamId = 0;
13092 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 if((csrIsConnStateConnected(pMac, sessionId)) &&
13094 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13095 &pSession->connectedProfile.modifyProfileFields,
13096 sizeof(tCsrRoamModifyProfileFields)))) )
13097 {
13098 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13099 if(pRoamId)
13100 {
13101 *pRoamId = roamId;
13102 }
13103
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13105 eCsrSmeIssuedReassocToSameAP, roamId,
13106 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 return status;
13109}
Jeff Johnson295189b2012-06-20 16:38:30 -070013110static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13111{
13112 eHalStatus status = eHAL_STATUS_SUCCESS;
13113 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13115 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13116 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13117 return (status);
13118}
Jeff Johnson295189b2012-06-20 16:38:30 -070013119eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13120{
13121 eHalStatus status = eHAL_STATUS_SUCCESS;
13122 tListElem *pEntry = NULL;
13123 tSmeCmd *pCommand = NULL;
13124 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 do
13126 {
13127 if(pMsg == NULL)
13128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013129 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013130 status = eHAL_STATUS_FAILURE;
13131 break;
13132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13134 if(pEntry)
13135 {
13136 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13137 if(eSmeCommandAddStaSession == pCommand->command)
13138 {
13139 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013140 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 //Remove this command out of the active list
13144 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13145 {
13146 //Now put this command back on the avilable command list
13147 csrReleaseCommand(pMac, pCommand);
13148 }
13149 smeProcessPendingQueue( pMac );
13150 }
13151 else
13152 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013153 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 -070013154 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 status = eHAL_STATUS_FAILURE;
13156 break;
13157 }
13158 }
13159 else
13160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013161 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 -070013162 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 status = eHAL_STATUS_FAILURE;
13164 break;
13165 }
13166 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013168}
Jeff Johnson295189b2012-06-20 16:38:30 -070013169eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13170{
13171 tSirSmeAddStaSelfReq *pMsg;
13172 tANI_U16 msgLen;
13173 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13176 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13178 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013179 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13181 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 // self station address
13183 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013184 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 pMsg->selfMacAddr[0],
13186 pMsg->selfMacAddr[1],
13187 pMsg->selfMacAddr[2],
13188 pMsg->selfMacAddr[3],
13189 pMsg->selfMacAddr[4],
13190 pMsg->selfMacAddr[5]);
13191 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 return( status );
13194}
Jeff Johnson295189b2012-06-20 16:38:30 -070013195eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
13196{
13197 eHalStatus status = eHAL_STATUS_SUCCESS;
13198 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 pCommand = csrGetCommandBuffer(pMac);
13200 if(NULL == pCommand)
13201 {
13202 status = eHAL_STATUS_RESOURCES;
13203 }
13204 else
13205 {
13206 pCommand->command = eSmeCommandAddStaSession;
13207 pCommand->sessionId = (tANI_U8)sessionId;
13208 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13210 if( !HAL_STATUS_SUCCESS( status ) )
13211 {
13212 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013213 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 }
13215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 return (status);
13217}
Jeff Johnson295189b2012-06-20 16:38:30 -070013218eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13219{
13220 return csrSendMBAddSelfStaReqMsg( pMac,
13221 pCommand->u.addStaSessionCmd.selfMacAddr );
13222}
Jeff Johnson295189b2012-06-20 16:38:30 -070013223eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
13224 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
13225{
13226 eHalStatus status = eHAL_STATUS_SUCCESS;
13227 tANI_U32 i;
13228 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 *pbSessionId = CSR_SESSION_ID_INVALID;
13230 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13231 {
13232 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13233 {
13234 pSession = CSR_GET_SESSION( pMac, i );
13235 status = eHAL_STATUS_SUCCESS;
13236 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13237 pSession->sessionId = (tANI_U8)i;
13238 pSession->callback = callback;
13239 pSession->pContext = pContext;
13240 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13241 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13243 &pSession->roamingTimerInfo);
13244 if(!HAL_STATUS_SUCCESS(status))
13245 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013246 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 break;
13248 }
13249#ifdef FEATURE_WLAN_BTAMP_UT_RF
13250 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13251 &pSession->joinRetryTimerInfo);
13252 if(!HAL_STATUS_SUCCESS(status))
13253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013254 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 break;
13256 }
13257#endif
13258 pSession->ibssJoinTimerInfo.pMac = pMac;
13259 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13261 &pSession->ibssJoinTimerInfo);
13262 if(!HAL_STATUS_SUCCESS(status))
13263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013264 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 break;
13266 }
13267 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13268 break;
13269 }
13270 }
13271 if( CSR_ROAM_SESSION_MAX == i )
13272 {
13273 //No session is available
13274 status = eHAL_STATUS_RESOURCES;
13275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 return ( status );
13277}
Jeff Johnson295189b2012-06-20 16:38:30 -070013278eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13279{
13280 eHalStatus status = eHAL_STATUS_SUCCESS;
13281 tListElem *pEntry = NULL;
13282 tSmeCmd *pCommand = NULL;
13283 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 do
13285 {
13286 if(pMsg == NULL)
13287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013288 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 status = eHAL_STATUS_FAILURE;
13290 break;
13291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13293 if(pEntry)
13294 {
13295 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13296 if(eSmeCommandDelStaSession == pCommand->command)
13297 {
13298 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013300 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 //This session is done.
13302 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 if(pCommand->u.delStaSessionCmd.callback)
13304 {
13305
13306 status = sme_ReleaseGlobalLock( &pMac->sme );
13307 if ( HAL_STATUS_SUCCESS( status ) )
13308 {
13309 pCommand->u.delStaSessionCmd.callback(
13310 pCommand->u.delStaSessionCmd.pContext);
13311 status = sme_AcquireGlobalLock( &pMac->sme );
13312 if (! HAL_STATUS_SUCCESS( status ) )
13313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013314 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 return status;
13316 }
13317 }
13318 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013319 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 }
13321 }
13322
13323 //Remove this command out of the active list
13324 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13325 {
13326 //Now put this command back on the avilable command list
13327 csrReleaseCommand(pMac, pCommand);
13328 }
13329 smeProcessPendingQueue( pMac );
13330 }
13331 else
13332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013333 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 -070013334 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 status = eHAL_STATUS_FAILURE;
13336 break;
13337 }
13338 }
13339 else
13340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013341 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 -070013342 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 status = eHAL_STATUS_FAILURE;
13344 break;
13345 }
13346 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348}
Jeff Johnson295189b2012-06-20 16:38:30 -070013349eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13350{
13351 tSirSmeDelStaSelfReq *pMsg;
13352 tANI_U16 msgLen;
13353 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013354 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13356 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13358 if ( !HAL_STATUS_SUCCESS(status) ) break;
13359
13360 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13362 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 // self station address
13364 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 return( status );
13368}
Jeff Johnson295189b2012-06-20 16:38:30 -070013369eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13370 tSirMacAddr sessionMacAddr,
13371 csrRoamSessionCloseCallback callback,
13372 void *pContext)
13373{
13374 eHalStatus status = eHAL_STATUS_SUCCESS;
13375 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 pCommand = csrGetCommandBuffer(pMac);
13377 if(NULL == pCommand)
13378 {
13379 status = eHAL_STATUS_RESOURCES;
13380 }
13381 else
13382 {
13383 pCommand->command = eSmeCommandDelStaSession;
13384 pCommand->sessionId = (tANI_U8)sessionId;
13385 pCommand->u.delStaSessionCmd.callback = callback;
13386 pCommand->u.delStaSessionCmd.pContext = pContext;
13387 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13389 if( !HAL_STATUS_SUCCESS( status ) )
13390 {
13391 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013392 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 }
13394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 return (status);
13396}
Jeff Johnson295189b2012-06-20 16:38:30 -070013397eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13398{
13399 return csrSendMBDelSelfStaReqMsg( pMac,
13400 pCommand->u.delStaSessionCmd.selfMacAddr );
13401}
Jeff Johnson295189b2012-06-20 16:38:30 -070013402static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13403{
13404 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13405 tListElem *pEntry, *pNext;
13406 tSmeCmd *pCommand;
13407 tDblLinkList localList;
13408
13409 vos_mem_zero(&localList, sizeof(tDblLinkList));
13410 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13411 {
13412 smsLog(pMac, LOGE, FL(" failed to open list"));
13413 return;
13414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 csrLLLock(pList);
13416 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13417 while(pEntry != NULL)
13418 {
13419 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13420 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13421 if(pCommand->sessionId == sessionId)
13422 {
13423 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13424 {
13425 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13426 }
13427 }
13428 pEntry = pNext;
13429 }
13430 csrLLUnlock(pList);
13431
13432 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13433 {
13434 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13435 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13436 }
13437 csrLLClose(&localList);
13438}
13439
Jeff Johnson295189b2012-06-20 16:38:30 -070013440void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13441{
13442 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13443 {
13444 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 csrRoamStop(pMac, sessionId);
13446 csrFreeConnectBssDesc(pMac, sessionId);
13447 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13448 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13449 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13450#ifdef FEATURE_WLAN_BTAMP_UT_RF
13451 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13452#endif
13453 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13454 purgeSmeSessionCmdList(pMac, sessionId);
13455 purgeCsrSessionCmdList(pMac, sessionId);
13456 csrInitSession(pMac, sessionId);
13457 }
13458}
13459
Jeff Johnson295189b2012-06-20 16:38:30 -070013460eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13461 tANI_BOOLEAN fSync,
13462 csrRoamSessionCloseCallback callback,
13463 void *pContext )
13464{
13465 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13467 {
13468 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13469 if(fSync)
13470 {
13471 csrCleanupSession(pMac, sessionId);
13472 }
13473 else
13474 {
13475 purgeSmeSessionCmdList(pMac, sessionId);
13476 purgeCsrSessionCmdList(pMac, sessionId);
13477 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13478 pSession->selfMacAddr, callback, pContext);
13479 }
13480 }
13481 else
13482 {
13483 status = eHAL_STATUS_INVALID_PARAMETER;
13484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 return ( status );
13486}
13487
Jeff Johnson295189b2012-06-20 16:38:30 -070013488static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13489{
13490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013491
13492 if(!pSession)
13493 {
13494 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13495 return;
13496 }
13497
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13499 pSession->sessionId = CSR_SESSION_ID_INVALID;
13500 pSession->callback = NULL;
13501 pSession->pContext = NULL;
13502 pSession->ibss_join_pending = FALSE;
13503 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13504 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13505 csrFreeRoamProfile( pMac, sessionId );
13506 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13507 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13508 csrFreeConnectBssDesc(pMac, sessionId);
13509 csrScanEnable(pMac);
13510 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13511 if(pSession->pWpaRsnReqIE)
13512 {
13513 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13514 pSession->pWpaRsnReqIE = NULL;
13515 }
13516 pSession->nWpaRsnReqIeLength = 0;
13517 if(pSession->pWpaRsnRspIE)
13518 {
13519 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13520 pSession->pWpaRsnRspIE = NULL;
13521 }
13522 pSession->nWpaRsnRspIeLength = 0;
13523#ifdef FEATURE_WLAN_WAPI
13524 if(pSession->pWapiReqIE)
13525 {
13526 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13527 pSession->pWapiReqIE = NULL;
13528 }
13529 pSession->nWapiReqIeLength = 0;
13530 if(pSession->pWapiRspIE)
13531 {
13532 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13533 pSession->pWapiRspIE = NULL;
13534 }
13535 pSession->nWapiRspIeLength = 0;
13536#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 if(pSession->pAddIEScan)
13538 {
13539 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13540 pSession->pAddIEScan = NULL;
13541 }
13542 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 if(pSession->pAddIEAssoc)
13544 {
13545 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13546 pSession->pAddIEAssoc = NULL;
13547}
13548 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013549}
13550
Jeff Johnson295189b2012-06-20 16:38:30 -070013551eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13552{
13553 eHalStatus status = eHAL_STATUS_FAILURE;
13554 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13556 {
13557 if( CSR_IS_SESSION_VALID( pMac, i ) )
13558 {
13559 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13560 {
13561 //Found it
13562 status = eHAL_STATUS_SUCCESS;
13563 *pSessionId = i;
13564 break;
13565 }
13566 }
13567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 return( status );
13569}
13570
Jeff Johnson295189b2012-06-20 16:38:30 -070013571//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13572//session because for IBSS, the bssid changes.
13573static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13574{
13575 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13576 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13578 {
13579 if( CSR_IS_SESSION_VALID( pMac, i ) )
13580 {
13581 pSession = CSR_GET_SESSION( pMac, i );
13582 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13583 {
13584 //Found it
13585 nRet = i;
13586 break;
13587 }
13588 }
13589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 return (nRet);
13591}
Jeff Johnson295189b2012-06-20 16:38:30 -070013592static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13593{
13594 /* Update the current BSS info in ho control block based on connected
13595 profile info from pmac global structure */
13596
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013597 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13599 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 /* Check for user misconfig of RSSI trigger threshold */
13601 pMac->roam.configParam.vccRssiThreshold =
13602 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13603 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13604 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 /* Check for user misconfig of UL MAC Loss trigger threshold */
13606 pMac->roam.configParam.vccUlMacLossThreshold =
13607 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13608 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013609#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13610 {
13611 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 /* Indicate the neighbor roal algorithm about the connect indication */
13613 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13614 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13615 }
13616#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013617}
13618
Jeff Johnson295189b2012-06-20 16:38:30 -070013619static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13620{
13621 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013622
13623 if(!pSession)
13624 {
13625 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13626 return;
13627 }
13628
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 //Only to handle the case for Handover on infra link
13630 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13631 {
13632 return;
13633 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13635 csrRoamDeregStatisticsReq(pMac);
13636 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13637#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13638 /* Indicate the neighbor roal algorithm about the disconnect indication */
13639 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13640#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013641
13642 //Remove this code once SLM_Sessionization is supported
13643 //BMPS_WORKAROUND_NOT_NEEDED
13644 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013645 csrIsInfraApStarted( pMac ) &&
13646 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013647 {
13648 pMac->roam.configParam.doBMPSWorkaround = 0;
13649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013650}
13651
Jeff Johnson295189b2012-06-20 16:38:30 -070013652void csrRoamTlStatsTimerHandler(void *pv)
13653{
13654 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13655 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13657
Jeff Johnsone7245742012-09-05 17:12:55 -070013658 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13659
Jeff Johnson295189b2012-06-20 16:38:30 -070013660#if 0
13661 // TODO Persession .???
13662 //req TL for stats
13663 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013665 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 }
13667 else
13668 {
13669 //save in SME
13670 csrRoamSaveStatsFromTl(pMac, tlStats);
13671 }
13672#endif
13673 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13674 {
13675 if(pMac->roam.tlStatsReqInfo.periodicity)
13676 {
13677 //start timer
13678 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13679 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13680 if(!HAL_STATUS_SUCCESS(status))
13681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013682 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 return;
13684 }
13685 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13686 }
13687 }
13688}
Jeff Johnson295189b2012-06-20 16:38:30 -070013689void csrRoamPeStatsTimerHandler(void *pv)
13690{
13691 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13692 eHalStatus status;
13693 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13694 VOS_STATUS vosStatus;
13695 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 pPeStatsReqListEntry->timerRunning = FALSE;
13697 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13698 {
13699 // If we entered here, meaning the timer could not be successfully
13700 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13701
13702 /* Destroy the timer */
13703 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13704 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013706 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 }
13708
13709 // Free the entry
13710 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13711 pPeStatsReqListEntry = NULL;
13712 }
13713 else
13714 {
13715 if(!pPeStatsReqListEntry->rspPending)
13716 {
13717 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13718 pPeStatsReqListEntry->staId);
13719 if(!HAL_STATUS_SUCCESS(status))
13720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013721 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 }
13723 else
13724 {
13725 pPeStatsReqListEntry->rspPending = TRUE;
13726 }
13727 }
13728
13729 //send down a req
13730 if(pPeStatsReqListEntry->periodicity &&
13731 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13732 {
13733 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13734 if(ePMC_FULL_POWER == powerState)
13735 {
13736 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13737 {
13738 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13739 }
13740 }
13741 else
13742 {
13743 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13744 {
13745 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13746 }
13747 }
13748 //start timer
13749 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13750 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013752 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 return;
13754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 pPeStatsReqListEntry->timerRunning = TRUE;
13756
13757 }
13758
13759 }
13760}
Jeff Johnson295189b2012-06-20 16:38:30 -070013761void csrRoamStatsClientTimerHandler(void *pv)
13762{
13763 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13765 {
13766#if 0
13767 // TODO Stats fix for multisession
13768 //start the timer
13769 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13770
13771 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013773 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 }
13775#endif
13776 }
13777#if 0
13778 //send up the stats report
13779 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13780 pStaEntry->staId, pStaEntry->pContext);
13781#endif
13782}
13783
13784
13785
Jeff Johnson295189b2012-06-20 16:38:30 -070013786eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13787{
13788 tAniGetPEStatsReq *pMsg;
13789 eHalStatus status = eHAL_STATUS_SUCCESS;
13790 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13791 if ( !HAL_STATUS_SUCCESS(status) )
13792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013793 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 return status;
13795 }
13796 // need to initiate a stats request to PE
13797 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13798 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13799 pMsg->staId = staId;
13800 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 if(!HAL_STATUS_SUCCESS(status))
13803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013804 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 return status;
13807}
Jeff Johnson295189b2012-06-20 16:38:30 -070013808void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13809{
13810 tAniGetPEStatsRsp *pSmeStatsRsp;
13811 eHalStatus status = eHAL_STATUS_FAILURE;
13812 tListElem *pEntry = NULL;
13813 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13814 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13815 tANI_U32 tempMask = 0;
13816 tANI_U8 counter = 0;
13817 tANI_U8 *pStats = NULL;
13818 tANI_U32 length = 0;
13819 v_PVOID_t pvosGCtx;
13820 v_S7_t rssi = 0;
13821 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13823 if(pSmeStatsRsp->rc)
13824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013825 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 goto post_update;
13827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 tempMask = pSmeStatsRsp->statsMask;
13829 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 /* subtract all statistics from this length, and after processing the entire
13831 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13832 * in this 'stats' message.
13833 */
13834 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 //new stats info from PE, fill up the stats strucutres in PMAC
13836 while(tempMask)
13837 {
13838 if(tempMask & 1)
13839 {
13840 switch(counter)
13841 {
13842 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013843 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13845 pStats, sizeof(tCsrSummaryStatsInfo));
13846 if(!HAL_STATUS_SUCCESS(status))
13847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013848 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 }
13850 pStats += sizeof(tCsrSummaryStatsInfo);
13851 length -= sizeof(tCsrSummaryStatsInfo);
13852 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013854 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13856 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13857 if(!HAL_STATUS_SUCCESS(status))
13858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013859 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013860 }
13861 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13862 length -= sizeof(tCsrGlobalClassAStatsInfo);
13863 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013865 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13867 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13868 if(!HAL_STATUS_SUCCESS(status))
13869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013870 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 }
13872 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13873 length -= sizeof(tCsrGlobalClassBStatsInfo);
13874 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013876 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13878 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13879 if(!HAL_STATUS_SUCCESS(status))
13880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013881 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 }
13883 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13884 length -= sizeof(tCsrGlobalClassCStatsInfo);
13885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013887 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13889 {
13890 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13891 pStats, sizeof(tCsrPerStaStatsInfo));
13892 }
13893 else
13894 {
13895 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013896 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 VOS_ASSERT( 0 );
13898 }
13899 if(!HAL_STATUS_SUCCESS(status))
13900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013901 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 }
13903 pStats += sizeof(tCsrPerStaStatsInfo);
13904 length -= sizeof(tCsrPerStaStatsInfo);
13905 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013907 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 }
13910 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 tempMask >>=1;
13912 counter++;
13913 }
13914 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13915 if (length != 0)
13916 {
13917 pRssi = (tANI_U32*)pStats;
13918 rssi = (v_S7_t)*pRssi;
13919 }
13920 else
13921 {
13922 /* If riva is not sending rssi, continue to use the hack */
13923 rssi = RSSI_HACK_BMPS;
13924 }
13925 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013926post_update:
13927 //make sure to update the pe stats req list
13928 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13929 if(pEntry)
13930 {
13931 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13932 pPeStaEntry->rspPending = FALSE;
13933
13934 }
13935 //check the one timer cases
13936 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13937 if(pEntry)
13938 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 if(pTempStaEntry->timerExpired)
13941 {
13942 //send up the stats report
13943 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13944 pTempStaEntry->staId, pTempStaEntry->pContext);
13945 //also remove from the client list
13946 csrRoamRemoveStatListEntry(pMac, pEntry);
13947 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 }
13949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013950}
Jeff Johnson295189b2012-06-20 16:38:30 -070013951tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13952{
13953 tListElem *pEntry = NULL;
13954 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 if(!pEntry)
13957 {
13958 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013959 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 return NULL;
13961 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 while( pEntry )
13963 {
13964 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 if(pTempStaEntry->statsMask == statsMask)
13966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013967 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 break;
13969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 return pEntry;
13973}
13974
Jeff Johnson295189b2012-06-20 16:38:30 -070013975tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13976 tANI_BOOLEAN update)
13977{
13978 tListElem *pEntry;
13979 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 if(!pEntry)
13982 {
13983 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013984 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013985 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 return NULL;
13987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 while( pEntry )
13989 {
13990 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13992 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013994 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 if(update)
13996 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013997 pTempStaEntry->periodicity = pStaEntry->periodicity;
13998 pTempStaEntry->callback = pStaEntry->callback;
13999 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 }
14001 break;
14002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 return pEntry;
14006}
Jeff Johnson295189b2012-06-20 16:38:30 -070014007tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14008{
14009 tListElem *pEntry;
14010 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 if(!pEntry)
14013 {
14014 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014015 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014016 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 return NULL;
14018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 while( pEntry )
14020 {
14021 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014024 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 break;
14026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 return pEntry;
14030}
Jeff Johnson295189b2012-06-20 16:38:30 -070014031eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14032 csrRoamLinkQualityIndCallback callback,
14033 void *pContext)
14034{
14035 pMac->roam.linkQualityIndInfo.callback = callback;
14036 pMac->roam.linkQualityIndInfo.context = pContext;
14037 if( NULL == callback )
14038 {
14039 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14040 }
14041 else
14042 {
14043 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 /* do we need to invoke the callback to notify client of initial value ?? */
14045 }
14046 return eHAL_STATUS_SUCCESS;
14047}
Jeff Johnson295189b2012-06-20 16:38:30 -070014048void csrRoamVccTrigger(tpAniSirGlobal pMac)
14049{
14050 eCsrRoamLinkQualityInd newVccLinkQuality;
14051 tANI_U32 ul_mac_loss = 0;
14052 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14054 /*-------------------------------------------------------------------------
14055 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 Check for a change in link quality and notify client if necessary
14057 -------------------------------------------------------------------------*/
14058 ul_mac_loss_trigger_threshold =
14059 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014061 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014062 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014065 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14067 }
14068 else
14069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014070 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14074 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014077 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014080 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 newVccLinkQuality );
14082
14083 /* we now invoke the callback once to notify client of initial value */
14084 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14085 pMac->roam.linkQualityIndInfo.context );
14086 //event: EVENT_WLAN_VCC
14087 }
14088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 pMac->roam.vccLinkQuality = newVccLinkQuality;
14090
Jeff Johnson295189b2012-06-20 16:38:30 -070014091}
Jeff Johnson295189b2012-06-20 16:38:30 -070014092VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14093 v_U8_t rssiNotification,
14094 void * context)
14095{
14096 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14097 eCsrRoamLinkQualityInd newVccLinkQuality;
14098 // TODO : Session info unavailable
14099 tANI_U32 sessionId = 0;
14100 VOS_STATUS status = VOS_STATUS_SUCCESS;
14101 /*-------------------------------------------------------------------------
14102 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 Check for a change in link quality and notify client if necessary
14104 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014105 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014106 pMac->roam.configParam.vccRssiThreshold);
14107 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014109 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 return VOS_STATUS_SUCCESS;
14111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014114 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14116 }
14117 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14118 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014119 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14121 }
14122 else
14123 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014124 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 //Set to this so the code below won't do anything
14126 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 VOS_ASSERT(0);
14128 }
14129
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014132 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014135 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 /* we now invoke the callback once to notify client of initial value */
14138 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14139 pMac->roam.linkQualityIndInfo.context );
14140 //event: EVENT_WLAN_VCC
14141 }
14142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 return status;
14145}
Jeff Johnson295189b2012-06-20 16:38:30 -070014146tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14147 tDblLinkList *pStaList,
14148 tCsrStatsClientReqInfo *pStaEntry)
14149{
14150 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 //if same entity requested for same set of stats with different periodicity &
14153 // callback update it
14154 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14155 {
14156
14157 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14158 if (!HAL_STATUS_SUCCESS(status))
14159 {
14160 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014161 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014162 return NULL;
14163 }
14164
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 pNewStaEntry->callback = pStaEntry->callback;
14166 pNewStaEntry->pContext = pStaEntry->pContext;
14167 pNewStaEntry->periodicity = pStaEntry->periodicity;
14168 pNewStaEntry->requesterId = pStaEntry->requesterId;
14169 pNewStaEntry->statsMask = pStaEntry->statsMask;
14170 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14171 pNewStaEntry->pMac = pStaEntry->pMac;
14172 pNewStaEntry->staId = pStaEntry->staId;
14173 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14174
14175 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14176 }
14177 return pNewStaEntry;
14178}
14179
Jeff Johnson295189b2012-06-20 16:38:30 -070014180tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14181 tDblLinkList *pStaList,
14182 tCsrPeStatsReqInfo *pStaEntry)
14183{
14184 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14187 if (!HAL_STATUS_SUCCESS(status))
14188 {
14189 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014190 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 return NULL;
14192 }
14193
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14195 pNewStaEntry->numClient = pStaEntry->numClient;
14196 pNewStaEntry->periodicity = pStaEntry->periodicity;
14197 pNewStaEntry->statsMask = pStaEntry->statsMask;
14198 pNewStaEntry->pMac = pStaEntry->pMac;
14199 pNewStaEntry->staId = pStaEntry->staId;
14200 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14201 pNewStaEntry->rspPending = pStaEntry->rspPending;
14202
14203 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 return pNewStaEntry;
14205}
Jeff Johnson295189b2012-06-20 16:38:30 -070014206eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14207 tCsrRssiCallback callback,
14208 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14209{
14210 eHalStatus status = eHAL_STATUS_SUCCESS;
14211 vos_msg_t msg;
14212 tANI_U32 sessionId;
14213
14214 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014215 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14217 if ( !HAL_STATUS_SUCCESS(status) )
14218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014219 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 return status;
14221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14223
14224 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14225 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14226 pMsg->sessionId = sessionId;
14227 pMsg->staId = staId;
14228 pMsg->rssiCallback = callback;
14229 pMsg->pDevContext = pContext;
14230 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 msg.type = eWNI_SME_GET_RSSI_REQ;
14232 msg.bodyptr = pMsg;
14233 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014236 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 palFreeMemory(pMac->hHdd, (void *)pMsg);
14238 status = eHAL_STATUS_FAILURE;
14239 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014240 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 return status;
14242}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014243
14244#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14245eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14246 tCsrRssiCallback callback,
14247 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14248{
14249 eHalStatus status = eHAL_STATUS_SUCCESS;
14250 tAniGetRssiReq *pMsg;
14251
14252 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14253 if ( !HAL_STATUS_SUCCESS(status) )
14254 {
14255 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14256 return status;
14257 }
14258 // need to initiate a stats request to PE
14259 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14260 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14261 pMsg->staId = staId;
14262 pMsg->rssiCallback = callback;
14263 pMsg->pDevContext = pContext;
14264 pMsg->pVosContext = pVosContext;
14265 status = palSendMBMessage(pMac->hHdd, pMsg );
14266 if(!HAL_STATUS_SUCCESS(status))
14267 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014268 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14269 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014270 status = eHAL_STATUS_FAILURE;
14271 }
14272 return status;
14273}
14274#endif
14275
Jeff Johnson295189b2012-06-20 16:38:30 -070014276eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14277 tANI_U32 statsMask,
14278 tCsrStatsCallback callback,
14279 tANI_U32 periodicity, tANI_BOOLEAN cache,
14280 tANI_U8 staId, void *pContext)
14281{
14282 tCsrStatsClientReqInfo staEntry;
14283 tCsrStatsClientReqInfo *pStaEntry = NULL;
14284 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14285 tListElem *pEntry = NULL;
14286 tANI_BOOLEAN found = FALSE;
14287 eHalStatus status = eHAL_STATUS_SUCCESS;
14288 tANI_BOOLEAN insertInClientList = FALSE;
14289 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014290 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014291
14292 if( csrIsAllSessionDisconnected(pMac) )
14293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014294 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 return eHAL_STATUS_FAILURE;
14296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 if((!statsMask) && (!callback))
14298 {
14299 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014300 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 return eHAL_STATUS_FAILURE;
14302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 //for the search list method for deregister
14304 staEntry.requesterId = requesterId;
14305 staEntry.statsMask = statsMask;
14306 //requester wants to deregister or just an error
14307 if((statsMask) && (!callback))
14308 {
14309 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14310 if(!pEntry)
14311 {
14312 //msg
14313 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014314 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 return eHAL_STATUS_FAILURE;
14316 }
14317 else
14318 {
14319 //clean up & return
14320 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014321 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014322 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014323 pStaEntry->pPeStaEntry->numClient--;
14324 //check if we need to delete the entry from peStatsReqList too
14325 if(!pStaEntry->pPeStaEntry->numClient)
14326 {
14327 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14328 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014330
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 //check if we need to stop the tl stats timer too
14332 pMac->roam.tlStatsReqInfo.numClient--;
14333 if(!pMac->roam.tlStatsReqInfo.numClient)
14334 {
14335 if(pMac->roam.tlStatsReqInfo.timerRunning)
14336 {
14337 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14338 if(!HAL_STATUS_SUCCESS(status))
14339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014340 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 return eHAL_STATUS_FAILURE;
14342 }
14343 }
14344 pMac->roam.tlStatsReqInfo.periodicity = 0;
14345 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14346 }
14347 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014348 // Destroy the vos timer...
14349 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14350 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14351 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014352 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014354 csrRoamRemoveStatListEntry(pMac, pEntry);
14355 pStaEntry = NULL;
14356 return eHAL_STATUS_SUCCESS;
14357 }
14358 }
14359
14360 if(cache && !periodicity)
14361 {
14362 //return the cached stats
14363 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14364 }
14365 else
14366 {
14367 //add the request in the client req list
14368 staEntry.callback = callback;
14369 staEntry.pContext = pContext;
14370 staEntry.periodicity = periodicity;
14371 staEntry.pPeStaEntry = NULL;
14372 staEntry.staId = staId;
14373 staEntry.pMac = pMac;
14374 staEntry.timerExpired = FALSE;
14375
14376
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 //if periodic report requested with non cached result from PE/TL
14378 if(periodicity)
14379 {
14380
14381 //if looking for stats from PE
14382 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14383 {
14384
14385 //check if same request made already & waiting for rsp
14386 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14387 periodicity, &found, staId);
14388 if(!pPeStaEntry)
14389 {
14390 //bail out, maxed out on number of req for PE
14391 return eHAL_STATUS_FAILURE;
14392 }
14393 else
14394 {
14395 staEntry.pPeStaEntry = pPeStaEntry;
14396 }
14397
14398 }
14399 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14400 if(statsMask & (1 << eCsrGlobalClassDStats))
14401 {
14402 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014404 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 }
14406 else
14407 {
14408
14409 //update periodicity
14410 if(pMac->roam.tlStatsReqInfo.periodicity)
14411 {
14412 pMac->roam.tlStatsReqInfo.periodicity =
14413 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14414 }
14415 else
14416 {
14417 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14418 }
14419 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14420 {
14421 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14422 }
14423
14424 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14425 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014426 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14427 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014428 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014429 //req TL for class D stats
14430 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14431 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014432 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014433 }
14434 else
14435 {
14436 //save in SME
14437 csrRoamSaveStatsFromTl(pMac, pTlStats);
14438 }
14439 vos_mem_free(pTlStats);
14440 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 }
14442 else
14443 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014444 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014446
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 if(pMac->roam.tlStatsReqInfo.periodicity)
14448 {
14449 //start timer
14450 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14451 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14452 if(!HAL_STATUS_SUCCESS(status))
14453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014454 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 return eHAL_STATUS_FAILURE;
14456 }
14457 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14458 }
14459 }
14460 }
14461 pMac->roam.tlStatsReqInfo.numClient++;
14462 }
14463
14464 insertInClientList = TRUE;
14465 }
14466 //if one time report requested with non cached result from PE/TL
14467 else if(!cache && !periodicity)
14468 {
14469 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14470 {
14471 //send down a req
14472 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14473 if(!HAL_STATUS_SUCCESS(status))
14474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014475 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014476 }
14477 //so that when the stats rsp comes back from PE we respond to upper layer
14478 //right away
14479 staEntry.timerExpired = TRUE;
14480 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 }
14482 if(statsMask & (1 << eCsrGlobalClassDStats))
14483 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014484 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14485 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014487 //req TL for class D stats
14488 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014490 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014491 }
14492 else
14493 {
14494 //save in SME
14495 csrRoamSaveStatsFromTl(pMac, pTlStats);
14496 }
14497 vos_mem_free(pTlStats);
14498 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 }
14500 else
14501 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014502 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014503 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014504
14505 }
14506 //if looking for stats from TL only
14507 if(!insertInClientList)
14508 {
14509 //return the stats
14510 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 if(insertInClientList)
14514 {
14515 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14516 if(!pStaEntry)
14517 {
14518 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014519 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 return eHAL_STATUS_FAILURE;
14521 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014522 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 //Init & start timer if needed
14524 if(periodicity)
14525 {
14526 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14527 csrRoamStatsClientTimerHandler, pStaEntry );
14528 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14529 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014530 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 return eHAL_STATUS_FAILURE;
14532 }
14533 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14534 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014536 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 return eHAL_STATUS_FAILURE;
14538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 }
14542 return eHAL_STATUS_SUCCESS;
14543}
14544
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014545#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14546
14547static tSirRetStatus
14548csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14549 tANI_U8* pBD,
14550 tANI_U8 type,
14551 tANI_U8 subType,
14552 tSirMacAddr peerAddr,
14553 tSirMacAddr selfMacAddr)
14554{
14555 tSirRetStatus statusCode = eSIR_SUCCESS;
14556 tpSirMacMgmtHdr pMacHdr;
14557
14558 /* Prepare MAC management header */
14559 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14560
14561 /* Prepare FC */
14562 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14563 pMacHdr->fc.type = type;
14564 pMacHdr->fc.subType = subType;
14565
14566 /* Prepare Address 1 */
14567 palCopyMemory( pMac->hHdd,
14568 (tANI_U8 *) pMacHdr->da,
14569 (tANI_U8 *) peerAddr,
14570 sizeof( tSirMacAddr ));
14571
14572 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14573
14574 /* Prepare Address 3 */
14575 palCopyMemory( pMac->hHdd,
14576 (tANI_U8 *) pMacHdr->bssId,
14577 (tANI_U8 *) peerAddr,
14578 sizeof( tSirMacAddr ));
14579 return statusCode;
14580} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14581
14582static tSirRetStatus
14583csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14584 tANI_U8 nChannelNum,
14585 tANI_U32 dot11mode,
14586 tSirMacAddr selfMacAddr,
14587 tANI_U8 *pFrame,
14588 tANI_U16 *pusLen)
14589{
14590 tDot11fProbeRequest pr;
14591 tANI_U32 nStatus, nBytes, nPayload;
14592 tSirRetStatus nSirStatus;
14593 /*Bcast tx*/
14594 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14595 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14596
14597
14598 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14599
14600 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14601
14602 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14603 {
14604 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14605 }
14606
14607
14608 if (IS_DOT11_MODE_HT(dot11mode))
14609 {
14610 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14611 }
14612
14613
14614 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14615 if ( DOT11F_FAILED( nStatus ) )
14616 {
14617 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14618 "Failed to calculate the packed size f"
14619 "or a Probe Request (0x%08x).\n", nStatus );
14620
14621
14622 nPayload = sizeof( tDot11fProbeRequest );
14623 }
14624 else if ( DOT11F_WARNED( nStatus ) )
14625 {
14626 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14627 "There were warnings while calculating"
14628 "the packed size for a Probe Request ("
14629 "0x%08x).\n", nStatus );
14630 }
14631
14632 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14633
14634 /* Prepare outgoing frame*/
14635 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14636
14637
14638 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
14639 SIR_MAC_MGMT_PROBE_REQ, bssId ,selfMacAddr);
14640
14641 if ( eSIR_SUCCESS != nSirStatus )
14642 {
14643 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14644 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14645 nSirStatus );
14646 return nSirStatus;
14647 }
14648
14649
14650 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14651 sizeof( tSirMacMgmtHdr ),
14652 nPayload, &nPayload );
14653 if ( DOT11F_FAILED( nStatus ) )
14654 {
14655 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14656 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14657 return eSIR_FAILURE;
14658 }
14659 else if ( DOT11F_WARNED( nStatus ) )
14660 {
14661 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14662 "There were warnings while packing a Probe Request (0x%08x).\n" );
14663 }
14664
14665 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14666 return eSIR_SUCCESS;
14667}
14668
14669eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14670{
14671 vos_msg_t msg;
14672 tSirRoamOffloadScanReq *pRequestBuf;
14673 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14674 tCsrRoamSession *pSession;
14675 tANI_U8 i,num_channels = 0, ucDot11Mode;
14676 tANI_U8 *ChannelList = NULL;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014677 tANI_U8 MaxDwellPeriod;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014678 tANI_U32 sessionId;
14679 eHalStatus status = eHAL_STATUS_SUCCESS;
14680 tpCsrChannelInfo currChannelListInfo;
14681 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14682
14683 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled)
14684 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014685 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set \n");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014686 return eHAL_STATUS_FAILURE;
14687 }
14688 status = csrRoamGetSessionIdFromBSSID(pMac,
14689 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14690 &sessionId);
14691 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14692 * It is important to ensure that the command is passed down to the FW only
14693 * if the Infra Station is in a connected state.A connected station could also be
14694 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14695 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14696 * irrespective of whichever state we are in.*/
14697 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14698 (command != ROAM_SCAN_OFFLOAD_STOP))
14699 {
14700 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14701 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14702 return eHAL_STATUS_FAILURE;
14703 }
14704
14705 if ( !HAL_STATUS_SUCCESS( status ) )
14706 {
14707 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14708 return eHAL_STATUS_FAILURE;
14709 }
14710 pSession = CSR_GET_SESSION( pMac, sessionId );
14711 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14712 if (NULL == pRequestBuf)
14713 {
14714 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14715 return eHAL_STATUS_FAILED_ALLOC;
14716 }
14717
14718 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14719 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14720 * host driver reloads, but Riva still up and running*/
14721 if(command == ROAM_SCAN_OFFLOAD_STOP)
14722 pRequestBuf->RoamScanOffloadEnabled = 0;
14723 else
14724 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14725 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14726 sizeof(tCsrBssid));
14727 pRequestBuf->ConnectedNetwork.ssId.length =
14728 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14729 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14730 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14731 pRequestBuf->ConnectedNetwork.ssId.length);
14732 pRequestBuf->ConnectedNetwork.authentication =
14733 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14734 pRequestBuf->ConnectedNetwork.encryption =
14735 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14736 pRequestBuf->ConnectedNetwork.mcencryption =
14737 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14738 pRequestBuf->LookupThreshold =
14739 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14740 pRequestBuf->RoamRssiDiff =
14741 pMac->roam.configParam.RoamRssiDiff;
14742 pRequestBuf->Command = command;
14743 pRequestBuf->StartScanReason = reason;
14744 pRequestBuf->NeighborScanTimerPeriod =
14745 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14746 pRequestBuf->NeighborRoamScanRefreshPeriod =
14747 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14748 pRequestBuf->NeighborScanChannelMinTime =
14749 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14750 pRequestBuf->NeighborScanChannelMaxTime =
14751 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14752 pRequestBuf->EmptyRefreshScanPeriod =
14753 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14754#ifdef FEATURE_WLAN_CCX
14755 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14756#endif
14757 if (
14758#ifdef FEATURE_WLAN_CCX
14759 ((pNeighborRoamInfo->isCCXAssoc) &&
14760 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14761 eANI_BOOLEAN_FALSE)) ||
14762 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14763#endif // CCX
14764 currChannelListInfo->numOfChannels == 0)
14765 {
14766
14767 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14768 * Give Preference to INI Channels.*/
14769 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14770 {
14771 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14772 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14773 {
14774 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14775 {
14776 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14777 }
14778 ChannelList++;
14779 }
14780 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14781 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14782 }
14783 else{
14784 ChannelList = pMac->scan.occupiedChannels.channelList;
14785 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14786 {
14787 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14788 {
14789 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14790 }
14791 ChannelList++;
14792 }
14793 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14794 /* If the profile changes as to what it was earlier, inform the FW through
14795 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14796 * for the earlier profile and try to learn them afresh.*/
14797 if (reason == REASON_FLUSH_CHANNEL_LIST)
14798 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14799 else {
14800 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14801 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14802 else
14803 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14804 }
14805 }
14806 }
14807#ifdef FEATURE_WLAN_CCX
14808 else
14809 {
14810 /* If CCX is enabled, and a neighbor Report is received,then
14811 * Ignore the INI Channels or the Occupied Channel List. Consider
14812 * the channels in the neighbor list sent by the CCX AP.*/
14813 if (currChannelListInfo->numOfChannels != 0)
14814 {
14815 ChannelList = currChannelListInfo->ChannelList;
14816 for (i=0;i<currChannelListInfo->numOfChannels;i++)
14817 {
14818 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14819 {
14820 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14821 }
14822 ChannelList++;
14823 }
14824 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14825 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14826 }
14827 }
14828#endif
14829 num_channels = 0;
14830 ChannelList = NULL;
14831
14832 /* Maintain the Valid Channels List*/
14833 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
14834 {
14835 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
14836 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
14837 {
14838 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14839 {
14840 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14841 }
14842 ChannelList++;
14843 }
14844 pRequestBuf->ValidChannelCount = num_channels;
14845 } else {
14846 ChannelList = pMac->roam.validChannelList;
14847 for(i=0; i<pMac->roam.numValidChannels; i++)
14848 {
14849 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14850 {
14851 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
14852 }
14853 ChannelList++;
14854 }
14855 pRequestBuf->ValidChannelCount = num_channels;
14856 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014857 pRequestBuf->MDID.mdiePresent =
14858 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
14859 pRequestBuf->MDID.mobilityDomain =
14860 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014861 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
14862
14863 /*Max Dwell Period is calculated here to ensure that,
14864 * Home Away Time is atleast equal to (MaxDwellPeriod +
14865 * (2*SRF)), where SRF is the RF Switching time.The RF
14866 * switching time is considered twice to consider the
14867 * time to go off channel and return to the home channel.*/
14868 MaxDwellPeriod = pRequestBuf->NeighborScanChannelMaxTime/pRequestBuf->nProbes;
14869 if(MaxDwellPeriod < 1)
14870 MaxDwellPeriod = 1;
14871 if(pMac->roam.configParam.nRoamScanHomeAwayTime <
14872 (MaxDwellPeriod + (2 * SIR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
14873 {
14874 pRequestBuf->HomeAwayTime = MaxDwellPeriod + (2 * SIR_ROAM_SCAN_CHANNEL_SWITCH_TIME);
14875 } else {
14876 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
14877 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014878 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
14879 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
14880 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
14881 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14882 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
14883
14884 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
14885 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014886 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014887 msg.reserved = 0;
14888 msg.bodyptr = pRequestBuf;
14889 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
14890 {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070014891 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 -070014892 vos_mem_free(pRequestBuf);
14893 return eHAL_STATUS_FAILURE;
14894 }
14895
14896 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
14897 return status;
14898}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014899
14900eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
14901{
14902 switch(reason)
14903 {
14904 case 0:
14905 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
14906 break;
14907 case REASON_OS_REQUESTED_ROAMING_NOW:
14908 csrNeighborRoamProceedWithHandoffReq(pMac);
14909 break;
14910 default:
14911 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with unknown Reason %d", reason);
14912 }
14913 return eHAL_STATUS_SUCCESS;
14914}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014915#endif
14916
Jeff Johnson295189b2012-06-20 16:38:30 -070014917tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14918 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14919{
14920 tANI_BOOLEAN found = FALSE;
14921 eHalStatus status = eHAL_STATUS_SUCCESS;
14922 tCsrPeStatsReqInfo staEntry;
14923 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14924 tListElem *pStaEntry = NULL;
14925 VOS_STATUS vosStatus;
14926 tPmcPowerState powerState;
14927 *pFound = FALSE;
14928
14929 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14930 if(pStaEntry)
14931 {
14932 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14933 if(pTempStaEntry->periodicity)
14934 {
14935 pTempStaEntry->periodicity =
14936 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14937 }
14938 else
14939 {
14940 pTempStaEntry->periodicity = periodicity;
14941 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 pTempStaEntry->numClient++;
14943 found = TRUE;
14944 }
14945 else
14946 {
14947 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14948 staEntry.numClient = 1;
14949 staEntry.periodicity = periodicity;
14950 staEntry.pMac = pMac;
14951 staEntry.rspPending = FALSE;
14952 staEntry.staId = staId;
14953 staEntry.statsMask = statsMask;
14954 staEntry.timerRunning = FALSE;
14955 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14956 if(!pTempStaEntry)
14957 {
14958 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014959 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 return NULL;
14961 }
14962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14964 if(ePMC_FULL_POWER == powerState)
14965 {
14966 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14967 {
14968 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14969 }
14970 }
14971 else
14972 {
14973 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14974 {
14975 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14976 }
14977 }
14978 if(!pTempStaEntry->timerRunning)
14979 {
14980 //send down a req in case of one time req, for periodic ones wait for timer to expire
14981 if(!pTempStaEntry->rspPending &&
14982 !pTempStaEntry->periodicity)
14983 {
14984 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14985 if(!HAL_STATUS_SUCCESS(status))
14986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014987 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 }
14989 else
14990 {
14991 pTempStaEntry->rspPending = TRUE;
14992 }
14993 }
14994 if(pTempStaEntry->periodicity)
14995 {
14996 if(!found)
14997 {
14998
14999 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15000 csrRoamPeStatsTimerHandler, pTempStaEntry );
15001 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015003 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015004 return NULL;
15005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 }
15007 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015008 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015009 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15010 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015012 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 return NULL;
15014 }
15015 pTempStaEntry->timerRunning = TRUE;
15016 }
15017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 *pFound = found;
15019 return pTempStaEntry;
15020}
15021
Jeff Johnson295189b2012-06-20 16:38:30 -070015022/*
15023 pStaEntry is no longer invalid upon the return of this function.
15024*/
15025static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15026{
15027 if(pEntry)
15028 {
15029 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15030 {
15031 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015033 }
15034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015035
15036void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15037{
15038 tListElem *pEntry;
15039 tCsrPeStatsReqInfo *pTempStaEntry;
15040 VOS_STATUS vosStatus;
15041 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015042 if(!pEntry)
15043 {
15044 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015045 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015046 return;
15047 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 while( pEntry )
15049 {
15050 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15052 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015053 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015054 if(pTempStaEntry->timerRunning)
15055 {
15056 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15057 /* If we are not able to stop the timer here, just remove
15058 * the entry from the linked list. Destroy the timer object
15059 * and free the memory in the timer CB
15060 */
15061 if( vosStatus == VOS_STATUS_SUCCESS )
15062 {
15063 /* the timer is successfully stopped */
15064 pTempStaEntry->timerRunning = FALSE;
15065
15066 /* Destroy the timer */
15067 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15068 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015070 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 }
15072 }
15073 else
15074 {
15075 // the timer could not be stopped. Hence destroy and free the
15076 // memory for the PE stat entry in the timer CB.
15077 pTempStaEntry->timerStopFailed = TRUE;
15078 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015080
15081 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15082 {
15083 // Only free the memory if we could stop the timer successfully
15084 if(!pTempStaEntry->timerStopFailed)
15085 {
15086 palFreeMemory(pMac->hHdd, pTempStaEntry);
15087 pTempStaEntry = NULL;
15088 }
15089 break;
15090 }
15091
15092 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15093 }
15094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 return;
15096}
15097
15098
Jeff Johnsone7245742012-09-05 17:12:55 -070015099void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015100{
15101
Jeff Johnsone7245742012-09-05 17:12:55 -070015102 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15103 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15104 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15105 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15106 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15107 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15108 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015109 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015110 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15111 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15112 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15113 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15114 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15115 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015116 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015117 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15118 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015119
15120}
15121
Jeff Johnson295189b2012-06-20 16:38:30 -070015122void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15123 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15124{
15125 tANI_U8 stats[500];
15126 tANI_U8 *pStats = NULL;
15127 tANI_U32 tempMask = 0;
15128 tANI_U8 counter = 0;
15129 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 if(!callback)
15131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015132 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 return;
15134 }
15135 if(!statsMask)
15136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015137 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015138 return;
15139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 while(tempMask)
15143 {
15144 if(tempMask & 1)
15145 {
15146 //new stats info from PE, fill up the stats strucutres in PMAC
15147 switch(counter)
15148 {
15149 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015150 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15152 sizeof(tCsrSummaryStatsInfo));
15153 if(!HAL_STATUS_SUCCESS(status))
15154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015155 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 }
15157 pStats += sizeof(tCsrSummaryStatsInfo);
15158 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015160 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15162 sizeof(tCsrGlobalClassAStatsInfo));
15163 if(!HAL_STATUS_SUCCESS(status))
15164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015165 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 }
15167 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015170 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015171 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15172 sizeof(tCsrGlobalClassBStatsInfo));
15173 if(!HAL_STATUS_SUCCESS(status))
15174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 }
15177 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015180 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15182 sizeof(tCsrGlobalClassCStatsInfo));
15183 if(!HAL_STATUS_SUCCESS(status))
15184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015185 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015186 }
15187 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015189 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015190 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15192 sizeof(tCsrGlobalClassDStatsInfo));
15193 if(!HAL_STATUS_SUCCESS(status))
15194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015195 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015196 }
15197 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015200 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15202 sizeof(tCsrPerStaStatsInfo));
15203 if(!HAL_STATUS_SUCCESS(status))
15204 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015205 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 }
15207 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015210 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015212 }
15213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015214 tempMask >>=1;
15215 counter++;
15216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015217 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015218}
15219
Jeff Johnson295189b2012-06-20 16:38:30 -070015220eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15221{
15222 tListElem *pEntry = NULL;
15223 tListElem *pPrevEntry = NULL;
15224 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15225 eHalStatus status = eHAL_STATUS_SUCCESS;
15226 VOS_STATUS vosStatus;
15227 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 if(!pEntry)
15229 {
15230 //list empty
15231 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015232 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 return status;
15234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 while( pEntry )
15236 {
15237 if(pPrevEntry)
15238 {
15239 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15240 //send up the stats report
15241 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15242 pTempStaEntry->staId, pTempStaEntry->pContext);
15243 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015245 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15247 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015248 pTempStaEntry->pPeStaEntry->numClient--;
15249 //check if we need to delete the entry from peStatsReqList too
15250 if(!pTempStaEntry->pPeStaEntry->numClient)
15251 {
15252 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 //check if we need to stop the tl stats timer too
15256 pMac->roam.tlStatsReqInfo.numClient--;
15257 if(!pMac->roam.tlStatsReqInfo.numClient)
15258 {
15259 if(pMac->roam.tlStatsReqInfo.timerRunning)
15260 {
15261 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15262 if(!HAL_STATUS_SUCCESS(status))
15263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015264 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 //we will continue
15266 }
15267 }
15268 pMac->roam.tlStatsReqInfo.periodicity = 0;
15269 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15270 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015271 if (pTempStaEntry->periodicity)
15272 {
15273 //While creating StaEntry in csrGetStatistics,
15274 //Initializing and starting timer only when periodicity is set.
15275 //So Stop and Destroy timer only when periodicity is set.
15276
Jeff Johnsone7245742012-09-05 17:12:55 -070015277 vos_timer_stop( &pTempStaEntry->timer );
15278 // Destroy the vos timer...
15279 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15280 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015282 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015283 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015285
Jeff Johnson295189b2012-06-20 16:38:30 -070015286
15287 pPrevEntry = pEntry;
15288 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15289 }
15290 //the last one
15291 if(pPrevEntry)
15292 {
15293 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15294 //send up the stats report
15295 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15296 pTempStaEntry->staId, pTempStaEntry->pContext);
15297 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15298 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 return status;
15300
15301}
15302
Jeff Johnson295189b2012-06-20 16:38:30 -070015303eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15304 tRequestFullPowerReason *pReason,
15305 tANI_BOOLEAN *pfNeedPower )
15306{
15307 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15308 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15309 tPmcState pmcState;
15310 eHalStatus status = eHAL_STATUS_SUCCESS;
15311 // TODO : Session info unavailable
15312 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 if( pfNeedPower )
15314 {
15315 *pfNeedPower = eANI_BOOLEAN_FALSE;
15316 }
15317 //We only handle CSR commands
15318 if( !(eSmeCsrCommandMask & pCommand->command) )
15319 {
15320 return eHAL_STATUS_SUCCESS;
15321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015322 //Check PMC state first
15323 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 switch( pmcState )
15325 {
15326 case REQUEST_IMPS:
15327 case IMPS:
15328 if( eSmeCommandScan == pCommand->command )
15329 {
15330 switch( pCommand->u.scanCmd.reason )
15331 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015332#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15333 case eCsrScanGetLfrResult:
15334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 case eCsrScanGetResult:
15336 case eCsrScanBGScanAbort:
15337 case eCsrScanBGScanEnable:
15338 case eCsrScanGetScanChnInfo:
15339 //Internal process, no need for full power
15340 fNeedFullPower = eANI_BOOLEAN_FALSE;
15341 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015342 default:
15343 //Other scans are real scan, ask for power
15344 fNeedFullPower = eANI_BOOLEAN_TRUE;
15345 break;
15346 } //switch
15347 }
15348 else
15349 {
15350 //ask for power for roam and status change
15351 fNeedFullPower = eANI_BOOLEAN_TRUE;
15352 }
15353 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015354 case REQUEST_BMPS:
15355 case BMPS:
15356 case REQUEST_START_UAPSD:
15357 case UAPSD:
15358 //We treat WOWL same as BMPS
15359 case REQUEST_ENTER_WOWL:
15360 case WOWL:
15361 if( eSmeCommandRoam == pCommand->command )
15362 {
15363 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15364 tCsrScanResult *pScanResult;
15365 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 switch ( pCommand->u.roamCmd.roamReason )
15367 {
15368 case eCsrForcedDisassoc:
15369 case eCsrForcedDisassocMICFailure:
15370 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15371 fNeedFullPower = eANI_BOOLEAN_TRUE;
15372 break;
15373 case eCsrSmeIssuedDisassocForHandoff:
15374 case eCsrForcedDeauth:
15375 case eCsrHddIssuedReassocToSameAP:
15376 case eCsrSmeIssuedReassocToSameAP:
15377 fNeedFullPower = eANI_BOOLEAN_TRUE;
15378 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 case eCsrCapsChange:
15380 fNeedFullPower = eANI_BOOLEAN_TRUE;
15381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 default:
15383 //Check whether the profile is already connected. If so, no need for full power
15384 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15385 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15386 {
15387 //Only need to check the first one
15388 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15389 if( pEntry )
15390 {
15391 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15392#if 0
15393 // TODO : Session Specific info pConnectBssDesc
15394 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15395 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15396 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15397 {
15398 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15399 // with Authenticating first. To force this, stop the current association (Disassociate) and
15400 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15401 // a new Association.
15402 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15403 {
15404 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15405 {
15406 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15407 //No need for full power
15408 //Set the flag so the code later can avoid to do the above
15409 //check again.
15410 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15411 break;
15412 }
15413 }
15414 }
15415#endif
15416 }
15417 }
15418 //If we are here, full power is needed
15419 fNeedFullPower = eANI_BOOLEAN_TRUE;
15420 break;
15421 }
15422 }
15423 else if( eSmeCommandWmStatusChange == pCommand->command )
15424 {
15425 //need full power for all
15426 fNeedFullPower = eANI_BOOLEAN_TRUE;
15427 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15428 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015429#ifdef FEATURE_WLAN_TDLS
15430 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15431 {
15432 //TDLS link is getting established. need full power
15433 fNeedFullPower = eANI_BOOLEAN_TRUE;
15434 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15435 }
15436#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 case REQUEST_STOP_UAPSD:
15439 case REQUEST_EXIT_WOWL:
15440 if( eSmeCommandRoam == pCommand->command )
15441 {
15442 fNeedFullPower = eANI_BOOLEAN_TRUE;
15443 switch ( pCommand->u.roamCmd.roamReason )
15444 {
15445 case eCsrForcedDisassoc:
15446 case eCsrForcedDisassocMICFailure:
15447 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15448 break;
15449 default:
15450 break;
15451 }
15452 }
15453 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 case STOPPED:
15455 case REQUEST_STANDBY:
15456 case STANDBY:
15457 case LOW_POWER:
15458 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015459 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015460 status = eHAL_STATUS_FAILURE;
15461 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015462 case FULL_POWER:
15463 case REQUEST_FULL_POWER:
15464 default:
15465 //No need to ask for full power. This has to be FULL_POWER state
15466 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015468 if( pReason )
15469 {
15470 *pReason = reason;
15471 }
15472 if( pfNeedPower )
15473 {
15474 *pfNeedPower = fNeedFullPower;
15475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015476 return ( status );
15477}
15478
Jeff Johnson295189b2012-06-20 16:38:30 -070015479static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15480{
15481 eHalStatus status = eHAL_STATUS_SUCCESS;
15482 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15483 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15486 {
15487 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15488 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 return ( status );
15490}
15491
Jeff Johnson295189b2012-06-20 16:38:30 -070015492tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15493{
15494 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 if( pCmd )
15496 {
15497 pMac->roam.sPendingCommands++;
15498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015499 return ( pCmd );
15500}
15501
Jeff Johnson295189b2012-06-20 16:38:30 -070015502void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15503{
15504 if (pMac->roam.sPendingCommands > 0)
15505 {
15506 //All command allocated through csrGetCommandBuffer need to
15507 //decrement the pending count when releasing.
15508 pMac->roam.sPendingCommands--;
15509 smeReleaseCommand( pMac, pCommand );
15510 }
15511 else
15512 {
15513 smsLog(pMac, LOGE, FL( "no pending commands"));
15514 VOS_ASSERT(0);
15515 }
15516}
15517
Jeff Johnson295189b2012-06-20 16:38:30 -070015518//Return SUCCESS is the command is queued, failed
15519eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15520{
15521 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15523 {
15524 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15525 pCommand->u.scanCmd.reason);
15526 return eHAL_STATUS_CSR_WRONG_STATE;
15527 }
15528
15529 //We can call request full power first before putting the command into pending Q
15530 //because we are holding SME lock at this point.
15531 status = csrRequestFullPower( pMac, pCommand );
15532 if( HAL_STATUS_SUCCESS( status ) )
15533 {
15534 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015535 //make sure roamCmdPendingList is not empty first
15536 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15537 if( fNoCmdPending )
15538 {
15539 smePushCommand( pMac, pCommand, fHighPriority );
15540 }
15541 else
15542 {
15543 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15544 //no list lock is needed since SME lock is held
15545 if( !fHighPriority )
15546 {
15547 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15548 }
15549 else {
15550 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15551 }
15552 }
15553 }
15554 else if( eHAL_STATUS_PMC_PENDING == status )
15555 {
15556 //no list lock is needed since SME lock is held
15557 if( !fHighPriority )
15558 {
15559 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15560 }
15561 else {
15562 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15563 }
15564 //Let caller know the command is queue
15565 status = eHAL_STATUS_SUCCESS;
15566 }
15567 else
15568 {
15569 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15570 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015571 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015574}
Jeff Johnson295189b2012-06-20 16:38:30 -070015575eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15576{
15577 eHalStatus status = eHAL_STATUS_SUCCESS;
15578 tSirUpdateAPWPSIEsReq *pMsg;
15579 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15580
15581 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15582 if (NULL == pSession)
15583 {
15584 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15585 return eHAL_STATUS_FAILURE;
15586 }
15587
Jeff Johnson295189b2012-06-20 16:38:30 -070015588 do
15589 {
15590 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15591 if (!HAL_STATUS_SUCCESS(status)) break;
15592 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15593 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15594
15595 pBuf = (tANI_U8 *)&pMsg->transactionId;
15596 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015597 // transactionId
15598 *pBuf = 0;
15599 *( pBuf + 1 ) = 0;
15600 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015601 // bssId
15602 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15603 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015604 //sessionId
15605 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 // APWPSIEs
15607 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15608 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015609 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015610 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015611 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015612 return ( status );
15613}
Jeff Johnson295189b2012-06-20 16:38:30 -070015614eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15615{
15616 eHalStatus status = eHAL_STATUS_SUCCESS;
15617 tSirUpdateAPWPARSNIEsReq *pMsg;
15618 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015619 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15620 if (NULL == pSession)
15621 {
15622 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15623 return eHAL_STATUS_FAILURE;
15624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015625 do
15626 {
15627 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15628 if (!HAL_STATUS_SUCCESS(status)) break;
15629 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15630 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015631 pBuf = (tANI_U8 *)&pMsg->transactionId;
15632 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 // transactionId
15634 *pBuf = 0;
15635 *( pBuf + 1 ) = 0;
15636 pBuf += sizeof(tANI_U16);
15637
15638 // bssId
15639 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15640 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 // sessionId
15642 *pBuf++ = (tANI_U8)sessionId;
15643
15644 // APWPARSNIEs
15645 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15646 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015649 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015650 return ( status );
15651}
Jeff Johnson295189b2012-06-20 16:38:30 -070015652
15653#ifdef WLAN_FEATURE_VOWIFI_11R
15654//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15655eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15656{
15657 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15658 tpSirFTPreAuthReq pftPreAuthReq;
15659 tANI_U16 auth_req_len = 0;
15660 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015661 auth_req_len = sizeof(tSirFTPreAuthReq);
15662 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15663 if (pftPreAuthReq == NULL)
15664 {
15665 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15666 return eHAL_STATUS_RESOURCES;
15667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015668 // Save the SME Session ID here. We need it while processing the preauth response
15669 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 vos_mem_zero(pftPreAuthReq, auth_req_len);
15671
15672 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15673 sizeof(pBssDescription->length) + pBssDescription->length);
15674
15675 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15676
15677 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15678
Jeff Johnson295189b2012-06-20 16:38:30 -070015679 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015680 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15681
Jeff Johnson295189b2012-06-20 16:38:30 -070015682#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015683 if (csrRoamIs11rAssoc(pMac) &&
15684 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015685 {
15686 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15687 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15688 pMac->ft.ftSmeContext.auth_ft_ies_length);
15689 }
15690 else
15691#endif
15692 {
15693 pftPreAuthReq->ft_ies_length = 0;
15694 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015695 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15696 sizeof(pBssDescription->length) + pBssDescription->length);
15697 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015698 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15699}
Jeff Johnson295189b2012-06-20 16:38:30 -070015700/*--------------------------------------------------------------------------
15701 * This will receive and process the FT Pre Auth Rsp from the current
15702 * associated ap.
15703 *
15704 * This will invoke the hdd call back. This is so that hdd can now
15705 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15706 ------------------------------------------------------------------------*/
15707void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15708{
15709 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15710 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015711#ifdef FEATURE_WLAN_LFR
15712 tCsrRoamInfo roamInfo;
15713#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015714
15715#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015716 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015717#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015718#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015719 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015720 if (status != eHAL_STATUS_SUCCESS) {
15721 /*
15722 * Bail out if pre-auth was not even processed.
15723 */
15724 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15725 return;
15726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015727#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015728 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15729 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15730 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 // Implies a success
15732 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015733 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15734 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15735 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015736 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15737 * actual transition from the current to handoff AP is triggered */
15738 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15739 60 * PAL_TIMER_TO_MS_UNIT,
15740 eANI_BOOLEAN_FALSE);
15741 if (eHAL_STATUS_SUCCESS != status)
15742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015743 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015744 return;
15745 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015746 // Save the received response
15747 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15748 if (csrRoamIs11rAssoc(pMac))
15749 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15750 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15751
15752 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015753#ifdef FEATURE_WLAN_LFR
15754 // If Legacy Fast Roaming is enabled, signal the supplicant
15755 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015756 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015757 {
15758 // Save the bssid from the received response
15759 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15760 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15761 }
15762
15763#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015764
15765 // Done with it, init it.
15766 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15767}
15768#endif
15769#ifdef FEATURE_WLAN_BTAMP_UT_RF
15770void csrRoamJoinRetryTimerHandler(void *pv)
15771{
15772 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15773 tpAniSirGlobal pMac = pInfo->pMac;
15774 tANI_U32 sessionId = pInfo->sessionId;
15775 tCsrRoamSession *pSession;
15776
15777 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15778 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015779 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 pSession = CSR_GET_SESSION( pMac, sessionId );
15781 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15782 {
15783 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015785 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015786 }
15787 }
15788 }
15789}
Jeff Johnson295189b2012-06-20 16:38:30 -070015790eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15791{
15792 eHalStatus status = eHAL_STATUS_FAILURE;
15793 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15794
15795 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015797 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015798 pSession->maxRetryCount--;
15799 pSession->joinRetryTimerInfo.pMac = pMac;
15800 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15801 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15802 if(!HAL_STATUS_SUCCESS(status))
15803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015804 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015805 }
15806 }
15807 else
15808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015809 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015810 pSession->maxRetryCount);
15811 }
15812
15813 return (status);
15814}
Jeff Johnson295189b2012-06-20 16:38:30 -070015815eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15816{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015817 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015818 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15819 {
15820 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15821 }
15822
15823 return eHAL_STATUS_SUCCESS;
15824}
15825#endif
15826
15827
15828/*
15829 pBuf points to the beginning of the message
15830 LIM packs disassoc rsp as below,
15831 messageType - 2 bytes
15832 messageLength - 2 bytes
15833 sessionId - 1 byte
15834 transactionId - 2 bytes (tANI_U16)
15835 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15836 peerMacAddr - 6 bytes
15837 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15838*/
15839static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15840{
15841 if(pBuf && pRsp)
15842 {
15843 pBuf += 4; //skip type and length
15844 pRsp->sessionId = *pBuf++;
15845 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15846 pBuf += 2;
15847 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15848 pBuf += 4;
15849 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15850 }
15851}
15852
Jeff Johnsond13512a2012-07-17 11:42:19 -070015853eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15854{
15855 static uNvTables nvTables;
15856 eHalStatus status = eHAL_STATUS_SUCCESS;
15857 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15858
15859 /* read the country code from NV and use it */
15860 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15861 {
15862 palCopyMemory( pMac->hHdd, pCountry,
15863 nvTables.defaultCountryTable.countryCode,
15864 WNI_CFG_COUNTRY_CODE_LEN );
15865 return status;
15866 }
15867 else
15868 {
15869 palCopyMemory( pMac->hHdd, pCountry,
15870 "XXX",
15871 WNI_CFG_COUNTRY_CODE_LEN );
15872 status = eHAL_STATUS_FAILURE;
15873 return status;
15874 }
15875}
15876
15877eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15878{
15879 palCopyMemory( pMac->hHdd, pCountry,
15880 pMac->scan.countryCode11d,
15881 WNI_CFG_COUNTRY_CODE_LEN );
15882 return eHAL_STATUS_SUCCESS;
15883}
schang86c22c42013-03-13 18:41:24 -070015884
15885eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
15886{
15887 tSirSetTxPowerReq *pMsg = NULL;
15888 eHalStatus status = eHAL_STATUS_SUCCESS;
15889 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15890
15891 if (!pSession)
15892 {
15893 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15894 return eHAL_STATUS_FAILURE;
15895 }
15896
15897 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
15898 if (HAL_STATUS_SUCCESS(status))
15899 {
15900 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
15901 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
15902 pMsg->length = sizeof(tSirSetTxPowerReq);
15903 pMsg->mwPower = mW;
15904 palCopyMemory( pMac->hHdd,
15905 (tSirMacAddr *)pMsg->bssId,
15906 &pSession->selfMacAddr,
15907 sizeof(tSirMacAddr) );
15908 status = palSendMBMessage(pMac->hHdd, pMsg);
15909 if (!HAL_STATUS_SUCCESS(status))
15910 {
15911 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015912 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070015913 }
15914 }
15915 return status;
15916}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015917
15918/* Returns whether a session is in VOS_STA_MODE...or not */
15919tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
15920{
15921 tCsrRoamSession *pSession = NULL;
15922 pSession = CSR_GET_SESSION ( pMac, sessionId );
15923 if(!pSession)
15924 {
15925 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
15926 return eANI_BOOLEAN_FALSE;
15927 }
15928 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
15929 {
15930 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
15931 return eANI_BOOLEAN_FALSE;
15932 }
15933 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15934 {
15935 return eANI_BOOLEAN_FALSE;
15936 }
15937 /* There is a possibility that the above check may fail,because
15938 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
15939 * when it is connected.So,we may sneak through the above check even
15940 * if we are not a STA mode INFRA station. So, if we sneak through
15941 * the above condition, we can use the following check if we are
15942 * really in STA Mode.*/
15943
15944 if ( NULL != pSession->pCurRoamProfile )
15945 {
15946 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
15947 {
15948 return eANI_BOOLEAN_TRUE;
15949 } else {
15950 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
15951 return eANI_BOOLEAN_FALSE;
15952 }
15953 }
15954
15955 return eANI_BOOLEAN_FALSE;
15956}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015957
15958#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15959eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
15960 tCsrHandoffRequest *pHandoffInfo)
15961{
15962 eHalStatus status = eHAL_STATUS_SUCCESS;
15963 vos_msg_t msg;
15964
15965 tAniHandoffReq *pMsg;
15966 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
15967 if ( !HAL_STATUS_SUCCESS(status) )
15968 {
15969 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
15970 return status;
15971 }
15972 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
15973 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
15974 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
15975 pMsg->channel = pHandoffInfo->channel;
15976 palCopyMemory(pMac->hHdd, pMsg->bssid,
15977 pHandoffInfo->bssid,
15978 6);
15979 msg.type = eWNI_SME_HANDOFF_REQ;
15980 msg.bodyptr = pMsg;
15981 msg.reserved = 0;
15982 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15983 {
15984 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
15985 palFreeMemory(pMac->hHdd, (void *)pMsg);
15986 status = eHAL_STATUS_FAILURE;
15987 }
15988 return status;
15989}
15990#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */