blob: e757a2fb2f56b57ac851a35e83a6e93caa3d898b [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 csrRoamClose(pMac);
446 csrScanClose(pMac);
447 csrLLClose(&pMac->roam.statsClientReqList);
448 csrLLClose(&pMac->roam.peStatsReqList);
449 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 /* DeInit Globals */
451 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 return (status);
453}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530454
455eHalStatus csrUpdateChannelList(tCsrScanStruct *pScan)
456{
457 tSirUpdateChanList *pChanList;
458 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
459 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
460 (sizeof(tSirUpdateChanParam) * (numChan - 1));
461 vos_msg_t msg;
462 tANI_U8 i;
463
464 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
465 if (!pChanList)
466 {
467 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
468 "Failed to allocate memory for tSirUpdateChanList");
469 return eHAL_STATUS_FAILED_ALLOC;
470 }
471
472 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
473 msg.reserved = 0;
474 msg.bodyptr = pChanList;
475 pChanList->numChan = numChan;
476 for (i = 0; i < pChanList->numChan; i++)
477 {
478 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
479 pChanList->chanParam[i].pwr = pScan->defaultPowerTable[i].pwr;
480 }
481
482 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
483 {
484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
485 "%s: Failed to post msg to WDA", __func__);
486 vos_mem_free(pChanList);
487 return eHAL_STATUS_FAILURE;
488 }
489
490 return eHAL_STATUS_SUCCESS;
491}
492
Jeff Johnson295189b2012-06-20 16:38:30 -0700493eHalStatus csrStart(tpAniSirGlobal pMac)
494{
495 eHalStatus status = eHAL_STATUS_SUCCESS;
496 tANI_U32 i;
497
498 do
499 {
500 //save the global vos context
501 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
502 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
503 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
504
505 status = csrRoamStart(pMac);
506 if(!HAL_STATUS_SUCCESS(status)) break;
507 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
508 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
509 if(!HAL_STATUS_SUCCESS(status)) break;
510 pMac->roam.sPendingCommands = 0;
511 csrScanEnable(pMac);
512#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
513 status = csrNeighborRoamInit(pMac);
514#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
515 pMac->roam.tlStatsReqInfo.numClient = 0;
516 pMac->roam.tlStatsReqInfo.periodicity = 0;
517 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
518 //init the link quality indication also
519 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
520 if(!HAL_STATUS_SUCCESS(status))
521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800522 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 break;
524 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530525
526 if (pMac->fScanOffload)
527 {
528 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
529 "Scan offload is enabled, update default chan list");
530 status = csrUpdateChannelList(&pMac->scan);
531 }
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700534#if defined(ANI_LOGDUMP)
535 csrDumpInit(pMac);
536#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 return (status);
538}
539
Jeff Johnson295189b2012-06-20 16:38:30 -0700540eHalStatus csrStop(tpAniSirGlobal pMac)
541{
542 tANI_U32 sessionId;
543 tANI_U32 i;
544
545 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
546 {
547 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
548 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 csrScanDisable(pMac);
550 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
551 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
553
554#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
555 csrNeighborRoamClose(pMac);
556#endif
557 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 // deregister from PMC since we register during csrStart()
559 // (ignore status since there is nothing we can do if it fails)
560 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 //Reset the domain back to the deault
562 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800563 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700564
565 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
566 {
567 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
568 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
569 }
570
571 return (eHAL_STATUS_SUCCESS);
572}
573
Jeff Johnson295189b2012-06-20 16:38:30 -0700574eHalStatus csrReady(tpAniSirGlobal pMac)
575{
576 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 csrScanGetSupportedChannels( pMac );
578 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
579 //use it to init the background scan list
580 csrInitBGScanChannelList(pMac);
581 /* HDD issues the init scan */
582 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800583 /* If the gScanAgingTime is set to '0' then scan results aging timeout
584 based on timer feature is not enabled*/
585 if(0 != pMac->scan.scanResultCfgAgingTime )
586 {
587 csrScanStartResultCfgAgingTimer(pMac);
588 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 //Store the AC weights in TL for later use
590 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 status = csrInitChannelList( pMac );
592 if ( ! HAL_STATUS_SUCCESS( status ) )
593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800594 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 status );
596 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 return (status);
598}
Jeff Johnson295189b2012-06-20 16:38:30 -0700599void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
600{
601 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
603 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
604}
Jeff Johnson295189b2012-06-20 16:38:30 -0700605void csrSetGlobalCfgs( tpAniSirGlobal pMac )
606{
Jeff Johnsone7245742012-09-05 17:12:55 -0700607
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
609 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
610 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
611 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
612 NULL, eANI_BOOLEAN_FALSE);
613 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700614 /* 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
615 * Once session is established we will use the session related params stored in PE session for CB mode
616 */
617 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
619
620 //Update the operating mode to configured value during initialization,
621 //So that client can advertise full capabilities in Probe request frame.
622 csrSetDefaultDot11Mode( pMac );
623}
624
Jeff Johnson295189b2012-06-20 16:38:30 -0700625eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
626{
627 eHalStatus status = eHAL_STATUS_SUCCESS;
628 tANI_U32 i;
629 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 do
631 {
632 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
633 {
634 pSession = CSR_GET_SESSION( pMac, i );
635 pSession->roamingTimerInfo.pMac = pMac;
636 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
637 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
639 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
640 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
641 &pMac->roam.WaitForKeyTimerInfo);
642 if(!HAL_STATUS_SUCCESS(status))
643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800644 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700645 break;
646 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
648 if(!HAL_STATUS_SUCCESS(status))
649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800650 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 return eHAL_STATUS_FAILURE;
652 }
653 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 return (status);
655}
656
Jeff Johnson295189b2012-06-20 16:38:30 -0700657eHalStatus csrRoamClose(tpAniSirGlobal pMac)
658{
659 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
661 {
662 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
663 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700664 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
665 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
667 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 return (eHAL_STATUS_SUCCESS);
669}
670
Jeff Johnson295189b2012-06-20 16:38:30 -0700671eHalStatus csrRoamStart(tpAniSirGlobal pMac)
672{
673 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 return (eHAL_STATUS_SUCCESS);
675}
676
Jeff Johnson295189b2012-06-20 16:38:30 -0700677void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
678{
679 csrRoamStopRoamingTimer(pMac, sessionId);
680 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
681 csrRoamDeregStatisticsReq(pMac);
682}
Jeff Johnson295189b2012-06-20 16:38:30 -0700683eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
684{
685 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800686 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 {
688 status = eHAL_STATUS_SUCCESS;
689 *pState = pMac->roam.roamSession[sessionId].connectState;
690 }
691 return (status);
692}
693
Jeff Johnson295189b2012-06-20 16:38:30 -0700694eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
695{
696 eHalStatus status = eHAL_STATUS_FAILURE;
697 tANI_U32 size = 0;
698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700699
700 if(!pSession)
701 {
702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
703 return eHAL_STATUS_FAILURE;
704 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
706 if(pProfile)
707 {
708 if(pSession->pConnectBssDesc)
709 {
710 do
711 {
712 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
713 if(size)
714 {
715 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
716 if(HAL_STATUS_SUCCESS(status))
717 {
718 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
719 }
720 else
721 break;
722 }
723 else
724 {
725 pProfile->pBssDesc = NULL;
726 }
727 pProfile->AuthType = pSession->connectedProfile.AuthType;
728 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
729 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
730 pProfile->BSSType = pSession->connectedProfile.BSSType;
731 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
732 pProfile->CBMode = pSession->connectedProfile.CBMode;
733 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
734 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
735#ifdef WLAN_FEATURE_VOWIFI_11R
736 if (pSession->connectedProfile.MDID.mdiePresent)
737 {
738 pProfile->MDID.mdiePresent = 1;
739 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
740 }
741 else
742 {
743 pProfile->MDID.mdiePresent = 0;
744 pProfile->MDID.mobilityDomain = 0;
745 }
746#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700747#ifdef FEATURE_WLAN_CCX
748 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
750 {
751 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
752 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
753 pProfile->ccxCckmInfo.reassoc_req_num=
754 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
755 pProfile->ccxCckmInfo.krk_plumbed =
756 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
757 }
758#endif
759 }while(0);
760 }
761 }
762
763 return (status);
764}
765
Jeff Johnson295189b2012-06-20 16:38:30 -0700766eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
767{
768 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700769
770 if((csrIsConnStateConnected(pMac, sessionId)) ||
771 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 {
773 if(pProfile)
774 {
775 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
776 }
777 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 return (status);
779}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
782{
783 eHalStatus status = eHAL_STATUS_SUCCESS;
784
785 if(pProfile->pBssDesc)
786 {
787 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
788 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700789 if(pProfile->pAddIEAssoc)
790 {
791 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
792 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
794 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
795 return (status);
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
799{
800 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 if( pConnectedInfo->pbFrames )
802 {
803 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
804 pConnectedInfo->pbFrames = NULL;
805 }
806 pConnectedInfo->nBeaconLength = 0;
807 pConnectedInfo->nAssocReqLength = 0;
808 pConnectedInfo->nAssocRspLength = 0;
809 pConnectedInfo->staId = 0;
810#ifdef WLAN_FEATURE_VOWIFI_11R
811 pConnectedInfo->nRICRspLength = 0;
812#endif
813#ifdef FEATURE_WLAN_CCX
814 pConnectedInfo->nTspecIeLength = 0;
815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 return ( status );
817}
818
Jeff Johnson295189b2012-06-20 16:38:30 -0700819
820
Jeff Johnsone7245742012-09-05 17:12:55 -0700821
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700822void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
823{
824 csrReinitPreauthCmd(pMac, pCommand);
825 csrReleaseCommand( pMac, pCommand );
826}
827
Jeff Johnson295189b2012-06-20 16:38:30 -0700828void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
829{
830 csrReinitRoamCmd(pMac, pCommand);
831 csrReleaseCommand( pMac, pCommand );
832}
833
Jeff Johnson295189b2012-06-20 16:38:30 -0700834void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
835{
836 csrReinitScanCmd(pMac, pCommand);
837 csrReleaseCommand( pMac, pCommand );
838}
839
Jeff Johnson295189b2012-06-20 16:38:30 -0700840void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
841{
842 csrReinitWmStatusChangeCmd(pMac, pCommand);
843 csrReleaseCommand( pMac, pCommand );
844}
845
Jeff Johnson295189b2012-06-20 16:38:30 -0700846void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
847{
848 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
849}
850
Jeff Johnson295189b2012-06-20 16:38:30 -0700851void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
852{
853 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
854}
855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
857{
858 csrReinitSetKeyCmd(pMac, pCommand);
859 csrReleaseCommand( pMac, pCommand );
860}
Jeff Johnson295189b2012-06-20 16:38:30 -0700861void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
862{
863 csrReinitRemoveKeyCmd(pMac, pCommand);
864 csrReleaseCommand( pMac, pCommand );
865}
Jeff Johnson295189b2012-06-20 16:38:30 -0700866void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
867{
868
869 if( eSmeCsrCommandMask & pCommand->command )
870 {
871 switch (pCommand->command)
872 {
873 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800874 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800875 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700876 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 if (NULL != pCommand->u.scanCmd.callback)
878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800879 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
881 }
882 csrReleaseCommandScan( pMac, pCommand );
883 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 case eSmeCommandRoam:
885 csrReleaseCommandRoam( pMac, pCommand );
886 break;
887
888 case eSmeCommandWmStatusChange:
889 csrReleaseCommandWmStatusChange( pMac, pCommand );
890 break;
891
892 case eSmeCommandSetKey:
893 csrReleaseCommandSetKey( pMac, pCommand );
894 break;
895
896 case eSmeCommandRemoveKey:
897 csrReleaseCommandRemoveKey( pMac, pCommand );
898 break;
899
900 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800901 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 csrReleaseCommand( pMac, pCommand );
903 break;
904 }
905 }
906}
907
Jeff Johnson295189b2012-06-20 16:38:30 -0700908void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
909{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800910 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 if(pMac->roam.curSubState[sessionId] == NewSubstate)
913 {
914 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700915 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 pMac->roam.curSubState[sessionId] = NewSubstate;
917}
918
Jeff Johnson295189b2012-06-20 16:38:30 -0700919eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
920{
921 eCsrRoamState PreviousState;
922
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800923 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700924
925 PreviousState = pMac->roam.curState[sessionId];
926
927 if ( NewRoamState != pMac->roam.curState[sessionId] )
928 {
929 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
930 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
931 {
932 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
933 }
934
935 pMac->roam.curState[sessionId] = NewRoamState;
936 }
937 return( PreviousState );
938}
939
Jeff Johnson295189b2012-06-20 16:38:30 -0700940void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
941{
942 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 if(catOffset)
944 {
945 pMac->roam.configParam.bCatRssiOffset = catOffset;
946 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
947 {
948 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
949 }
950 }
951}
952
Jeff Johnson295189b2012-06-20 16:38:30 -0700953static void initConfigParam(tpAniSirGlobal pMac)
954{
955 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
957 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
958 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700959
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
961 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
962 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
963 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
964 pMac->roam.configParam.HeartbeatThresh24 = 40;
965 pMac->roam.configParam.HeartbeatThresh50 = 40;
966 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
967 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
968 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700969 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 pMac->roam.configParam.RTSThreshold = 2346;
971 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
972 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
973 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
974 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
975 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
976 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
977 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
978 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
979 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
980 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
981 {
982 pMac->roam.configParam.BssPreferValue[i] = i;
983 }
984 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
985 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
986 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
987 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
989 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
990 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
991 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
992 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
993 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800994 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
995 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700996 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700997#ifdef WLAN_AP_STA_CONCURRENCY
998 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
999 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1000 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1001 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1002 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001003 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1004 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001005#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1007 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1008 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1009 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001010#ifdef WLAN_FEATURE_VOWIFI_11R
1011 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1012#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001013#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1014 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1015 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1016 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1017 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1018 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1019 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1020 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1021 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1022 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1023 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1024 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001025 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001026#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001027#ifdef WLAN_FEATURE_11AC
1028 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001030
1031 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1032 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001033
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001034 //Remove this code once SLM_Sessionization is supported
1035 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001036 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001037
Jeff Johnsone7245742012-09-05 17:12:55 -07001038}
Jeff Johnson295189b2012-06-20 16:38:30 -07001039eCsrBand csrGetCurrentBand(tHalHandle hHal)
1040{
1041 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1042 return pMac->roam.configParam.bandCapability;
1043}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001044
1045#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1046tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
1047{
1048 /* Get country code from CFG */
1049 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
1050 tANI_U8 i = 0;
1051 v_BOOL_t retVal = FALSE;
1052 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1053 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1054
1055 /* Compare against KR valid list */
1056 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1057 (NULL != pCountryValidChannelList))
1058 {
1059 for (i = 0; i <(*pNumChannels); i++)
1060 {
1061 if (channel == pCountryValidChannelList[i])
1062 {
1063 retVal = TRUE;
1064 break;
1065 }
1066 }
1067 }
1068 else
1069 {
1070 retVal = csrRoamIsChannelValid(pMac, channel);
1071 }
1072
1073 return retVal;
1074}
1075
1076void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1077{
1078 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1079 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1080}
1081
1082/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001083 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001084*/
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001085eHalStatus csrFlushBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001086{
1087 eHalStatus status = eHAL_STATUS_SUCCESS;
1088 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1089
1090 /* Free up the memory first (if required) */
1091 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1092 {
1093 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1094 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001095 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001096 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001097 return status;
1098}
1099
1100
1101
1102/*
1103 This function flushes the roam scan cache and creates fresh cache
1104 based on the input channel list
1105*/
1106eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1107 const tANI_U8 *pChannelList,
1108 const tANI_U8 numChannels)
1109{
1110 eHalStatus status = eHAL_STATUS_SUCCESS;
1111 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1112
Srinivas Girigowdade697412013-02-14 16:31:48 -08001113 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1114
1115 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1116 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1117
1118 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1119 {
1120 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1121 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1122 return eHAL_STATUS_RESOURCES;
1123 }
1124
1125 /* Update the roam global structure */
1126 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1127 pChannelList,
1128 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1129 return status;
1130}
1131
1132/* This function modifies the bgscan channel list set via config ini or
1133 runtime, whenever the band changes.
1134 if the band is auto, then no operation is performed on the channel list
1135 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1136 if the band is 5G, then make sure channel list contains only 5G valid channels
1137*/
1138eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1139 eCsrBand eBand)
1140{
1141 eHalStatus status = eHAL_STATUS_SUCCESS;
1142 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1143 tANI_U8 outNumChannels = 0;
1144 tANI_U8 inNumChannels = 0;
1145 tANI_U8 *inPtr = NULL;
1146 tANI_U8 i = 0;
1147 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1148
1149 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1150
1151 {
1152 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1153 "No update required for channel list "
1154 "either cfg.ini channel list is not set up or "
1155 "auto band (Band %d)", eBand);
1156 return status;
1157 }
1158
1159 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1160 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1161 if (eCSR_BAND_24 == eBand)
1162 {
1163 for (i = 0; i < inNumChannels; i++)
1164 {
1165 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1166 {
1167 ChannelList[outNumChannels++] = inPtr[i];
1168 }
1169 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001170 csrFlushBgScanRoamChannelList(pMac);
1171 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001172 }
1173 else if (eCSR_BAND_5G == eBand)
1174 {
1175 for (i = 0; i < inNumChannels; i++)
1176 {
1177 /* Add 5G Non-DFS channel */
1178 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1179 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1180 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1181 {
1182 ChannelList[outNumChannels++] = inPtr[i];
1183 }
1184 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001185 csrFlushBgScanRoamChannelList(pMac);
1186 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001187 }
1188 else if (eCSR_BAND_ALL == eBand)
1189 {
1190 for (i = 0; i < inNumChannels; i++)
1191 {
1192 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1193 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1194 {
1195 ChannelList[outNumChannels++] = inPtr[i];
1196 }
1197 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001198 csrFlushBgScanRoamChannelList(pMac);
1199 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001200 }
1201 else
1202 {
1203 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1204 "Invalid band, No operation carried out (Band %d)", eBand);
1205 status = eHAL_STATUS_INVALID_PARAMETER;
1206 }
1207
1208 return status;
1209}
1210
1211/*
1212 This function initializes the valid channel list based on country code
1213*/
1214eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1215 tANI_U8 Revision)
1216{
1217 eHalStatus status = eHAL_STATUS_SUCCESS;
1218 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001219 tANI_U8 **pOutChannelList = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001220 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1221 const tANI_U8 *pChannelList = NULL;
1222
1223 if (SME_KR_3 == Revision)
1224 {
1225 pChannelList = KR_3;
1226 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1227 }
1228 else if (SME_KR_24 == Revision)
1229 {
1230 pChannelList = KR_24;
1231 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1232 }
1233 else if (SME_KR_25 == Revision)
1234 {
1235 pChannelList = KR_25;
1236 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1237 }
1238 else
1239 return eHAL_STATUS_INVALID_PARAMETER;
1240
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001241 /* Free any existing channel list */
1242 vos_mem_free(*pOutChannelList);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001243
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001244 *pOutChannelList = vos_mem_malloc(*pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001245
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001246 if (NULL == *pOutChannelList)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001247 {
1248 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1249 *pNumChannels = 0;
1250 return eHAL_STATUS_RESOURCES;
1251 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001252 /* Update the roam global structure */
Jeff Johnsonbc4396f2013-04-03 18:26:56 -07001253 palCopyMemory(pMac->hHdd, *pOutChannelList, pChannelList, *pNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001254 return status;
1255}
1256
1257#endif
1258
Jeff Johnson295189b2012-06-20 16:38:30 -07001259eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1260{
1261 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1262 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1264 (eBand == eCSR_BAND_24))
1265 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001266 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001268 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001269 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 pMac->roam.configParam.uCfgDot11Mode, eBand);
1271 return eHAL_STATUS_INVALID_PARAMETER;
1272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1274 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1275 (eBand == eCSR_BAND_5G))
1276 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001277 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001279 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001280 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001281 pMac->roam.configParam.uCfgDot11Mode, eBand);
1282 return eHAL_STATUS_INVALID_PARAMETER;
1283 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001284 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001285 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001286 pMac->roam.configParam.eBand = eBand;
1287 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001289#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1290 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1291#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 status = csrInitGetChannels( pMac );
1293 if (eHAL_STATUS_SUCCESS == status)
1294 csrInitChannelList( hHal );
1295 return status;
1296}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001297
1298
Jeff Johnsone7245742012-09-05 17:12:55 -07001299/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1300 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1301 * Ideally we should have kept the ini value and enum value same and representing the same
1302 * cb values as in 11n standard i.e.
1303 * Set to 1 (SCA) if the secondary channel is above the primary channel
1304 * Set to 3 (SCB) if the secondary channel is below the primary channel
1305 * Set to 0 (SCN) if no secondary channel is present
1306 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1307 * 0 - secondary none
1308 * 1 - secondary LOW
1309 * 2 - secondary HIGH
1310 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1311 * The enum values are as follows:
1312 * PHY_SINGLE_CHANNEL_CENTERED = 0
1313 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1314 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1315 */
1316ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1317{
1318
1319 ePhyChanBondState phyCbState;
1320 switch (cbIniValue) {
1321 // secondary none
1322 case 0:
1323 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1324 break;
1325 // secondary LOW
1326 case 1:
1327 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1328 break;
1329 // secondary HIGH
1330 case 2:
1331 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1332 break;
1333#ifdef WLAN_FEATURE_11AC
1334 case 3:
1335 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1336 break;
1337 case 4:
1338 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1339 break;
1340 case 5:
1341 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1342 break;
1343 case 6:
1344 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1345 break;
1346 case 7:
1347 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1348 break;
1349 case 8:
1350 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1351 break;
1352 case 9:
1353 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1354 break;
1355#endif
1356 default:
1357 // If an invalid value is passed, disable CHANNEL BONDING
1358 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1359 break;
1360 }
1361 return phyCbState;
1362}
1363
1364v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1365{
1366
1367 v_U32_t cbIniValue;
1368 switch (phyCbState) {
1369 // secondary none
1370 case PHY_SINGLE_CHANNEL_CENTERED:
1371 cbIniValue = 0;
1372 break;
1373 // secondary LOW
1374 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1375 cbIniValue = 1;
1376 break;
1377 // secondary HIGH
1378 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1379 cbIniValue = 2;
1380 break;
1381#ifdef WLAN_FEATURE_11AC
1382 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1383 cbIniValue = 3;
1384 break;
1385 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1386 cbIniValue = 4;
1387 break;
1388 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1389 cbIniValue = 5;
1390 break;
1391 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1392 cbIniValue = 6;
1393 break;
1394 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1395 cbIniValue = 7;
1396 break;
1397 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1398 cbIniValue = 8;
1399 break;
1400 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1401 cbIniValue = 9;
1402 break;
1403#endif
1404 default:
1405 // return some invalid value
1406 cbIniValue = 10;
1407 break;
1408 }
1409 return cbIniValue;
1410}
Jeff Johnson295189b2012-06-20 16:38:30 -07001411
1412eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1413{
1414 eHalStatus status = eHAL_STATUS_SUCCESS;
1415
1416 if(pParam)
1417 {
1418 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1419 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1420 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1421 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1422 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1423 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1424
1425 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001426 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1427
Jeff Johnsone7245742012-09-05 17:12:55 -07001428 /* channelBondingMode5GHz plays a dual role right now
1429 * 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
1430 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1431 */
1432 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001434 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001435 }
1436 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1437 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001439 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001440 }
1441 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1443 pMac->roam.configParam.phyMode = pParam->phyMode;
1444 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1445 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1446 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1447 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1448 pMac->roam.configParam.TxRate = pParam->TxRate;
1449 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1450 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1451 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1452 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1453 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001454 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 //if HDD passed down non zero values then only update,
1456 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001457 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 {
1459 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1460 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001461 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 {
1463 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1464 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001465 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 {
1467 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1468 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001469 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 {
1471 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1472 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001473 if (pParam->nActiveMaxChnTimeBtc)
1474 {
1475 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1476 }
1477 if (pParam->nActiveMinChnTimeBtc)
1478 {
1479 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1480 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001481#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001482 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001483 {
1484 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1485 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001486 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001487 {
1488 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1489 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001490 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001491 {
1492 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1493 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001494 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001495 {
1496 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1497 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001498 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001499 {
1500 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1501 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001502 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001503 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001504 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1505 }
1506 if (pParam->nNumP2PChanCombinedConc)
1507 {
1508 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001509 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001510#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001512 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 {
1514 //Change the unit from second to microsecond
1515 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1517 {
1518 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1519 }
1520 else
1521 {
1522 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1523 }
1524 }
1525 else
1526 {
1527 pMac->roam.configParam.impsSleepTime = 0;
1528 }
1529 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1531 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 //if HDD passed down non zero values for age params, then only update,
1533 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001534 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 {
1536 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 if(pParam->scanAgeTimeNCNPS)
1539 {
1540 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 if(pParam->scanAgeTimeNCPS)
1543 {
1544 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 if(pParam->scanAgeTimeCNPS)
1547 {
1548 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1549 }
1550 if(pParam->scanAgeTimeCPS)
1551 {
1552 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1553 }
1554
1555 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1556 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1557 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1558 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1559 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1560 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001561 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1562 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1564 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1565 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1566 //Assign this before calling CsrInit11dInfo
1567 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 if( csrIs11dSupported( pMac ) )
1569 {
1570 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1571 }
1572 else
1573 {
1574 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1575 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001576
1577 /* Initialize the power + channel information if 11h is enabled.
1578 If 11d is enabled this information has already been initialized */
1579 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1580 {
1581 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1582 }
1583
1584
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301585#ifdef WLAN_FEATURE_VOWIFI_11R
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001587 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001588#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001589#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001591 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001592 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001593 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001594 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001595 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001596 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001597 pMac->roam.configParam.nProbes = pParam->nProbes;
1598 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001599#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001600#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1601 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001602 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001603#endif
1604#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001605 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1606#endif
1607
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301608#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1610#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001611#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1612 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001613 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1614 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1615 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1616 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1617 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1618 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1619 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1620 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 {
1622 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001623 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 -07001624 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1625 {
1626 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1627 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001628 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 }
1630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1632 pMac->scan.fValidateList = pParam->fValidateList;
1633 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1634 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001635 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1638 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1639 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1640 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1641 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1642 * single session
1643 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001644 //Remove this code once SLM_Sessionization is supported
1645 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001646 pMac->roam.configParam.doBMPSWorkaround = 0;
1647
Jeff Johnsone7245742012-09-05 17:12:55 -07001648#ifdef WLAN_FEATURE_11AC
1649 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001650 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001651 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001652 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001653#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001654 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni4f087d22013-07-29 16:32:26 -07001655 pMac->roam.configParam.enableOxygenNwk = pParam->enableOxygenNwk;
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 }
1657
1658 return status;
1659}
1660
Jeff Johnson295189b2012-06-20 16:38:30 -07001661eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1662{
1663 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 if(pParam)
1665 {
1666 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1667 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1668 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1669 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1670 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1671 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001672 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1673 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1675 pParam->phyMode = pMac->roam.configParam.phyMode;
1676 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1677 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1678 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1679 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1680 pParam->TxRate = pMac->roam.configParam.TxRate;
1681 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1682 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1683 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1684 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1685 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1687 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1688 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1689 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001690 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1691 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1692 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001693#ifdef WLAN_AP_STA_CONCURRENCY
1694 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1695 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1696 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1697 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1698 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001699 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1700 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001701#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 //Change the unit from microsecond to second
1703 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1704 pParam->eBand = pMac->roam.configParam.eBand;
1705 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1706 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1707 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1708 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1709 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1710 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1711 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1712 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1713 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1714 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1715 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1716 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1717 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1719 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1720 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1721 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1723 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1724 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1725 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1726 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001727 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001728 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001729 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001730 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001731
1732#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1733 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1734#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001735#ifdef WLAN_FEATURE_11AC
1736 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001737 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001738 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001739#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001740#ifdef WLAN_FEATURE_VOWIFI_11R
1741 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1742#endif
1743#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1744 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1745 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1746 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1747 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1748 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001749 pParam->nProbes = pMac->roam.configParam.nProbes;
1750 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001751#endif
1752#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1753 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1754 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1755#endif
1756#ifdef FEATURE_WLAN_LFR
1757 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1758#endif
1759
1760#ifdef FEATURE_WLAN_CCX
1761 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1762#endif
1763#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1764 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1765 {
1766 int i;
1767 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1768 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1769 {
1770 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1771 }
1772 smsLog( pMac, LOG1, "");
1773 }
1774#endif
1775
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001776 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001777 pParam->enableOxygenNwk = pMac->roam.configParam.enableOxygenNwk;
1778
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 csrSetChannels(pMac, pParam);
1780
1781 status = eHAL_STATUS_SUCCESS;
1782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 return (status);
1784}
1785
Jeff Johnson295189b2012-06-20 16:38:30 -07001786eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1787{
1788 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1789 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1790 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1791 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 do
1793 {
1794 if(eCSR_BAND_24 == eBand)
1795 {
1796 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1797 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1798 }
1799 if(eCSR_BAND_5G == eBand)
1800 {
1801 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1802 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1803 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1804 )
1805 {
1806 break;
1807 }
1808 }
1809 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1810 {
1811 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1812 }
1813 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1814 {
1815 newPhyMode = eCSR_DOT11_MODE_AUTO;
1816 }
1817 else
1818 {
1819 //Check for dual band and higher capability first
1820 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1821 {
1822 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1823 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1824 }
1825 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1826 {
1827 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1828 if(eCSR_BAND_24 == eBand) break;
1829 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1830 eBand = eCSR_BAND_5G;
1831 }
1832 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1833 {
1834 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1835 if(eCSR_BAND_5G == eBand) break;
1836 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1837 eBand = eCSR_BAND_24;
1838 }
1839 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1840 {
1841 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1842 if(eCSR_BAND_5G == eBand) break;
1843 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1844 eBand = eCSR_BAND_24;
1845 }
1846 else if(eCSR_DOT11_MODE_11n & phyMode)
1847 {
1848 newPhyMode = eCSR_DOT11_MODE_11n;
1849 }
1850 else if(eCSR_DOT11_MODE_abg & phyMode)
1851 {
1852 newPhyMode = eCSR_DOT11_MODE_abg;
1853 }
1854 else if(eCSR_DOT11_MODE_11a & phyMode)
1855 {
1856 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1857 {
1858 if(eCSR_BAND_ALL == eBand)
1859 {
1860 newPhyMode = eCSR_DOT11_MODE_abg;
1861 }
1862 else
1863 {
1864 //bad setting
1865 break;
1866 }
1867 }
1868 else
1869 {
1870 newPhyMode = eCSR_DOT11_MODE_11a;
1871 eBand = eCSR_BAND_5G;
1872 }
1873 }
1874 else if(eCSR_DOT11_MODE_11g & phyMode)
1875 {
1876 newPhyMode = eCSR_DOT11_MODE_11g;
1877 eBand = eCSR_BAND_24;
1878 }
1879 else if(eCSR_DOT11_MODE_11b & phyMode)
1880 {
1881 newPhyMode = eCSR_DOT11_MODE_11b;
1882 eBand = eCSR_BAND_24;
1883 }
1884 else
1885 {
1886 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001887 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 newPhyMode = eCSR_DOT11_MODE_AUTO;
1889 }
1890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 //Done validating
1892 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 //Now we need to check whether a restart is needed.
1894 if(eBand != pMac->roam.configParam.eBand)
1895 {
1896 fRestartNeeded = eANI_BOOLEAN_TRUE;
1897 break;
1898 }
1899 if(newPhyMode != pMac->roam.configParam.phyMode)
1900 {
1901 fRestartNeeded = eANI_BOOLEAN_TRUE;
1902 break;
1903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 if(HAL_STATUS_SUCCESS(status))
1906 {
1907 pMac->roam.configParam.eBand = eBand;
1908 pMac->roam.configParam.phyMode = newPhyMode;
1909 if(pfRestartNeeded)
1910 {
1911 *pfRestartNeeded = fRestartNeeded;
1912 }
1913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 return (status);
1915}
1916
Jeff Johnson295189b2012-06-20 16:38:30 -07001917void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1918{
1919 tANI_U8 Index;
1920 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 // for dual band NICs, don't need to trim the channel list....
1922 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1923 {
1924 // 2.4 GHz band operation requires the channel list to be trimmed to
1925 // the 2.4 GHz channels only...
1926 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1927 {
1928 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1929 Index++ )
1930 {
1931 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1932 {
1933 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1934 cChannels++;
1935 }
1936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1938 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1939 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1940 // only if we need to.
1941 //
1942 // The amount of memory to clear is the number of channesl that we trimmed
1943 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1944
1945 if ( pChannelList->numChannels > cChannels )
1946 {
1947 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1948 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1949
1950 }
1951
1952 pChannelList->numChannels = cChannels;
1953 }
1954 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1955 {
1956 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1957 {
1958 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1959 {
1960 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1961 cChannels++;
1962 }
1963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1965 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1966 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1967 // only if we need to.
1968 //
1969 // The amount of memory to clear is the number of channesl that we trimmed
1970 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1971 if ( pChannelList->numChannels > cChannels )
1972 {
1973 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1974 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1975 }
1976
1977 pChannelList->numChannels = cChannels;
1978 }
1979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001980}
Jeff Johnson295189b2012-06-20 16:38:30 -07001981#define INFRA_AP_DEFAULT_CHANNEL 6
1982eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1983{
1984 tANI_U8 index= 0;
1985 eHalStatus status = eHAL_STATUS_FAILURE;
1986 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1987 {
1988 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1989 status = eHAL_STATUS_SUCCESS;
1990 break;
1991 }
1992 }
1993 return status;
1994}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07001995
1996eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1997{
1998 eHalStatus status = eHAL_STATUS_SUCCESS;
1999 tANI_U8 num20MHzChannelsFound = 0;
2000 VOS_STATUS vosStatus;
2001 tANI_U8 num40MHzChannelsFound = 0;
2002 tANI_U8 Index = 0;
2003 tANI_U8 channelList = 0;
2004
2005 // Updating the defaultpower Table for changed Domain Id
2006 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2007 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2008
2009 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2010 {
2011 smsLog( pMac, LOGE, FL("failed to get channels"));
2012 status = eHAL_STATUS_FAILURE;
2013 }
2014 else
2015 {
2016 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2017 {
2018 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2019 }
2020
2021 // Move the only 5GHZ channel list to the global data,
2022 // As 2.4GHZ list coming from the AP for the changed domain
2023 // structure -- this will be used as the scan list
2024 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
2025 {
2026 // If Channel is 5GHz just break the for loop
2027 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
2028 break;
2029 }
2030 // Update the 5G channels from nv.bin
2031 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2032 {
2033 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
2034 {
Krunal Sonia75019a2013-05-01 01:08:22 -07002035 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
2036 {
2037 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
2038 channelList++;
2039 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002040 }
2041 }
2042
2043 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
2044 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
2045 // Filling the remaining index as Zero Just for causion
2046 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
2047 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
2048 }
2049 return status;
2050}
2051
2052eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
2053{
2054 eHalStatus status = eHAL_STATUS_SUCCESS;
2055 tANI_U8 num20MHzChannelsFound = 0;
2056 VOS_STATUS vosStatus;
2057 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302058 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002059 tANI_U8 num40MHzChannelsFound = 0;
2060 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
2061 tANI_U8 channelList = 0;
2062
2063 // Read the scan channel list (including the power limit) from EEPROM
2064 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2065 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2066
2067 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2068 {
2069 smsLog( pMac, LOGE, FL("failed to get channels \n"));
2070 status = eHAL_STATUS_FAILURE;
2071 }
2072 else
2073 {
2074 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2075 {
2076 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2077 }
2078
2079 // Move the 2.4GHZ channel list only to the global data,
2080 // As 5GHz list been provided by AP as part of 11d IE
2081 // structure -- this will be used as the scan list
2082 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
2083 {
2084 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
2085 {
2086 // First taking the 5GHz channel list backup
2087 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2088 nuum5GchannelListBackup++;
2089 }
2090 }
2091 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302092 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002093 {
2094 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302095 {
2096 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2097 numChan++;
2098 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002099 }
2100 // Restoring the Backed up 5 GHZ channels
2101 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2102 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302103 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002104 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302105 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2106 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002107 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002108 }
2109
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302110 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2111 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002112 }
2113 return (status);
2114}
2115
Jeff Johnson295189b2012-06-20 16:38:30 -07002116eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2117{
2118 eHalStatus status = eHAL_STATUS_SUCCESS;
2119 tANI_U8 num20MHzChannelsFound = 0;
2120 VOS_STATUS vosStatus;
2121 tANI_U8 Index = 0;
2122 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002123
Jeff Johnson295189b2012-06-20 16:38:30 -07002124
2125 //TODO: this interface changed to include the 40MHz channel list
2126 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2127 // Read the scan channel list (including the power limit) from EEPROM
2128 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2129 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2130 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002132 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 status = eHAL_STATUS_FAILURE;
2134 }
2135 else
2136 {
2137 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2138 {
2139 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2140 }
2141 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2142 // Move the channel list to the global data
2143 // structure -- this will be used as the scan list
2144 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2145 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 }
2148 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2149 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2150 {
2151 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2152 }
2153 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2154 {
2155 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2156 }
2157 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 return (status);
2160}
2161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162eHalStatus csrInitChannelList( tHalHandle hHal )
2163{
2164 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2165 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2167 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002168 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2169 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002171 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002172
2173 return (status);
2174}
Jeff Johnson295189b2012-06-20 16:38:30 -07002175eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2176 tCsrUpdateConfigParam *pUpdateConfigParam)
2177{
2178 eHalStatus status = eHAL_STATUS_FAILURE;
2179 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2181 status = CsrInit11dInfo(pMac, ps11dinfo);
2182 return status;
2183}
2184
Jeff Johnson295189b2012-06-20 16:38:30 -07002185static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2186{
2187 eHalStatus status = eHAL_STATUS_FAILURE;
2188 tANI_U8 index;
2189 tANI_U32 count=0;
2190 tSirMacChanInfo *pChanInfo;
2191 tSirMacChanInfo *pChanInfoStart;
2192 tANI_BOOLEAN applyConfig = TRUE;
2193
2194 if(!ps11dinfo)
2195 {
2196 return (status);
2197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2199 {
2200 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2201 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2202 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2203 if(!HAL_STATUS_SUCCESS(status)) return (status);
2204 }
2205 else
2206 {
2207 //No change
2208 return (eHAL_STATUS_SUCCESS);
2209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 //legacy maintenance
2211 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2212 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2213 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 //Tush: at csropen get this initialized with default, during csr reset if this
2215 // already set with some value no need initilaize with default again
2216 if(0 == pMac->scan.countryCodeCurrent[0])
2217 {
2218 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2219 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2220 if(!HAL_STATUS_SUCCESS(status)) return (status);
2221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 // need to add the max power channel list
2223 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2224 {
2225 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2226 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002227 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2228 {
2229 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2230 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2231 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2232 pChanInfo++;
2233 count++;
2234 }
2235 if(count)
2236 {
2237 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2238 }
2239 palFreeMemory(pMac->hHdd, pChanInfoStart);
2240 }
2241 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2242 if( HAL_STATUS_SUCCESS(status) )
2243 {
2244 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2245 {
2246 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2247 {
2248 applyConfig = FALSE;
2249 }
2250 }
2251
2252 if(TRUE == applyConfig)
2253 {
2254 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002255 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002256 }
2257
2258 }
2259 return (status);
2260}
2261/* Initialize the Channel + Power List in the local cache and in the CFG */
2262eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2263{
2264 tANI_U8 index;
2265 tANI_U32 count=0;
2266 tSirMacChanInfo *pChanInfo;
2267 tSirMacChanInfo *pChanInfoStart;
2268
2269 if(!ps11dinfo || !pMac)
2270 {
2271 return eHAL_STATUS_FAILURE;
2272 }
2273
2274 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2275 {
2276 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2277 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002278
2279 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2280 {
2281 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2282 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2283 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2284 pChanInfo++;
2285 count++;
2286 }
2287 if(count)
2288 {
2289 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2290 }
2291 palFreeMemory(pMac->hHdd, pChanInfoStart);
2292 }
2293
Jeff Johnsone7245742012-09-05 17:12:55 -07002294 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002295}
2296
2297//pCommand may be NULL
2298//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2299void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2300{
2301 tListElem *pEntry, *pNextEntry;
2302 tSmeCmd *pDupCommand;
2303 tDblLinkList localList;
2304
2305 vos_mem_zero(&localList, sizeof(tDblLinkList));
2306 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2307 {
2308 smsLog(pMac, LOGE, FL(" failed to open list"));
2309 return;
2310 }
2311 csrLLLock( &pMac->sme.smeCmdPendingList );
2312 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2313 while( pEntry )
2314 {
2315 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2316 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 // Remove the previous command if..
2318 // - the new roam command is for the same RoamReason...
2319 // - the new roam command is a NewProfileList.
2320 // - the new roam command is a Forced Dissoc
2321 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2322 if (
2323 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2324 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002325 /* This peermac check is requried for Softap/GO scenarios
2326 * For STA scenario below OR check will suffice as pCommand will
2327 * always be NULL for STA scenarios
2328 */
2329 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2331 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2332 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2333 ||
2334 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002335 ( (sessionId == pDupCommand->sessionId) &&
2336 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 ((eCsrForcedDisassoc == eRoamReason) ||
2338 (eCsrHddIssued == eRoamReason))
2339 )
2340 )
2341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002342 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 // Remove the 'stale' roam command from the pending list...
2344 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2345 {
2346 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2347 }
2348 }
2349 pEntry = pNextEntry;
2350 }
2351 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2352
2353 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2354 {
2355 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2356 //Tell caller that the command is cancelled
2357 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2358 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2359 csrReleaseCommandRoam(pMac, pDupCommand);
2360 }
2361 csrLLClose(&localList);
2362}
Jeff Johnson295189b2012-06-20 16:38:30 -07002363eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2364 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2365{
2366 eHalStatus status = eHAL_STATUS_SUCCESS;
2367#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2368 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2369#endif
2370 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2372 {
2373 pSession = CSR_GET_SESSION( pMac, sessionId );
2374 }
2375 else
2376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002377 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 VOS_ASSERT(0);
2379 return eHAL_STATUS_FAILURE;
2380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002383 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002385 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2386 /*
2387 * Decrement bRefAssocStartCnt for FT reassoc failure.
2388 * Reason: For FT reassoc failures, we first call
2389 * csrRoamCallCallback before notifying a failed roam
2390 * completion through csrRoamComplete. The latter in
2391 * turn calls csrRoamProcessResults which tries to
2392 * once again call csrRoamCallCallback if bRefAssocStartCnt
2393 * is non-zero. Since this is redundant for FT reassoc
2394 * failure, decrement bRefAssocStartCnt.
2395 */
2396 pSession->bRefAssocStartCnt--;
2397 }
2398
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 if ( (pSession == NULL) ||
2400 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002402 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 return eHAL_STATUS_FAILURE;
2404 }
2405
2406 if(NULL != pSession->callback)
2407 {
2408 if( pRoamInfo )
2409 {
2410 pRoamInfo->sessionId = (tANI_U8)sessionId;
2411 }
2412
2413 /* avoid holding the global lock when making the roaming callback , original change came
2414 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2415 is possible on other OS ports where the callback may need to take locks to protect
2416 HDD state
2417 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2418 that may actually depend on the lock being held */
2419 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2420 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2421 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2422 }
2423 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2424 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2425#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2426 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2427 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2428 {
2429 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2430 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2431 if(NULL != pRoamInfo->pBssDesc)
2432 {
2433 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2434 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2437 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2438 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2439 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2440 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2441 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2444 {
2445 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2446 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2447 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 if(eCSR_ROAM_RESULT_FORCED == u2)
2450 {
2451 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2452 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2453 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2454 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2456 {
2457 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2458 connectionStatus.reason = eCSR_REASON_DISASSOC;
2459 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2462 {
2463 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2464 connectionStatus.reason = eCSR_REASON_DEAUTH;
2465 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002467#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2468
2469 return (status);
2470}
Jeff Johnson295189b2012-06-20 16:38:30 -07002471// Returns whether handoff is currently in progress or not
2472tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2473{
2474#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2475 return csrNeighborRoamIsHandoffInProgress(pMac);
2476#else
2477 return eANI_BOOLEAN_FALSE;
2478#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002479}
Jeff Johnson295189b2012-06-20 16:38:30 -07002480eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2481 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2482{
2483 eHalStatus status = eHAL_STATUS_SUCCESS;
2484 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2485 tANI_U16 reasonCode;
2486 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002487
2488 if(!pSession)
2489 {
2490 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2491 return eHAL_STATUS_FAILURE;
2492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
2494 //Restore AC weight in case we change it
2495 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2496 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002497 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 -07002498 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2499 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2500 }
2501
2502 if ( fMICFailure )
2503 {
2504 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2505 }
2506 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2507 {
2508 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002509 }
2510 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 {
2512 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002514#ifdef WLAN_FEATURE_VOWIFI_11R
2515 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2516 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2517 {
2518 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2519 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002520 }
2521 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002522#endif
2523 if(pSession->pConnectBssDesc)
2524 {
2525 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2526 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002527
Jeff Johnson295189b2012-06-20 16:38:30 -07002528
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002529 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2530 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2531 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2532
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2534
2535 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2536
2537 if(HAL_STATUS_SUCCESS(status))
2538 {
2539 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002540#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2541 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2542 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2543 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002544 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2546 }
2547#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002548 }
2549 else
2550 {
2551 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2552 }
2553
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 return (status);
2555}
Jeff Johnson295189b2012-06-20 16:38:30 -07002556
Jeff Johnson295189b2012-06-20 16:38:30 -07002557/* ---------------------------------------------------------------------------
2558 \fn csrRoamIssueDisassociateStaCmd
2559 \brief csr function that HDD calls to disassociate a associated station
2560 \param sessionId - session Id for Soft AP
2561 \param pPeerMacAddr - MAC of associated station to delete
2562 \param reason - reason code, be one of the tSirMacReasonCodes
2563 \return eHalStatus
2564 ---------------------------------------------------------------------------*/
2565eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2566 tANI_U32 sessionId,
2567 tANI_U8 *pPeerMacAddr,
2568 tANI_U32 reason)
2569{
2570 eHalStatus status = eHAL_STATUS_SUCCESS;
2571 tSmeCmd *pCommand;
2572
2573 do
2574 {
2575 pCommand = csrGetCommandBuffer( pMac );
2576 if ( !pCommand )
2577 {
2578 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2579 status = eHAL_STATUS_RESOURCES;
2580 break;
2581 }
2582 pCommand->command = eSmeCommandRoam;
2583 pCommand->sessionId = (tANI_U8)sessionId;
2584 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2585 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2586 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2587 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2588 if( !HAL_STATUS_SUCCESS( status ) )
2589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002590 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 csrReleaseCommandRoam( pMac, pCommand );
2592 }
2593 }while(0);
2594
2595 return status;
2596}
2597
2598
Jeff Johnson295189b2012-06-20 16:38:30 -07002599/* ---------------------------------------------------------------------------
2600 \fn csrRoamIssueDeauthSta
2601 \brief csr function that HDD calls to delete a associated station
2602 \param sessionId - session Id for Soft AP
2603 \param pPeerMacAddr - MAC of associated station to delete
2604 \param reason - reason code, be one of the tSirMacReasonCodes
2605 \return eHalStatus
2606 ---------------------------------------------------------------------------*/
2607eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2608 tANI_U32 sessionId,
2609 tANI_U8 *pPeerMacAddr,
2610 tANI_U32 reason)
2611{
2612 eHalStatus status = eHAL_STATUS_SUCCESS;
2613 tSmeCmd *pCommand;
2614
2615 do
2616 {
2617 pCommand = csrGetCommandBuffer( pMac );
2618 if ( !pCommand )
2619 {
2620 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2621 status = eHAL_STATUS_RESOURCES;
2622 break;
2623 }
2624 pCommand->command = eSmeCommandRoam;
2625 pCommand->sessionId = (tANI_U8)sessionId;
2626 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2627 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2628 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2629 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2630 if( !HAL_STATUS_SUCCESS( status ) )
2631 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002632 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 csrReleaseCommandRoam( pMac, pCommand );
2634 }
2635 }while(0);
2636
2637 return status;
2638}
Jeff Johnson295189b2012-06-20 16:38:30 -07002639eHalStatus
2640csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2641 tANI_BOOLEAN bEnable )
2642{
2643 eHalStatus status = eHAL_STATUS_FAILURE;
2644 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2645 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 if (!pSession)
2647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002648 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 return (status);
2650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 if (pSession->pConnectBssDesc)
2652 {
2653 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2654 }
2655 else
2656 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002657 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 return (status);
2659 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002660 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 -07002661 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2662 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2664 return (status);
2665}
Jeff Johnson295189b2012-06-20 16:38:30 -07002666eHalStatus
2667csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2668 VOS_MODULE_ID modId, void *pUsrContext,
2669 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2670{
2671 eHalStatus status = eHAL_STATUS_SUCCESS;
2672 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2673 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 if (!pSession)
2675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002676 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 return (status);
2678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 if(pSession->pConnectBssDesc)
2680 {
2681 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2682 }
2683 else
2684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002685 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 return (status);
2687 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002688 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2690 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2692 return (status);
2693}
Jeff Johnson295189b2012-06-20 16:38:30 -07002694eHalStatus
2695csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2696 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2697{
2698 eHalStatus status = eHAL_STATUS_SUCCESS;
2699 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2700 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2701
2702 if (!pSession)
2703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002704 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 return (status);
2706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 if(pSession->pConnectBssDesc)
2708 {
2709 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2710 }
2711 else
2712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002713 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 return (status);
2715 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002716 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2718 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2719
2720 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2721
2722 return (status);
2723}
Jeff Johnson295189b2012-06-20 16:38:30 -07002724eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2725{
2726 eHalStatus status = eHAL_STATUS_SUCCESS;
2727 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2728 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002729
2730 if (!pSession)
2731 {
2732 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2733 return eHAL_STATUS_FAILURE;
2734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002735
2736 if(pSession->pConnectBssDesc)
2737 {
2738 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2739 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002740 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2742 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2744
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302745 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002746 if(!HAL_STATUS_SUCCESS(status))
2747 {
2748 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2749 }
2750
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 return (status);
2752}
2753
Jeff Johnson295189b2012-06-20 16:38:30 -07002754eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2755{
2756 eHalStatus status = eHAL_STATUS_SUCCESS;
2757 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2758 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002759
2760 if(!pSession)
2761 {
2762 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2763 return eHAL_STATUS_FAILURE;
2764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002765
2766 // If no BSS description was found in this connection (happens with start IBSS), then
2767 // nix the BSS description that we keep around for the connected BSS) and get out...
2768 if(NULL == pBssDesc)
2769 {
2770 csrFreeConnectBssDesc(pMac, sessionId);
2771 }
2772 else
2773 {
2774 size = pBssDesc->length + sizeof( pBssDesc->length );
2775 if(NULL != pSession->pConnectBssDesc)
2776 {
2777 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2778 {
2779 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2780 csrFreeConnectBssDesc(pMac, sessionId);
2781 }
2782 }
2783 if(NULL == pSession->pConnectBssDesc)
2784 {
2785 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2786 }
2787 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2788 {
2789 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2790 }
2791 }
2792
2793 return (status);
2794}
2795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2797 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2798 tDot11fBeaconIEs *pIes)
2799{
2800 eHalStatus status = eHAL_STATUS_SUCCESS;
2801 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302803 if (pIes == NULL)
2804 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002805
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 do
2807 {
2808 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2809 //get qos
2810 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2811 //get SSID
2812 if(pIes->SSID.present)
2813 {
2814 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2815 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2816 }
2817 else
2818 pBssConfig->SSID.length = 0;
2819 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002821 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 //Return failed if profile doesn't have an SSID either.
2823 if(pProfile->SSIDs.numOfSSIDs == 0)
2824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002825 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 status = eHAL_STATUS_FAILURE;
2827 break;
2828 }
2829 }
2830 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2831 {
2832 pBssConfig->eBand = eCSR_BAND_5G;
2833 }
2834 else
2835 {
2836 pBssConfig->eBand = eCSR_BAND_24;
2837 }
2838 //phymode
2839 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2840 {
2841 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2842 }
2843 else
2844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002845 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 //force it
2847 if(eCSR_BAND_24 == pBssConfig->eBand)
2848 {
2849 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2850 }
2851 else
2852 {
2853 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2854 }
2855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 //Qos
2857 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2858 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2859 {
2860 //Joining BSS is not 11n capable and WMM is disabled on client.
2861 //Disable QoS and WMM
2862 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2863 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302864
2865 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302866 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302867 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2868 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2869 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2870 {
2871 //Joining BSS is 11n capable and WMM is disabled on AP.
2872 //Assume all HT AP's are QOS AP's and enable WMM
2873 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2874 }
2875
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 //auth type
2877 switch( pProfile->negotiatedAuthType )
2878 {
2879 default:
2880 case eCSR_AUTH_TYPE_WPA:
2881 case eCSR_AUTH_TYPE_WPA_PSK:
2882 case eCSR_AUTH_TYPE_WPA_NONE:
2883 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2884 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 case eCSR_AUTH_TYPE_SHARED_KEY:
2887 pBssConfig->authType = eSIR_SHARED_KEY;
2888 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 case eCSR_AUTH_TYPE_AUTOSWITCH:
2890 pBssConfig->authType = eSIR_AUTO_SWITCH;
2891 break;
2892 }
2893 //short slot time
2894 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2895 {
2896 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2897 }
2898 else
2899 {
2900 pBssConfig->uShortSlotTime = 0;
2901 }
2902 if(pBssConfig->BssCap.ibss)
2903 {
2904 //We don't support 11h on IBSS
2905 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2906 }
2907 else
2908 {
2909 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2910 }
2911 //power constraint
2912 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2913 //heartbeat
2914 if ( CSR_IS_11A_BSS( pBssDesc ) )
2915 {
2916 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2917 }
2918 else
2919 {
2920 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2921 }
2922 //Join timeout
2923 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002924 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 if ( pBssDesc->beaconInterval )
2926 {
2927 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002928 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 }
2930 else
2931 {
2932 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2933 }
2934 //validate CB
2935 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2936 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 return (status);
2938}
2939
Jeff Johnson295189b2012-06-20 16:38:30 -07002940static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2941 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2942{
2943 eHalStatus status = eHAL_STATUS_SUCCESS;
2944 tANI_U8 operationChannel = 0;
2945 tANI_U8 qAPisEnabled = FALSE;
2946 //SSID
2947 pBssConfig->SSID.length = 0;
2948 if(pProfile->SSIDs.numOfSSIDs)
2949 {
2950 //only use the first one
2951 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2952 }
2953 else
2954 {
2955 //SSID must present
2956 return eHAL_STATUS_FAILURE;
2957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 //Settomg up the capabilities
2959 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2960 {
2961 pBssConfig->BssCap.ibss = 1;
2962 }
2963 else
2964 {
2965 pBssConfig->BssCap.ess = 1;
2966 }
2967 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2968 {
2969 pBssConfig->BssCap.privacy = 1;
2970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 pBssConfig->eBand = pMac->roam.configParam.eBand;
2972 //phymode
2973 if(pProfile->ChannelInfo.ChannelList)
2974 {
2975 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2978 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 //QOS
2980 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 if ( pBssConfig->BssCap.ess == 1 )
2982 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 /*For Softap case enable WMM*/
2984 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2985 qAPisEnabled = TRUE;
2986 }
2987 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2989 qAPisEnabled = TRUE;
2990 } else {
2991 qAPisEnabled = FALSE;
2992 }
2993 } else {
2994 qAPisEnabled = TRUE;
2995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2997 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2998 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2999 )
3000 {
3001 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3002 } else {
3003 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3004 }
3005
3006 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003007 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 {
3009 default:
3010 case eCSR_AUTH_TYPE_WPA:
3011 case eCSR_AUTH_TYPE_WPA_PSK:
3012 case eCSR_AUTH_TYPE_WPA_NONE:
3013 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3014 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3015 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 case eCSR_AUTH_TYPE_SHARED_KEY:
3017 pBssConfig->authType = eSIR_SHARED_KEY;
3018 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 case eCSR_AUTH_TYPE_AUTOSWITCH:
3020 pBssConfig->authType = eSIR_AUTO_SWITCH;
3021 break;
3022 }
3023 //short slot time
3024 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3025 {
3026 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3027 }
3028 else
3029 {
3030 pBssConfig->uShortSlotTime = 0;
3031 }
3032 //power constraint. We don't support 11h on IBSS
3033 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3034 pBssConfig->uPowerLimit = 0;
3035 //heartbeat
3036 if ( eCSR_BAND_5G == pBssConfig->eBand )
3037 {
3038 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3039 }
3040 else
3041 {
3042 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3043 }
3044 //Join timeout
3045 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003046
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 return (status);
3048}
Jeff Johnson295189b2012-06-20 16:38:30 -07003049static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3050{
3051 eHalStatus status = eHAL_STATUS_FAILURE;
3052 tDot11fBeaconIEs *pIes = NULL;
3053
3054 do
3055 {
3056 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3057 {
3058 //err msg
3059 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003060 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 break;
3062 }
3063 //check if the AP is QAP & it supports APSD
3064 if( CSR_IS_QOS_BSS(pIes) )
3065 {
3066 return eHAL_STATUS_SUCCESS;
3067 }
3068 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 return status;
3070}
3071
Jeff Johnson295189b2012-06-20 16:38:30 -07003072void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3073{
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3075 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3076 // See !!Note: below in this function...
3077 tANI_U32 PrivacyEnabled = 0;
3078 tANI_U32 RsnEnabled = 0;
3079 tANI_U32 WepDefaultKeyId = 0;
3080 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3081 tANI_U32 Key0Length = 0;
3082 tANI_U32 Key1Length = 0;
3083 tANI_U32 Key2Length = 0;
3084 tANI_U32 Key3Length = 0;
3085
3086 // Reserve for the biggest key
3087 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3088 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3089 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3090 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3091
3092 switch ( pProfile->negotiatedUCEncryptionType )
3093 {
3094 case eCSR_ENCRYPT_TYPE_NONE:
3095
3096 // for NO encryption, turn off Privacy and Rsn.
3097 PrivacyEnabled = 0;
3098 RsnEnabled = 0;
3099
3100 // WEP key length and Wep Default Key ID don't matter in this case....
3101
3102 // clear out the WEP keys that may be hanging around.
3103 Key0Length = 0;
3104 Key1Length = 0;
3105 Key2Length = 0;
3106 Key3Length = 0;
3107
3108 break;
3109
3110 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303111 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003112
3113 // Privacy is ON. NO RSN for Wep40 static key.
3114 PrivacyEnabled = 1;
3115 RsnEnabled = 0;
3116
3117 // Set the Wep default key ID.
3118 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 // Wep key size if 5 bytes (40 bits).
3120 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3121
3122 // set encryption keys in the CFG database or clear those that are not present in this profile.
3123 if ( pProfile->Keys.KeyLength[0] )
3124 {
3125 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
3126 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3127 }
3128 else
3129 {
3130 Key0Length = 0;
3131 }
3132
3133 if ( pProfile->Keys.KeyLength[1] )
3134 {
3135 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
3136 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3137 }
3138 else
3139 {
3140 Key1Length = 0;
3141 }
3142
3143 if ( pProfile->Keys.KeyLength[2] )
3144 {
3145 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
3146 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3147 }
3148 else
3149 {
3150 Key2Length = 0;
3151 }
3152
3153 if ( pProfile->Keys.KeyLength[3] )
3154 {
3155 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
3156 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3157 }
3158 else
3159 {
3160 Key3Length = 0;
3161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 break;
3163
3164 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303165 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003166
3167 // Privacy is ON. NO RSN for Wep40 static key.
3168 PrivacyEnabled = 1;
3169 RsnEnabled = 0;
3170
3171 // Set the Wep default key ID.
3172 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3173
3174 // Wep key size if 13 bytes (104 bits).
3175 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3176
3177 // set encryption keys in the CFG database or clear those that are not present in this profile.
3178 if ( pProfile->Keys.KeyLength[0] )
3179 {
3180 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3181 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3182 }
3183 else
3184 {
3185 Key0Length = 0;
3186 }
3187
3188 if ( pProfile->Keys.KeyLength[1] )
3189 {
3190 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3191 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3192 }
3193 else
3194 {
3195 Key1Length = 0;
3196 }
3197
3198 if ( pProfile->Keys.KeyLength[2] )
3199 {
3200 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3201 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3202 }
3203 else
3204 {
3205 Key2Length = 0;
3206 }
3207
3208 if ( pProfile->Keys.KeyLength[3] )
3209 {
3210 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3211 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3212 }
3213 else
3214 {
3215 Key3Length = 0;
3216 }
3217
3218 break;
3219
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 case eCSR_ENCRYPT_TYPE_TKIP:
3221 case eCSR_ENCRYPT_TYPE_AES:
3222#ifdef FEATURE_WLAN_WAPI
3223 case eCSR_ENCRYPT_TYPE_WPI:
3224#endif /* FEATURE_WLAN_WAPI */
3225 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3226 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3227 PrivacyEnabled = (0 != fPrivacy);
3228
3229 // turn on RSN enabled for WPA associations
3230 RsnEnabled = 1;
3231
3232 // WEP key length and Wep Default Key ID don't matter in this case....
3233
3234 // clear out the static WEP keys that may be hanging around.
3235 Key0Length = 0;
3236 Key1Length = 0;
3237 Key2Length = 0;
3238 Key3Length = 0;
3239
3240 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 default:
3242 PrivacyEnabled = 0;
3243 RsnEnabled = 0;
3244 break;
3245 }
3246
3247 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3248 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3249 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3250 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3251 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3252 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3253 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3254 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3255}
3256
Jeff Johnson295189b2012-06-20 16:38:30 -07003257static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3258{
3259 tANI_U32 len = 0;
3260 if(pSSID->length <= WNI_CFG_SSID_LEN)
3261 {
3262 len = pSSID->length;
3263 }
3264 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3265}
3266
Jeff Johnson295189b2012-06-20 16:38:30 -07003267eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3268{
3269 eHalStatus status = eHAL_STATUS_SUCCESS;
3270 tANI_U32 QoSEnabled;
3271 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 // set the CFG enable/disable variables based on the qosType being configured...
3273 switch( qosType )
3274 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3276 QoSEnabled = FALSE;
3277 WmeEnabled = TRUE;
3278 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3280 QoSEnabled = FALSE;
3281 WmeEnabled = TRUE;
3282 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3284 QoSEnabled = FALSE;
3285 WmeEnabled = TRUE;
3286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3288 QoSEnabled = TRUE;
3289 WmeEnabled = FALSE;
3290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 case eCSR_MEDIUM_ACCESS_11e_HCF:
3292 QoSEnabled = TRUE;
3293 WmeEnabled = FALSE;
3294 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 default:
3296 case eCSR_MEDIUM_ACCESS_DCF:
3297 QoSEnabled = FALSE;
3298 WmeEnabled = FALSE;
3299 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 }
3301 //save the WMM setting for later use
3302 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3304 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 return (status);
3306}
Jeff Johnson295189b2012-06-20 16:38:30 -07003307static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3308 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3309{
3310 eHalStatus status = eHAL_STATUS_FAILURE;
3311 int i;
3312 eCsrCfgDot11Mode cfgDot11Mode;
3313 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3315 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003317
3318 if( NULL != pIes )
3319 {
3320 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 // Originally, we thought that for 11a networks, the 11a rates are always
3322 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3323 // appear in the Operational Rate set. Consequently, in either case, we
3324 // would blindly put the rates we support into our Operational Rate set
3325 // (including the basic rates, which we have already verified are
3326 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 // However, it turns out that this is not always the case. Some AP's
3328 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3329 // too. Now, we're a little more careful:
3330 pDstRate = pOpRateSet->rate;
3331 if(pIes->SuppRates.present)
3332 {
3333 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3334 {
3335 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3336 {
3337 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003338 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 }
3340 }
3341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3343 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3344 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3345 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3346 {
3347 // If there are Extended Rates in the beacon, we will reflect those
3348 // extended rates that we support in out Extended Operational Rate
3349 // set:
3350 pDstRate = pExRateSet->rate;
3351 if(pIes->ExtSuppRates.present)
3352 {
3353 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3354 {
3355 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3356 {
3357 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3358 pExRateSet->numRates++;
3359 }
3360 }
3361 }
3362 }
3363 }//Parsing BSSDesc
3364 else
3365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003366 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 }
3368 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3369 return status;
3370}
3371
3372static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3373 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3374{
3375 int i;
3376 tANI_U8 *pDstRate;
3377 eCsrCfgDot11Mode cfgDot11Mode;
3378 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3379 tANI_U32 OperationalRatesLength = 0;
3380 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3381 tANI_U32 ExtendedOperationalRatesLength = 0;
3382 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3383 tANI_U32 ProprietaryOperationalRatesLength = 0;
3384 tANI_U32 PropRatesEnable = 0;
3385 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3386 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 if( NULL != pIes )
3389 {
3390 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 // Originally, we thought that for 11a networks, the 11a rates are always
3392 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3393 // appear in the Operational Rate set. Consequently, in either case, we
3394 // would blindly put the rates we support into our Operational Rate set
3395 // (including the basic rates, which we have already verified are
3396 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 // However, it turns out that this is not always the case. Some AP's
3398 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3399 // too. Now, we're a little more careful:
3400 pDstRate = OperationalRates;
3401 if(pIes->SuppRates.present)
3402 {
3403 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3404 {
3405 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3406 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3407 {
3408 *pDstRate++ = pIes->SuppRates.rates[ i ];
3409 OperationalRatesLength++;
3410 }
3411 }
3412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3414 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3415 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3416 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3417 {
3418 // If there are Extended Rates in the beacon, we will reflect those
3419 // extended rates that we support in out Extended Operational Rate
3420 // set:
3421 pDstRate = ExtendedOperationalRates;
3422 if(pIes->ExtSuppRates.present)
3423 {
3424 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3425 {
3426 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3427 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3428 {
3429 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3430 ExtendedOperationalRatesLength++;
3431 }
3432 }
3433 }
3434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 // Enable proprietary MAC features if peer node is Airgo node and STA
3436 // user wants to use them
3437 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3438 {
3439 PropRatesEnable = 1;
3440 }
3441 else
3442 {
3443 PropRatesEnable = 0;
3444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 // For ANI network companions, we need to populate the proprietary rate
3446 // set with any proprietary rates we found in the beacon, only if user
3447 // allows them...
3448 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3449 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3450 {
3451 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3452 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3453 {
3454 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3455 }
3456 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3457 }
3458 else {
3459 // No proprietary modes...
3460 ProprietaryOperationalRatesLength = 0;
3461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 /* Get MCS Rate */
3463 pDstRate = MCSRateIdxSet;
3464 if ( pIes->HTCaps.present )
3465 {
3466 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3467 {
3468 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3469 {
3470 MCSRateLength++;
3471 *pDstRate++ = i;
3472 }
3473 }
3474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 // Set the operational rate set CFG variables...
3476 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3477 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3478 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3479 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3480 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3481 ProprietaryOperationalRates,
3482 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3483 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3484 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3485 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3486 }//Parsing BSSDesc
3487 else
3488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003489 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 }
3491}
3492
Jeff Johnson295189b2012-06-20 16:38:30 -07003493static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3494 tCsrRoamProfile *pProfile )
3495{
3496 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3497 { 8,
3498 { SIR_MAC_RATE_6,
3499 SIR_MAC_RATE_9,
3500 SIR_MAC_RATE_12,
3501 SIR_MAC_RATE_18,
3502 SIR_MAC_RATE_24,
3503 SIR_MAC_RATE_36,
3504 SIR_MAC_RATE_48,
3505 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3507 { 4,
3508 { SIR_MAC_RATE_1,
3509 SIR_MAC_RATE_2,
3510 SIR_MAC_RATE_5_5,
3511 SIR_MAC_RATE_11 } } };
3512
3513
3514 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3515 { SIR_MAC_RATE_72,
3516 SIR_MAC_RATE_96,
3517 SIR_MAC_RATE_108 } };
3518 eCsrCfgDot11Mode cfgDot11Mode;
3519 eCsrBand eBand;
3520 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3521 tANI_U32 OperationalRatesLength = 0;
3522 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3523 tANI_U32 ExtendedOperationalRatesLength = 0;
3524 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3525 tANI_U32 ProprietaryOperationalRatesLength = 0;
3526 tANI_U32 PropRatesEnable = 0;
3527 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 if(pProfile->ChannelInfo.ChannelList)
3529 {
3530 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3534 // networks, the 11b rates appear in the Operational Rate set. In either case,
3535 // we can blindly put the rates we support into our Operational Rate set
3536 // (including the basic rates, which we have already verified are supported
3537 // earlier in the roaming decision).
3538 if ( eCSR_BAND_5G == eBand )
3539 {
3540 // 11a rates into the Operational Rate Set.
3541 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3542 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3543 palCopyMemory( pMac->hHdd, OperationalRates,
3544 DefaultSupportedRates11a.supportedRateSet.rate,
3545 OperationalRatesLength );
3546
3547 // Nothing in the Extended rate set.
3548 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 // populate proprietary rates if user allows them
3550 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3551 {
3552 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3553 sizeof(*DefaultSupportedPropRates.propRate);
3554 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3555 DefaultSupportedPropRates.propRate,
3556 ProprietaryOperationalRatesLength );
3557 }
3558 else
3559 {
3560 // No proprietary modes
3561 ProprietaryOperationalRatesLength = 0;
3562 }
3563 }
3564 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3565 {
3566 // 11b rates into the Operational Rate Set.
3567 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3568 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3569 palCopyMemory( pMac->hHdd, OperationalRates,
3570 DefaultSupportedRates11b.supportedRateSet.rate,
3571 OperationalRatesLength );
3572 // Nothing in the Extended rate set.
3573 ExtendedOperationalRatesLength = 0;
3574 // No proprietary modes
3575 ProprietaryOperationalRatesLength = 0;
3576 }
3577 else
3578 {
3579 // 11G
3580
3581 // 11b rates into the Operational Rate Set.
3582 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3583 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3584 palCopyMemory( pMac->hHdd, OperationalRates,
3585 DefaultSupportedRates11b.supportedRateSet.rate,
3586 OperationalRatesLength );
3587
3588 // 11a rates go in the Extended rate set.
3589 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3590 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3591 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3592 DefaultSupportedRates11a.supportedRateSet.rate,
3593 ExtendedOperationalRatesLength );
3594
3595 // populate proprietary rates if user allows them
3596 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3597 {
3598 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3599 sizeof(*DefaultSupportedPropRates.propRate);
3600 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3601 DefaultSupportedPropRates.propRate,
3602 ProprietaryOperationalRatesLength );
3603 }
3604 else
3605 {
3606 // No proprietary modes
3607 ProprietaryOperationalRatesLength = 0;
3608 }
3609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3611 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3612 {
3613 PropRatesEnable = 1;
3614 }
3615 else
3616 {
3617 PropRatesEnable = 0;
3618 }
3619
3620 // Set the operational rate set CFG variables...
3621 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3622 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3623 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3624 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3625 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3626 ProprietaryOperationalRates,
3627 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3628 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629}
Jeff Johnson295189b2012-06-20 16:38:30 -07003630void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3631{
3632 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003633
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3635 tANI_U32 sessionId;
3636 tSmeCmd *pCommand = NULL;
3637
3638 if(NULL == pEntry)
3639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003640 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 return;
3642 }
3643 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3644 sessionId = pCommand->sessionId;
3645
3646 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3647 {
3648 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3649 }
3650}
3651
Jeff Johnson295189b2012-06-20 16:38:30 -07003652//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3653tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3654{
3655 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3656 {
3657 return (WNI_CFG_PHY_MODE_11B);
3658 }
3659 else
3660 {
3661 if(eCSR_BAND_24 == band)
3662 return (WNI_CFG_PHY_MODE_11G);
3663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 return (WNI_CFG_PHY_MODE_11A);
3665}
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
Jeff Johnsone7245742012-09-05 17:12:55 -07003667
3668#ifdef WLAN_FEATURE_11AC
3669ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3670{
3671 switch ( aniCBMode )
3672 {
3673 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3674 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3675 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3676 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3677 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3678 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3679 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3680 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3681 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003682 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003683 return PHY_SINGLE_CHANNEL_CENTERED;
3684 }
3685}
3686#endif
3687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688//pIes may be NULL
3689eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3690 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3691 tDot11fBeaconIEs *pIes)
3692{
3693 eHalStatus status = eHAL_STATUS_SUCCESS;
3694 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3695 tANI_U8 channel = 0;
3696 //Make sure we have the domain info for the BSS we try to connect to.
3697 //Do we need to worry about sequence for OSs that are not Windows??
3698 if(pBssDesc)
3699 {
3700 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3701 {
3702 //Make sure the 11d info from this BSSDesc can be applied
3703 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3704 csrApplyCountryInformation( pMac, TRUE );
3705 }
Kiran4a17ebe2013-01-31 10:43:43 -08003706 if ((csrIs11dSupported (pMac)) && pIes)
3707 {
3708 if (!pIes->Country.present)
3709 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 //Qos
3713 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3714 //SSID
3715 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3716 //fragment threshold
3717 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3718 //RTS threshold
3719 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3720
3721 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3722
3723 //Auth type
3724 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3725 //encryption type
3726 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3727 //short slot time
3728 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 //11d
3730 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3731 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3732 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 /*//11h
3734 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3735 */
3736 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3737 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003738
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003739 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 {
3741 channel = pProfile->operationChannel;
3742 }
3743 else
3744 {
3745 if(pBssDesc)
3746 {
3747 channel = pBssDesc->channelId;
3748 }
3749 }
3750 if(0 != channel)
3751 {
3752 if(CSR_IS_CHANNEL_24GHZ(channel))
3753 {//for now if we are on 2.4 Ghz, CB will be always disabled
3754 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3755 }
3756 else
3757 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003758 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 }
3760 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003761#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003762 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3763 // in function csrConvertCBIniValueToPhyCBState()
3764 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3765 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003766 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003767 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003768 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003769 }
3770 else
3771 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003772 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003773 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003774 }
3775 else
3776#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3778 //Rate
3779 //Fixed Rate
3780 if(pBssDesc)
3781 {
3782 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3783 }
3784 else
3785 {
3786 csrSetCfgRateSetFromProfile(pMac, pProfile);
3787 }
3788 //Make this the last CFG to set. The callback will trigger a join_req
3789 //Join time out
3790 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3791
3792 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 return (status);
3794}
3795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3797 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3798{
3799 eHalStatus status;
3800 tBssConfigParam *pBssConfig;
3801 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003802
3803 if(!pSession)
3804 {
3805 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3806 return eHAL_STATUS_FAILURE;
3807 }
3808
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3810 if(HAL_STATUS_SUCCESS(status))
3811 {
3812 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3813 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3814 if(HAL_STATUS_SUCCESS(status))
3815 {
3816 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003817 /* This will allow to pass cbMode during join req */
3818 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 //For IBSS, we need to prepare some more information
3820 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 )
3823 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003824 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 }
3826 // If we are in an IBSS, then stop the IBSS...
3827 ////Not worry about WDS connection for now
3828 if ( csrIsConnStateIbss( pMac, sessionId ) )
3829 {
3830 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3831 }
3832 else
3833 {
3834 // if we are in an Infrastructure association....
3835 if ( csrIsConnStateInfra( pMac, sessionId ) )
3836 {
3837 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3838 // across SSIDs (roaming to a new SSID)... //
3839 //Not worry about WDS connection for now
3840 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3841 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3842 {
3843 // then we need to disassociate from the Infrastructure network...
3844 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3845 }
3846 else
3847 {
3848 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3849 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3850 if ( pBssDesc )
3851 {
3852 // Set parameters for this Bss.
3853 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3854 }
3855 }
3856 }
3857 else
3858 {
3859 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3860 // Nothing to stop.
3861 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 )
3864 {
3865 // Set parameters for this Bss.
3866 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3867 }
3868 }
3869 }
3870 }//Success getting BSS config info
3871 palFreeMemory(pMac->hHdd, pBssConfig);
3872 }//Allocate memory
3873
3874 return (status);
3875}
3876
Jeff Johnson295189b2012-06-20 16:38:30 -07003877eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3878 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3879{
3880 eCsrJoinState eRoamState = eCsrContinueRoaming;
3881 eHalStatus status;
3882 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3883 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3884 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003885
3886 if(!pSession)
3887 {
3888 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3889 return (eCsrStopRoaming);
3890 }
3891
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 if( CSR_IS_WDS_STA( pProfile ) )
3893 {
3894 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3895 if( !HAL_STATUS_SUCCESS( status ) )
3896 {
3897 eRoamState = eCsrStopRoaming;
3898 }
3899 }
3900 else
3901 {
3902 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3903 {
3904 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3905 return (eCsrStopRoaming);
3906 }
3907 if ( csrIsInfraBssDesc( pBssDesc ) )
3908 {
3909 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3910 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3911 // have changed and handle the changes (without disturbing the current association).
3912
3913 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3914 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3915 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3916 )
3917 {
3918 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3919 // with Authenticating first. To force this, stop the current association (Disassociate) and
3920 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3921 // a new Association.
3922 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003924 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3926 {
3927 eRoamState = eCsrReassocToSelfNoCapChange;
3928 }
3929 else
3930 {
3931 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 //The key changes
3933 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3934 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3935 if(HAL_STATUS_SUCCESS(status))
3936 {
3937 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003938 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 //Reapply the config including Keys so reassoc is happening.
3940 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3941 if(!HAL_STATUS_SUCCESS(status))
3942 {
3943 eRoamState = eCsrStopRoaming;
3944 }
3945 }
3946 else
3947 {
3948 eRoamState = eCsrStopRoaming;
3949 }
3950 }//same profile
3951 }
3952 else
3953 {
3954 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3955 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003957 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 eRoamState = eCsrStopRoaming;
3959 }
3960 }
3961 }
3962 else
3963 {
3964 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3965 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3966 // work much better.
3967 //
3968 //
3969 // stop the existing network before attempting to join the new network...
3970 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3971 {
3972 eRoamState = eCsrStopRoaming;
3973 }
3974 }
3975 }//Infra
3976 else
3977 {
3978 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3979 {
3980 eRoamState = eCsrStopRoaming;
3981 }
3982 }
3983 if( pIesLocal && !pScanResult->pvIes )
3984 {
3985 palFreeMemory(pMac->hHdd, pIesLocal);
3986 }
3987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 return( eRoamState );
3989}
3990
Jeff Johnson295189b2012-06-20 16:38:30 -07003991eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3992 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3993{
3994 eHalStatus status = eHAL_STATUS_SUCCESS;
3995 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3997 roamInfo.pBssDesc = pBssDesc;
3998 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3999 return (status);
4000}
Jeff Johnson295189b2012-06-20 16:38:30 -07004001//In case no matching BSS is found, use whatever default we can find
4002static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4003{
4004 //Need to get all negotiated types in place first
4005 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004006 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 {
4008 default:
4009 case eCSR_AUTH_TYPE_WPA:
4010 case eCSR_AUTH_TYPE_WPA_PSK:
4011 case eCSR_AUTH_TYPE_WPA_NONE:
4012 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4013 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4014 break;
4015
4016 case eCSR_AUTH_TYPE_SHARED_KEY:
4017 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4018 break;
4019
4020 case eCSR_AUTH_TYPE_AUTOSWITCH:
4021 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4022 break;
4023 }
4024 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4025 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4026 //In this case, the multicast encryption needs to follow the uncast ones.
4027 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4028 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4029}
4030
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004031
4032static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4033{
4034 switch(pCommand->u.roamCmd.roamReason)
4035 {
4036 case eCsrLostLink1:
4037 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4038 break;
4039 case eCsrLostLink2:
4040 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4041 break;
4042 case eCsrLostLink3:
4043 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4044 break;
4045 default:
4046 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4047 pCommand->u.roamCmd.roamReason);
4048 break;
4049 }
4050}
4051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4053{
4054 eHalStatus status;
4055 tCsrScanResult *pScanResult = NULL;
4056 eCsrJoinState eRoamState = eCsrStopRoaming;
4057 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4058 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4059 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4060#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4061 v_U8_t acm_mask = 0;
4062#endif
4063 tANI_U32 sessionId = pCommand->sessionId;
4064 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4065 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4066 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004067
4068 if(!pSession)
4069 {
4070 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4071 return (eCsrStopRoaming);
4072 }
4073
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 do
4075 {
4076 // Check for Cardbus eject condition, before trying to Roam to any BSS
4077 //***if( !balIsCardPresent(pAdapter) ) break;
4078
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004079 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4080 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 if(NULL != pBSSList)
4082 {
4083 // When handling AP's capability change, continue to associate to
4084 // same BSS and make sure pRoamBssEntry is not Null.
4085 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4086 {
4087 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4088 {
4089 //Try the first BSS
4090 pCommand->u.roamCmd.pLastRoamBss = NULL;
4091 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4092 }
4093 else
4094 {
4095 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4096 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4097 {
4098 //Done with all the BSSs
4099 //In this case, will tell HDD the completion
4100 break;
4101 }
4102 else
4103 {
4104 //We need to indicate to HDD that we are done with this one.
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004105 //palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4107 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4108 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4109 pRoamInfo = &roamInfo;
4110 }
4111 }
4112 while(pCommand->u.roamCmd.pRoamBssEntry)
4113 {
4114 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 /*If concurrency enabled take the concurrent connected channel first. */
4116 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004117 if (vos_concurrent_sessions_running() &&
4118 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 {
4120 concurrentChannel =
4121 csrGetConcurrentOperationChannel(pMac);
4122 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004123 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 if ((concurrentChannel) &&
4125 (concurrentChannel ==
4126 pScanResult->Result.BssDescriptor.channelId))
4127 {
4128 //make this 0 because we do not want the
4129 //below check to pass as we don't want to
4130 //connect on other channel
4131 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4132 FL("Concurrent channel match =%d"),
4133 concurrentChannel);
4134 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 }
4136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004137
4138 if (!concurrentChannel)
4139 {
4140
4141 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4142 sessionId, &pScanResult->Result.BssDescriptor,
4143 pCommand->u.roamCmd.roamId)))
4144 {
4145 //Ok to roam this
4146 break;
4147 }
4148 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004149 else
4150 {
4151 eRoamState = eCsrStopRoamingDueToConcurrency;
4152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4154 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4155 {
4156 //Done with all the BSSs
4157 fDone = eANI_BOOLEAN_TRUE;
4158 break;
4159 }
4160 }
4161 if(fDone)
4162 {
4163 break;
4164 }
4165 }
4166 }
4167 //We have something to roam, tell HDD when it is infra.
4168 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4169 //For WDS, the indication is eCSR_ROAM_WDS_IND
4170 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4171 {
4172 if(pRoamInfo)
4173 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004174 if(pSession->bRefAssocStartCnt)
4175 {
4176 pSession->bRefAssocStartCnt--;
4177 //Complete the last association attemp because a new one is about to be tried
4178 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4179 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004181 }
4182 }
4183 /* If the roaming has stopped, not to continue the roaming command*/
4184 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4185 {
4186 //No need to complete roaming here as it already completes
4187 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4188 pCommand->u.roamCmd.roamReason);
4189 eRoamState = eCsrStopRoaming;
4190 csrSetAbortRoamingCommand(pMac, pCommand);
4191 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 }
4193 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4194 if(pScanResult)
4195 {
4196 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4198 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004199 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 fDone = eANI_BOOLEAN_TRUE;
4201 eRoamState = eCsrStopRoaming;
4202 break;
4203 }
4204 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4205 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4206 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4207 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4208 CSR_IS_QOS_BSS(pIesLocal) &&
4209 CSR_IS_UAPSD_BSS(pIesLocal) )
4210 {
4211#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4213 pIesLocal);
4214 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4215#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 }
4217 else
4218 {
4219 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4220 }
4221 if( pIesLocal && !pScanResult->Result.pvIes)
4222 {
4223 palFreeMemory(pMac->hHdd, pIesLocal);
4224 }
4225 }
4226 else
4227 {
4228 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4229 }
4230 roamInfo.pProfile = pProfile;
4231 pSession->bRefAssocStartCnt++;
4232 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4233 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4236 {
4237 // If this is a start IBSS profile, then we need to start the IBSS.
4238 if ( CSR_IS_START_IBSS(pProfile) )
4239 {
4240 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 // Attempt to start this IBSS...
4242 csrRoamAssignDefaultParam( pMac, pCommand );
4243 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4244 if(HAL_STATUS_SUCCESS(status))
4245 {
4246 if ( fSameIbss )
4247 {
4248 eRoamState = eCsrStartIbssSameIbss;
4249 }
4250 else
4251 {
4252 eRoamState = eCsrContinueRoaming;
4253 }
4254 }
4255 else
4256 {
4257 //it somehow fail need to stop
4258 eRoamState = eCsrStopRoaming;
4259 }
4260 break;
4261 }
4262 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 )
4265 {
4266 // Attempt to start this WDS...
4267 csrRoamAssignDefaultParam( pMac, pCommand );
4268 /* For AP WDS, we dont have any BSSDescription */
4269 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4270 if(HAL_STATUS_SUCCESS(status))
4271 {
4272 eRoamState = eCsrContinueRoaming;
4273 }
4274 else
4275 {
4276 //it somehow fail need to stop
4277 eRoamState = eCsrStopRoaming;
4278 }
4279 }
4280 else
4281 {
4282 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004283 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 eRoamState = eCsrStopRoaming;
4285 break;
4286 }
4287 }
4288 else //We have BSS
4289 {
4290 //Need to assign these value because they are used in csrIsSameProfile
4291 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4292 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4293 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4294 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4295 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4296 {
4297 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4298 {
4299 eRoamState = eCsrStartIbssSameIbss;
4300 break;
4301 }
4302 }
4303 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4304 {
4305 //trying to connect to the one already connected
4306 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4307 eRoamState = eCsrReassocToSelfNoCapChange;
4308 break;
4309 }
4310 // Attempt to Join this Bss...
4311 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4312 break;
4313 }
4314
4315 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4317 {
4318 //Need to indicate association_completion if association_start has been done
4319 if(pSession->bRefAssocStartCnt > 0)
4320 {
4321 pSession->bRefAssocStartCnt--;
4322 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004323 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4325 eCSR_ROAM_ASSOCIATION_COMPLETION,
4326 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4327 }
4328 }
4329
4330 return( eRoamState );
4331}
4332
Jeff Johnson295189b2012-06-20 16:38:30 -07004333static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4334{
4335 eHalStatus status = eHAL_STATUS_SUCCESS;
4336 eCsrJoinState RoamState;
4337 tANI_U32 sessionId = pCommand->sessionId;
4338
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 //***if( hddIsRadioStateOn( pAdapter ) )
4340 {
4341 // Attept to join a Bss...
4342 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004343
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004345 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 {
4347 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 // and if connected in Infrastructure mode...
4349 if ( csrIsConnStateInfra(pMac, sessionId) )
4350 {
4351 //... then we need to issue a disassociation
4352 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4353 if(!HAL_STATUS_SUCCESS(status))
4354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004355 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 //roam command is completed by caller in the failed case
4357 fComplete = eANI_BOOLEAN_TRUE;
4358 }
4359 }
4360 else if( csrIsConnStateIbss(pMac, sessionId) )
4361 {
4362 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4363 if(!HAL_STATUS_SUCCESS(status))
4364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004365 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 //roam command is completed by caller in the failed case
4367 fComplete = eANI_BOOLEAN_TRUE;
4368 }
4369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4371 {
4372 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4373 if(!HAL_STATUS_SUCCESS(status))
4374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004375 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 //roam command is completed by caller in the failed case
4377 fComplete = eANI_BOOLEAN_TRUE;
4378 }
4379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 else
4381 {
4382 fComplete = eANI_BOOLEAN_TRUE;
4383 }
4384 if(fComplete)
4385 {
4386 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004387 if(eCsrStopRoamingDueToConcurrency == RoamState)
4388 {
4389 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4390 }
4391 else
4392 {
4393 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 }
4396 }
4397 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4398 {
4399 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4400 }
4401 else if ( eCsrStartIbssSameIbss == RoamState )
4402 {
4403 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4404 }
4405 }//hddIsRadioStateOn
4406
4407 return status;
4408}
Jeff Johnson295189b2012-06-20 16:38:30 -07004409eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4410{
4411 tANI_U32 sessionId;
4412 tCsrRoamSession *pSession;
4413 tCsrScanResult *pScanResult = NULL;
4414 tSirBssDescription *pBssDesc = NULL;
4415 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 sessionId = pCommand->sessionId;
4417 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004418
4419 if(!pSession)
4420 {
4421 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4422 return eHAL_STATUS_FAILURE;
4423 }
4424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4426 {
4427 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004428 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4430 return eHAL_STATUS_FAILURE;
4431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 if (pCommand->u.roamCmd.pRoamBssEntry)
4433 {
4434 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4435 pBssDesc = &pScanResult->Result.BssDescriptor;
4436 }
4437 else
4438 {
4439 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004440 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4442 return eHAL_STATUS_FAILURE;
4443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4445 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4446 return status;
4447}
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4450{
4451 eHalStatus status = eHAL_STATUS_SUCCESS;
4452 tCsrRoamInfo roamInfo;
4453 tANI_U32 sessionId = pCommand->sessionId;
4454 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004455
4456 if(!pSession)
4457 {
4458 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4459 return eHAL_STATUS_FAILURE;
4460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004461
4462 switch ( pCommand->u.roamCmd.roamReason )
4463 {
4464 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004466 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 case eCsrSmeIssuedDisassocForHandoff:
4469 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4470#if 0 // TODO : Confirm this change
4471 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4472#else
4473 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4474#endif
4475
4476 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004479 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004483 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 case eCsrHddIssuedReassocToSameAP:
4486 case eCsrSmeIssuedReassocToSameAP:
4487 {
4488 tDot11fBeaconIEs *pIes = NULL;
4489
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 if( pSession->pConnectBssDesc )
4491 {
4492 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4493 if(!HAL_STATUS_SUCCESS(status) )
4494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004495 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 }
4497 else
4498 {
4499 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4500 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4501 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4503 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4504 pSession->bRefAssocStartCnt++;
4505 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4506 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4507
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004508 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004509 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4510 &pCommand->u.roamCmd.roamProfile );
4511 if(!HAL_STATUS_SUCCESS(status))
4512 {
4513 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004514 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004515 }
4516
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 palFreeMemory(pMac->hHdd, pIes);
4518 pIes = NULL;
4519 }
4520 }
4521 break;
4522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004524 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4526 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4527 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004529 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4531 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004532
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 case eCsrStopBss:
4534 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4535 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4536 break;
4537
4538 case eCsrForcedDisassocSta:
4539 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4540 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4541 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4542 pCommand->u.roamCmd.reason);
4543 break;
4544
4545 case eCsrForcedDeauthSta:
4546 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4547 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4548 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4549 pCommand->u.roamCmd.reason);
4550 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004551
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004552 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004553 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004554 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4555 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004556 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004557
4558 default:
4559 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4560
4561 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4562 {
4563 //Remember the roaming profile
4564 csrFreeRoamProfile(pMac, sessionId);
4565 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4566 {
4567 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4568 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4569 }
4570 }
4571
4572 //At this point, original uapsd_mask is saved in pCurRoamProfile
4573 //uapsd_mask in the pCommand may change from this point on.
4574
4575 // Attempt to roam with the new scan results (if we need to..)
4576 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004577 if(!HAL_STATUS_SUCCESS(status))
4578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004579 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 break;
4582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 return (status);
4584}
4585
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004586void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4587{
4588 pCommand->u.roamCmd.pLastRoamBss = NULL;
4589 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4590 //Because u.roamCmd is union and share with scanCmd and StatusChange
4591 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4592}
4593
Jeff Johnson295189b2012-06-20 16:38:30 -07004594void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4595{
4596 if(pCommand->u.roamCmd.fReleaseBssList)
4597 {
4598 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4599 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4600 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4601 }
4602 if(pCommand->u.roamCmd.fReleaseProfile)
4603 {
4604 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4605 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4606 }
4607 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4608 //Because u.roamCmd is union and share with scanCmd and StatusChange
4609 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4610}
4611
Jeff Johnson295189b2012-06-20 16:38:30 -07004612void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4613{
4614 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4615}
Jeff Johnson295189b2012-06-20 16:38:30 -07004616void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4617{
4618 tListElem *pEntry;
4619 tSmeCmd *pCommand;
4620 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004621 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4623 if ( pEntry )
4624 {
4625 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 // If the head of the queue is Active and it is a ROAM command, remove
4627 // and put this on the Free queue.
4628 if ( eSmeCommandRoam == pCommand->command )
4629 {
4630 //we need to process the result first before removing it from active list because state changes
4631 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4632 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4633 if( fReleaseCommand )
4634 {
4635 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4636 {
4637 csrReleaseCommandRoam( pMac, pCommand );
4638 }
4639 else
4640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004641 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004642 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 }
4644 }
4645 else
4646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004647 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004648 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 }
4650 }
4651 else
4652 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004653 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 }
4655 }
4656 else
4657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004658 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 if( fReleaseCommand )
4661 {
4662 smeProcessPendingQueue( pMac );
4663 }
4664}
4665
Jeff Johnson295189b2012-06-20 16:38:30 -07004666void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4667{
4668 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004669 if(!pSession)
4670 {
4671 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4672 return;
4673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4675 pSession->NumPmkidCandidate = 0;
4676}
Jeff Johnson295189b2012-06-20 16:38:30 -07004677#ifdef FEATURE_WLAN_WAPI
4678void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4679{
4680 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004681 if(!pSession)
4682 {
4683 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4684 return;
4685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4687 pSession->NumBkidCandidate = 0;
4688}
4689#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004690extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4691
Jeff Johnson295189b2012-06-20 16:38:30 -07004692static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4693 tSirBssDescription *pSirBssDesc,
4694 tDot11fBeaconIEs *pIes)
4695{
4696 eHalStatus status = eHAL_STATUS_SUCCESS;
4697 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4698 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004699
4700 if(!pSession)
4701 {
4702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4703 return eHAL_STATUS_FAILURE;
4704 }
4705
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 if((eCSR_AUTH_TYPE_WPA == authType) ||
4707 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4708 (eCSR_AUTH_TYPE_RSN == authType) ||
4709 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4710#if defined WLAN_FEATURE_VOWIFI_11R
4711 ||
4712 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4713 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4714#endif /* FEATURE_WLAN_WAPI */
4715#ifdef FEATURE_WLAN_WAPI
4716 ||
4717 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4718 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4719#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004720#ifdef WLAN_FEATURE_11W
4721 ||
4722 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4723#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 )
4725 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004728 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 }
4730 if( pIesLocal )
4731 {
4732 tANI_U32 nIeLen;
4733 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 if((eCSR_AUTH_TYPE_RSN == authType) ||
4735#if defined WLAN_FEATURE_VOWIFI_11R
4736 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4737 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4738#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004739#if defined WLAN_FEATURE_11W
4740 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4741#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4743 {
4744 if(pIesLocal->RSN.present)
4745 {
4746 //Calculate the actual length
4747 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4748 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4749 + 2 //akm_suite_count
4750 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4751 + 2; //reserved
4752 if( pIesLocal->RSN.pmkid_count )
4753 {
4754 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4755 }
4756 //nIeLen doesn't count EID and length fields
4757 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4758 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004759 palZeroMemory(pMac->hHdd, pSession->pWpaRsnRspIE, nIeLen + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4761 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4762 //copy upto akm_suites
4763 pIeBuf = pSession->pWpaRsnRspIE + 2;
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004764 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, sizeof(pIesLocal->RSN.version));
4765 pIeBuf += sizeof(pIesLocal->RSN.version);
4766 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.gp_cipher_suite, sizeof(pIesLocal->RSN.gp_cipher_suite));
4767 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
4768 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count, sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
4769 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 if( pIesLocal->RSN.pwise_cipher_suite_count )
4771 {
4772 //copy pwise_cipher_suites
4773 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4774 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4775 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4776 }
4777 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4778 pIeBuf += 2;
4779 if( pIesLocal->RSN.akm_suite_count )
4780 {
4781 //copy akm_suites
4782 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4783 pIesLocal->RSN.akm_suite_count * 4);
4784 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4785 }
4786 //copy the rest
4787 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4788 pIesLocal->RSN.akm_suite_count * 4,
4789 2 + pIesLocal->RSN.pmkid_count * 4);
4790 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4791 }
4792 }
4793 }
4794 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4795 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4796 {
4797 if(pIesLocal->WPA.present)
4798 {
4799 //Calculate the actual length
4800 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4801 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4802 + 2 //auth_suite_count
4803 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4804 // The WPA capabilities follows the Auth Suite (two octects)--
4805 // this field is optional, and we always "send" zero, so just
4806 // remove it. This is consistent with our assumptions in the
4807 // frames compiler; c.f. bug 15234:
4808 //nIeLen doesn't count EID and length fields
4809 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4810 {
4811 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4812 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4813 pIeBuf = pSession->pWpaRsnRspIE + 2;
4814 //Copy WPA OUI
4815 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4816 pIeBuf += 4;
4817 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4818 pIesLocal->WPA.unicast_cipher_count * 4);
4819 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4820 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4821 pIesLocal->WPA.auth_suite_count * 4);
4822 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4823 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4824 }
4825 }
4826 }
4827#ifdef FEATURE_WLAN_WAPI
4828 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4829 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4830 {
4831 if(pIesLocal->WAPI.present)
4832 {
4833 //Calculate the actual length
4834 nIeLen = 4 //version + akm_suite_count
4835 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4836 + 2 //pwise_cipher_suite_count
4837 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4838 + 6; //gp_cipher_suite + preauth + reserved
4839 if( pIesLocal->WAPI.bkid_count )
4840 {
4841 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4842 }
4843
4844 //nIeLen doesn't count EID and length fields
4845 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4846 {
4847 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4848 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4849 pIeBuf = pSession->pWapiRspIE + 2;
4850 //copy upto akm_suite_count
lukez3c809222013-05-03 10:23:02 -07004851 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 pIeBuf += 4;
4853 if( pIesLocal->WAPI.akm_suite_count )
4854 {
4855 //copy akm_suites
4856 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4857 pIesLocal->WAPI.akm_suite_count * 4);
4858 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4859 }
4860 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4861 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4863 {
4864 //copy pwise_cipher_suites
4865 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4866 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4867 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4868 }
lukez3c809222013-05-03 10:23:02 -07004869 //gp_cipher_suite
4870 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite, 4);
4871 //preauth + reserved
4872 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.multicast_cipher_suite + 4, 2);
4873 //bkid_count
4874 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
4875
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 pIeBuf += 8;
4877 if( pIesLocal->WAPI.bkid_count )
4878 {
4879 //copy akm_suites
4880 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4881 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4882 }
4883 pSession->nWapiRspIeLength = nIeLen + 2;
4884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 }
4886 }
4887#endif /* FEATURE_WLAN_WAPI */
4888 if( !pIes )
4889 {
4890 //locally allocated
4891 palFreeMemory(pMac->hHdd, pIesLocal);
4892 }
4893 }
4894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 return (status);
4896}
4897
Jeff Johnson295189b2012-06-20 16:38:30 -07004898static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4899{
4900 v_U8_t bACWeights[WLANTL_MAX_AC];
4901 v_U8_t paramBk, paramBe, paramVi, paramVo;
4902 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4904 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4905 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4906 //This doesn't address the case where the lower AC needs a real higher weight
4907 if( pIEs->WMMParams.present )
4908 {
4909 //no change to the lowest ones
4910 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4911 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4912 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4913 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4914 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4915 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4916 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4917 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4918 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4919 {
4920 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4921 fWeightChange = VOS_TRUE;
4922 }
4923 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4924 {
4925 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4926 fWeightChange = VOS_TRUE;
4927 }
4928 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4929 {
4930 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4931 fWeightChange = VOS_TRUE;
4932 }
4933 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4934 {
4935 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4936 fWeightChange = VOS_TRUE;
4937 }
4938 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4939 {
4940 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4941 fWeightChange = VOS_TRUE;
4942 }
4943 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4944 {
4945 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4946 fWeightChange = VOS_TRUE;
4947 }
4948 if(fWeightChange)
4949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004950 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 bACWeights[2], bACWeights[3]);
4952 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4953 }
4954 }
4955}
Jeff Johnson295189b2012-06-20 16:38:30 -07004956#ifdef WLAN_FEATURE_VOWIFI_11R
4957//Returns whether the current association is a 11r assoc or not
4958tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4959{
4960#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4961 return csrNeighborRoamIs11rAssoc(pMac);
4962#else
4963 return eANI_BOOLEAN_FALSE;
4964#endif
4965}
4966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004967#ifdef FEATURE_WLAN_CCX
4968//Returns whether the current association is a CCX assoc or not
4969tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4970{
4971#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4972 return csrNeighborRoamIsCCXAssoc(pMac);
4973#else
4974 return eANI_BOOLEAN_FALSE;
4975#endif
4976}
4977#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004978#ifdef FEATURE_WLAN_LFR
4979//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304980tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004981{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304982 tCsrRoamSession *pSession = NULL;
4983
4984 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4985 {
4986 pSession = CSR_GET_SESSION( pMac, sessionId );
4987 if (NULL != pSession->pCurRoamProfile)
4988 {
4989 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4990 {
4991 return eANI_BOOLEAN_FALSE;
4992 }
4993 }
4994 }
4995
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07004996#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4997 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
4998 {
4999 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5000 }
5001 else
5002#endif
5003 {
5004 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005005 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005006 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005007}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005008
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005009#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5010//Returns whether "FW based BG scan" is currently enabled...or not
5011tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5012{
5013 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5014}
5015#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005016#endif
5017
Jeff Johnson295189b2012-06-20 16:38:30 -07005018//Return true means the command can be release, else not
5019static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5020 eCsrRoamCompleteResult Result, void *Context )
5021{
5022 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5023 tSirBssDescription *pSirBssDesc = NULL;
5024 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5025 tCsrScanResult *pScanResult = NULL;
5026 tCsrRoamInfo roamInfo;
5027 sme_QosAssocInfo assocInfo;
5028 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5029 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5030 tDot11fBeaconIEs *pIes = NULL;
5031 tANI_U32 sessionId = pCommand->sessionId;
5032 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5033 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5034 eRoamCmdStatus roamStatus;
5035 eCsrRoamResult roamResult;
5036 eHalStatus status;
5037 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005039
Jeff Johnson32d95a32012-09-10 13:15:23 -07005040 if(!pSession)
5041 {
5042 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5043 return eANI_BOOLEAN_FALSE;
5044 }
5045
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005046 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 switch( Result )
5048 {
5049 case eCsrJoinSuccess:
5050 // reset the IDLE timer
5051 // !!
5052 // !! fall through to the next CASE statement here is intentional !!
5053 // !!
5054 case eCsrReassocSuccess:
5055 if(eCsrReassocSuccess == Result)
5056 {
5057 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5058 }
5059 else
5060 {
5061 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5062 }
5063 // Success Join Response from LIM. Tell NDIS we are connected and save the
5064 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005065 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5067 //always free the memory here
5068 if(pSession->pWpaRsnRspIE)
5069 {
5070 pSession->nWpaRsnRspIeLength = 0;
5071 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
5072 pSession->pWpaRsnRspIE = NULL;
5073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005074#ifdef FEATURE_WLAN_WAPI
5075 if(pSession->pWapiRspIE)
5076 {
5077 pSession->nWapiRspIeLength = 0;
5078 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
5079 pSession->pWapiRspIE = NULL;
5080 }
5081#endif /* FEATURE_WLAN_WAPI */
5082#ifdef FEATURE_WLAN_BTAMP_UT_RF
5083 //Reset counter so no join retry is needed.
5084 pSession->maxRetryCount = 0;
5085 csrRoamStopJoinRetryTimer(pMac, sessionId);
5086#endif
5087 /* This creates problem since we have not saved the connected profile.
5088 So moving this after saving the profile
5089 */
5090 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5091 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5092 {
5093 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5094 }
5095 else
5096 {
5097 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 //Use the last connected bssdesc for reassoc-ing to the same AP.
5100 //NOTE: What to do when reassoc to a different AP???
5101 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5102 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5103 {
5104 pSirBssDesc = pSession->pConnectBssDesc;
5105 if(pSirBssDesc)
5106 {
5107 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5108 }
5109 }
5110 else
5111 {
5112
5113 if(pCommand->u.roamCmd.pRoamBssEntry)
5114 {
5115 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5116 if(pScanResult != NULL)
5117 {
5118 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5119 //this can be NULL
5120 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5121 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5122 }
5123 }
5124 }
5125 if( pSirBssDesc )
5126 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5129 //Save WPA/RSN IE
5130 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5131#ifdef FEATURE_WLAN_CCX
5132 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5133#endif
5134
5135 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5136 // substate change.
5137 // Moving even save profile above so that below mentioned conditon is also met.
5138 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5139 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5141 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5142 // will be dropped for the security context may not be set properly.
5143 //
5144 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5145 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5146 //
5147 // this reordering was done on titan_prod_usb branch and is being replicated here.
5148 //
5149
5150 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5151 !pProfile->bWPSAssociation)
5152 {
5153 // Issue the set Context request to LIM to establish the Unicast STA context
5154 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5155 pProfile->negotiatedUCEncryptionType,
5156 pSirBssDesc, &(pSirBssDesc->bssId),
5157 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005159 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5161 }
5162 // Issue the set Context request to LIM to establish the Broadcast STA context
5163 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5164 pSirBssDesc, &BroadcastMac,
5165 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5166 }
5167 else
5168 {
5169 //Need to wait for supplicant authtication
5170 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 //Set the subestate to WaitForKey in case authentiation is needed
5172 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5173
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 if(pProfile->bWPSAssociation)
5175 {
5176 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5177 }
5178 else
5179 {
5180 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5181 }
5182
5183 //Save sessionId in case of timeout
5184 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5185 //This time should be long enough for the rest of the process plus setting key
5186 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5187 {
5188 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005189 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5191 }
5192 }
5193
5194 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5195 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 if(Context)
5197 {
5198 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5199 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5201 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5202#ifdef WLAN_FEATURE_VOWIFI_11R
5203 len += pJoinRsp->parsedRicRspLen;
5204#endif /* WLAN_FEATURE_VOWIFI_11R */
5205#ifdef FEATURE_WLAN_CCX
5206 len += pJoinRsp->tspecIeLen;
5207#endif
5208 if(len)
5209 {
5210 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
5211 (void **)&pSession->connectedInfo.pbFrames, len)))
5212 {
5213 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
5214 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
5215 {
5216 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5217 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5218 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
5219#ifdef WLAN_FEATURE_VOWIFI_11R
5220 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
5221#endif /* WLAN_FEATURE_VOWIFI_11R */
5222#ifdef FEATURE_WLAN_CCX
5223 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
5224#endif
5225 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5226 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5227 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5228 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5229 }
5230 else
5231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005232 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005233 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
5235 pSession->connectedInfo.pbFrames = NULL;
5236 }
5237 }
5238 }
5239 if(pCommand->u.roamCmd.fReassoc)
5240 {
5241 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5242 }
5243 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5244 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5245 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5246 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5247 }
5248 else
5249 {
5250 if(pCommand->u.roamCmd.fReassoc)
5251 {
5252 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5253 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5254 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5255 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5256 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5257 }
5258 }
5259#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5260 // Indicate SME-QOS with reassoc success event, only after
5261 // copying the frames
5262 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 roamInfo.pBssDesc = pSirBssDesc;
5265 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5266 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5267#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5268 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5269#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5270 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5272 //It may be better to let QoS do this????
5273 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005275 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5277 pmcStartUapsd( pMac, NULL, NULL );
5278 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305279 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5281 if( pSession->bRefAssocStartCnt > 0 )
5282 {
5283 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005284 //Remove this code once SLM_Sessionization is supported
5285 //BMPS_WORKAROUND_NOT_NEEDED
5286 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005287 {
5288 pMac->roam.configParam.doBMPSWorkaround = 1;
5289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5291 }
5292
5293 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 // reset the PMKID candidate list
5295 csrResetPMKIDCandidateList( pMac, sessionId );
5296 //Update TL's AC weight base on the current EDCA parameters
5297 //These parameters may change in the course of the connection, that sictuation
5298 //is not taken care here. This change is mainly to address a WIFI WMM test where
5299 //BE has a equal or higher TX priority than VI.
5300 //We only do this for infra link
5301 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5302 {
5303 csrCheckAndUpdateACWeight(pMac, pIes);
5304 }
5305#ifdef FEATURE_WLAN_WAPI
5306 // reset the BKID candidate list
5307 csrResetBKIDCandidateList( pMac, sessionId );
5308#endif /* FEATURE_WLAN_WAPI */
5309 }
5310 else
5311 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005312 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 csrScanCancelIdleScan(pMac);
5315 //Not to signal link up because keys are yet to be set.
5316 //The linkup function will overwrite the sub-state that we need to keep at this point.
5317 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5318 {
5319 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5322 //enough to let security and DHCP handshake succeed before entry into BMPS
5323 if (pmcShouldBmpsTimerRun(pMac))
5324 {
5325 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5326 != eHAL_STATUS_SUCCESS)
5327 {
5328 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5329 }
5330 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 break;
5333
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 case eCsrStartBssSuccess:
5335 // on the StartBss Response, LIM is returning the Bss Description that we
5336 // are beaconing. Add this Bss Description to our scan results and
5337 // chain the Profile to this Bss Description. On a Start BSS, there was no
5338 // detected Bss description (no partner) so we issued the Start Bss to
5339 // start the Ibss without any Bss description. Lim was kind enough to return
5340 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005341 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5345 if( CSR_IS_IBSS( pProfile ) )
5346 {
5347 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 else if (CSR_IS_INFRA_AP(pProfile))
5350 {
5351 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 else
5354 {
5355 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5356 }
5357 if( !CSR_IS_WDS_STA( pProfile ) )
5358 {
5359 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005363 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 roamInfo.pBssDesc = pSirBssDesc;
5365 //We need to associate_complete it first, becasue Associate_start already indicated.
5366 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5367 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5368 break;
5369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005372 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 }
5374 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5375 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5376 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5377 if(pSirBssDesc)
5378 {
5379 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5380 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5381 }
5382 //We are doen with the IEs so free it
5383 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005384#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5385 {
5386 vos_log_ibss_pkt_type *pIbssLog;
5387 tANI_U32 bi;
5388
5389 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5390 if(pIbssLog)
5391 {
5392 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5393 {
5394 //We start the IBSS (didn't find any matched IBSS out there)
5395 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5396 }
5397 else
5398 {
5399 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5400 }
5401 if(pSirBssDesc)
5402 {
5403 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5404 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5405 }
5406 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5407 {
5408 //***U8 is not enough for beacon interval
5409 pIbssLog->beaconInterval = (v_U8_t)bi;
5410 }
5411 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5412 }
5413 }
5414#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5415 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5416 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5418 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5420 csrRoamIssueSetContextReq( pMac, sessionId,
5421 pProfile->negotiatedMCEncryptionType,
5422 pSirBssDesc, &BroadcastMac,
5423 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5424 }
5425 }
5426 else
5427 {
5428 //Keep the state to eCSR_ROAMING_STATE_JOINING
5429 //Need to send join_req.
5430 if(pCommand->u.roamCmd.pRoamBssEntry)
5431 {
5432 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5433 {
5434 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5435 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5436 // Set the roaming substate to 'join attempt'...
5437 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005438 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 }
5440 }
5441 else
5442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005443 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 VOS_ASSERT( 0 );
5445 }
5446 }
5447 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5448 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5449 //trigger the connection start indication in Vista
5450 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5451 {
5452 roamStatus = eCSR_ROAM_IBSS_IND;
5453 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5454 if( CSR_IS_WDS( pProfile ) )
5455 {
5456 roamStatus = eCSR_ROAM_WDS_IND;
5457 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 if( CSR_IS_INFRA_AP( pProfile ) )
5460 {
5461 roamStatus = eCSR_ROAM_INFRA_IND;
5462 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005464
5465 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5466 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5467 //trigger the connection start indication in Vista
5468 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5469 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5470 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5471 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5472 {
5473 //We start the IBSS (didn't find any matched IBSS out there)
5474 roamInfo.pBssDesc = pSirBssDesc;
5475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005477 vos_mem_copy (roamInfo.bssid, pSirBssDesc->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005478 //Remove this code once SLM_Sessionization is supported
5479 //BMPS_WORKAROUND_NOT_NEEDED
5480 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005481 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005482 {
5483 pMac->roam.configParam.doBMPSWorkaround = 1;
5484 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005485
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5487 }
5488
5489 csrScanCancelIdleScan(pMac);
5490 //Only use this timer for ibss. BAP has its own timer for WDS
5491 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5492 {
5493 //start the join IBSS timer
5494 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5495 pSession->ibss_join_pending = TRUE;
5496 }
5497 if( HAL_STATUS_SUCCESS( status ) )
5498 {
5499 //Already sent join_req for the WDS station
5500 fReleaseCommand = eANI_BOOLEAN_FALSE;
5501 }
5502 else if( CSR_IS_WDS_STA( pProfile ) )
5503 {
5504 //need to send stop BSS because we fail to send join_req
5505 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5506 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5507 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 case eCsrStartBssFailure:
5511#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5512 {
5513 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5515 if(pIbssLog)
5516 {
5517 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5518 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5519 }
5520 }
5521#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 roamStatus = eCSR_ROAM_IBSS_IND;
5523 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5524 if( CSR_IS_WDS( pProfile ) )
5525 {
5526 roamStatus = eCSR_ROAM_WDS_IND;
5527 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 if( CSR_IS_INFRA_AP( pProfile ) )
5530 {
5531 roamStatus = eCSR_ROAM_INFRA_IND;
5532 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 if(Context)
5535 {
5536 pSirBssDesc = (tSirBssDescription *)Context;
5537 }
5538 else
5539 {
5540 pSirBssDesc = NULL;
5541 }
5542 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5543 roamInfo.pBssDesc = pSirBssDesc;
5544 //We need to associate_complete it first, becasue Associate_start already indicated.
5545 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5546 csrSetDefaultDot11Mode( pMac );
5547 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 case eCsrSilentlyStopRoaming:
5549 // We are here because we try to start the same IBSS
5550 //No message to PE
5551 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005552 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5554 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5555 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5556 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5557 if( roamInfo.pBssDesc )
5558 {
5559 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5560 }
5561 //Since there is no change in the current state, simply pass back no result otherwise
5562 //HDD may be mistakenly mark to disconnected state.
5563 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5564 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 case eCsrSilentlyStopRoamingSaveState:
5567 //We are here because we try to connect to the same AP
5568 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005569 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5571
5572 //to aviod resetting the substate to NONE
5573 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5574 //No need to change substate to wai_for_key because there is no state change
5575 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5576 if( roamInfo.pBssDesc )
5577 {
5578 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5581 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5582 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5583 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5584 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5585 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5586 roamInfo.staId = pSession->connectedInfo.staId;
5587 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 pSession->bRefAssocStartCnt--;
5590 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5591 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5592 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5593 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 case eCsrReassocFailure:
5595#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5596 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5597#endif
5598 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005599 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 csrFreeConnectBssDesc(pMac, sessionId);
5601 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5602 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5603 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5604 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5605 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5606 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5607 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5608 eCSR_ROAM_WDS_IND,
5609 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5610 //Need to issue stop_bss
5611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 case eCsrJoinFailure:
5613 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005614 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 default:
5616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005617 smsLog(pMac, LOGW, FL("receives no association indication"));
5618 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005619 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5621 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5622 {
5623 //do not free for the other profiles as we need to send down stop BSS later
5624 csrFreeConnectBssDesc(pMac, sessionId);
5625 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5626 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5627 csrSetDefaultDot11Mode( pMac );
5628 }
5629
5630 switch( pCommand->u.roamCmd.roamReason )
5631 {
5632 // If this transition is because of an 802.11 OID, then we transition
5633 // back to INIT state so we sit waiting for more OIDs to be issued and
5634 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005635 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 case eCsrSmeIssuedAssocToSimilarAP:
5637 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005638 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5640 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5641 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5642 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5643 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005644 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tCsrBssid));
5645
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 /* Defeaturize this later if needed */
5647#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5648 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5649 if (csrRoamIsHandoffInProgress(pMac))
5650 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 /* Should indicate neighbor roam algorithm about the connect failure here */
5652 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005654#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 if(pSession->bRefAssocStartCnt > 0)
5656 {
5657 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005658 if(eCsrJoinFailureDueToConcurrency == Result)
5659 {
5660 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5661 eCSR_ROAM_ASSOCIATION_COMPLETION,
5662 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5663 }
5664 else
5665 {
5666 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 eCSR_ROAM_ASSOCIATION_COMPLETION,
5668 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005671 else
5672 {
5673 /* bRefAssocStartCnt is not incremented when
5674 * eRoamState == eCsrStopRoamingDueToConcurrency
5675 * in csrRoamJoinNextBss API. so handle this in
5676 * else case by sending assoc failure
5677 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005678 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005679 pCommand->u.scanCmd.roamId,
5680 eCSR_ROAM_ASSOCIATION_FAILURE,
5681 eCSR_ROAM_RESULT_FAILURE);
5682 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005683 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005684#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5685 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5686#endif
5687 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5688 csrScanStartIdleScan(pMac);
5689#ifdef FEATURE_WLAN_BTAMP_UT_RF
5690 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5691 //BT activity and not able to recevie WLAN traffic. Retry the join
5692 if( CSR_IS_WDS_STA(pProfile) )
5693 {
5694 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5695 }
5696#endif
5697 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 case eCsrHddIssuedReassocToSameAP:
5699 case eCsrSmeIssuedReassocToSameAP:
5700 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5701
5702 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5703#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5704 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5705#endif
5706 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5707 csrScanStartIdleScan(pMac);
5708 break;
5709 case eCsrForcedDisassoc:
5710 case eCsrForcedDeauth:
5711 case eCsrSmeIssuedIbssJoinFailure:
5712 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5713
5714 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5715 {
5716 // Notify HDD that IBSS join failed
5717 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5718 }
5719 else
5720 {
5721 csrRoamCallCallback(pMac, sessionId, NULL,
5722 pCommand->u.roamCmd.roamId,
5723 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5724 }
5725#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5726 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5727#endif
5728 csrRoamLinkDown(pMac, sessionId);
5729 csrScanStartIdleScan(pMac);
5730 break;
5731 case eCsrForcedIbssLeave:
5732 csrRoamCallCallback(pMac, sessionId, NULL,
5733 pCommand->u.roamCmd.roamId,
5734 eCSR_ROAM_IBSS_LEAVE,
5735 eCSR_ROAM_RESULT_IBSS_STOP);
5736 break;
5737 case eCsrForcedDisassocMICFailure:
5738 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5739
5740 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5741#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5742 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5743#endif
5744 csrScanStartIdleScan(pMac);
5745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 case eCsrStopBss:
5747 csrRoamCallCallback(pMac, sessionId, NULL,
5748 pCommand->u.roamCmd.roamId,
5749 eCSR_ROAM_INFRA_IND,
5750 eCSR_ROAM_RESULT_INFRA_STOPPED);
5751 break;
5752 case eCsrForcedDisassocSta:
5753 case eCsrForcedDeauthSta:
5754 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5755 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5756 {
5757 pSession = CSR_GET_SESSION(pMac, sessionId);
5758 if (!pSession)
5759 break;
5760
5761 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5762 {
5763 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5764 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5765 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5766 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5767 roamInfo.statusCode = eSIR_SME_SUCCESS;
5768 status = csrRoamCallCallback(pMac, sessionId,
5769 &roamInfo, pCommand->u.roamCmd.roamId,
5770 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5771 }
5772 }
5773 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 case eCsrLostLink1:
5775 // if lost link roam1 failed, then issue lost link Scan2 ...
5776 csrScanRequestLostLink2(pMac, sessionId);
5777 break;
5778 case eCsrLostLink2:
5779 // if lost link roam2 failed, then issue lost link scan3 ...
5780 csrScanRequestLostLink3(pMac, sessionId);
5781 break;
5782 case eCsrLostLink3:
5783 default:
5784 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5785
5786 //We are done with one round of lostlink roaming here
5787 csrScanHandleFailedLostlink3(pMac, sessionId);
5788 break;
5789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 break;
5791 }
5792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 return ( fReleaseCommand );
5794}
5795
Jeff Johnson295189b2012-06-20 16:38:30 -07005796eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5797{
5798 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 return (status);
5800}
5801
Jeff Johnson295189b2012-06-20 16:38:30 -07005802eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5803{
5804 eHalStatus status = eHAL_STATUS_SUCCESS;
5805 tANI_U32 size = 0;
5806
5807 do
5808 {
5809 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5810 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5811 {
5812 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5813 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5814 if(!HAL_STATUS_SUCCESS(status))
5815 {
5816 break;
5817 }
5818 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5819 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5820 }
5821 if(pSrcProfile->SSIDs.numOfSSIDs)
5822 {
5823 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5824 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5825 if(!HAL_STATUS_SUCCESS(status))
5826 {
5827 break;
5828 }
5829 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5830 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5831 }
5832 if(pSrcProfile->nWPAReqIELength)
5833 {
5834 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5835 if(!HAL_STATUS_SUCCESS(status))
5836 {
5837 break;
5838 }
5839 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5840 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5841 }
5842 if(pSrcProfile->nRSNReqIELength)
5843 {
5844 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5845 if(!HAL_STATUS_SUCCESS(status))
5846 {
5847 break;
5848 }
5849 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5850 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5851 }
5852#ifdef FEATURE_WLAN_WAPI
5853 if(pSrcProfile->nWAPIReqIELength)
5854 {
5855 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5856 if(!HAL_STATUS_SUCCESS(status))
5857 {
5858 break;
5859 }
5860 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5861 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5862 }
5863#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 if(pSrcProfile->nAddIEScanLength)
5865 {
5866 status = palAllocateMemory(pMac->hHdd,
5867 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5868 if(!HAL_STATUS_SUCCESS(status))
5869 {
5870 break;
5871 }
5872 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5873 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5874 pSrcProfile->nAddIEScanLength);
5875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 if(pSrcProfile->nAddIEAssocLength)
5877 {
5878 status = palAllocateMemory(pMac->hHdd,
5879 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5880 if(!HAL_STATUS_SUCCESS(status))
5881 {
5882 break;
5883 }
5884 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5885 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5886 pSrcProfile->nAddIEAssocLength);
5887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 if(pSrcProfile->ChannelInfo.ChannelList)
5889 {
5890 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5891 if(!HAL_STATUS_SUCCESS(status))
5892 {
5893 break;
5894 }
5895 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5896 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 pDstProfile->AuthType = pSrcProfile->AuthType;
5899 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5900 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5901 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5902 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5903 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07005904#ifdef WLAN_FEATURE_11W
5905 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
5906 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
5907 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
5908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 pDstProfile->BSSType = pSrcProfile->BSSType;
5910 pDstProfile->phyMode = pSrcProfile->phyMode;
5911 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5912
5913#ifdef FEATURE_WLAN_WAPI
5914 if(csrIsProfileWapi(pSrcProfile))
5915 {
5916 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5917 {
5918 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5919 }
5920 }
5921#endif /* FEATURE_WLAN_WAPI */
5922 pDstProfile->CBMode = pSrcProfile->CBMode;
5923 /*Save the WPS info*/
5924 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5925 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 pDstProfile->privacy = pSrcProfile->privacy;
5928 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5929 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5930 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5931 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5932 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5933 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5934 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5935 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5936 pDstProfile->wps_state = pSrcProfile->wps_state;
5937 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005939#ifdef WLAN_FEATURE_VOWIFI_11R
5940 if (pSrcProfile->MDID.mdiePresent)
5941 {
5942 pDstProfile->MDID.mdiePresent = 1;
5943 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5944 }
5945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 }while(0);
5947
5948 if(!HAL_STATUS_SUCCESS(status))
5949 {
5950 csrReleaseProfile(pMac, pDstProfile);
5951 pDstProfile = NULL;
5952 }
5953
5954 return (status);
5955}
Jeff Johnson295189b2012-06-20 16:38:30 -07005956eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5957{
5958 eHalStatus status = eHAL_STATUS_SUCCESS;
5959 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5960 do
5961 {
5962 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5963 if(pSrcProfile->bssid)
5964 {
5965 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5966 if(!HAL_STATUS_SUCCESS(status))
5967 {
5968 break;
5969 }
5970 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5971 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5972 }
5973 if(pSrcProfile->SSID.ssId)
5974 {
5975 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5976 if(!HAL_STATUS_SUCCESS(status))
5977 {
5978 break;
5979 }
5980 pDstProfile->SSIDs.numOfSSIDs = 1;
5981 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5982 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5983 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5984 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005985 if(pSrcProfile->nAddIEAssocLength)
5986 {
5987 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5988 if(!HAL_STATUS_SUCCESS(status))
5989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005990 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005991 break;
5992 }
5993 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5994 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5995 pSrcProfile->nAddIEAssocLength);
5996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5998 if(!HAL_STATUS_SUCCESS(status))
5999 {
6000 break;
6001 }
6002 pDstProfile->ChannelInfo.numOfChannels = 1;
6003 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 pDstProfile->AuthType.numEntries = 1;
6005 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6006 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6007 pDstProfile->EncryptionType.numEntries = 1;
6008 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6009 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6010 pDstProfile->mcEncryptionType.numEntries = 1;
6011 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6012 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6013 pDstProfile->BSSType = pSrcProfile->BSSType;
6014 pDstProfile->CBMode = pSrcProfile->CBMode;
6015 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
6016#ifdef WLAN_FEATURE_VOWIFI_11R
6017 if (pSrcProfile->MDID.mdiePresent)
6018 {
6019 pDstProfile->MDID.mdiePresent = 1;
6020 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6021 }
6022#endif
6023
6024 }while(0);
6025
6026 if(!HAL_STATUS_SUCCESS(status))
6027 {
6028 csrReleaseProfile(pMac, pDstProfile);
6029 pDstProfile = NULL;
6030 }
6031
6032 return (status);
6033}
6034
Jeff Johnson295189b2012-06-20 16:38:30 -07006035eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6036 tScanResultHandle hBSSList,
6037 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6038 tANI_BOOLEAN fClearScan)
6039{
6040 eHalStatus status = eHAL_STATUS_SUCCESS;
6041 tSmeCmd *pCommand;
6042
6043 pCommand = csrGetCommandBuffer(pMac);
6044 if(NULL == pCommand)
6045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006046 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 status = eHAL_STATUS_RESOURCES;
6048 }
6049 else
6050 {
6051 if( fClearScan )
6052 {
6053 csrScanCancelIdleScan(pMac);
6054 csrScanAbortMacScanNotForConnect(pMac);
6055 }
6056 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6057 if(NULL == pProfile)
6058 {
6059 //We can roam now
6060 //Since pProfile is NULL, we need to build our own profile, set everything to default
6061 //We can only support open and no encryption
6062 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6063 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6064 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6065 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6066 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6067 }
6068 else
6069 {
6070 //make a copy of the profile
6071 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6072 if(HAL_STATUS_SUCCESS(status))
6073 {
6074 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6075 }
6076 }
6077 pCommand->command = eSmeCommandRoam;
6078 pCommand->sessionId = (tANI_U8)sessionId;
6079 pCommand->u.roamCmd.hBSSList = hBSSList;
6080 pCommand->u.roamCmd.roamId = roamId;
6081 pCommand->u.roamCmd.roamReason = reason;
6082 //We need to free the BssList when the command is done
6083 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6084 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6086 FL("CSR PERSONA=%d"),
6087 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6089 if( !HAL_STATUS_SUCCESS( status ) )
6090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006091 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 csrReleaseCommandRoam( pMac, pCommand );
6093 }
6094 }
6095
6096 return (status);
6097}
Jeff Johnson295189b2012-06-20 16:38:30 -07006098eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6099 tCsrRoamModifyProfileFields *pMmodProfileFields,
6100 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6101{
6102 eHalStatus status = eHAL_STATUS_SUCCESS;
6103 tSmeCmd *pCommand;
6104
6105 pCommand = csrGetCommandBuffer(pMac);
6106 if(NULL == pCommand)
6107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006108 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 status = eHAL_STATUS_RESOURCES;
6110 }
6111 else
6112 {
6113 csrScanCancelIdleScan(pMac);
6114 csrScanAbortMacScanNotForConnect(pMac);
6115 if(pProfile)
6116 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 //This is likely trying to reassoc to different profile
6118 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6119 //make a copy of the profile
6120 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6121 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 }
6123 else
6124 {
6125 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6126 //how to update WPA/WPA2 info in roamProfile??
6127 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 if(HAL_STATUS_SUCCESS(status))
6130 {
6131 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6132 }
6133 pCommand->command = eSmeCommandRoam;
6134 pCommand->sessionId = (tANI_U8)sessionId;
6135 pCommand->u.roamCmd.roamId = roamId;
6136 pCommand->u.roamCmd.roamReason = reason;
6137 //We need to free the BssList when the command is done
6138 //For reassoc there is no BSS list, so the boolean set to false
6139 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6140 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6141 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6143 if( !HAL_STATUS_SUCCESS( status ) )
6144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006145 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6147 csrReleaseCommandRoam( pMac, pCommand );
6148 }
6149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 return (status);
6151}
6152
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006153eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6154 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
6155// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6156{
6157 eHalStatus status = eHAL_STATUS_SUCCESS;
6158 tSmeCmd *pCommand;
6159
6160 pCommand = csrGetCommandBuffer(pMac);
6161 if(NULL == pCommand)
6162 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006163 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006164 status = eHAL_STATUS_RESOURCES;
6165 }
6166 else
6167 {
6168 if(pBssDescription)
6169 {
6170 //copy over the parameters we need later
6171 pCommand->command = eSmeCommandRoam;
6172 pCommand->sessionId = (tANI_U8)sessionId;
6173 pCommand->u.roamCmd.roamReason = reason;
6174 //this is the important parameter
6175 //in this case we are using this field for the "next" BSS
6176 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6177 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6178 if( !HAL_STATUS_SUCCESS( status ) )
6179 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006180 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006181 csrReleaseCommandPreauth( pMac, pCommand );
6182 }
6183 }
6184 else
6185 {
6186 //Return failure
6187 status = eHAL_STATUS_RESOURCES;
6188 }
6189 }
6190 return (status);
6191}
6192
6193eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6194{
6195 tListElem *pEntry;
6196 tSmeCmd *pCommand;
6197 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6198 if ( pEntry )
6199 {
6200 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6201 if ( (eSmeCommandRoam == pCommand->command) &&
6202 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6203 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006204 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006205 pCommand->command, pCommand->u.roamCmd.roamReason);
6206 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6207 csrReleaseCommandPreauth( pMac, pCommand );
6208 }
6209 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006210 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006211 pCommand->command, pCommand->u.roamCmd.roamReason);
6212 }
6213 }
6214 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006215 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006216 }
6217 smeProcessPendingQueue( pMac );
6218 return eHAL_STATUS_SUCCESS;
6219}
6220
Jeff Johnson295189b2012-06-20 16:38:30 -07006221eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6222 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6223{
6224 eHalStatus status = eHAL_STATUS_FAILURE;
6225 tScanResultHandle hBSSList;
6226 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6228 if(HAL_STATUS_SUCCESS(status))
6229 {
6230 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6231 if(pRoamId)
6232 {
6233 *pRoamId = roamId;
6234 }
6235 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6236 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6237 if(!HAL_STATUS_SUCCESS(status))
6238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006239 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 csrScanResultPurge(pMac, hBSSList);
6241 }
6242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 return (status);
6244}
6245
Jeff Johnson295189b2012-06-20 16:38:30 -07006246eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6247 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6248{
6249 eHalStatus status = eHAL_STATUS_SUCCESS;
6250 tScanResultHandle hBSSList;
6251 tCsrScanResultFilter *pScanFilter;
6252 tANI_U32 roamId = 0;
6253 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6254 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 if (NULL == pProfile)
6256 {
6257 smsLog(pMac, LOGP, FL("No profile specified"));
6258 return eHAL_STATUS_FAILURE;
6259 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006260 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 if( CSR_IS_WDS( pProfile ) &&
6263 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006265 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006266 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 return status;
6268 }
6269 csrRoamCancelRoaming(pMac, sessionId);
6270 csrScanRemoveFreshScanCommand(pMac, sessionId);
6271 csrScanCancelIdleScan(pMac);
6272 //Only abort the scan if it is not used for other roam/connect purpose
6273 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6275 {
6276 csrScanDisable(pMac);
6277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6279 //Check whether ssid changes
6280 if(csrIsConnStateConnected(pMac, sessionId))
6281 {
6282 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6283 {
6284 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6285 }
6286 }
6287#ifdef FEATURE_WLAN_BTAMP_UT_RF
6288 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6289#endif
6290 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006292 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6294 if(pRoamId)
6295 {
6296 roamId = *pRoamId;
6297 }
6298 if(!HAL_STATUS_SUCCESS(status))
6299 {
6300 fCallCallback = eANI_BOOLEAN_TRUE;
6301 }
6302 }
6303 else
6304 {
6305 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6306 if(HAL_STATUS_SUCCESS(status))
6307 {
6308 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6309 //Try to connect to any BSS
6310 if(NULL == pProfile)
6311 {
6312 //No encryption
6313 pScanFilter->EncryptionType.numEntries = 1;
6314 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6315 }//we don't have a profile
6316 else
6317 {
6318 //Here is the profile we need to connect to
6319 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6320 }//We have a profile
6321 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6322 if(pRoamId)
6323 {
6324 *pRoamId = roamId;
6325 }
6326
6327 if(HAL_STATUS_SUCCESS(status))
6328 {
6329 /*Save the WPS info*/
6330 if(NULL != pProfile)
6331 {
6332 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6333 }
6334 else
6335 {
6336 pScanFilter->bWPSAssociation = 0;
6337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 do
6339 {
6340 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 )
6343 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006344 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6346 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6347 if(!HAL_STATUS_SUCCESS(status))
6348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006349 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 fCallCallback = eANI_BOOLEAN_TRUE;
6351 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006352 else
6353 {
6354 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 break;
6357 }
6358 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006359 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 if(HAL_STATUS_SUCCESS(status))
6361 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6363 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6364 if(!HAL_STATUS_SUCCESS(status))
6365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006366 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 csrScanResultPurge(pMac, hBSSList);
6368 fCallCallback = eANI_BOOLEAN_TRUE;
6369 }
6370 }//Have scan result
6371 else if(NULL != pProfile)
6372 {
6373 //Check whether it is for start ibss
6374 if(CSR_IS_START_IBSS(pProfile))
6375 {
6376 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6377 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6378 if(!HAL_STATUS_SUCCESS(status))
6379 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006380 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 fCallCallback = eANI_BOOLEAN_TRUE;
6382 }
6383 }
6384 else
6385 {
6386 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006387 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 if(!HAL_STATUS_SUCCESS(status))
6389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006390 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 fCallCallback = eANI_BOOLEAN_TRUE;
6392 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006393 else
6394 {
6395 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 }
6398 }
6399 else
6400 {
6401 fCallCallback = eANI_BOOLEAN_TRUE;
6402 }
6403 } while (0);
6404 if(NULL != pProfile)
6405 {
6406 //we need to free memory for filter if profile exists
6407 csrFreeScanFilter(pMac, pScanFilter);
6408 }
6409 }//Got the scan filter from profile
6410
6411 palFreeMemory(pMac->hHdd, pScanFilter);
6412 }//allocated memory for pScanFilter
6413 }//No Bsslist coming in
6414 //tell the caller if we fail to trigger a join request
6415 if( fCallCallback )
6416 {
6417 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6418 }
6419
6420 return (status);
6421}
Jeff Johnson295189b2012-06-20 16:38:30 -07006422eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6423 tCsrRoamModifyProfileFields modProfileFields,
6424 tANI_U32 *pRoamId)
6425{
6426 eHalStatus status = eHAL_STATUS_SUCCESS;
6427 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6428 tANI_U32 roamId = 0;
6429 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 if (NULL == pProfile)
6431 {
6432 smsLog(pMac, LOGP, FL("No profile specified"));
6433 return eHAL_STATUS_FAILURE;
6434 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006435 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 -07006436 csrRoamCancelRoaming(pMac, sessionId);
6437 csrScanRemoveFreshScanCommand(pMac, sessionId);
6438 csrScanCancelIdleScan(pMac);
6439 csrScanAbortMacScanNotForConnect(pMac);
6440 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 if(csrIsConnStateConnected(pMac, sessionId))
6442 {
6443 if(pProfile)
6444 {
6445 if(pProfile->SSIDs.numOfSSIDs &&
6446 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6447 {
6448 fCallCallback = eANI_BOOLEAN_FALSE;
6449 }
6450 else
6451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006452 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 }
6454 }
6455 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6456 &pSession->connectedProfile.modifyProfileFields,
6457 sizeof(tCsrRoamModifyProfileFields)))
6458 {
6459 fCallCallback = eANI_BOOLEAN_FALSE;
6460 }
6461 else
6462 {
6463 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006464 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 }
6466 }
6467 else
6468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006469 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 if(!fCallCallback)
6472 {
6473 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6474 if(pRoamId)
6475 {
6476 *pRoamId = roamId;
6477 }
6478
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6480 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 }
6482 else
6483 {
6484 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6485 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 return status;
6488}
Jeff Johnson295189b2012-06-20 16:38:30 -07006489eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6490{
6491 eHalStatus status = eHAL_STATUS_FAILURE;
6492 tScanResultHandle hBSSList = NULL;
6493 tCsrScanResultFilter *pScanFilter = NULL;
6494 tANI_U32 roamId;
6495 tCsrRoamProfile *pProfile = NULL;
6496 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006497
6498 if(!pSession)
6499 {
6500 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6501 return eHAL_STATUS_FAILURE;
6502 }
6503
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 do
6505 {
6506 if(pSession->pCurRoamProfile)
6507 {
6508 csrScanCancelIdleScan(pMac);
6509 csrScanAbortMacScanNotForConnect(pMac);
6510 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6511 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6512 if(!HAL_STATUS_SUCCESS(status))
6513 break;
6514 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6515 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6516 if(!HAL_STATUS_SUCCESS(status))
6517 break;
6518 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6519 if(!HAL_STATUS_SUCCESS(status))
6520 {
6521 break;
6522 }
6523 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6524 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6525 if(!HAL_STATUS_SUCCESS(status))
6526 {
6527 break;
6528 }
6529 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6530 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6531 if(HAL_STATUS_SUCCESS(status))
6532 {
6533 //we want to put the last connected BSS to the very beginning, if possible
6534 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6535 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6536 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6537 if(!HAL_STATUS_SUCCESS(status))
6538 {
6539 csrScanResultPurge(pMac, hBSSList);
6540 break;
6541 }
6542 }
6543 else
6544 {
6545 //Do a scan on this profile
6546 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006547 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 if(!HAL_STATUS_SUCCESS(status))
6549 {
6550 break;
6551 }
6552 }
6553 }//We have a profile
6554 else
6555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006556 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 break;
6558 }
6559 }while(0);
6560 if(pScanFilter)
6561 {
6562 csrFreeScanFilter(pMac, pScanFilter);
6563 palFreeMemory(pMac->hHdd, pScanFilter);
6564 }
6565 if(NULL != pProfile)
6566 {
6567 csrReleaseProfile(pMac, pProfile);
6568 palFreeMemory(pMac->hHdd, pProfile);
6569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 return (status);
6571}
Jeff Johnson295189b2012-06-20 16:38:30 -07006572eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6573{
6574 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 if(csrIsConnStateConnected(pMac, sessionId))
6576 {
6577 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6578 if(HAL_STATUS_SUCCESS(status))
6579 {
6580 status = csrRoamJoinLastProfile(pMac, sessionId);
6581 }
6582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 return (status);
6584}
6585
Jeff Johnson295189b2012-06-20 16:38:30 -07006586eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6587{
6588 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006589 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 csrRoamCancelRoaming(pMac, sessionId);
6591 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6592 if(csrIsConnStateDisconnected(pMac, sessionId))
6593 {
6594 status = csrRoamJoinLastProfile(pMac, sessionId);
6595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 return (status);
6597}
6598
Jeff Johnson295189b2012-06-20 16:38:30 -07006599eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6600{
6601 eHalStatus status = eHAL_STATUS_SUCCESS;
6602 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6603 eCsrRoamSubState NewSubstate;
6604 tANI_U32 sessionId = pCommand->sessionId;
6605
6606 // change state to 'Roaming'...
6607 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6608
6609 if ( csrIsConnStateIbss( pMac, sessionId ) )
6610 {
6611 // If we are in an IBSS, then stop the IBSS...
6612 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6613 fComplete = (!HAL_STATUS_SUCCESS(status));
6614 }
6615 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006617 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 -07006618 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6619 //Restore AC weight in case we change it
6620 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6621 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6622 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6623 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6624 {
6625 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6626 }
6627 if( fDisassoc )
6628 {
6629 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6630 }
6631 else
6632 {
6633 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6634 }
6635 fComplete = (!HAL_STATUS_SUCCESS(status));
6636 }
6637 else if ( csrIsConnStateWds( pMac, sessionId ) )
6638 {
6639 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6640 {
6641 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6642 fComplete = (!HAL_STATUS_SUCCESS(status));
6643 }
6644 //This has to be WDS station
6645 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6646 {
6647
6648 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6649 if( fDisassoc )
6650 {
6651 status = csrRoamIssueDisassociate( pMac, sessionId,
6652 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6653 fComplete = (!HAL_STATUS_SUCCESS(status));
6654 }
6655 }
6656 } else {
6657 // we got a dis-assoc request while not connected to any peer
6658 // just complete the command
6659 fComplete = eANI_BOOLEAN_TRUE;
6660 status = eHAL_STATUS_FAILURE;
6661 }
6662 if(fComplete)
6663 {
6664 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6665 }
6666
6667 if(HAL_STATUS_SUCCESS(status))
6668 {
6669 if ( csrIsConnStateInfra( pMac, sessionId ) )
6670 {
6671 //Set the state to disconnect here
6672 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6673 }
6674 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006675 else
6676 {
6677 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 return (status);
6680}
6681
Jeff Johnson295189b2012-06-20 16:38:30 -07006682/* This is been removed from latest code base */
6683/*
6684static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6685{
6686 eHalStatus status;
6687 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6689 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 return ( status );
6691}
6692*/
6693
Jeff Johnson295189b2012-06-20 16:38:30 -07006694eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6695{
6696 eHalStatus status = eHAL_STATUS_SUCCESS;
6697 tSmeCmd *pCommand;
6698 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 do
6700 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006701 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 pCommand = csrGetCommandBuffer( pMac );
6703 if ( !pCommand )
6704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006705 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 status = eHAL_STATUS_RESOURCES;
6707 break;
6708 }
6709 //Change the substate in case it is wait-for-key
6710 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6711 {
6712 csrRoamStopWaitForKeyTimer( pMac );
6713 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6714 }
6715 pCommand->command = eSmeCommandRoam;
6716 pCommand->sessionId = (tANI_U8)sessionId;
6717 switch ( reason )
6718 {
6719 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6720 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6721 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 case eCSR_DISCONNECT_REASON_DEAUTH:
6723 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 case eCSR_DISCONNECT_REASON_HANDOFF:
6726 fHighPriority = eANI_BOOLEAN_TRUE;
6727 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6730 case eCSR_DISCONNECT_REASON_DISASSOC:
6731 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6732 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6734 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6737 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6738 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 default:
6740 break;
6741 }
6742 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6743 if( !HAL_STATUS_SUCCESS( status ) )
6744 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006745 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 csrReleaseCommandRoam( pMac, pCommand );
6747 }
6748 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 return( status );
6750}
6751
Jeff Johnson295189b2012-06-20 16:38:30 -07006752eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6753{
6754 eHalStatus status = eHAL_STATUS_SUCCESS;
6755 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 pCommand = csrGetCommandBuffer( pMac );
6757 if ( NULL != pCommand )
6758 {
6759 //Change the substate in case it is wait-for-key
6760 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6761 {
6762 csrRoamStopWaitForKeyTimer( pMac );
6763 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6764 }
6765 pCommand->command = eSmeCommandRoam;
6766 pCommand->sessionId = (tANI_U8)sessionId;
6767 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6768 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6769 if( !HAL_STATUS_SUCCESS( status ) )
6770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006771 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 csrReleaseCommandRoam( pMac, pCommand );
6773 }
6774 }
6775 else
6776 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006777 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 status = eHAL_STATUS_RESOURCES;
6779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 return ( status );
6781}
6782
Jeff Johnson295189b2012-06-20 16:38:30 -07006783eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6784{
6785 eHalStatus status = eHAL_STATUS_SUCCESS;
6786 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006787
6788 if(!pSession)
6789 {
6790 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6791 return eHAL_STATUS_FAILURE;
6792 }
6793
Jeff Johnson295189b2012-06-20 16:38:30 -07006794#ifdef FEATURE_WLAN_BTAMP_UT_RF
6795 //Stop te retry
6796 pSession->maxRetryCount = 0;
6797 csrRoamStopJoinRetryTimer(pMac, sessionId);
6798#endif
6799 //Not to call cancel roaming here
6800 //Only issue disconnect when necessary
6801 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6802 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6803 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6804
6805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006806 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 return (status);
6810}
6811
Jeff Johnson295189b2012-06-20 16:38:30 -07006812eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6813{
6814 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006815
6816 if(!pSession)
6817 {
6818 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6819 return eHAL_STATUS_FAILURE;
6820 }
6821
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 csrRoamCancelRoaming(pMac, sessionId);
6823 pSession->ibss_join_pending = FALSE;
6824 csrRoamStopIbssJoinTimer(pMac, sessionId);
6825 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6826
6827 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6828}
6829
Jeff Johnson295189b2012-06-20 16:38:30 -07006830eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6831 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6832{
6833 eHalStatus status = eHAL_STATUS_SUCCESS;
6834 tDot11fBeaconIEs *pIesTemp = pIes;
6835 tANI_U8 index;
6836 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6837 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006838
6839 if(!pSession)
6840 {
6841 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6842 return eHAL_STATUS_FAILURE;
6843 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006844
6845 if(pConnectProfile->pAddIEAssoc)
6846 {
6847 palFreeMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc);
6848 pConnectProfile->pAddIEAssoc = NULL;
6849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6851 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6852 pConnectProfile->AuthInfo = pProfile->AuthType;
6853 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6854 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6855 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6856 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6857 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6858 pConnectProfile->BSSType = pProfile->BSSType;
6859 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6860 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006861 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6862
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08006864
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006865 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6866 if(pProfile->nAddIEAssocLength)
6867 {
6868 status = palAllocateMemory(pMac->hHdd,
6869 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6870 if(!HAL_STATUS_SUCCESS(status))
6871 {
6872 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6873 return eHAL_STATUS_FAILURE;
6874 }
6875 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6876 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6877 pProfile->nAddIEAssocLength);
6878 }
6879
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 //Save bssid
6881 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6882#ifdef WLAN_FEATURE_VOWIFI_11R
6883 if (pSirBssDesc->mdiePresent)
6884 {
6885 pConnectProfile->MDID.mdiePresent = 1;
6886 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6887 }
6888#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07006889 if( NULL == pIesTemp )
6890 {
6891 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006893#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006894 if ((csrIsProfileCCX(pProfile) ||
6895 ((pIesTemp->CCXVersion.present)
6896 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6897 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6898 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6899 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07006900#ifdef WLAN_FEATURE_11W
6901 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
6902#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05306903 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006904 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 {
6906 pConnectProfile->isCCXAssoc = 1;
6907 }
6908#endif
6909 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 if(HAL_STATUS_SUCCESS(status))
6911 {
6912 if(pIesTemp->SSID.present)
6913 {
6914 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6915 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6916 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6917 }
6918
6919 //Save the bss desc
6920 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306921
6922 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306924 //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 -07006925 pConnectProfile->qap = TRUE;
6926 }
6927 else
6928 {
6929 pConnectProfile->qap = FALSE;
6930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 if ( NULL == pIes )
6932 {
6933 //Free memory if it allocated locally
6934 palFreeMemory(pMac->hHdd, pIesTemp);
6935 }
6936 }
6937 //Save Qos connection
6938 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6939
6940 if(!HAL_STATUS_SUCCESS(status))
6941 {
6942 csrFreeConnectBssDesc(pMac, sessionId);
6943 }
6944 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6945 {
6946 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6947 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6948 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6949 {
6950 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6951 break;
6952 }
6953 pConnectProfile->handoffPermitted = FALSE;
6954 }
6955
6956 return (status);
6957}
6958
Jeff Johnson295189b2012-06-20 16:38:30 -07006959static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6960{
6961 tListElem *pEntry = NULL;
6962 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 //The head of the active list is the request we sent
6964 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6965 if(pEntry)
6966 {
6967 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6970 {
6971 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6972 {
6973#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6974 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6975#endif
6976 }
6977 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6978 }
6979 else
6980 {
6981 tANI_U32 roamId = 0;
6982 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006983 if(!pSession)
6984 {
6985 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6986 return;
6987 }
6988
Jeff Johnson295189b2012-06-20 16:38:30 -07006989
6990 //The head of the active list is the request we sent
6991 //Try to get back the same profile and roam again
6992 if(pCommand)
6993 {
6994 roamId = pCommand->u.roamCmd.roamId;
6995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6997 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006998 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006999#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7000 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7001 if (csrRoamIsHandoffInProgress(pMac))
7002 {
7003 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7004 /* Should indicate neighbor roam algorithm about the connect failure here */
7005 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7006 }
7007#endif
7008 if (pCommand)
7009 {
7010 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7011 {
7012 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7013 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7014 csrRoamReissueRoamCommand(pMac);
7015 }
7016 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7017 {
7018 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7019 }
7020 else
7021 {
7022 csrRoam(pMac, pCommand);
7023 }
7024 }
7025 else
7026 {
7027 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7028 }
7029 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7030}
7031
Jeff Johnson295189b2012-06-20 16:38:30 -07007032eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7033 tDot11fBeaconIEs *pIes,
7034 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7035{
7036 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007037 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
7039 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
7040
7041 // Set the roaming substate to 'join attempt'...
7042 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007044 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 return (status);
7046}
7047
Jeff Johnson295189b2012-06-20 16:38:30 -07007048static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7049 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7050{
7051 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 // Set the roaming substate to 'join attempt'...
7053 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7054
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007055 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007056
7057 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007058 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007059}
7060
Jeff Johnson295189b2012-06-20 16:38:30 -07007061void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7062{
7063 tListElem *pEntry;
7064 tSmeCmd *pCommand;
7065 tCsrRoamInfo roamInfo;
7066 tANI_U32 sessionId;
7067 tCsrRoamSession *pSession;
7068
7069 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7070 if(pEntry)
7071 {
7072 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7073 if ( eSmeCommandRoam == pCommand->command )
7074 {
7075 sessionId = pCommand->sessionId;
7076 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007077
7078 if(!pSession)
7079 {
7080 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7081 return;
7082 }
7083
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 if( pCommand->u.roamCmd.fStopWds )
7085 {
7086 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7087 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7088 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7089 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7092 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7093 eCSR_ROAM_WDS_IND,
7094 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7096 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7097 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7098 eCSR_ROAM_INFRA_IND,
7099 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7100 }
7101
Jeff Johnson295189b2012-06-20 16:38:30 -07007102
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007105 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7107 }
7108 }
7109 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007111 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7113 }
7114 }
7115 else
7116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007117 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007118 }
7119 }
7120 else
7121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007122 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 }
7124}
7125
Jeff Johnson295189b2012-06-20 16:38:30 -07007126tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7127{
7128 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7129 tListElem *pEntry;
7130 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 //alwasy lock active list before locking pending list
7132 csrLLLock( &pMac->sme.smeCmdActiveList );
7133 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7134 if(pEntry)
7135 {
7136 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7137 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7138 {
7139 fRet = eANI_BOOLEAN_TRUE;
7140 }
7141 }
7142 if(eANI_BOOLEAN_FALSE == fRet)
7143 {
7144 csrLLLock(&pMac->sme.smeCmdPendingList);
7145 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7146 while(pEntry)
7147 {
7148 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7149 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7150 {
7151 fRet = eANI_BOOLEAN_TRUE;
7152 break;
7153 }
7154 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7155 }
7156 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7157 }
7158 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 return (fRet);
7160}
7161
Jeff Johnson295189b2012-06-20 16:38:30 -07007162tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7163{
7164 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7165 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7167 {
7168 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7169 {
7170 break;
7171 }
7172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 return ( fRet );
7174}
7175
Jeff Johnson295189b2012-06-20 16:38:30 -07007176tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7177{
7178 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 //alwasy lock active list before locking pending list
7180 csrLLLock( &pMac->sme.smeCmdActiveList );
7181 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7182 if(eANI_BOOLEAN_FALSE == fRet)
7183 {
7184 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7185 }
7186 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 return (fRet);
7188}
7189
Jeff Johnson295189b2012-06-20 16:38:30 -07007190tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7191{
7192 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7193 tListElem *pEntry;
7194 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 //alwasy lock active list before locking pending list
7196 csrLLLock( &pMac->sme.smeCmdActiveList );
7197 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7198 if( pEntry )
7199 {
7200 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7201 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7202 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7203 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7204 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7205 {
7206 fRet = eANI_BOOLEAN_TRUE;
7207 }
7208 }
7209 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007210 return (fRet);
7211}
Jeff Johnson295189b2012-06-20 16:38:30 -07007212eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7213{
7214 eHalStatus status = eHAL_STATUS_SUCCESS;
7215 tSmeCmd *pCommand = NULL;
7216 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7217 tANI_BOOLEAN fRemoveCmd = FALSE;
7218 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 // Delete the old assoc command. All is setup for reassoc to be serialized
7220 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7221 if ( pEntry )
7222 {
7223 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7224 if ( !pCommand )
7225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007226 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 return eHAL_STATUS_RESOURCES;
7228 }
7229 if ( eSmeCommandRoam == pCommand->command )
7230 {
7231 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7232 {
7233 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7234 }
7235 else
7236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007237 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 }
7239 if (fRemoveCmd == FALSE)
7240 {
7241 // Implies we did not get the serialized assoc command we
7242 // were expecting
7243 pCommand = NULL;
7244 }
7245 }
7246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 if(NULL == pCommand)
7248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007249 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 return eHAL_STATUS_RESOURCES;
7251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 do
7253 {
7254 //Change the substate in case it is wait-for-key
7255 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7256 {
7257 csrRoamStopWaitForKeyTimer( pMac );
7258 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7259 }
7260 pCommand->command = eSmeCommandRoam;
7261 pCommand->sessionId = (tANI_U8)sessionId;
7262 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7264 if( !HAL_STATUS_SUCCESS( status ) )
7265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007266 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 csrReleaseCommandRoam( pMac, pCommand );
7268 }
7269 } while( 0 );
7270
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 return( status );
7272}
7273static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7274{
7275 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7276 tCsrScanResult *pScanResult = NULL;
7277 tSirBssDescription *pBssDesc = NULL;
7278 tSmeCmd *pCommand = NULL;
7279 tANI_U32 sessionId;
7280 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 if(NULL == pEntry)
7282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007283 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 return;
7285 }
7286 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7287 sessionId = pCommand->sessionId;
7288 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007289
7290 if(!pSession)
7291 {
7292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7293 return;
7294 }
7295
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7297 {
7298 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007299 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7301 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007302 /* If the roaming has stopped, not to continue the roaming command*/
7303 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7304 {
7305 //No need to complete roaming here as it already completes
7306 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7307 pCommand->u.roamCmd.roamReason);
7308 csrSetAbortRoamingCommand( pMac, pCommand );
7309 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 else
7312 {
7313 if ( CCM_IS_RESULT_SUCCESS(result) )
7314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007315 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 // Successfully set the configuration parameters for the new Bss. Attempt to
7317 // join the roaming Bss.
7318 if(pCommand->u.roamCmd.pRoamBssEntry)
7319 {
7320 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7321 pBssDesc = &pScanResult->Result.BssDescriptor;
7322 }
7323 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7324 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007325 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 )
7327 {
7328 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7329 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7330 pBssDesc, pCommand->u.roamCmd.roamId )))
7331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007332 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 //We need to complete the command
7334 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7335 }
7336 }
7337 else
7338 {
7339 if (!pCommand->u.roamCmd.pRoamBssEntry)
7340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007341 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 //We need to complete the command
7343 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7344 return;
7345 }
7346 // If we are roaming TO an Infrastructure BSS...
7347 VOS_ASSERT(pScanResult != NULL);
7348 if ( csrIsInfraBssDesc( pBssDesc ) )
7349 {
7350 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7352 {
7353 // ..and currently in an Infrastructure connection....
7354 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7355 {
7356 // ...and the SSIDs are equal, then we Reassoc.
7357 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7358 pIesLocal ) )
7359 // ..and currently in an infrastructure connection
7360 {
7361 // then issue a Reassoc.
7362 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7363 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7364 &pCommand->u.roamCmd.roamProfile );
7365 }
7366 else
7367 {
7368
7369 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7370 // previously associated AP.
7371 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7372 pIesLocal,
7373 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7374 {
7375 //try something else
7376 csrRoam( pMac, pCommand );
7377 }
7378 }
7379 }
7380 else
7381 {
7382 eHalStatus status = eHAL_STATUS_SUCCESS;
7383
7384 /* We need to come with other way to figure out that this is because of HO in BMP
7385 The below API will be only available for Android as it uses a different HO algorithm */
7386 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7387 * use join request */
7388#ifdef WLAN_FEATURE_VOWIFI_11R
7389 if (csrRoamIsHandoffInProgress(pMac) &&
7390 csrRoamIs11rAssoc(pMac))
7391 {
7392 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7393 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7394 }
7395 else
7396#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007397#ifdef FEATURE_WLAN_CCX
7398 if (csrRoamIsHandoffInProgress(pMac) &&
7399 csrRoamIsCCXAssoc(pMac))
7400 {
7401 // Now serialize the reassoc command.
7402 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7403 }
7404 else
7405#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007406#ifdef FEATURE_WLAN_LFR
7407 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307408 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007409 {
7410 // Now serialize the reassoc command.
7411 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7412 }
7413 else
7414#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 // else we are not connected and attempting to Join. Issue the
7416 // Join request.
7417 {
7418 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7419 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7420 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7421 }
7422 if(!HAL_STATUS_SUCCESS(status))
7423 {
7424 //try something else
7425 csrRoam( pMac, pCommand );
7426 }
7427 }
7428 if( !pScanResult->Result.pvIes )
7429 {
7430 //Locally allocated
7431 palFreeMemory(pMac->hHdd, pIesLocal);
7432 }
7433 }
7434 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7435 else
7436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007437 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 }
7439 }//else
7440 }//if ( WNI_CFG_SUCCESS == result )
7441 else
7442 {
7443 // In the event the configuration failed, for infra let the roam processor
7444 //attempt to join something else...
7445 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7446 {
7447 csrRoam(pMac, pCommand);
7448 }
7449 else
7450 {
7451 //We need to complete the command
7452 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7453 {
7454 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7455 }
7456 else
7457 {
7458 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7459 }
7460 }
7461 }
7462 }//we have active entry
7463}
7464
Jeff Johnson295189b2012-06-20 16:38:30 -07007465static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7466{
7467 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007468 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007469 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007471 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7473 // join the new one...
7474 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7476 }
7477 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007478 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 /***profHandleLostLinkAfterReset(pAdapter);
7480 // In the event the authenticate fails, let the roam processor attempt to join something else...
7481 roamRoam( pAdapter );***/
7482 }
7483}
7484
Jeff Johnson295189b2012-06-20 16:38:30 -07007485static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7486{
7487 eCsrRoamCompleteResult result;
7488 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7489 tCsrRoamInfo roamInfo;
7490 tANI_U32 roamId = 0;
7491
7492 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007494 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 /* Defeaturize this part later if needed */
7497#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7498 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7499 * we need the response contents while processing the result in csrRoamProcessResults() */
7500 if (csrRoamIsHandoffInProgress(pMac))
7501 {
7502 /* Need to dig more on indicating events to SME QoS module */
7503 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7504 csrRoamComplete( pMac, result, pSmeJoinRsp);
7505 }
7506 else
7507#endif
7508 {
7509 csrRoamComplete( pMac, result, NULL );
7510 }
7511 }
7512 /* Should we handle this similar to handling the join failure? Is it ok
7513 * to call csrRoamComplete() with state as CsrJoinFailure */
7514 else
7515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007516 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007517 result = eCsrReassocFailure;
7518#ifdef WLAN_FEATURE_VOWIFI_11R
7519 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7520 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7521 {
7522 // Inform HDD to turn off FT flag in HDD
7523 if (pNeighborRoamInfo)
7524 {
7525 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7526 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7527 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007528 /*
7529 * Since the above callback sends a disconnect
7530 * to HDD, we should clean-up our state
7531 * machine as well to be in sync with the upper
7532 * layers. There is no need to send a disassoc
7533 * since: 1) we will never reassoc to the current
7534 * AP in LFR, and 2) there is no need to issue a
7535 * disassoc to the AP with which we were trying
7536 * to reassoc.
7537 */
7538 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7539 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 }
7541 }
7542#endif
7543 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7544 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7545 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7546 //The disassoc rsp message will remove the command from active list
7547 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7548 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7549 {
7550 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7551 }
7552 }
7553}
7554
Jeff Johnson295189b2012-06-20 16:38:30 -07007555static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7556{
Jeff Johnson295189b2012-06-20 16:38:30 -07007557#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7558 {
7559 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7561 if(pIbssLog)
7562 {
7563 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7564 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7565 {
7566 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7567 }
7568 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7569 }
7570 }
7571#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7573 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7574 {
7575 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7576 }
7577 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7578 {
7579 csrRoamReissueRoamCommand(pMac);
7580 }
7581}
7582
Jeff Johnson295189b2012-06-20 16:38:30 -07007583void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7584{
7585 tSirResultCodes statusCode;
7586#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7587 tScanResultHandle hBSSList;
7588 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7589 eHalStatus status;
7590 tCsrRoamInfo roamInfo;
7591 tCsrScanResultFilter *pScanFilter = NULL;
7592 tANI_U32 roamId = 0;
7593 tCsrRoamProfile *pCurRoamProfile = NULL;
7594 tListElem *pEntry = NULL;
7595 tSmeCmd *pCommand = NULL;
7596#endif
7597 tANI_U32 sessionId;
7598 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007599
Jeff Johnson295189b2012-06-20 16:38:30 -07007600 tSirSmeDisassocRsp SmeDisassocRsp;
7601
7602 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7603 sessionId = SmeDisassocRsp.sessionId;
7604 statusCode = SmeDisassocRsp.statusCode;
7605
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007606 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007607
7608 if ( csrIsConnStateInfra( pMac, sessionId ) )
7609 {
7610 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007613
7614 if(!pSession)
7615 {
7616 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7617 return;
7618 }
7619
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7621 {
7622 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7623 }
7624 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7625 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7626 {
7627 if ( eSIR_SME_SUCCESS == statusCode )
7628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007629 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7631 }
7632 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007636 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007637#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007638 /*
7639 * First ensure if the roam profile is in the scan cache.
7640 * If not, post a reassoc failure and disconnect.
7641 */
7642 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7643 if(HAL_STATUS_SUCCESS(status))
7644 {
7645 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7646 status = csrRoamPrepareFilterFromProfile(pMac,
7647 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7648 if(!HAL_STATUS_SUCCESS(status))
7649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007650 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007651 __func__, status);
7652 goto POST_ROAM_FAILURE;
7653 }
7654 else
7655 {
7656 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7657 if (!HAL_STATUS_SUCCESS(status))
7658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007659 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007660 __func__, status);
7661 goto POST_ROAM_FAILURE;
7662 }
7663 }
7664 }
7665 else
7666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007667 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007668 __func__, status);
7669 goto POST_ROAM_FAILURE;
7670 }
7671
7672 /*
7673 * After ensuring that the roam profile is in the scan result list,
7674 * dequeue the command from the active list.
7675 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7677 if ( pEntry )
7678 {
7679 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007680 /* If the head of the queue is Active and it is a ROAM command, remove
7681 * and put this on the Free queue.
7682 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 if ( eSmeCommandRoam == pCommand->command )
7684 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007685
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007686 /*
7687 * we need to process the result first before removing it from active list
7688 * because state changes still happening insides roamQProcessRoamResults so
7689 * no other roam command should be issued.
7690 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007691 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7692 if(pCommand->u.roamCmd.fReleaseProfile)
7693 {
7694 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7695 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 else
7700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007701 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007702 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 }
7704 }
7705 else
7706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007707 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007708 }
7709 }
7710 else
7711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007712 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007714
7715 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007716 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7717
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007718 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7719 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7720 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007721
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007722 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7723 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007724
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007725 /* Copy the connected profile to apply the same for this connection as well */
7726 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7727 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007729 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7730 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7731 //make sure to put it at the head of the cmd queue
7732 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7733 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7734 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7735
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 if(!HAL_STATUS_SUCCESS(status))
7737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007738 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007739 __func__, status);
7740 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 }
7742
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007743 /* Notify sub-modules like QoS etc. that handoff happening */
7744 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007745 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007746 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007747 csrFreeScanFilter(pMac, pScanFilter);
7748 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007749 return;
7750 }
7751
7752POST_ROAM_FAILURE:
7753 if (pScanFilter)
7754 {
7755 csrFreeScanFilter(pMac, pScanFilter);
7756 palFreeMemory( pMac->hHdd, pScanFilter );
7757 }
7758 if (pCurRoamProfile)
7759 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7760
7761 /* Inform the upper layers that the reassoc failed */
7762 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7763 csrRoamCallCallback(pMac, sessionId,
7764 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7765
7766 /*
7767 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7768 * Upon success, we would re-enter this routine after receiving the disassoc
7769 * response and will fall into the reassoc fail sub-state. And, eventually
7770 * call csrRoamComplete which would remove the roam command from SME active
7771 * queue.
7772 */
7773 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7774 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007776 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007777 __func__, status);
7778 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007780#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007781
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7783 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7784 {
7785 // Disassoc due to Reassoc failure falls into this codepath....
7786 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7787 }
7788 else
7789 {
7790 if ( eSIR_SME_SUCCESS == statusCode )
7791 {
7792 // Successfully disassociated from the 'old' Bss...
7793 //
7794 // We get Disassociate response in three conditions.
7795 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7796 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7797 // Infrastructure network.
7798 // - Third is where we are doing an Infra to Infra roam between networks with different
7799 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7800
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007801 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007802 }
7803 else
7804 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007805 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 }
7807 //We are not done yet. Get the data and continue roaming
7808 csrRoamReissueRoamCommand(pMac);
7809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007810}
7811
Jeff Johnson295189b2012-06-20 16:38:30 -07007812static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7813{
7814 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007816 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7818 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7819 {
7820 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7821 }
7822 else
7823 {
7824 if ( eSIR_SME_SUCCESS == statusCode )
7825 {
7826 // Successfully deauth from the 'old' Bss...
7827 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007828 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 }
7830 else
7831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007832 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 }
7834 //We are not done yet. Get the data and continue roaming
7835 csrRoamReissueRoamCommand(pMac);
7836 }
7837}
7838
Jeff Johnson295189b2012-06-20 16:38:30 -07007839static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7840{
7841 eCsrRoamCompleteResult result;
7842
7843 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007845 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 result = eCsrStartBssSuccess;
7847 }
7848 else
7849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007850 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007851 //Let csrRoamComplete decide what to do
7852 result = eCsrStartBssFailure;
7853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007855}
7856
Jeff Johnson295189b2012-06-20 16:38:30 -07007857/*
7858 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7859 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7860 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7861 For the messages where sender allocates memory for specific structures, then it can be
7862 cast accordingly.
7863*/
7864void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7865{
7866 tSirSmeRsp *pSmeRsp;
7867 tSmeIbssPeerInd *pIbssPeerInd;
7868 tCsrRoamInfo roamInfo;
7869 // TODO Session Id need to be acquired in this function
7870 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007872 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007873 pSmeRsp->messageType, pSmeRsp->messageType,
7874 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 pSmeRsp->messageType = (pSmeRsp->messageType);
7876 pSmeRsp->length = (pSmeRsp->length);
7877 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 switch (pSmeRsp->messageType)
7879 {
7880
7881 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7882 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7883 {
7884 //We sent a JOIN_REQ
7885 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7886 }
7887 break;
7888
7889 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7890 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7891 {
7892 //We sent a AUTH_REQ
7893 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7894 }
7895 break;
7896
7897 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7898 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7899 {
7900 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7901 }
7902 break;
7903
7904 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7905 {
7906 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7907 }
7908 break;
7909
7910 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7911 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7912 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7913 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7914 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7915 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7916//HO
7917 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007919 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7921 }
7922 break;
7923
7924 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7925 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7926 {
7927 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7928 }
7929 break;
7930
7931 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7932 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7933 {
7934 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7935 }
7936 break;
7937
7938 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7939 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7940 {
7941 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7945 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7946 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007947 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7949 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7950 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7951 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7952 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7953 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7954 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7955 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7956 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007957 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007958 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 pSmeRsp->messageType, pSmeRsp->messageType,
7960 pMac->roam.curSubState[pSmeRsp->sessionId] );
7961
7962 //If we are connected, check the link status change
7963 if(!csrIsConnStateDisconnected(pMac, sessionId))
7964 {
7965 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7966 }
7967 break;
7968 }
7969}
7970
Jeff Johnson295189b2012-06-20 16:38:30 -07007971void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7972{
7973 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 switch (pSirMsg->messageType)
7975 {
7976 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007977 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007978 csrRoamStatsRspProcessor( pMac, pSirMsg );
7979 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7981 {
7982 tCsrRoamSession *pSession;
7983 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7984 tCsrRoamInfo roamInfo;
7985 tCsrRoamInfo *pRoamInfo = NULL;
7986 tANI_U32 sessionId;
7987 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007988 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7990 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7992 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7993 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007994
7995 if(!pSession)
7996 {
7997 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7998 return;
7999 }
8000
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8002 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008003 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8004 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8005 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8007 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
8009 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008011 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8012 {
8013 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8014 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8015 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8016 }
8017 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8018 {
8019 vos_sleep( 100 );
8020 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8021 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8022 }
8023
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 }
8025 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008026 default:
8027 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8028 break;
8029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008030}
8031
Jeff Johnson295189b2012-06-20 16:38:30 -07008032eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8033 tSirBssDescription *pBssDescription,
8034 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8035 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8036 tANI_U8 keyId, tANI_U16 keyLength,
8037 tANI_U8 *pKey, tANI_U8 paeRole )
8038{
8039 eHalStatus status = eHAL_STATUS_SUCCESS;
8040 tAniEdType edType;
8041
8042 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8043 {
8044 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8045 }
8046
8047 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8048
8049 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8050 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8051 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8052 addKey )
8053 {
8054 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 setKey.encType = EncryptType;
8056 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
8057 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
8058 setKey.paeRole = paeRole; //0 for supplicant
8059 setKey.keyId = keyId; // Kye index
8060 setKey.keyLength = keyLength;
8061 if( keyLength )
8062 {
8063 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
8064 }
8065 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 return (status);
8068}
8069
Jeff Johnson295189b2012-06-20 16:38:30 -07008070static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8071 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8072{
8073 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8074 tSmeCmd *pCommand = NULL;
8075#ifdef FEATURE_WLAN_CCX
8076 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8077#endif /* FEATURE_WLAN_CCX */
8078
8079 do
8080 {
8081 pCommand = csrGetCommandBuffer(pMac);
8082 if(NULL == pCommand)
8083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008084 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 status = eHAL_STATUS_RESOURCES;
8086 break;
8087 }
8088 pCommand->command = eSmeCommandSetKey;
8089 pCommand->sessionId = (tANI_U8)sessionId;
8090 // validate the key length, Adjust if too long...
8091 // for static WEP the keys are not set thru' SetContextReq
8092 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8093 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8094 {
8095 //KeyLength maybe 0 for static WEP
8096 if( pSetKey->keyLength )
8097 {
8098 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008100 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 break;
8102 }
8103
8104 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
8105 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
8106 }
8107 }
8108 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8109 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8110 {
8111 //KeyLength maybe 0 for static WEP
8112 if( pSetKey->keyLength )
8113 {
8114 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008116 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 break;
8118 }
8119
8120 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
8121 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
8122 }
8123 }
8124 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8125 {
8126 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008128 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 break;
8130 }
8131 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
8132 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
8133 }
8134 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8135 {
8136 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008138 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 break;
8140 }
8141 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
8142 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
8143 }
8144#ifdef FEATURE_WLAN_WAPI
8145 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8146 {
8147 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008149 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 break;
8151 }
8152 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
8153 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
8154 }
8155#endif /* FEATURE_WLAN_WAPI */
8156#ifdef FEATURE_WLAN_CCX
8157 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8158 {
8159 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008161 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008162 break;
8163 }
8164 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
8165 pSession->ccxCckmInfo.reassoc_req_num=1;
8166 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8167 status = eHAL_STATUS_SUCCESS;
8168 break;
8169 }
8170#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008171
Jeff Johnson295189b2012-06-20 16:38:30 -07008172#ifdef WLAN_FEATURE_11W
8173 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008174 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008175 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008176 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008178 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 break;
8180 }
8181 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Chet Lanctot186b5732013-03-18 10:26:30 -07008182 palCopyMemory(pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 }
8184#endif
8185 status = eHAL_STATUS_SUCCESS;
8186 pCommand->u.setKeyCmd.roamId = roamId;
8187 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8188 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
8189 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
8190 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8191 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
8192 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
8193 //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
8194
8195 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8196 if( !HAL_STATUS_SUCCESS( status ) )
8197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008198 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 }
8200 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 // Free the command if there has been a failure, or it is a
8202 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008203 if ( ( NULL != pCommand ) &&
8204 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008205#ifdef FEATURE_WLAN_CCX
8206 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8207#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008208 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 {
8210 csrReleaseCommandSetKey( pMac, pCommand );
8211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 return( status );
8213}
8214
Jeff Johnson295189b2012-06-20 16:38:30 -07008215eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8216 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8217{
8218 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8219 tSmeCmd *pCommand = NULL;
8220 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 do
8222 {
8223 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008225 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 status = eHAL_STATUS_CSR_WRONG_STATE;
8227 break;
8228 }
8229 pCommand = csrGetCommandBuffer(pMac);
8230 if(NULL == pCommand)
8231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008232 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008233 status = eHAL_STATUS_RESOURCES;
8234 break;
8235 }
8236 pCommand->command = eSmeCommandRemoveKey;
8237 pCommand->sessionId = (tANI_U8)sessionId;
8238 pCommand->u.removeKeyCmd.roamId = roamId;
8239 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
8240 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
8241 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8242 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8243 {
8244 //in this case, put it to the end of the Q incase there is a set key pending.
8245 fImediate = eANI_BOOLEAN_FALSE;
8246 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008247 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 pRemoveKey->encType, pRemoveKey->keyId,
8249 pCommand->u.removeKeyCmd.peerMac[0],
8250 pCommand->u.removeKeyCmd.peerMac[1],
8251 pCommand->u.removeKeyCmd.peerMac[2],
8252 pCommand->u.removeKeyCmd.peerMac[3],
8253 pCommand->u.removeKeyCmd.peerMac[4],
8254 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8256 if( !HAL_STATUS_SUCCESS( status ) )
8257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008258 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 break;
8260 }
8261 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8263 {
8264 csrReleaseCommandRemoveKey( pMac, pCommand );
8265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 return (status );
8267}
8268
Jeff Johnson295189b2012-06-20 16:38:30 -07008269eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8270{
8271 eHalStatus status;
8272 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8273 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8274 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8275 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008276#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8277 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8278 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008279 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 {
8281 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8282 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8283 {
8284 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8285 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8286 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8287 }
8288 else
8289 {
8290 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8291 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8292 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8293 }
8294 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
lukez3c809222013-05-03 10:23:02 -07008295 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 {
8297 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 //It has to be static WEP here
8299 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8300 {
8301 setKeyEvent.keyId = (v_U8_t)defKeyId;
8302 }
8303 }
8304 else
8305 {
8306 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8307 }
8308 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8309 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8310 }
8311#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 if( csrIsSetKeyAllowed(pMac, sessionId) )
8313 {
8314 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8315 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8316 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8317 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8318 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8319 pCommand->u.setKeyCmd.keyRsc);
8320 }
8321 else
8322 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008323 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 //Set this status so the error handling take care of the case.
8325 status = eHAL_STATUS_CSR_WRONG_STATE;
8326 }
8327 if( !HAL_STATUS_SUCCESS(status) )
8328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008329 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008331#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008332 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 {
8334 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8335 {
8336 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8337 }
8338 else
8339 {
8340 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8341 }
8342 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8343 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8344 }
8345#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 return ( status );
8348}
8349
Jeff Johnson295189b2012-06-20 16:38:30 -07008350eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8351{
8352 eHalStatus status;
8353 tpSirSmeRemoveKeyReq pMsg = NULL;
8354 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8355 tANI_U8 *p;
8356 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008357#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8358 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8359 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8361 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8362 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8363 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8364 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8365 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8366 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8367 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8368#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 if( csrIsSetKeyAllowed(pMac, sessionId) )
8370 {
8371 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8372 }
8373 else
8374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008375 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008376 //Set the error status so error handling kicks in below
8377 status = eHAL_STATUS_CSR_WRONG_STATE;
8378 }
8379 if( HAL_STATUS_SUCCESS( status ) )
8380 {
8381 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8382 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8383 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 pMsg->sessionId = (tANI_U8)sessionId;
8385 pMsg->transactionId = 0;
8386 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8387 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8388 // bssId - copy from session Info
8389 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8390 p += sizeof(tSirMacAddr);
8391 // peerMacAddr
8392 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8393 p += sizeof(tSirMacAddr);
8394 // edType
8395 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8396 p++;
8397 // weptype
8398 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8399 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8400 {
8401 *p = (tANI_U8)eSIR_WEP_STATIC;
8402 }
8403 else
8404 {
8405 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8406 }
8407 p++;
8408 //keyid
8409 *p = pCommand->u.removeKeyCmd.keyId;
8410 p++;
8411 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 status = palSendMBMessage(pMac->hHdd, pMsg);
8413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 if( !HAL_STATUS_SUCCESS( status ) )
8415 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008416 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008417#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8418 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008419 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8421#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 return ( status );
8425}
8426
Jeff Johnson295189b2012-06-20 16:38:30 -07008427eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8428{
8429 eHalStatus status;
8430
8431 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8432 {
8433 status = eHAL_STATUS_CSR_WRONG_STATE;
8434 }
8435 else
8436 {
8437 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 return ( status );
8440}
8441
Jeff Johnson295189b2012-06-20 16:38:30 -07008442/*
8443 Prepare a filter base on a profile for parsing the scan results.
8444 Upon successful return, caller MUST call csrFreeScanFilter on
8445 pScanFilter when it is done with the filter.
8446*/
8447eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8448 tCsrScanResultFilter *pScanFilter)
8449{
8450 eHalStatus status = eHAL_STATUS_SUCCESS;
8451 tANI_U32 size = 0;
8452 tANI_U8 index = 0;
8453
8454 do
8455 {
8456 if(pProfile->BSSIDs.numOfBSSIDs)
8457 {
8458 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8459 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8460 if(!HAL_STATUS_SUCCESS(status))
8461 {
8462 break;
8463 }
8464 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8465 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8466 }
8467 if(pProfile->SSIDs.numOfSSIDs)
8468 {
8469 if( !CSR_IS_WDS_STA( pProfile ) )
8470 {
8471 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8472 }
8473 else
8474 {
8475 //For WDS station
8476 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8477 pScanFilter->SSIDs.numOfSSIDs = 1;
8478 }
8479 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8480 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8481 if(!HAL_STATUS_SUCCESS(status))
8482 {
8483 break;
8484 }
8485 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8486 }
8487 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8488 {
8489 pScanFilter->ChannelInfo.numOfChannels = 0;
8490 pScanFilter->ChannelInfo.ChannelList = NULL;
8491 }
8492 else if(pProfile->ChannelInfo.numOfChannels)
8493 {
8494 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8495 pScanFilter->ChannelInfo.numOfChannels = 0;
8496 if(HAL_STATUS_SUCCESS(status))
8497 {
8498 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8499 {
8500 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8501 {
8502 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8503 = pProfile->ChannelInfo.ChannelList[index];
8504 pScanFilter->ChannelInfo.numOfChannels++;
8505 }
8506 else
8507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008508 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 }
8511 }
8512 else
8513 {
8514 break;
8515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 }
8517 else
8518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008519 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 status = eHAL_STATUS_FAILURE;
8521 break;
8522 }
8523 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8524 pScanFilter->authType = pProfile->AuthType;
8525 pScanFilter->EncryptionType = pProfile->EncryptionType;
8526 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8527 pScanFilter->BSSType = pProfile->BSSType;
8528 pScanFilter->phyMode = pProfile->phyMode;
8529#ifdef FEATURE_WLAN_WAPI
8530 //check if user asked for WAPI with 11n or auto mode, in that case modify
8531 //the phymode to 11g
8532 if(csrIsProfileWapi(pProfile))
8533 {
8534 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8535 {
8536 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8537 }
8538 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8539 {
8540 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8541 }
8542 if(!pScanFilter->phyMode)
8543 {
8544 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8545 }
8546 }
8547#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 /*Save the WPS info*/
8549 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 if( pProfile->countryCode[0] )
8551 {
8552 //This causes the matching function to use countryCode as one of the criteria.
8553 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8554 WNI_CFG_COUNTRY_CODE_LEN );
8555 }
8556#ifdef WLAN_FEATURE_VOWIFI_11R
8557 if (pProfile->MDID.mdiePresent)
8558 {
8559 pScanFilter->MDID.mdiePresent = 1;
8560 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8561 }
8562#endif
8563
8564 }while(0);
8565
8566 if(!HAL_STATUS_SUCCESS(status))
8567 {
8568 csrFreeScanFilter(pMac, pScanFilter);
8569 }
8570
8571 return(status);
8572}
8573
Jeff Johnson295189b2012-06-20 16:38:30 -07008574tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8575 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8576{
8577 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8578 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 do
8580 {
8581 // Validate the type is ok...
8582 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8583 pCommand = csrGetCommandBuffer( pMac );
8584 if ( !pCommand )
8585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008586 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 break;
8588 }
8589 //Change the substate in case it is waiting for key
8590 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8591 {
8592 csrRoamStopWaitForKeyTimer( pMac );
8593 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8594 }
8595 pCommand->command = eSmeCommandWmStatusChange;
8596 pCommand->sessionId = (tANI_U8)sessionId;
8597 pCommand->u.wmStatusChangeCmd.Type = Type;
8598 if ( eCsrDisassociated == Type )
8599 {
8600 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8601 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8602 }
8603 else
8604 {
8605 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8606 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8607 }
8608 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8609 {
8610 fCommandQueued = eANI_BOOLEAN_TRUE;
8611 }
8612 else
8613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008614 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 csrReleaseCommandWmStatusChange( pMac, pCommand );
8616 }
8617
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8619 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 return( fCommandQueued );
8622}
8623
Jeff Johnson295189b2012-06-20 16:38:30 -07008624static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8625{
8626 v_S7_t rssi = 0;
8627 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8628 if(pGetRssiReq)
8629 {
8630 if(NULL != pGetRssiReq->pVosContext)
8631 {
8632 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8633 }
8634 else
8635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008636 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 return;
8638 }
8639
8640 if(NULL != pGetRssiReq->rssiCallback)
8641 {
8642 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8643 }
8644 else
8645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008646 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 return;
8648 }
8649 }
8650 else
8651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008652 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 }
8654 return;
8655}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008656#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8657void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8658{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008659 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8660
Jeff Johnson36d483b2013-04-08 11:08:53 -07008661 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008662 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008663 /* Get roam Rssi request is backed up and passed back to the response,
8664 Extract the request message to fetch callback */
8665 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8666 v_S7_t rssi = pRoamRssiRsp->rssi;
8667
8668 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008669 {
8670 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8671 reqBkp->rssiCallback = NULL;
8672 vos_mem_free(reqBkp);
8673 }
8674 else
8675 {
8676 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8677 if (NULL != reqBkp)
8678 {
8679 vos_mem_free(reqBkp);
8680 }
8681 }
8682 }
8683 else
8684 {
8685 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8686 }
8687 return;
8688}
8689#endif
8690
Jeff Johnsone7245742012-09-05 17:12:55 -07008691static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8692{
8693 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8694 if(pTlRssiInd)
8695 {
8696 if(NULL != pTlRssiInd->tlCallback)
8697 {
8698 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008699 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008700 }
8701 else
8702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008703 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008704 }
8705 }
8706 else
8707 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008708 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008709 }
8710 return;
8711}
Jeff Johnson295189b2012-06-20 16:38:30 -07008712
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308713eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8714{
8715 tpSirResetAPCapsChange pMsg;
8716 tANI_U16 len;
8717 eHalStatus status = eHAL_STATUS_SUCCESS;
8718
8719 /* Create the message and send to lim */
8720 len = sizeof(tSirResetAPCapsChange);
8721 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8722 if (HAL_STATUS_SUCCESS(status))
8723 {
8724 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8725 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8726 pMsg->length = len;
8727 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8728 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8729 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8730 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8731 status = palSendMBMessage(pMac->hHdd, pMsg);
8732 }
8733 else
8734 {
8735 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8736 }
8737 return status;
8738}
8739
Jeff Johnson295189b2012-06-20 16:38:30 -07008740void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8741{
8742 tSirSmeAssocInd *pAssocInd;
8743 tSirSmeDisassocInd *pDisassocInd;
8744 tSirSmeDeauthInd *pDeauthInd;
8745 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8746 tSirSmeNewBssInfo *pNewBss;
8747 tSmeIbssPeerInd *pIbssPeerInd;
8748 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8749 tSirSmeApNewCaps *pApNewCaps;
8750 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8751 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8752 tCsrRoamInfo *pRoamInfo = NULL;
8753 tCsrRoamInfo roamInfo;
8754 eHalStatus status;
8755 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8756 tCsrRoamSession *pSession = NULL;
8757 tpSirSmeSwitchChannelInd pSwitchChnInd;
8758 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008759 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 pSirMsg->messageType = (pSirMsg->messageType);
8761 pSirMsg->length = (pSirMsg->length);
8762 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008763 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 switch( pSirMsg->messageType )
8765 {
8766 case eWNI_SME_ASSOC_IND:
8767 {
8768 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008769 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8771 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8772 if( HAL_STATUS_SUCCESS( status ) )
8773 {
8774 pSession = CSR_GET_SESSION(pMac, sessionId);
8775
Jeff Johnson32d95a32012-09-10 13:15:23 -07008776 if(!pSession)
8777 {
8778 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8779 return;
8780 }
8781
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 pRoamInfo = &roamInfo;
8783
8784 // Required for indicating the frames to upper layer
8785 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8786 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8787
8788 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8789 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8790 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8791 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8792
8793 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8794 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8795 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8796
8797 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8798 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8800 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8802 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008803 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8805 {
8806 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8807 {
8808 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8809 pSession->pConnectBssDesc,
8810 &(pRoamInfo->peerMac),
8811 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8812 pRoamInfo->fAuthRequired = FALSE;
8813 }
8814 else
8815 {
8816 pRoamInfo->fAuthRequired = TRUE;
8817 }
8818 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8819 if (!HAL_STATUS_SUCCESS(status))
8820 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008822 /* Send Association completion message to PE */
8823 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8824
8825 /* send a message to CSR itself just to avoid the EAPOL frames going
8826 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8828 {
8829 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8832 {
8833 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8834 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8835 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 }
8838 }
8839 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008841 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 // Check if AP dis-associated us because of MIC failure. If so,
8843 // then we need to take action immediately and not wait till the
8844 // the WmStatusChange requests is pushed and processed
8845 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8846 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8847 if( HAL_STATUS_SUCCESS( status ) )
8848 {
8849 // If we are in neighbor preauth done state then on receiving
8850 // disassoc or deauth we dont roam instead we just disassoc
8851 // from current ap and then go to disconnected state
8852 // This happens for CCX and 11r FT connections ONLY.
8853#ifdef WLAN_FEATURE_VOWIFI_11R
8854 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8855 {
8856 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8857 }
8858#endif
8859#ifdef FEATURE_WLAN_CCX
8860 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8861 {
8862 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8863 }
8864#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008865#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308866 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008867 {
8868 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8869 }
8870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 pSession = CSR_GET_SESSION( pMac, sessionId );
8872
Jeff Johnson32d95a32012-09-10 13:15:23 -07008873 if(!pSession)
8874 {
8875 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8876 return;
8877 }
8878
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 if ( csrIsConnStateInfra( pMac, sessionId ) )
8880 {
8881 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008883#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8884 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8885#endif
8886 csrRoamLinkDown(pMac, sessionId);
8887 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8889 {
8890
8891 pRoamInfo = &roamInfo;
8892
8893 pRoamInfo->statusCode = pDisassocInd->statusCode;
8894 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8895
8896 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8897
8898 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8899 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8900
8901 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008902
8903 /*
8904 * STA/P2P client got disassociated so remove any pending deauth
8905 * commands in sme pending list
8906 */
8907 pCommand.command = eSmeCommandRoam;
8908 pCommand.sessionId = (tANI_U8)sessionId;
8909 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8910 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8911 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 }
8914 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008916 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8918 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8919 if( HAL_STATUS_SUCCESS( status ) )
8920 {
8921 // If we are in neighbor preauth done state then on receiving
8922 // disassoc or deauth we dont roam instead we just disassoc
8923 // from current ap and then go to disconnected state
8924 // This happens for CCX and 11r FT connections ONLY.
8925#ifdef WLAN_FEATURE_VOWIFI_11R
8926 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8927 {
8928 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8929 }
8930#endif
8931#ifdef FEATURE_WLAN_CCX
8932 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8933 {
8934 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8935 }
8936#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008937#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308938 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008939 {
8940 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8941 }
8942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 pSession = CSR_GET_SESSION( pMac, sessionId );
8944
Jeff Johnson32d95a32012-09-10 13:15:23 -07008945 if(!pSession)
8946 {
8947 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8948 return;
8949 }
8950
Jeff Johnson295189b2012-06-20 16:38:30 -07008951 if ( csrIsConnStateInfra( pMac, sessionId ) )
8952 {
8953 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008955#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8956 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8957#endif
8958 csrRoamLinkDown(pMac, sessionId);
8959 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008960 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8961 {
8962
8963 pRoamInfo = &roamInfo;
8964
8965 pRoamInfo->statusCode = pDeauthInd->statusCode;
8966 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8967
8968 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8969
8970 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8971 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8972
8973 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 }
8976 break;
8977
8978 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 -08008979 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8981 //Update with the new channel id.
8982 //The channel id is hidden in the statusCode.
8983 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8984 if( HAL_STATUS_SUCCESS( status ) )
8985 {
8986 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008987 if(!pSession)
8988 {
8989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8990 return;
8991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8993 if(pSession->pConnectBssDesc)
8994 {
8995 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8996 }
8997 }
8998 break;
8999
9000 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009001 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009002 {
9003 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9004 sessionId = pDeauthRsp->sessionId;
9005 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9006 {
9007 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009008 if(!pSession)
9009 {
9010 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9011 return;
9012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9014 {
9015 pRoamInfo = &roamInfo;
9016 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9017 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
9018 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9019 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9020 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9021 }
9022 }
9023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 break;
9025
9026 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009027 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009028 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 {
9030 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9031 sessionId = pDisassocRsp->sessionId;
9032 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9033 {
9034 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009035 if(!pSession)
9036 {
9037 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9038 return;
9039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9041 {
9042 pRoamInfo = &roamInfo;
9043 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9044 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
9045 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9046 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9047 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9048 }
9049 }
9050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 case eWNI_SME_MIC_FAILURE_IND:
9053 {
9054 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9055 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9056 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07009057#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9058 {
lukez3c809222013-05-03 10:23:02 -07009059 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009061 if(!pSession)
9062 {
9063 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9064 return;
9065 }
lukez3c809222013-05-03 10:23:02 -07009066
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
9068 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9069 secEvent.encryptionModeMulticast =
9070 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9071 secEvent.encryptionModeUnicast =
9072 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9073 secEvent.authMode =
9074 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9075 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
9076 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9077 }
9078#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9080 if( HAL_STATUS_SUCCESS( status ) )
9081 {
9082 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9083 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9084 pRoamInfo = &roamInfo;
9085 if(pMicInd->info.multicast)
9086 {
9087 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9088 }
9089 else
9090 {
9091 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9092 }
9093 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9094 }
9095 }
9096 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9098 {
9099 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9100 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009101 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009102
9103 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9104 if( HAL_STATUS_SUCCESS( status ) )
9105 {
9106 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9107 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9108 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9109 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9110 }
9111 }
9112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009113
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9115 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9116 switch( pStatusChangeMsg->statusChangeCode )
9117 {
9118 case eSIR_SME_IBSS_ACTIVE:
9119 sessionId = csrFindIbssSession( pMac );
9120 if( CSR_SESSION_ID_INVALID != sessionId )
9121 {
9122 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009123 if(!pSession)
9124 {
9125 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9126 return;
9127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9129 if(pSession->pConnectBssDesc)
9130 {
9131 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9132 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9133 pRoamInfo = &roamInfo;
9134 }
9135 else
9136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009137 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009138 }
9139 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9140 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9141 }
9142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 case eSIR_SME_IBSS_INACTIVE:
9144 sessionId = csrFindIbssSession( pMac );
9145 if( CSR_SESSION_ID_INVALID != sessionId )
9146 {
9147 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009148 if(!pSession)
9149 {
9150 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9151 return;
9152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9154 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9155 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9156 }
9157 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9159 sessionId = csrFindIbssSession( pMac );
9160 if( CSR_SESSION_ID_INVALID != sessionId )
9161 {
9162 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009163 if(!pSession)
9164 {
9165 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9166 return;
9167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 // update the connection state information
9169 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009170#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9171 {
9172 vos_log_ibss_pkt_type *pIbssLog;
9173 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9175 if(pIbssLog)
9176 {
9177 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9178 if(pNewBss)
9179 {
9180 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
9181 if(pNewBss->ssId.length)
9182 {
9183 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
9184 }
9185 pIbssLog->operatingChannel = pNewBss->channelNumber;
9186 }
9187 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9188 {
9189 //***U8 is not enough for beacon interval
9190 pIbssLog->beaconInterval = (v_U8_t)bi;
9191 }
9192 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9193 }
9194 }
9195#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009197
9198 if ((eCSR_ENCRYPT_TYPE_NONE ==
9199 pSession->connectedProfile.EncryptionType ))
9200 {
9201 csrRoamIssueSetContextReq( pMac, sessionId,
9202 pSession->connectedProfile.EncryptionType,
9203 pSession->pConnectBssDesc,
9204 &Broadcastaddr,
9205 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9208 roamStatus = eCSR_ROAM_IBSS_IND;
9209 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
9210 pRoamInfo = &roamInfo;
9211 //This BSSID is th ereal BSSID, let's save it
9212 if(pSession->pConnectBssDesc)
9213 {
9214 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
9215 }
9216 // Stop the join IBSS timer in case of join, for
9217 // genuine merge do nothing
9218 if(pSession->ibss_join_pending)
9219 {
9220 pSession->ibss_join_pending = FALSE;
9221 csrRoamStopIbssJoinTimer(pMac, sessionId);
9222 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
9223 }
9224 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009225 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 // detection by LIM that the capabilities of the associated AP have changed.
9228 case eSIR_SME_AP_CAPS_CHANGED:
9229 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009230 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9232 if( HAL_STATUS_SUCCESS( status ) )
9233 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009234 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9235 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309236 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009237 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9238 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9239 )
9240 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309241 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9242 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009243 }
9244 else
9245 {
9246 smsLog(pMac, LOGW,
9247 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009248 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009249 pMac->roam.curState[sessionId],
9250 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309251 /* We ignore the caps change event if CSR is not in full connected state.
9252 * Send one event to PE to reset limSentCapsChangeNtf
9253 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9254 * otherwise lim cannot send any CAPS change events to SME */
9255 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 }
9258 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309259
Jeff Johnson295189b2012-06-20 16:38:30 -07009260 default:
9261 roamStatus = eCSR_ROAM_FAILED;
9262 result = eCSR_ROAM_RESULT_NONE;
9263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 } // end switch on statusChangeCode
9265 if(eCSR_ROAM_RESULT_NONE != result)
9266 {
9267 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9268 }
9269 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 case eWNI_SME_IBSS_NEW_PEER_IND:
9271 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009272#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9273 {
9274 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9276 if(pIbssLog)
9277 {
9278 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
9279 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9280 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9281 }
9282 }
9283#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 sessionId = csrFindIbssSession( pMac );
9285 if( CSR_SESSION_ID_INVALID != sessionId )
9286 {
9287 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009288
9289 if(!pSession)
9290 {
9291 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9292 return;
9293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009294 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9295 if(pSession->pConnectBssDesc)
9296 {
9297 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9298 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
9299 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9300 {
9301 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
9302 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
9303 if(HAL_STATUS_SUCCESS(status))
9304 {
9305 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
9306 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9307 roamInfo.nBeaconLength);
9308 }
9309 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9310 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9311 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9312 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
9313 pSession->pConnectBssDesc->length);
9314 if(HAL_STATUS_SUCCESS(status))
9315 {
9316 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
9317 pSession->pConnectBssDesc->length);
9318 }
9319 if(HAL_STATUS_SUCCESS(status))
9320 {
9321 pRoamInfo = &roamInfo;
9322 }
9323 else
9324 {
9325 if(roamInfo.pbFrames)
9326 {
9327 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9328 }
9329 if(roamInfo.pBssDesc)
9330 {
9331 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9332 }
9333 }
9334 }
9335 else
9336 {
9337 pRoamInfo = &roamInfo;
9338 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009339 if ((eCSR_ENCRYPT_TYPE_NONE ==
9340 pSession->connectedProfile.EncryptionType ))
9341 {
9342 csrRoamIssueSetContextReq( pMac, sessionId,
9343 pSession->connectedProfile.EncryptionType,
9344 pSession->pConnectBssDesc,
9345 &(pIbssPeerInd->peerAddr),
9346 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 }
9349 else
9350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009351 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 }
9353 //send up the sec type for the new peer
9354 if (pRoamInfo)
9355 {
9356 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9357 }
9358 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9359 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9360 if(pRoamInfo)
9361 {
9362 if(roamInfo.pbFrames)
9363 {
9364 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9365 }
9366 if(roamInfo.pBssDesc)
9367 {
9368 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9369 }
9370 }
9371 }
9372 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009373 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9374 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9375 sessionId = csrFindIbssSession( pMac );
9376 if( CSR_SESSION_ID_INVALID != sessionId )
9377 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009378#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9379 {
9380 vos_log_ibss_pkt_type *pIbssLog;
9381
9382 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9383 if(pIbssLog)
9384 {
9385 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9386 if(pIbssPeerInd)
9387 {
9388 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9389 }
9390 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9391 }
9392 }
9393#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009394 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9396 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9397 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9398 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9399 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9400 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9401 }
9402 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 case eWNI_SME_SETCONTEXT_RSP:
9404 {
9405 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9406 tListElem *pEntry;
9407 tSmeCmd *pCommand;
9408
9409 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9410 if ( pEntry )
9411 {
9412 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9413 if ( eSmeCommandSetKey == pCommand->command )
9414 {
9415 sessionId = pCommand->sessionId;
9416 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009417
9418 if(!pSession)
9419 {
9420 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9421 return;
9422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009423
9424#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9425 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9426 {
9427 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9428 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9429 if( pRsp->peerMacAddr[0] & 0x01 )
9430 {
9431 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9432 }
9433 else
9434 {
9435 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9436 }
9437 setKeyEvent.encryptionModeMulticast =
9438 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9439 setKeyEvent.encryptionModeUnicast =
9440 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9441 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9442 setKeyEvent.authMode =
9443 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009444 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 {
9446 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9447 }
9448 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9449 }
9450#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9451 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9452 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009453 csrRoamStopWaitForKeyTimer( pMac );
9454
Jeff Johnson295189b2012-06-20 16:38:30 -07009455 //We are done with authentication, whethere succeed or not
9456 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 //We do it here because this linkup function is not called after association
9458 //when a key needs to be set.
9459 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9460 {
9461 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9462 }
9463 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009464 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 {
9466 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009467 //Make sure we install the GTK before indicating to HDD as authenticated
9468 //This is to prevent broadcast packets go out after PTK and before GTK.
9469 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9470 sizeof(tSirMacAddr) ) )
9471 {
Yathish9f22e662012-12-10 14:21:35 -08009472#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9473 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9474 {
9475 tpSirSetActiveModeSetBncFilterReq pMsg;
9476 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9477 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9478 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9479 pMsg->seesionId = sessionId;
9480 status = palSendMBMessage(pMac->hHdd, pMsg );
9481 }
9482#endif
9483 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009484 }
9485 else
9486 {
9487 result = eCSR_ROAM_RESULT_NONE;
9488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 pRoamInfo = &roamInfo;
9490 }
9491 else
9492 {
9493 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009494 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9496 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9497 }
9498 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9499 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9501 // can go ahead and initiate the TSPEC if any are pending
9502 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009503#ifdef FEATURE_WLAN_CCX
9504 //Send Adjacent AP repot to new AP.
9505 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9506 pSession->isPrevApInfoValid &&
9507 pSession->connectedProfile.isCCXAssoc)
9508 {
9509#ifdef WLAN_FEATURE_VOWIFI
9510 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9511#endif
9512 pSession->isPrevApInfoValid = FALSE;
9513 }
9514#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9516 {
9517 csrReleaseCommandSetKey( pMac, pCommand );
9518 }
9519 }
9520 else
9521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009522 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009523 }
9524 }
9525 else
9526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009527 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 smeProcessPendingQueue( pMac );
9530 }
9531 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009532 case eWNI_SME_REMOVEKEY_RSP:
9533 {
9534 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9535 tListElem *pEntry;
9536 tSmeCmd *pCommand;
9537
9538 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9539 if ( pEntry )
9540 {
9541 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9542 if ( eSmeCommandRemoveKey == pCommand->command )
9543 {
9544 sessionId = pCommand->sessionId;
9545 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009546
9547 if(!pSession)
9548 {
9549 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9550 return;
9551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9553 {
9554 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9555 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9556 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9557 removeKeyEvent.encryptionModeMulticast =
9558 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9559 removeKeyEvent.encryptionModeUnicast =
9560 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9561 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9562 removeKeyEvent.authMode =
9563 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009564 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 {
9566 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9567 }
9568 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9569 }
9570#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009571 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009572 {
9573 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9574 result = eCSR_ROAM_RESULT_NONE;
9575 pRoamInfo = &roamInfo;
9576 }
9577 else
9578 {
9579 result = eCSR_ROAM_RESULT_FAILURE;
9580 }
9581 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9582 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9583 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9584 {
9585 csrReleaseCommandRemoveKey( pMac, pCommand );
9586 }
9587 }
9588 else
9589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009590 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 }
9592 }
9593 else
9594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009595 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 smeProcessPendingQueue( pMac );
9598 }
9599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009601 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 csrRoamStatsRspProcessor( pMac, pSirMsg );
9603 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009604#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9605 case eWNI_SME_GET_ROAM_RSSI_RSP:
9606 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9607 csrRoamRssiRspProcessor( pMac, pSirMsg );
9608 break;
9609#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009611 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 csrUpdateRssi( pMac, pSirMsg );
9613 break;
9614
Jeff Johnson295189b2012-06-20 16:38:30 -07009615#ifdef WLAN_FEATURE_VOWIFI_11R
9616 case eWNI_SME_FT_PRE_AUTH_RSP:
9617 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9618 break;
9619#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9621 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009622 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 -07009623 sessionId = pSmeMaxAssocInd->sessionId;
9624 roamInfo.sessionId = sessionId;
9625 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9626 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9627 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9628 break;
9629
9630 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009631 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 btampEstablishLogLinkHdlr( pSirMsg );
9633 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009634 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009635 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009636 csrRoamRssiIndHdlr( pMac, pSirMsg );
9637 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009638#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
9639 case eWNI_SME_CANDIDATE_FOUND_IND:
9640 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
9641 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
9642 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07009643 case eWNI_SME_HANDOFF_REQ:
9644 smsLog( pMac, LOG2, FL("Handoff Req from self"));
9645 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
9646 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07009647#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009648
9649 default:
9650 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009652}
9653
Jeff Johnson295189b2012-06-20 16:38:30 -07009654void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9655 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9656{
9657 if(pSession)
9658 {
9659 if(pSession->bRefAssocStartCnt)
9660 {
9661 pSession->bRefAssocStartCnt--;
9662 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9663 //Need to call association_completion because there is an assoc_start pending.
9664 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9665 eCSR_ROAM_ASSOCIATION_COMPLETION,
9666 eCSR_ROAM_RESULT_FAILURE);
9667 }
9668 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9669 }
9670 else
9671 {
9672 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9673 }
9674}
9675
9676
9677eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9678{
9679 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9681 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9682 {
9683 status = csrScanRequestLostLink1( pMac, sessionId );
9684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 return(status);
9686}
9687
Jeff Johnson295189b2012-06-20 16:38:30 -07009688//return a boolean to indicate whether roaming completed or continue.
9689tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9690 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9691{
9692 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9693 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9694 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9695 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009696 if(!pSession)
9697 {
9698 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9699 return eANI_BOOLEAN_FALSE;
9700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 //Check whether time is up
9702 if(pSession->fCancelRoaming || fForce ||
9703 ((curTime - pSession->roamingStartTime) > roamTime) ||
9704 eCsrReassocRoaming == pSession->roamingReason ||
9705 eCsrDynamicRoaming == pSession->roamingReason)
9706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009707 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9709 {
9710 //roaming is cancelled, tell HDD to indicate disconnect
9711 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9712 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9713 //to be eSIR_BEACON_MISSED
9714 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9715 {
9716 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9717 }
9718 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9719 {
9720 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9721 }
9722 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9723 {
9724 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9725 }
9726 else
9727 {
9728 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9729 }
9730 }
9731 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9732 pSession->roamingReason = eCsrNotRoaming;
9733 }
9734 else
9735 {
9736 pSession->roamResult = roamResult;
9737 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9738 {
9739 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9740 pSession->roamingReason = eCsrNotRoaming;
9741 }
9742 else
9743 {
9744 fCompleted = eANI_BOOLEAN_FALSE;
9745 }
9746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 return(fCompleted);
9748}
9749
Jeff Johnson295189b2012-06-20 16:38:30 -07009750void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9751{
9752 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009753
9754 if(!pSession)
9755 {
9756 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9757 return;
9758 }
9759
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 if(CSR_IS_ROAMING(pSession))
9761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009762 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9764 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9765 {
9766 //No need to do anything in here because the handler takes care of it
9767 }
9768 else
9769 {
9770 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9771 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9772 //Roaming is stopped after here
9773 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9774 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9775 csrScanAbortMacScan(pMac);
9776 csrRoamStopRoamingTimer(pMac, sessionId);
9777 }
9778 }
9779}
9780
Jeff Johnson295189b2012-06-20 16:38:30 -07009781void csrRoamRoamingTimerHandler(void *pv)
9782{
9783 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9784 tpAniSirGlobal pMac = pInfo->pMac;
9785 tANI_U32 sessionId = pInfo->sessionId;
9786 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009787
9788 if(!pSession)
9789 {
9790 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9791 return;
9792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009793
9794 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9795 {
9796 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9797 {
9798 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9799 pSession->roamingReason = eCsrNotRoaming;
9800 }
9801 }
9802}
9803
Jeff Johnson295189b2012-06-20 16:38:30 -07009804eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9805{
9806 eHalStatus status;
9807 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009808
9809 if(!pSession)
9810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009811 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009812 return eHAL_STATUS_FAILURE;
9813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009814
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009815 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009816 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9817 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9818
9819 return (status);
9820}
9821
Jeff Johnson295189b2012-06-20 16:38:30 -07009822eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9823{
9824 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9825}
9826
Jeff Johnson295189b2012-06-20 16:38:30 -07009827void csrRoamWaitForKeyTimeOutHandler(void *pv)
9828{
9829 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9830 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009831 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9832
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009833 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009834 pMac->roam.neighborRoamInfo.neighborRoamState,
9835 pMac->roam.curSubState[pInfo->sessionId]);
9836
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9838 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009839#ifdef FEATURE_WLAN_LFR
9840 if (csrNeighborRoamIsHandoffInProgress(pMac))
9841 {
9842 /*
9843 * Enable heartbeat timer when hand-off is in progress
9844 * and Key Wait timer expired.
9845 */
9846 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009847 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009848 pMac->roam.configParam.HeartbeatThresh24);
9849 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9850 pMac->roam.configParam.HeartbeatThresh24,
9851 NULL, eANI_BOOLEAN_FALSE);
9852 }
9853#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009854 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 //Change the substate so command queue is unblocked.
9856 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009857 if (pSession)
9858 {
9859 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9860 {
9861 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9862 smeProcessPendingQueue(pMac);
9863 }
9864 else
9865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009866 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009867 __func__);
9868 }
9869 }
9870 else
9871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009872 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 }
9875
9876}
9877
Jeff Johnson295189b2012-06-20 16:38:30 -07009878eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9879{
9880 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009881#ifdef FEATURE_WLAN_LFR
9882 if (csrNeighborRoamIsHandoffInProgress(pMac))
9883 {
9884 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009885 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009886 __func__,
9887 pMac->roam.neighborRoamInfo.neighborRoamState,
9888 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9889 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9890 }
9891#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009892 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9894
9895 return (status);
9896}
9897
Jeff Johnson295189b2012-06-20 16:38:30 -07009898eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9899{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009900 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009901 pMac->roam.neighborRoamInfo.neighborRoamState,
9902 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9903#ifdef FEATURE_WLAN_LFR
9904 if (csrNeighborRoamIsHandoffInProgress(pMac))
9905 {
9906 /*
9907 * Enable heartbeat timer when hand-off is in progress
9908 * and Key Wait timer got stopped for some reason
9909 */
9910 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009911 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009912 pMac->roam.configParam.HeartbeatThresh24);
9913 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9914 pMac->roam.configParam.HeartbeatThresh24,
9915 NULL, eANI_BOOLEAN_FALSE);
9916 }
9917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9919}
9920
Jeff Johnson295189b2012-06-20 16:38:30 -07009921void csrRoamIbssJoinTimerHandler(void *pv)
9922{
9923 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9924 tpAniSirGlobal pMac = pInfo->pMac;
9925 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9926 tANI_U32 sessionId = pInfo->sessionId;
9927 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009928
9929 if(!pSession)
9930 {
9931 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9932 return;
9933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009934
9935 pSession->ibss_join_pending = FALSE;
9936 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9937 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9938 // Send an IBSS stop request to PE
9939 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009940}
Jeff Johnson295189b2012-06-20 16:38:30 -07009941eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9942{
9943 eHalStatus status;
9944 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009945
9946 if(!pSession)
9947 {
9948 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9949 return eHAL_STATUS_FAILURE;
9950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009951
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009952 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9954 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9955
9956 return (status);
9957}
Jeff Johnson295189b2012-06-20 16:38:30 -07009958eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9959{
9960 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9961}
Jeff Johnson295189b2012-06-20 16:38:30 -07009962void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9963 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9964{
9965 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9966 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009967 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9968 /* To silence the KW tool Null chaeck is added */
9969 if(!pSession)
9970 {
9971 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9972 return;
9973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009974
9975 if(pCommand)
9976 {
9977 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009978 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009980 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9981 {
9982 //if success, force roaming completion
9983 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9984 }
9985 else
9986 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009987 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009988 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009989 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9990 }
9991}
9992
Jeff Johnson295189b2012-06-20 16:38:30 -07009993eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9994{
9995 eHalStatus status = eHAL_STATUS_SUCCESS;
9996 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9997 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9998 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9999 tCsrRoamInfo *pRoamInfo = NULL;
10000 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010001 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010003 /* To silence the KW tool Null chaeck is added */
10004 if(!pSession)
10005 {
10006 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10007 return eHAL_STATUS_FAILURE;
10008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010010 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10012 if ( eWNI_SME_DISASSOC_IND == type )
10013 {
10014 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10015 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10016 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010017 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 }
10019 else if ( eWNI_SME_DEAUTH_IND == type )
10020 {
10021 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10022 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10023 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010024 /* Convert into proper reason code */
10025 pSession->joinFailStatusCode.reasonCode =
10026 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010027 0 : pDeauthIndMsg->reasonCode;
10028 /* cfg layer expects 0 as reason code if
10029 the driver dosent know the reason code
10030 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 }
10032 else
10033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010034 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010036 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 }
10038
10039 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 {
10042 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10043 }
10044
10045 if ( eWNI_SME_DISASSOC_IND == type )
10046 {
10047 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10048 }
10049 else if ( eWNI_SME_DEAUTH_IND == type )
10050 {
10051 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10052 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010053 if(!HAL_STATUS_SUCCESS(status))
10054 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010055 //If fail to send confirmation to PE, not to trigger roaming
10056 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 }
10058
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010059 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10061 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10062 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 if( eWNI_SME_DISASSOC_IND == type)
10064 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010065 //staMacAddr
10066 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10067 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 else if( eWNI_SME_DEAUTH_IND == type )
10070 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010071 //staMacAddr
10072 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
10073 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10074 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010075 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010076
10077 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10078 that we are roaming. But if we cannot possibly roam, or if we are unable to
10079 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 if(fToRoam)
10081 {
10082 //Only remove the connected BSS in infrastructure mode
10083 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10084 //Not to do anying for lostlink with WDS
10085 if( pMac->roam.configParam.nRoamingTime )
10086 {
10087 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10088 ( eWNI_SME_DEAUTH_IND == type ) ?
10089 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10090 {
10091 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
10092 //For IBSS, we need to give some more info to HDD
10093 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10094 {
10095 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10096 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10097 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10098 }
10099 else
10100 {
10101 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10102 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010103 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10105 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10106 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10107 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10108 }
10109 else
10110 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010111 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 fToRoam = eANI_BOOLEAN_FALSE;
10113 }
10114 }
10115 else
10116 {
10117 //We are told not to roam, indicate lostlink
10118 fToRoam = eANI_BOOLEAN_FALSE;
10119 }
10120 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010121 if(!fToRoam)
10122 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010123 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010124 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010125 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010126 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10127 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10128 * csrRoamCheckForLinkStatusChange API.
10129 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010130 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10131 }
10132
10133 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 Still enable idle scan for polling in case concurrent sessions are running */
10135 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10136 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010137 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 }
10139 }
10140
10141 return (status);
10142}
10143
Jeff Johnson295189b2012-06-20 16:38:30 -070010144eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10145{
10146 eHalStatus status = eHAL_STATUS_SUCCESS;
10147 tListElem *pEntry = NULL;
10148 tSmeCmd *pCommand = NULL;
10149 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010150
10151 if(!pSession)
10152 {
10153 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10154 return eHAL_STATUS_FAILURE;
10155 }
10156
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 //Only remove the connected BSS in infrastructure mode
10159 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10160 if(pMac->roam.configParam.nRoamingTime)
10161 {
10162 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10163 {
10164 //before starting the lost link logic release the roam command for handoff
10165 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10166 if(pEntry)
10167 {
10168 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10169 }
10170 if(pCommand)
10171 {
10172 if (( eSmeCommandRoam == pCommand->command ) &&
10173 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10174 {
10175 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10176 {
10177 csrReleaseCommandRoam( pMac, pCommand );
10178 }
10179 }
10180 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010181 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010182 }
10183 }
10184 else
10185 {
10186 //We are told not to roam, indicate lostlink
10187 status = eHAL_STATUS_FAILURE;
10188 }
10189
10190 return (status);
10191}
Jeff Johnson295189b2012-06-20 16:38:30 -070010192void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10193{
10194 tListElem *pEntry;
10195 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10197 if ( pEntry )
10198 {
10199 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10200 if ( eSmeCommandWmStatusChange == pCommand->command )
10201 {
10202 // Nothing to process in a Lost Link completion.... It just kicks off a
10203 // roaming sequence.
10204 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10205 {
10206 csrReleaseCommandWmStatusChange( pMac, pCommand );
10207 }
10208 else
10209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010210 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 }
10212
10213 }
10214 else
10215 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010216 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 }
10218 }
10219 else
10220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010221 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 smeProcessPendingQueue( pMac );
10224}
10225
Jeff Johnson295189b2012-06-20 16:38:30 -070010226void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10227{
10228 eHalStatus status = eHAL_STATUS_FAILURE;
10229 tSirSmeRsp *pSirSmeMsg;
10230 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010231
10232 if(!pSession)
10233 {
10234 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10235 return;
10236 }
10237
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 switch ( pCommand->u.wmStatusChangeCmd.Type )
10239 {
10240 case eCsrDisassociated:
10241 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10242 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10243 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 case eCsrDeauthenticated:
10245 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10246 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10247 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010249 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 break;
10251 }
10252 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10253 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10254 {
10255 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10256 {
10257 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010258 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 }
10260 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10262 // command here since there is nothing else to do.
10263 csrRoamWmStatusChangeComplete( pMac );
10264}
10265
Jeff Johnson295189b2012-06-20 16:38:30 -070010266//This function returns band and mode information.
10267//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10268//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010269static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10270 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010271{
Jeff Johnson295189b2012-06-20 16:38:30 -070010272 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10273 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10274 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010276
Jeff Johnson295189b2012-06-20 16:38:30 -070010277 //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 -070010278 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10279 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10280 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10281 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010282 {
10283 switch( pMac->roam.configParam.uCfgDot11Mode )
10284 {
10285 case eCSR_CFG_DOT11_MODE_11A:
10286 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10287 eBand = eCSR_BAND_5G;
10288 break;
10289 case eCSR_CFG_DOT11_MODE_11B:
10290 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10291 eBand = eCSR_BAND_24;
10292 break;
10293 case eCSR_CFG_DOT11_MODE_11G:
10294 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10295 eBand = eCSR_BAND_24;
10296 break;
10297 case eCSR_CFG_DOT11_MODE_11N:
10298 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010299 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10300 break;
10301#ifdef WLAN_FEATURE_11AC
10302 case eCSR_CFG_DOT11_MODE_11AC:
10303 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10304 {
10305 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10306 eBand = eCSR_BAND_5G;
10307 }
10308 else
10309 {
10310 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10311 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10312 }
10313 break;
10314 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10315 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10316 {
10317 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10318 eBand = eCSR_BAND_5G;
10319 }
10320 else
10321 {
10322 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10323 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10324 }
10325 break;
10326#endif
10327 case eCSR_CFG_DOT11_MODE_AUTO:
10328 eBand = pMac->roam.configParam.eBand;
10329 if (eCSR_BAND_24 == eBand)
10330 {
10331 // WiFi tests require IBSS networks to start in 11b mode
10332 // without any change to the default parameter settings
10333 // on the adapter. We use ACU to start an IBSS through
10334 // creation of a startIBSS profile. This startIBSS profile
10335 // has Auto MACProtocol and the adapter property setting
10336 // for dot11Mode is also AUTO. So in this case, let's
10337 // start the IBSS network in 11b mode instead of 11g mode.
10338 // So this is for Auto=profile->MacProtocol && Auto=Global.
10339 // dot11Mode && profile->channel is < 14, then start the IBSS
10340 // in b mode.
10341 //
10342 // Note: we used to have this start as an 11g IBSS for best
10343 // performance... now to specify that the user will have to
10344 // set the do11Mode in the property page to 11g to force it.
10345 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10346 }
10347 else
10348 {
10349#ifdef WLAN_FEATURE_11AC
10350 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10351 {
10352 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10353 eBand = eCSR_BAND_5G;
10354 }
10355 else
10356 {
10357 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10358 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10359 }
10360#else
10361 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10362 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10363#endif
10364 }
10365 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 default:
10367 // Global dot11 Mode setting is 11a/b/g.
10368 // use the channel number to determine the Mode setting.
10369 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10370 {
10371 eBand = pMac->roam.configParam.eBand;
10372 if(eCSR_BAND_24 == eBand)
10373 {
10374 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10375 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10376 }
10377 else
10378 {
10379 //prefer 5GHz
10380 eBand = eCSR_BAND_5G;
10381 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10382 }
10383 }
10384 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10385 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010386 // WiFi tests require IBSS networks to start in 11b mode
10387 // without any change to the default parameter settings
10388 // on the adapter. We use ACU to start an IBSS through
10389 // creation of a startIBSS profile. This startIBSS profile
10390 // has Auto MACProtocol and the adapter property setting
10391 // for dot11Mode is also AUTO. So in this case, let's
10392 // start the IBSS network in 11b mode instead of 11g mode.
10393 // So this is for Auto=profile->MacProtocol && Auto=Global.
10394 // dot11Mode && profile->channel is < 14, then start the IBSS
10395 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010397 // Note: we used to have this start as an 11g IBSS for best
10398 // performance... now to specify that the user will have to
10399 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10401 eBand = eCSR_BAND_24;
10402 }
10403 else
10404 {
10405 // else, it's a 5.0GHz channel. Set mode to 11a.
10406 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10407 eBand = eCSR_BAND_5G;
10408 }
10409 break;
10410 }//switch
10411 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10412 else
10413 {
10414 //dot11 mode is set, lets pick the band
10415 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10416 {
10417 // channel is Auto also.
10418 eBand = pMac->roam.configParam.eBand;
10419 if(eCSR_BAND_ALL == eBand)
10420 {
10421 //prefer 5GHz
10422 eBand = eCSR_BAND_5G;
10423 }
10424 }
10425 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10426 {
10427 eBand = eCSR_BAND_24;
10428 }
10429 else
10430 {
10431 eBand = eCSR_BAND_5G;
10432 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 if(pBand)
10435 {
10436 *pBand = eBand;
10437 }
10438
10439 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010440 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010441 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10442 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010443
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010444 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10445 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 -070010446 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010447#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010448 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010449#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010450 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10451 {
10452 //We cannot do 11n here
10453 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10454 {
10455 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10456 }
10457 else
10458 {
10459 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10460 }
10461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 return( cfgDot11Mode );
10463}
10464
Jeff Johnson295189b2012-06-20 16:38:30 -070010465eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10466{
10467 eHalStatus status;
10468 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010469
10470 if(!pSession)
10471 {
10472 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10473 return eHAL_STATUS_FAILURE;
10474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010475
10476#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10477 {
10478 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010479 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10480 if(pIbssLog)
10481 {
10482 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10483 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10484 }
10485 }
10486#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 pSession->ibss_join_pending = FALSE;
10488 csrRoamStopIbssJoinTimer(pMac, sessionId );
10489 // Set the roaming substate to 'stop Bss request'...
10490 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10491
10492 // attempt to stop the Bss (reason code is ignored...)
10493 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010494 if(!HAL_STATUS_SUCCESS(status))
10495 {
10496 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10497 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010498 return (status);
10499}
10500
Jeff Johnson295189b2012-06-20 16:38:30 -070010501//pNumChan is a caller allocated space with the sizeof pChannels
10502eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10503{
10504
10505 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10506 (tANI_U8 *)pChannels,
10507 pNumChan));
10508}
10509
Kiran4a17ebe2013-01-31 10:43:43 -080010510tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10511{
10512 tANI_U32 cfgLength = 0;
10513 tANI_U16 cfgId = 0;
10514 tPowerdBm maxTxPwr = 0;
10515 tANI_U8 *pCountryInfo = NULL;
10516 eHalStatus status;
10517 tANI_U8 count = 0;
10518 tANI_U8 firstChannel;
10519 tANI_U8 maxChannels;
10520
10521 if (CSR_IS_CHANNEL_5GHZ(channel))
10522 {
10523 cfgId = WNI_CFG_MAX_TX_POWER_5;
10524 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10525 }
10526 else if (CSR_IS_CHANNEL_24GHZ(channel))
10527 {
10528 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10529 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10530 }
10531 else
10532 return maxTxPwr;
10533
10534 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10535 if (status != eHAL_STATUS_SUCCESS)
10536 {
10537 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10538 FL("%s: palAllocateMemory() failed, status = %d"),
10539 __FUNCTION__, status);
10540 goto error;
10541 }
10542 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10543 if (status != eHAL_STATUS_SUCCESS)
10544 {
10545 goto error;
10546 }
10547 /* Identify the channel and maxtxpower */
10548 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10549 {
10550 firstChannel = pCountryInfo[count++];
10551 maxChannels = pCountryInfo[count++];
10552 maxTxPwr = pCountryInfo[count++];
10553
10554 if ((channel >= firstChannel) &&
10555 (channel < (firstChannel + maxChannels)))
10556 {
10557 break;
10558 }
10559 }
10560
10561error:
10562 if (NULL != pCountryInfo)
10563 palFreeMemory(pMac->hHdd, pCountryInfo);
10564
10565 return maxTxPwr;
10566}
10567
10568
Jeff Johnson295189b2012-06-20 16:38:30 -070010569tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10570{
10571 tANI_BOOLEAN fValid = FALSE;
10572 tANI_U32 idxValidChannels;
10573 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10574
10575 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10576 {
10577 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10578 {
10579 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10580 {
10581 fValid = TRUE;
10582 break;
10583 }
10584 }
10585 }
10586 pMac->roam.numValidChannels = len;
10587 return fValid;
10588}
10589
Jeff Johnson295189b2012-06-20 16:38:30 -070010590tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10591{
10592 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10593 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10595 {
10596 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10597 {
10598 fValid = eANI_BOOLEAN_TRUE;
10599 break;
10600 }
10601 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010602 return (fValid);
10603}
10604
Jeff Johnson295189b2012-06-20 16:38:30 -070010605//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010606 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010607{
Jeff Johnsone7245742012-09-05 17:12:55 -070010608 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010609 tANI_U8 centerChn;
10610 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10612 {
10613 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10614 }
10615 else
10616 {
10617 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10618 }
10619 //Figure what the other side's CB mode
10620 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10621 {
10622 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10623 {
10624 if(pIes->HTInfo.present)
10625 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010626 /* This is called during INFRA STA/CLIENT and should use the merged value of
10627 * supported channel width and recommended tx width as per standard
10628 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010629 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010630 pIes->HTCaps.supportedChannelWidthSet,
10631 pIes->HTInfo.recommendedTxWidthSet,
10632 pIes->HTInfo.secondaryChannelOffset);
10633
10634 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10635 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010636 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010637 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10638 switch (eRet) {
10639 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10640 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10641 break;
10642 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10643 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10644 break;
10645 case PHY_SINGLE_CHANNEL_CENTERED:
10646 default:
10647 centerChn = primaryChn;
10648 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010650 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010652 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010653 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010654 }
10655 }
10656 }
10657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 return eRet;
10659}
Jeff Johnson295189b2012-06-20 16:38:30 -070010660tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10661{
10662 tANI_BOOLEAN fFound = FALSE;
10663 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010664 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10665 {
10666 if( pCipherList->encryptionType[idx] == encryptionType )
10667 {
10668 fFound = TRUE;
10669 break;
10670 }
10671 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010672 return fFound;
10673}
Jeff Johnson295189b2012-06-20 16:38:30 -070010674tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10675{
10676 tANI_BOOLEAN fFound = FALSE;
10677 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10679 {
10680 if( pAuthList->authType[idx] == authType )
10681 {
10682 fFound = TRUE;
10683 break;
10684 }
10685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 return fFound;
10687}
Jeff Johnson295189b2012-06-20 16:38:30 -070010688tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10689{
10690 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10691 tCsrScanResultFilter *pScanFilter = NULL;
10692 eHalStatus status = eHAL_STATUS_SUCCESS;
10693
10694 if(pProfile1 && pProfile2)
10695 {
10696 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10697 if(HAL_STATUS_SUCCESS(status))
10698 {
10699 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10700 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10701 if(HAL_STATUS_SUCCESS(status))
10702 {
10703 fCheck = eANI_BOOLEAN_FALSE;
10704 do
10705 {
10706 tANI_U32 i;
10707 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10708 {
10709 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10710 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10711 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10712 if ( fCheck ) break;
10713 }
10714 if(!fCheck)
10715 {
10716 break;
10717 }
10718 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10719 || pProfile2->BSSType != pProfile1->BSSType
10720 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10721 )
10722 {
10723 fCheck = eANI_BOOLEAN_FALSE;
10724 break;
10725 }
10726#ifdef WLAN_FEATURE_VOWIFI_11R
10727 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10728 {
10729 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10730 {
10731 fCheck = eANI_BOOLEAN_FALSE;
10732 break;
10733 }
10734 }
10735#endif
10736 //Match found
10737 fCheck = eANI_BOOLEAN_TRUE;
10738 }while(0);
10739 csrFreeScanFilter(pMac, pScanFilter);
10740 }
10741 palFreeMemory(pMac->hHdd, pScanFilter);
10742 }
10743 }
10744
10745 return (fCheck);
10746}
10747
Jeff Johnson295189b2012-06-20 16:38:30 -070010748tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10749{
10750 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10751 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010752 do
10753 {
10754 //Only check for static WEP
10755 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10756 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10757 {
10758 fCheck = eANI_BOOLEAN_TRUE;
10759 break;
10760 }
10761 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10762 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10763 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10764 {
10765 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10766 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10767 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10768 {
10769 break;
10770 }
10771 }
10772 if( i == CSR_MAX_NUM_KEY)
10773 {
10774 fCheck = eANI_BOOLEAN_TRUE;
10775 }
10776 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 return (fCheck);
10778}
10779
Jeff Johnson295189b2012-06-20 16:38:30 -070010780//IBSS
10781
Jeff Johnson295189b2012-06-20 16:38:30 -070010782tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10783{
10784 tANI_U8 channel = 0;
10785 tANI_U32 idx;
10786 tANI_U32 idxValidChannels;
10787 tANI_BOOLEAN fFound = FALSE;
10788 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10789
10790 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10791 {
10792 channel = pMac->roam.configParam.AdHocChannel5G;
10793 if(!csrRoamIsChannelValid(pMac, channel))
10794 {
10795 channel = 0;
10796 }
10797 }
10798 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10799 {
10800 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10801 {
10802 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10803 {
10804 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10805 {
10806 fFound = TRUE;
10807 channel = csrStartIbssChannels50[ idx ];
10808 }
10809 }
10810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010811 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10812 if (!fFound)
10813 {
10814 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10815 {
10816 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10817 {
10818 channel = csrStartIbssChannels50[ idx ];
10819 break;
10820 }
10821 }
10822 }
10823 }//if
10824
10825 return( channel );
10826}
10827
Jeff Johnson295189b2012-06-20 16:38:30 -070010828tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10829{
10830 tANI_U8 channel = 1;
10831 tANI_U32 idx;
10832 tANI_U32 idxValidChannels;
10833 tANI_BOOLEAN fFound = FALSE;
10834 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10835
10836 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10837 {
10838 channel = pMac->roam.configParam.AdHocChannel24;
10839 if(!csrRoamIsChannelValid(pMac, channel))
10840 {
10841 channel = 0;
10842 }
10843 }
10844
10845 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10846 {
10847 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10848 {
10849 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10850 {
10851 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10852 {
10853 fFound = TRUE;
10854 channel = csrStartIbssChannels24[ idx ];
10855 }
10856 }
10857 }
10858 }
10859
10860 return( channel );
10861}
10862
Jeff Johnson295189b2012-06-20 16:38:30 -070010863static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10864 tCsrRoamStartBssParams *pParam )
10865{
10866 eCsrCfgDot11Mode cfgDot11Mode;
10867 eCsrBand eBand;
10868 tANI_U8 channel = 0;
10869 tSirNwType nwType;
10870 tANI_U8 operationChannel = 0;
10871
10872 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10873 {
10874 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10875 }
10876
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010878
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10880 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10881 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10882 )
10883 {
10884 /* This should never happen */
10885 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010886 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 pProfile->csrPersona);
10888 VOS_ASSERT(0);
10889 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010890 switch( cfgDot11Mode )
10891 {
10892 case eCSR_CFG_DOT11_MODE_11G:
10893 nwType = eSIR_11G_NW_TYPE;
10894 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 case eCSR_CFG_DOT11_MODE_11B:
10896 nwType = eSIR_11B_NW_TYPE;
10897 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 case eCSR_CFG_DOT11_MODE_11A:
10899 nwType = eSIR_11A_NW_TYPE;
10900 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010901 default:
10902 case eCSR_CFG_DOT11_MODE_11N:
10903 case eCSR_CFG_DOT11_MODE_TAURUS:
10904 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10905 if(eCSR_BAND_24 == eBand)
10906 {
10907 nwType = eSIR_11G_NW_TYPE;
10908 }
10909 else
10910 {
10911 nwType = eSIR_11A_NW_TYPE;
10912 }
10913 break;
10914 }
10915
10916 pParam->extendedRateSet.numRates = 0;
10917
10918 switch ( nwType )
10919 {
10920 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010921 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 case eSIR_11A_NW_TYPE:
10923
10924 pParam->operationalRateSet.numRates = 8;
10925
10926 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10927 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10928 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10929 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10930 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10931 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10932 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10933 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10934
10935 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10936 {
10937 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10938 if( 0 == channel &&
10939 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10940 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10941 )
10942 {
10943 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10944 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10945 nwType = eSIR_11B_NW_TYPE;
10946 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10947 pParam->operationalRateSet.numRates = 4;
10948 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10949 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10950 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10951 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10952 }
10953 }
10954 else
10955 {
10956 channel = operationChannel;
10957 }
10958 break;
10959
10960 case eSIR_11B_NW_TYPE:
10961 pParam->operationalRateSet.numRates = 4;
10962 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10963 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10964 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10965 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10967 {
10968 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10969 }
10970 else
10971 {
10972 channel = operationChannel;
10973 }
10974
10975 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010977 /* For P2P Client and P2P GO, disable 11b rates */
10978 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10979 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10980 )
10981 {
10982 pParam->operationalRateSet.numRates = 8;
10983
10984 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10985 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10986 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10987 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10988 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10989 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10990 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10991 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10992 }
10993 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010994 {
10995 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010996 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10997 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10998 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10999 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11000
11001 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11003 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11004 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11005 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11006 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11007 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11008 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11009 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11010 }
11011
11012 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11013 {
11014 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11015 }
11016 else
11017 {
11018 channel = operationChannel;
11019 }
11020
11021 break;
11022 }
11023 pParam->operationChn = channel;
11024 pParam->sirNwType = nwType;
11025}
11026
Jeff Johnson295189b2012-06-20 16:38:30 -070011027static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11028 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11029{
11030
11031 if( pParam )
11032 {
11033 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011034 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 pParam->operationChn = pBssDesc->channelId;
11036 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
11037
11038 if( pIes )
11039 {
11040 if(pIes->SuppRates.present)
11041 {
11042 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11043 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11044 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011045 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 -070011046 pIes->SuppRates.num_rates);
11047 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11048 }
11049 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11050 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
11051 }
11052 if( pIes->SSID.present )
11053 {
11054 pParam->ssId.length = pIes->SSID.num_ssid;
11055 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
11056 }
11057 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 }
11059 else
11060 {
11061 pParam->ssId.length = 0;
11062 pParam->operationalRateSet.numRates = 0;
11063 }
11064 }
11065}
11066
Jeff Johnson295189b2012-06-20 16:38:30 -070011067static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11068{
11069 tANI_U8 MaxRate = 0;
11070 tANI_U32 i;
11071 tANI_U8 *pRate;
11072
11073 pRate = pSirRateSet->rate;
11074 for ( i = 0; i < pSirRateSet->numRates; i++ )
11075 {
11076 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11077 }
11078
11079 // Save the max rate in the connected state information...
11080
11081 // modify LastRates variable as well
11082
11083 return;
11084}
11085
Jeff Johnson295189b2012-06-20 16:38:30 -070011086eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11087 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11088{
11089 eHalStatus status = eHAL_STATUS_SUCCESS;
11090 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 // Set the roaming substate to 'Start BSS attempt'...
11092 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011093#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11094 //Need to figure out whether we need to log WDS???
11095 if( CSR_IS_IBSS( pProfile ) )
11096 {
11097 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011098 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11099 if(pIbssLog)
11100 {
11101 if(pBssDesc)
11102 {
11103 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
11104 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
11105 }
11106 else
11107 {
11108 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11109 }
11110 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
11111 pParam->ssId.length);
11112 if(pProfile->ChannelInfo.numOfChannels == 0)
11113 {
11114 pIbssLog->channelSetting = AUTO_PICK;
11115 }
11116 else
11117 {
11118 pIbssLog->channelSetting = SPECIFIED;
11119 }
11120 pIbssLog->operatingChannel = pParam->operationChn;
11121 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11122 }
11123 }
11124#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11125 //Put RSN information in for Starting BSS
11126 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11127 pParam->pRSNIE = pProfile->pRSNReqIE;
11128
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 pParam->privacy = pProfile->privacy;
11130 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11131 pParam->authType = pProfile->csr80211AuthType;
11132 pParam->beaconInterval = pProfile->beaconInterval;
11133 pParam->dtimPeriod = pProfile->dtimPeriod;
11134 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11135 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11136 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11137 {
11138 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11139 {
11140 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11141 }
11142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 pParam->protEnabled = pProfile->protEnabled;
11144 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11145 pParam->ht_protection = pProfile->cfg_protection;
11146 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011147
Jeff Johnson295189b2012-06-20 16:38:30 -070011148 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11149 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 pParam->bssPersona = pProfile->csrPersona;
11151 // When starting an IBSS, start on the channel from the Profile.
11152 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 return (status);
11154}
11155
Jeff Johnson295189b2012-06-20 16:38:30 -070011156static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011157 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011158{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011159 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011160 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011161 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011162
11163 if(!pSession)
11164 {
11165 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11166 return;
11167 }
11168
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 if( pBssDesc )
11170 {
11171 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11172 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11173 //The following code has to be do after that.
11174 //For WDS station, use selfMac as the self BSSID
11175 if( CSR_IS_WDS_STA( pProfile ) )
11176 {
11177 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11178 }
11179 }
11180 else
11181 {
11182 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 //Use the first SSID
11184 if(pProfile->SSIDs.numOfSSIDs)
11185 {
11186 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
11187 }
11188 //For WDS station, use selfMac as the self BSSID
11189 if( CSR_IS_WDS_STA( pProfile ) )
11190 {
11191 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
11192 }
11193 //Use the first BSSID
11194 else if( pProfile->BSSIDs.numOfBSSIDs )
11195 {
11196 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
11197 }
11198 else
11199 {
11200 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
11201 }
11202 }
11203 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 //Set operating channel in pProfile which will be used
11205 //in csrRoamSetBssConfigCfg() to determine channel bonding
11206 //mode and will be configured in CFG later
11207 pProfile->operationChannel = Channel;
11208
11209 if(Channel == 0)
11210 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011211 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 }
11213 else
11214 {
11215
11216 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011217 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011218 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011219 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011220 {
11221 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11222 }
11223 else
11224 {
11225 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11226 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011227 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011228 pBssConfig->cbMode = cbMode;
11229 pSession->bssParams.cbMode = cbMode;
11230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 }
11232}
11233
Jeff Johnson295189b2012-06-20 16:38:30 -070011234static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11235 tANI_BOOLEAN *pfSameIbss )
11236{
11237 eHalStatus status = eHAL_STATUS_SUCCESS;
11238 tANI_BOOLEAN fSameIbss = FALSE;
11239
11240 if ( csrIsConnStateIbss( pMac, sessionId ) )
11241 {
11242 // Check if any profile parameter has changed ? If any profile parameter
11243 // has changed then stop old BSS and start a new one with new parameters
11244 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11245 {
11246 fSameIbss = TRUE;
11247 }
11248 else
11249 {
11250 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11251 }
11252 }
11253 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11254 {
11255 // Disassociate from the connected Infrastructure network...
11256 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11257 }
11258 else
11259 {
11260 tBssConfigParam *pBssConfig;
11261
11262 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
11263 if(HAL_STATUS_SUCCESS(status))
11264 {
11265 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
11266 // there is no Bss description before we start an IBSS so we need to adopt
11267 // all Bss configuration parameters from the Profile.
11268 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11269 if(HAL_STATUS_SUCCESS(status))
11270 {
11271 //save dotMode
11272 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11273 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011274 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
11276 }
11277
11278 palFreeMemory(pMac->hHdd, pBssConfig);
11279 }//Allocate memory
11280 }
11281
11282 if(pfSameIbss)
11283 {
11284 *pfSameIbss = fSameIbss;
11285 }
11286 return( status );
11287}
11288
Jeff Johnson295189b2012-06-20 16:38:30 -070011289static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11290 tSirSmeNewBssInfo *pNewBss )
11291{
11292 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011293
11294 if(!pSession)
11295 {
11296 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11297 return;
11298 }
11299
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 if( pNewBss )
11301 {
11302 // Set the operating channel.
11303 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11304 // move the BSSId from the BSS description into the connected state information.
11305 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
11306 &(pNewBss->bssId), sizeof( tCsrBssid ) );
11307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 return;
11309}
11310
Jeff Johnson295189b2012-06-20 16:38:30 -070011311#ifdef FEATURE_WLAN_WAPI
11312eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11313 tANI_U32 numItems )
11314{
11315 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11316 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011317 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11318 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011319 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011320 return status;
11321 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011322 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 pSession = CSR_GET_SESSION( pMac, sessionId );
11324 if(numItems <= CSR_MAX_BKID_ALLOWED)
11325 {
11326 status = eHAL_STATUS_SUCCESS;
11327 //numItems may be 0 to clear the cache
11328 pSession->NumBkidCache = (tANI_U16)numItems;
11329 if(numItems && pBKIDCache)
11330 {
11331 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11332 sizeof(tBkidCacheInfo) * numItems );
11333 }
11334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 return (status);
11336}
Jeff Johnson295189b2012-06-20 16:38:30 -070011337eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11338 tBkidCacheInfo *pBkidCache)
11339{
11340 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11341 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11343 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011344 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 return status;
11346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 pSession = CSR_GET_SESSION( pMac, sessionId );
11348 if(pNum && pBkidCache)
11349 {
11350 if(pSession->NumBkidCache == 0)
11351 {
11352 *pNum = 0;
11353 status = eHAL_STATUS_SUCCESS;
11354 }
11355 else if(*pNum >= pSession->NumBkidCache)
11356 {
11357 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011359 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 -070011360 pSession->NumBkidCache);
11361 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11362 }
11363 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11364 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11365 *pNum = pSession->NumBkidCache;
11366 status = eHAL_STATUS_SUCCESS;
11367 }
11368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011369 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011370}
Jeff Johnson295189b2012-06-20 16:38:30 -070011371tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11372{
11373 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011374}
11375#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011376eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11377 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11378{
11379 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11380 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011381
11382 if(!pSession)
11383 {
11384 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11385 return eHAL_STATUS_FAILURE;
11386 }
11387
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011388 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11390 {
11391#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11392 {
11393 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11394 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11395 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11396 secEvent.encryptionModeMulticast =
11397 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11398 secEvent.encryptionModeUnicast =
11399 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11400 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11401 secEvent.authMode =
11402 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11403 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11404 }
11405#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 status = eHAL_STATUS_SUCCESS;
11407 //numItems may be 0 to clear the cache
11408 pSession->NumPmkidCache = (tANI_U16)numItems;
11409 if(numItems && pPMKIDCache)
11410 {
11411 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11412 sizeof(tPmkidCacheInfo) * numItems );
11413 }
11414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 return (status);
11416}
11417
Jeff Johnson295189b2012-06-20 16:38:30 -070011418tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11419{
11420 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11421}
11422
Jeff Johnson295189b2012-06-20 16:38:30 -070011423eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11424{
11425 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11426 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011427
11428 if(!pSession)
11429 {
11430 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11431 return eHAL_STATUS_FAILURE;
11432 }
11433
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 if(pNum && pPmkidCache)
11435 {
11436 if(pSession->NumPmkidCache == 0)
11437 {
11438 *pNum = 0;
11439 status = eHAL_STATUS_SUCCESS;
11440 }
11441 else if(*pNum >= pSession->NumPmkidCache)
11442 {
11443 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011445 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 -070011446 pSession->NumPmkidCache);
11447 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11448 }
11449 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11450 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11451 *pNum = pSession->NumPmkidCache;
11452 status = eHAL_STATUS_SUCCESS;
11453 }
11454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 return (status);
11456}
11457
Jeff Johnson295189b2012-06-20 16:38:30 -070011458eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11459{
11460 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11461 tANI_U32 len;
11462 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011463
11464 if(!pSession)
11465 {
11466 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11467 return eHAL_STATUS_FAILURE;
11468 }
11469
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 if(pLen)
11471 {
11472 len = *pLen;
11473 *pLen = pSession->nWpaRsnReqIeLength;
11474 if(pBuf)
11475 {
11476 if(len >= pSession->nWpaRsnReqIeLength)
11477 {
11478 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11479 }
11480 }
11481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 return (status);
11483}
11484
Jeff Johnson295189b2012-06-20 16:38:30 -070011485eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11486{
11487 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11488 tANI_U32 len;
11489 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011490
11491 if(!pSession)
11492 {
11493 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11494 return eHAL_STATUS_FAILURE;
11495 }
11496
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 if(pLen)
11498 {
11499 len = *pLen;
11500 *pLen = pSession->nWpaRsnRspIeLength;
11501 if(pBuf)
11502 {
11503 if(len >= pSession->nWpaRsnRspIeLength)
11504 {
11505 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11506 }
11507 }
11508 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 return (status);
11510}
Jeff Johnson295189b2012-06-20 16:38:30 -070011511#ifdef FEATURE_WLAN_WAPI
11512eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11513{
11514 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11515 tANI_U32 len;
11516 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011517
11518 if(!pSession)
11519 {
11520 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11521 return eHAL_STATUS_FAILURE;
11522 }
11523
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 if(pLen)
11525 {
11526 len = *pLen;
11527 *pLen = pSession->nWapiReqIeLength;
11528 if(pBuf)
11529 {
11530 if(len >= pSession->nWapiReqIeLength)
11531 {
11532 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11533 }
11534 }
11535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 return (status);
11537}
Jeff Johnson295189b2012-06-20 16:38:30 -070011538eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11539{
11540 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11541 tANI_U32 len;
11542 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011543
11544 if(!pSession)
11545 {
11546 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11547 return eHAL_STATUS_FAILURE;
11548 }
11549
Jeff Johnson295189b2012-06-20 16:38:30 -070011550 if(pLen)
11551 {
11552 len = *pLen;
11553 *pLen = pSession->nWapiRspIeLength;
11554 if(pBuf)
11555 {
11556 if(len >= pSession->nWapiRspIeLength)
11557 {
11558 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11559 }
11560 }
11561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011562 return (status);
11563}
11564#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011565eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11566{
11567 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11568 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011569
11570 if(!pSession)
11571 {
11572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11573 return (retStatus);
11574 }
11575
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 if(CSR_IS_ROAMING(pSession))
11577 {
11578 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11579 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011581 return (retStatus);
11582}
11583
Jeff Johnson295189b2012-06-20 16:38:30 -070011584//This function remove the connected BSS from te cached scan result
11585eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11586 tCsrRoamConnectedProfile *pConnProfile)
11587{
11588 eHalStatus status = eHAL_STATUS_FAILURE;
11589 tCsrScanResultFilter *pScanFilter = NULL;
11590 tListElem *pEntry;
11591 tCsrScanResult *pResult;
11592 tDot11fBeaconIEs *pIes;
11593 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11595 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11596 {
11597 do
11598 {
11599 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11600 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11601 if(!HAL_STATUS_SUCCESS(status)) break;
11602 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11603 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11604 if(!HAL_STATUS_SUCCESS(status)) break;
11605 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11606 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11607 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11608 {
11609 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11610 if(!HAL_STATUS_SUCCESS(status)) break;
11611 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11612 }
11613 pScanFilter->authType.numEntries = 1;
11614 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11615 pScanFilter->BSSType = pConnProfile->BSSType;
11616 pScanFilter->EncryptionType.numEntries = 1;
11617 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11618 pScanFilter->mcEncryptionType.numEntries = 1;
11619 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11620 //We ignore the channel for now, BSSID should be enough
11621 pScanFilter->ChannelInfo.numOfChannels = 0;
11622 //Also ignore the following fields
11623 pScanFilter->uapsd_mask = 0;
11624 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11625 pScanFilter->countryCode[0] = 0;
11626 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011627 csrLLLock(&pMac->scan.scanResultList);
11628 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11629 while( pEntry )
11630 {
11631 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11632 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11633 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11634 pScanFilter, NULL, NULL, NULL, &pIes);
11635 //Release the IEs allocated by csrMatchBSS is needed
11636 if( !pResult->Result.pvIes )
11637 {
11638 //need to free the IEs since it is allocated by csrMatchBSS
11639 palFreeMemory(pMac->hHdd, pIes);
11640 }
11641 if(fMatch)
11642 {
11643 //We found the one
11644 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11645 {
11646 //Free the memory
11647 csrFreeScanResultEntry( pMac, pResult );
11648 }
11649 break;
11650 }
11651 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11652 }//while
11653 csrLLUnlock(&pMac->scan.scanResultList);
11654 }while(0);
11655 if(pScanFilter)
11656 {
11657 csrFreeScanFilter(pMac, pScanFilter);
11658 palFreeMemory(pMac->hHdd, pScanFilter);
11659 }
11660 }
11661 return (status);
11662}
11663
Jeff Johnson295189b2012-06-20 16:38:30 -070011664//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011665eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11666{
11667 eHalStatus status = eHAL_STATUS_SUCCESS;
11668 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11670 {
11671 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11672 {
11673 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11674 {
11675 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011676 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 status = eHAL_STATUS_CSR_WRONG_STATE;
11678 break;
11679 }
11680 if( csrIsConnStateInfra( pMac, sessionId ) )
11681 {
11682 if( chnId &&
11683 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011685 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11687 status = eHAL_STATUS_CSR_WRONG_STATE;
11688 break;
11689 }
11690 }
11691 }
11692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 return ( status );
11694}
11695
Jeff Johnson295189b2012-06-20 16:38:30 -070011696static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11697{
11698 eHalStatus status = eHAL_STATUS_SUCCESS;
11699 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11700 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011701
11702 if(!pSession)
11703 {
11704 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11705 return eHAL_STATUS_FAILURE;
11706 }
11707
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 if ( csrIsConnStateIbss( pMac, sessionId ) )
11709 {
11710 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11711 }
11712 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11713 {
11714 // Disassociate from the connected Infrastructure network...
11715 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11716 }
11717 else
11718 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011719 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11720 //Otherwise we need to add code to handle the
11721 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11722 //send stop_bss to PE, before we can continue.
11723 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11725 /* Assume HDD provide bssid in profile */
11726 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11727 // there is no Bss description before we start an WDS so we need
11728 // to adopt all Bss configuration parameters from the Profile.
11729 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11730 if(HAL_STATUS_SUCCESS(status))
11731 {
11732 //Save profile for late use
11733 csrFreeRoamProfile( pMac, sessionId );
11734 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11735 (void **)&pSession->pCurRoamProfile,
11736 sizeof(tCsrRoamProfile))))
11737 {
11738 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11739 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011742 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11744 }
11745 }
11746
11747 return( status );
11748}
11749
Jeff Johnson295189b2012-06-20 16:38:30 -070011750////////////////////Mail box
11751
Jeff Johnson295189b2012-06-20 16:38:30 -070011752//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11753//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11754static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11755 tSirBssDescription *pBssDescription,
11756 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11757{
11758 tCsrChannelSet channelGroup;
11759 tSirMacCapabilityInfo *pAP_capabilityInfo;
11760 tAniBool fTmp;
11761 tANI_BOOLEAN found = FALSE;
11762 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011763 tANI_S8 pwrLimit = 0;
11764 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11766 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11767 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11768 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 // 802.11h
11770 //We can do this because it is in HOST CPU order for now.
11771 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011772 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11773 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11774 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 fTmp = (tAniBool)pal_cpu_to_be32(1);
11776 }
11777 else
11778 fTmp = (tAniBool)0;
11779
11780 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11781 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11782 pBuf += sizeof(tAniBool);
11783 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011784 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011785 // This is required for 11k test VoWiFi Ent: Test 2.
11786 // We need the power capabilities for Assoc Req.
11787 // This macro is provided by the halPhyCfg.h. We pick our
11788 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011789 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11790 if (0 != pwrLimit)
11791 {
11792 *pBuf++ = pwrLimit;
11793 }
11794 else
11795 {
11796 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 size = sizeof(pMac->roam.validChannelList);
11799 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11800 {
11801 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11802 for ( i = 0; i < size; i++)
11803 {
11804 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11805
11806 }
11807 }
11808 else
11809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011810 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 *pBuf++ = 0; //tSirSupChnl->numChnl
11812 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011813 //Check whether it is ok to enter UAPSD
11814#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11815 if( btcIsReadyForUapsd(pMac) )
11816#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11817 {
11818 *pBuf++ = uapsdMask;
11819 }
11820#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11821 else
11822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011823 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 *pBuf++ = 0;
11825 }
11826#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11827
Jeff Johnson295189b2012-06-20 16:38:30 -070011828 // move the entire BssDescription into the join request.
11829 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11830 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11832}
11833
Jeff Johnson295189b2012-06-20 16:38:30 -070011834/*
11835 * The communication between HDD and LIM is thru mailbox (MB).
11836 * Both sides will access the data structure "tSirSmeJoinReq".
11837 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11838 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11839 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11840 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11841 */
11842eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011843 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011844{
11845 eHalStatus status = eHAL_STATUS_SUCCESS;
11846 tSirSmeJoinReq *pMsg;
11847 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011848 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 tANI_U16 msgLen, wTmp, ieLen;
11850 tSirMacRateSet OpRateSet;
11851 tSirMacRateSet ExRateSet;
11852 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11853 tANI_U32 dwTmp;
11854 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011855 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011856
11857 if(!pSession)
11858 {
11859 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11860 return eHAL_STATUS_FAILURE;
11861 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011862 /* To satisfy klockworks */
11863 if (NULL == pBssDescription)
11864 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011865 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011866 return eHAL_STATUS_FAILURE;
11867 }
11868
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 do {
11870 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11871 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070011872 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11874 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11875 // IE fields, but the length field in the bssDescription needs to be interpreted to
11876 // determine length of the IE fields.
11877 //
11878 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11879 // add in the length from the bssDescription (then add the size of the 'length' field
11880 // itself because that is NOT included in the length field).
11881 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11882 pBssDescription->length + sizeof( pBssDescription->length ) +
11883 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 -070011884 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11885 if ( !HAL_STATUS_SUCCESS(status) ) break;
11886 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011887 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 pMsg->length = pal_cpu_to_be16(msgLen);
11889 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 // sessionId
11891 *pBuf = (tANI_U8)sessionId;
11892 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 // transactionId
11894 *pBuf = 0;
11895 *( pBuf + 1 ) = 0;
11896 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 // ssId
11898 if( pIes->SSID.present && pIes->SSID.num_ssid )
11899 {
11900 // ssId len
11901 *pBuf = pIes->SSID.num_ssid;
11902 pBuf++;
11903 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11904 pBuf += pIes->SSID.num_ssid;
11905 }
11906 else
11907 {
11908 *pBuf = 0;
11909 pBuf++;
11910 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 // selfMacAddr
11912 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11913 pBuf += sizeof(tSirMacAddr);
11914 // bsstype
11915 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11916 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11917 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11918 pBuf += sizeof(tSirBssType);
11919 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070011920 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11921 if (pBssDescription->channelId <= 14 &&
11922 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
11923 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
11924 {
11925 //Need to disable VHT operation in 2.4 GHz band
11926 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
11927 }
11928 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011929 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 //Persona
11931 *pBuf = (tANI_U8)pProfile->csrPersona;
11932 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011933 //CBMode
11934 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11935 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011936
11937 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011938 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11939
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 // uapsdPerAcBitmask
11941 *pBuf = pProfile->uapsd_mask;
11942 pBuf++;
11943
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011944
11945
Jeff Johnson295189b2012-06-20 16:38:30 -070011946 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011947 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 {
11949 // OperationalRateSet
11950 if (OpRateSet.numRates) {
11951 *pBuf++ = OpRateSet.numRates;
11952 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11953 pBuf += OpRateSet.numRates;
11954 } else *pBuf++ = 0;
11955 // ExtendedRateSet
11956 if (ExRateSet.numRates) {
11957 *pBuf++ = ExRateSet.numRates;
11958 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11959 pBuf += ExRateSet.numRates;
11960 } else *pBuf++ = 0;
11961 }
11962 else
11963 {
11964 *pBuf++ = 0;
11965 *pBuf++ = 0;
11966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011967 // rsnIE
11968 if ( csrIsProfileWpa( pProfile ) )
11969 {
11970 // Insert the Wpa IE into the join request
11971 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11972 (tCsrWpaIe *)( wpaRsnIE ) );
11973 }
11974 else if( csrIsProfileRSN( pProfile ) )
11975 {
11976 // Insert the RSN IE into the join request
11977 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11978 (tCsrRSNIe *)( wpaRsnIE ) );
11979 }
11980#ifdef FEATURE_WLAN_WAPI
11981 else if( csrIsProfileWapi( pProfile ) )
11982 {
11983 // Insert the WAPI IE into the join request
11984 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11985 (tCsrWapiIe *)( wpaRsnIE ) );
11986 }
11987#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 else
11989 {
11990 ieLen = 0;
11991 }
11992 //remember the IE for future use
11993 if( ieLen )
11994 {
11995 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011997 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 -070011998 ieLen = DOT11F_IE_RSN_MAX_LEN;
11999 }
12000#ifdef FEATURE_WLAN_WAPI
12001 if( csrIsProfileWapi( pProfile ) )
12002 {
12003 //Check whether we need to allocate more memory
12004 if(ieLen > pSession->nWapiReqIeLength)
12005 {
12006 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12007 {
12008 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12009 }
12010 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
12011 if(!HAL_STATUS_SUCCESS(status)) break;
12012 }
12013 pSession->nWapiReqIeLength = ieLen;
12014 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
12015 wTmp = pal_cpu_to_be16( ieLen );
12016 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12017 pBuf += sizeof(tANI_U16);
12018 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12019 pBuf += ieLen;
12020 }
12021 else//should be WPA/WPA2 otherwise
12022#endif /* FEATURE_WLAN_WAPI */
12023 {
12024 //Check whether we need to allocate more memory
12025 if(ieLen > pSession->nWpaRsnReqIeLength)
12026 {
12027 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12028 {
12029 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12030 }
12031 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
12032 if(!HAL_STATUS_SUCCESS(status)) break;
12033 }
12034 pSession->nWpaRsnReqIeLength = ieLen;
12035 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
12036 wTmp = pal_cpu_to_be16( ieLen );
12037 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12038 pBuf += sizeof(tANI_U16);
12039 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12040 pBuf += ieLen;
12041 }
12042 }
12043 else
12044 {
12045 //free whatever old info
12046 pSession->nWpaRsnReqIeLength = 0;
12047 if(pSession->pWpaRsnReqIE)
12048 {
12049 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
12050 pSession->pWpaRsnReqIE = NULL;
12051 }
12052#ifdef FEATURE_WLAN_WAPI
12053 pSession->nWapiReqIeLength = 0;
12054 if(pSession->pWapiReqIE)
12055 {
12056 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
12057 pSession->pWapiReqIE = NULL;
12058 }
12059#endif /* FEATURE_WLAN_WAPI */
12060 //length is two bytes
12061 *pBuf = 0;
12062 *(pBuf + 1) = 0;
12063 pBuf += 2;
12064 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012065#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012066 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012068 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012069 //length is two bytes
12070 *pBuf = 0;
12071 *(pBuf + 1) = 0;
12072 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012073 }
12074 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012076 // cckmIE
12077 if( csrIsProfileCCX( pProfile ) )
12078 {
12079 // Insert the CCKM IE into the join request
12080 ieLen = csrConstructCcxCckmIe( pMac,
12081 pSession,
12082 pProfile,
12083 pBssDescription,
12084 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 pSession->nWpaRsnReqIeLength,
12086 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012087 }
12088 else
12089 {
12090 ieLen = 0;
12091 }
12092 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12093 if( ieLen )
12094 {
12095 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12096 wTmp = pal_cpu_to_be16( ieLen );
12097 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12098 pBuf += sizeof(tANI_U16);
12099 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
12100 pBuf += ieLen;
12101 }
12102 else
12103 {
12104 //Indicate you have no CCKM IE
12105 //length is two bytes
12106 *pBuf = 0;
12107 *(pBuf + 1) = 0;
12108 pBuf += 2;
12109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 }
12111#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 // addIEScan
12113 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12114 {
12115 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 if(ieLen > pSession->nAddIEScanLength)
12117 {
12118 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12119 {
12120 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12121 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012122 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 (void **)&pSession->pAddIEScan, ieLen);
12124 if(!HAL_STATUS_SUCCESS(status)) break;
12125 }
12126 pSession->nAddIEScanLength = ieLen;
12127 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
12128 pProfile->pAddIEScan, ieLen);
12129 wTmp = pal_cpu_to_be16( ieLen );
12130 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12131 pBuf += sizeof(tANI_U16);
12132 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
12133 pBuf += ieLen;
12134 }
12135 else
12136 {
12137 pSession->nAddIEScanLength = 0;
12138 if(pSession->pAddIEScan)
12139 {
12140 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
12141 pSession->pAddIEScan = NULL;
12142 }
12143 *pBuf = 0;
12144 *(pBuf + 1) = 0;
12145 pBuf += 2;
12146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 // addIEAssoc
12148 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12149 {
12150 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 if(ieLen > pSession->nAddIEAssocLength)
12152 {
12153 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
12154 {
12155 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12156 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012157 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 (void **)&pSession->pAddIEAssoc, ieLen);
12159 if(!HAL_STATUS_SUCCESS(status)) break;
12160 }
12161 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012162 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 pProfile->pAddIEAssoc, ieLen);
12164 wTmp = pal_cpu_to_be16( ieLen );
12165 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12166 pBuf += sizeof(tANI_U16);
12167 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
12168 pBuf += ieLen;
12169 }
12170 else
12171 {
12172 pSession->nAddIEAssocLength = 0;
12173 if(pSession->pAddIEAssoc)
12174 {
12175 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
12176 pSession->pAddIEAssoc = NULL;
12177 }
12178 *pBuf = 0;
12179 *(pBuf + 1) = 0;
12180 pBuf += 2;
12181 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012182
12183 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012185 //Unmask any AC in reassoc that is ACM-set
12186 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12187 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012189 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12190 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012191#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012192 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012193#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012194 uapsd_mask &= ~(acm_mask);
12195 }
12196 else
12197 {
12198 uapsd_mask = 0;
12199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 }
12201 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012202
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
12204 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012205 pBuf += sizeof(tANI_U32);
12206
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
12208 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012209 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012210#ifdef WLAN_FEATURE_11W
12211 //MgmtEncryption
12212 if (pProfile->MFPEnabled)
12213 {
12214 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12215 }
12216 else
12217 {
12218 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12219 }
12220 palCopyMemory(pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32));
12221 pBuf += sizeof(tANI_U32);
12222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012223#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012224 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012225 if (csrIsProfile11r( pProfile )
12226#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012227 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12228 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012229#endif
12230 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012231 {
12232 // is11Rconnection;
12233 dwTmp = pal_cpu_to_be32(TRUE);
12234 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12235 pBuf += sizeof(tAniBool);
12236 }
12237 else
12238 {
12239 // is11Rconnection;
12240 dwTmp = pal_cpu_to_be32(FALSE);
12241 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12242 pBuf += sizeof(tAniBool);
12243 }
12244#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012245#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012246
12247 // isCCXFeatureIniEnabled
12248 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12249 {
12250 dwTmp = pal_cpu_to_be32(TRUE);
12251 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12252 pBuf += sizeof(tAniBool);
12253 }
12254 else
12255 {
12256 dwTmp = pal_cpu_to_be32(FALSE);
12257 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12258 pBuf += sizeof(tAniBool);
12259 }
12260
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012261 /* A profile can not be both CCX and 11R. But an 802.11R AP
12262 * may be advertising support for CCX as well. So if we are
12263 * associating Open or explicitly CCX then we will get CCX.
12264 * If we are associating explictly 11R only then we will get
12265 * 11R.
12266 */
12267 if ((csrIsProfileCCX(pProfile) ||
12268 ((pIes->CCXVersion.present)
12269 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012270 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12271 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12272 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012273#ifdef WLAN_FEATURE_11W
12274 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12275#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012276 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012277 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12278 {
12279 // isCCXconnection;
12280 dwTmp = pal_cpu_to_be32(TRUE);
12281 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12282 pBuf += sizeof(tAniBool);
12283 }
12284 else
12285 {
12286 //isCCXconnection;
12287 dwTmp = pal_cpu_to_be32(FALSE);
12288 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
12289 pBuf += sizeof(tAniBool);
12290 }
12291
12292 if (eWNI_SME_JOIN_REQ == messageType)
12293 {
12294 tCCXTspecInfo ccxTspec;
12295 // CCX-Tspec IEs in the ASSOC request is presently not supported
12296 // so nullify the TSPEC parameters
12297 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12298 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12299 pBuf += sizeof(tCCXTspecInfo);
12300 }
12301 else if (eWNI_SME_REASSOC_REQ == messageType)
12302 {
12303 if ((csrIsProfileCCX(pProfile) ||
12304 ((pIes->CCXVersion.present)
12305 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012306 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12307 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12308 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012309#ifdef WLAN_FEATURE_11W
12310 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12311#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012312 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012313 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 {
12315 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 // CCX Tspec information
12317 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12318 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12319 *pBuf = ccxTspec.numTspecs;
12320 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012321 // Copy the TSPEC information only if present
12322 if (ccxTspec.numTspecs) {
12323 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
12324 }
12325 pBuf += sizeof(ccxTspec.tspec);
12326 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012327 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012328 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 tCCXTspecInfo ccxTspec;
12330 // CCX-Tspec IEs in the ASSOC request is presently not supported
12331 // so nullify the TSPEC parameters
12332 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
12333 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
12334 pBuf += sizeof(tCCXTspecInfo);
12335 }
12336 }
12337#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012338#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012340 if (pMac->roam.configParam.isFastTransitionEnabled
12341#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012342 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012343#endif
12344 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012346 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012348 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 }
12350 else
12351 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012352 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012354 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 }
12356#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012357#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012358 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012359 {
12360 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012361 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012362 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012363 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012364 }
12365 else
12366 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012367 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012368 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012369 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012370 }
12371#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012372
12373 // txLdpcIniFeatureEnabled
12374 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12375 pBuf++;
12376
Kiran4a17ebe2013-01-31 10:43:43 -080012377 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12378 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12379 {
12380 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12381 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12382 csrApplyPower2Current(pMac);
12383 }
12384
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012385#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012386 // txBFIniFeatureEnabled
12387 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12388 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012389
12390 // txBFCsnValue
12391 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12392 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012393#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012394 //BssDesc
12395 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12396 (tANI_U8)pProfile->uapsd_mask);
12397 status = palSendMBMessage(pMac->hHdd, pMsg );
12398 if(!HAL_STATUS_SUCCESS(status))
12399 {
12400 break;
12401 }
12402 else
12403 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012404#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012405 if (eWNI_SME_JOIN_REQ == messageType)
12406 {
12407 //Tush-QoS: notify QoS module that join happening
12408 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12409 }
12410 else if (eWNI_SME_REASSOC_REQ == messageType)
12411 {
12412 //Tush-QoS: notify QoS module that reassoc happening
12413 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012415#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012419}
12420
Jeff Johnson295189b2012-06-20 16:38:30 -070012421//
12422eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12423{
12424 eHalStatus status = eHAL_STATUS_SUCCESS;
12425 tSirSmeDisassocReq *pMsg;
12426 tANI_U8 *pBuf;
12427 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12429 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12430 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012431 do {
12432 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12433 if ( !HAL_STATUS_SUCCESS(status) ) break;
12434 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12435 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12436 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 pBuf = &pMsg->sessionId;
12438 // sessionId
12439 *pBuf++ = (tANI_U8)sessionId;
12440 // transactionId
12441 *pBuf = 0;
12442 *( pBuf + 1 ) = 0;
12443 pBuf += sizeof(tANI_U16);
12444
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012445 if ( (pSession->pCurRoamProfile != NULL) &&
12446 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12447 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 {
12449 // Set the bssid address before sending the message to LIM
12450 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12451 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 // Set the peer MAC address before sending the message to LIM
12453 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12454 pBuf = pBuf + sizeof ( tSirMacAddr );
12455 }
12456 else
12457 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 // Set the peer MAC address before sending the message to LIM
12459 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12460 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012461 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12462 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 if(!HAL_STATUS_SUCCESS(status))
12465 {
12466 palFreeMemory(pMac->hHdd, pMsg);
12467 break;
12468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 // reasonCode
12470 wTmp = pal_cpu_to_be16(reasonCode);
12471 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12472 if(!HAL_STATUS_SUCCESS(status))
12473 {
12474 palFreeMemory(pMac->hHdd, pMsg);
12475 break;
12476 }
12477 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12479 Here we should not send the disassoc over the air to the AP */
12480 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12481#ifdef WLAN_FEATURE_VOWIFI_11R
12482 && csrRoamIs11rAssoc(pMac)
12483#endif
12484 )
12485 {
12486 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12487 }
12488 pBuf += sizeof(tANI_U8);
12489 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 return( status );
12492}
Jeff Johnson295189b2012-06-20 16:38:30 -070012493eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12494{
12495 eHalStatus status = eHAL_STATUS_SUCCESS;
12496 tSirSmeTkipCntrMeasReq *pMsg;
12497 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 do
12499 {
12500 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12501 if ( !HAL_STATUS_SUCCESS(status) ) break;
12502 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12503 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12504 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 pBuf = &pMsg->sessionId;
12506 // sessionId
12507 *pBuf++ = (tANI_U8)sessionId;
12508 // transactionId
12509 *pBuf = 0;
12510 *( pBuf + 1 ) = 0;
12511 pBuf += sizeof(tANI_U16);
12512 // bssid
12513 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12514 pBuf = pBuf + sizeof ( tSirMacAddr );
12515 // bEnable
12516 *pBuf = (tANI_BOOLEAN)bEnable;
12517 if(!HAL_STATUS_SUCCESS(status))
12518 {
12519 palFreeMemory(pMac->hHdd, pMsg);
12520 break;
12521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 return( status );
12525}
Jeff Johnson295189b2012-06-20 16:38:30 -070012526eHalStatus
12527csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12528 VOS_MODULE_ID modId, tSirMacAddr bssId,
12529 void *pUsrContext, void *pfnSapEventCallback,
12530 tANI_U8 *pAssocStasBuf )
12531{
12532 eHalStatus status = eHAL_STATUS_SUCCESS;
12533 tSirSmeGetAssocSTAsReq *pMsg;
12534 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12535 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 do
12537 {
12538 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12539 if (!HAL_STATUS_SUCCESS(status)) break;
12540 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12541 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 pBuf = (tANI_U8 *)&pMsg->bssId;
12543 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 // bssId
12545 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12546 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 // modId
12548 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12549 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12550 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 // pUsrContext
12552 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12553 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12554 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 // pfnSapEventCallback
12556 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12557 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12558 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 // pAssocStasBuf
12560 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12561 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12562 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 status = palSendMBMessage( pMac->hHdd, pMsg );
12565 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 return( status );
12567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012568eHalStatus
12569csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12570 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12571 {
12572 eHalStatus status = eHAL_STATUS_SUCCESS;
12573 tSirSmeGetWPSPBCSessionsReq *pMsg;
12574 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12575 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 do
12577 {
12578 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12579 if (!HAL_STATUS_SUCCESS(status)) break;
12580 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12581 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070012583 VOS_ASSERT(pBuf);
12584
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 // pUsrContext
12587 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12588 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12589 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 // pSapEventCallback
12591 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12592 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12593 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 // bssId
12595 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12596 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 // MAC Address of STA in WPS session
12598 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12599 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 return( status );
12604}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012605
12606eHalStatus
12607csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12608{
12609 tpSirChangeBIParams pMsg;
12610 tANI_U16 len = 0;
12611 eHalStatus status = eHAL_STATUS_SUCCESS;
12612 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12613
12614 if(!pSession)
12615 {
12616 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12617 return eHAL_STATUS_FAILURE;
12618 }
12619
12620 //NO need to update the Beacon Params if update beacon parameter flag is not set
12621 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12622 return eHAL_STATUS_SUCCESS;
12623
12624 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12625
12626 /* Create the message and send to lim */
12627 len = sizeof(tSirChangeBIParams);
12628 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12629 if(HAL_STATUS_SUCCESS(status))
12630 {
12631 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12632 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12633 pMsg->length = len;
12634
12635 // bssId
12636 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012637 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 -080012638 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12639 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12640 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012641 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012642 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12643 status = palSendMBMessage(pMac->hHdd, pMsg);
12644 }
12645 return status;
12646}
12647
Jeff Johnson295189b2012-06-20 16:38:30 -070012648eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12649{
12650 eHalStatus status = eHAL_STATUS_SUCCESS;
12651 tSirSmeDeauthReq *pMsg;
12652 tANI_U8 *pBuf;
12653 tANI_U16 wTmp;
12654 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12655 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12656 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 do {
12658 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12659 if ( !HAL_STATUS_SUCCESS(status) ) break;
12660 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12661 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12662 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12663 //sessionId
12664 pBuf = &pMsg->sessionId;
12665 *pBuf++ = (tANI_U8)sessionId;
12666
12667 //tansactionId
12668 *pBuf = 0;
12669 *(pBuf + 1 ) = 0;
12670 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12674 // Set the BSSID before sending the message to LIM
12675 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12676 pBuf = pBuf + sizeof(tSirMacAddr);
12677 }
12678 else
12679 {
12680 // Set the BSSID before sending the message to LIM
12681 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12682 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 }
12684 if(!HAL_STATUS_SUCCESS(status))
12685 {
12686 palFreeMemory(pMac->hHdd, pMsg);
12687 break;
12688 }
12689 // Set the peer MAC address before sending the message to LIM
12690 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12691 pBuf = pBuf + sizeof(tSirMacAddr);
12692 if(!HAL_STATUS_SUCCESS(status))
12693 {
12694 palFreeMemory(pMac->hHdd, pMsg);
12695 break;
12696 }
12697 wTmp = pal_cpu_to_be16(reasonCode);
12698 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12699 if(!HAL_STATUS_SUCCESS(status))
12700 {
12701 palFreeMemory(pMac->hHdd, pMsg);
12702 break;
12703 }
12704 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012705 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 return( status );
12707}
12708
Jeff Johnson295189b2012-06-20 16:38:30 -070012709eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12710{
12711 eHalStatus status = eHAL_STATUS_SUCCESS;
12712 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 do {
12714 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12715 if ( !HAL_STATUS_SUCCESS(status) ) break;
12716 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12717 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12718 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12719 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12720 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12721 if(!HAL_STATUS_SUCCESS(status))
12722 {
12723 palFreeMemory(pMac->hHdd, pMsg);
12724 break;
12725 }
12726//To test reconn
12727 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12728 if(!HAL_STATUS_SUCCESS(status))
12729 {
12730 palFreeMemory(pMac->hHdd, pMsg);
12731 break;
12732 }
12733//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 return( status );
12737}
12738
Jeff Johnson295189b2012-06-20 16:38:30 -070012739eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12740{
12741 eHalStatus status = eHAL_STATUS_SUCCESS;
12742 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 do {
12744 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12745 if ( !HAL_STATUS_SUCCESS(status) ) break;
12746 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12747 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12748 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12749 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12750 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12751 if(!HAL_STATUS_SUCCESS(status))
12752 {
12753 palFreeMemory(pMac->hHdd, pMsg);
12754 break;
12755 }
12756 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12757 if(!HAL_STATUS_SUCCESS(status))
12758 {
12759 palFreeMemory(pMac->hHdd, pMsg);
12760 break;
12761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 return( status );
12765}
Jeff Johnson295189b2012-06-20 16:38:30 -070012766eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12767{
12768 eHalStatus status = eHAL_STATUS_SUCCESS;
12769 tSirSmeAssocCnf *pMsg;
12770 tANI_U8 *pBuf;
12771 tSirResultCodes statusCode;
12772 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 do {
12774 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12775 if ( !HAL_STATUS_SUCCESS(status) ) break;
12776 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12777 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12778 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 pBuf = (tANI_U8 *)&pMsg->statusCode;
12780 if(HAL_STATUS_SUCCESS(Halstatus))
12781 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12782 else
12783 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12784 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12785 pBuf += sizeof(tSirResultCodes);
12786 // bssId
12787 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12788 pBuf += sizeof (tSirMacAddr);
12789 // peerMacAddr
12790 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12791 pBuf += sizeof (tSirMacAddr);
12792 // aid
12793 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12794 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12795 pBuf += sizeof (tANI_U16);
12796 // alternateBssId
12797 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12798 pBuf += sizeof (tSirMacAddr);
12799 // alternateChannelId
12800 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 status = palSendMBMessage( pMac->hHdd, pMsg );
12802 if(!HAL_STATUS_SUCCESS(status))
12803 {
12804 //pMsg is freed by palSendMBMessage
12805 break;
12806 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 return( status );
12809}
Jeff Johnson295189b2012-06-20 16:38:30 -070012810eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12811 tpSirSmeAssocInd pAssocInd,
12812 eHalStatus Halstatus,
12813 tANI_U8 sessionId)
12814{
12815 tSirMsgQ msgQ;
12816 eHalStatus status = eHAL_STATUS_SUCCESS;
12817 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12818 tANI_U8 *pBuf;
12819 tSirResultCodes statusCode;
12820 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 do {
12822 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12823 if ( !HAL_STATUS_SUCCESS(status) ) break;
12824 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012825
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12827 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12828
12829 pMsg->sessionId = sessionId;
12830
12831 pBuf = (tANI_U8 *)&pMsg->statusCode;
12832 if(HAL_STATUS_SUCCESS(Halstatus))
12833 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12834 else
12835 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12836 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12837 pBuf += sizeof(tSirResultCodes);
12838 // bssId
12839 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12840 pBuf += sizeof (tSirMacAddr);
12841 // peerMacAddr
12842 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12843 pBuf += sizeof (tSirMacAddr);
12844 // StaId
12845 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12846 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12847 pBuf += sizeof (tANI_U16);
12848 // alternateBssId
12849 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12850 pBuf += sizeof (tSirMacAddr);
12851 // alternateChannelId
12852 *pBuf = 11;
12853 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12855 //Wmm
12856 *pBuf = pAssocInd->wmmEnabledSta;
12857 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 //RSN IE
12859 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12860 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 //Additional IE
12862 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12863 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 //reassocReq
12865 *pBuf = pAssocInd->reassocReq;
12866 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12868 msgQ.bodyptr = pMsg;
12869 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 return( status );
12873}
Jeff Johnson295189b2012-06-20 16:38:30 -070012874
Jeff Johnson295189b2012-06-20 16:38:30 -070012875eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12876 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12877 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12878 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12879 tANI_U8 *pKeyRsc )
12880{
12881 tSirSmeSetContextReq *pMsg;
12882 tANI_U16 msgLen;
12883 eHalStatus status = eHAL_STATUS_FAILURE;
12884 tAniEdType tmpEdType;
12885 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053012886 tANI_U8 *pBuf = NULL;
12887 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012889 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12892 // key set. Since we only support upto one key, we always allocate memory for 1 key
12893 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12894 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12895 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12896 ( sizeof( pMsg->keyMaterial.key ) );
12897
12898 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12899 if ( !HAL_STATUS_SUCCESS(status) ) break;
12900 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12901 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12902 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 //sessionId
12904 pBuf = &pMsg->sessionId;
12905 *pBuf = (tANI_U8)sessionId;
12906 pBuf++;
12907 // transactionId
12908 *pBuf = 0;
12909 *(pBuf + 1) = 0;
12910 pBuf += sizeof(tANI_U16);
12911 // peerMacAddr
12912 palCopyMemory( pMac->hHdd, pBuf,
12913 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12914
12915 pBuf += sizeof(tSirMacAddr);
12916
12917 // bssId
12918 palCopyMemory( pMac->hHdd, pBuf,
12919 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12920
12921 pBuf += sizeof(tSirMacAddr);
12922
12923 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12925 // in the tSirKeyMaterial keyMaterial; field).
12926 //
12927 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12928 // shorter than this max size. Is LIM interpreting this ok ?
12929 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 -070012930 // set pMsg->keyMaterial.edType
12931 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12932 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12933 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 // set the pMsg->keyMaterial.numKeys field
12935 *p = numKeys;
12936 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 // set pSirKey->keyId = keyId;
12938 *p = keyId;
12939 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 // set pSirKey->unicast = (tANI_U8)fUnicast;
12941 *p = (tANI_U8)fUnicast;
12942 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012943 // set pSirKey->keyDirection = aniKeyDirection;
12944 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12945 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12946 p += sizeof(tAniKeyDirection);
12947 // pSirKey->keyRsc = ;;
12948 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12949 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 // set pSirKey->paeRole
12951 *p = paeRole; // 0 is Supplicant
12952 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 // set pSirKey->keyLength = keyLength;
12954 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 if ( keyLength && pKey )
12956 {
12957 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12958 if(keyLength == 16)
12959 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012960 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 -070012961 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12962 pKey[5], pKey[6], pKey[7], pKey[8],
12963 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12964 }
12965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012967 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 return( status );
12969}
12970
Jeff Johnson295189b2012-06-20 16:38:30 -070012971eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12972 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12973{
12974 eHalStatus status;
12975 tSirSmeStartBssReq *pMsg;
12976 tANI_U8 *pBuf = NULL;
12977 tANI_U8 *wTmpBuf = NULL;
12978 tANI_U16 msgLen, wTmp;
12979 tANI_U32 dwTmp;
12980 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012981 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012984
12985 if(!pSession)
12986 {
12987 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12988 return eHAL_STATUS_FAILURE;
12989 }
12990
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 do {
12992 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12993 pSession->joinFailStatusCode.reasonCode = 0;
12994 msgLen = sizeof(tSirSmeStartBssReq);
12995 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12996 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012997 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12998 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 //sessionId
13002 *pBuf = (tANI_U8)sessionId;
13003 pBuf++;
13004 // transactionId
13005 *pBuf = 0;
13006 *(pBuf + 1) = 0;
13007 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 // bssid
13009 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
13010 pBuf += sizeof(tSirMacAddr);
13011 // selfMacAddr
13012 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
13013 pBuf += sizeof(tSirMacAddr);
13014 // beaconInterval
13015 if( pBssDesc && pBssDesc->beaconInterval )
13016 {
13017 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 else if(pParam->beaconInterval)
13020 {
13021 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13022 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 else
13024 {
13025 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13026 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013027 if(csrIsconcurrentsessionValid (pMac, sessionId,
13028 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013029 == eHAL_STATUS_SUCCESS )
13030 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013031 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013032 pParam->bssPersona);
13033 //Update the beacon Interval
13034 pParam->beaconInterval = wTmp;
13035 }
13036 else
13037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013038 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013039 status = eHAL_STATUS_FAILURE;
Gopichand Nakkala114718f2013-03-25 19:19:46 -070013040 palFreeMemory( pMac->hHdd, pMsg );
Jeff Johnsone7245742012-09-05 17:12:55 -070013041 return status;
13042 }
13043
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13045 pBuf += sizeof(tANI_U16);
13046 // dot11mode
13047 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13048 pBuf += 1;
13049 // bssType
13050 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
13051 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
13052 pBuf += sizeof(tSirBssType);
13053 // ssId
13054 if( pParam->ssId.length )
13055 {
13056 // ssId len
13057 *pBuf = pParam->ssId.length;
13058 pBuf++;
13059 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
13060 pBuf += pParam->ssId.length;
13061 }
13062 else
13063 {
13064 *pBuf = 0;
13065 pBuf++;
13066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 // set the channel Id
13068 *pBuf = pParam->operationChn;
13069 pBuf++;
13070 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013071 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
13072 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
13073 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013074
Jeff Johnson295189b2012-06-20 16:38:30 -070013075 // Set privacy
13076 *pBuf = pParam->privacy;
13077 pBuf++;
13078
13079 //Set Uapsd
13080 *pBuf = pParam->ApUapsdEnable;
13081 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 //Set SSID hidden
13083 *pBuf = pParam->ssidHidden;
13084 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13086 pBuf++;
13087
13088 //Ht protection Enable/Disable
13089 *pBuf = (tANI_U8)pParam->protEnabled;
13090 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 //Enable Beacons to Receive for OBSS protection Enable/Disable
13092 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13093 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 //set cfg related to protection
13095 wTmp = pal_cpu_to_be16( pParam->ht_protection );
13096 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
13097 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 // Set Auth type
13099 authType = pal_cpu_to_be32(pParam->authType);
13100 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
13101 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 // Set DTIM
13103 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
13104 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
13105 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 // Set wps_state
13107 *pBuf = pParam->wps_state;
13108 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 //Persona
13110 *pBuf = (tANI_U8)pParam->bssPersona;
13111 pBuf++;
13112
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013113 //txLdpcIniFeatureEnabled
13114 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13115 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013116
13117 // prop IE enabled in .ini file
13118 *pBuf = (tANI_U8)pMac->roam.configParam.enableOxygenNwk;
13119 pBuf++;
13120
13121 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013122 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13123 {
13124 status = eHAL_STATUS_INVALID_PARAMETER;
13125 palFreeMemory( pMac->hHdd, pMsg );
13126 break;
13127 }
13128 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
13129 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
13130 pBuf += sizeof(tANI_U16);
13131 if( wTmp )
13132 {
13133 wTmp = pParam->nRSNIELength;
13134 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
13135 pBuf += wTmp;
13136 }
13137 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
13138 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
13139 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13141 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
13143 pBuf += pParam->operationalRateSet.numRates ;
13144 *pBuf++ = pParam->extendedRateSet.numRates;
13145 if(0 != pParam->extendedRateSet.numRates)
13146 {
13147 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
13148 pBuf += pParam->extendedRateSet.numRates;
13149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13151 pMsg->length = pal_cpu_to_be16(msgLen);
13152
13153 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 return( status );
13156}
13157
Jeff Johnson295189b2012-06-20 16:38:30 -070013158eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13159{
13160 eHalStatus status = eHAL_STATUS_FAILURE;
13161 tSirSmeStopBssReq *pMsg;
13162 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13163 tANI_U8 *pBuf;
13164 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013165
13166 if(!pSession)
13167 {
13168 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13169 return eHAL_STATUS_FAILURE;
13170 }
13171
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 do {
13173 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13174 if ( !HAL_STATUS_SUCCESS(status) ) break;
13175 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13176 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13177 pBuf = &pMsg->sessionId;
13178 //sessionId
13179 *pBuf = (tANI_U8)sessionId;
13180 pBuf++;
13181 // transactionId
13182 *pBuf = 0;
13183 pBuf += sizeof(tANI_U16);
13184 //reason code
13185 *pBuf = 0;
13186 pBuf += sizeof(tSirResultCodes);
13187 // bssid
13188 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13189 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13190 {
13191 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
13192 }
13193 else
13194 {
13195 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
13196 }
13197 pBuf += sizeof(tSirMacAddr);
13198 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13199 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 status = palSendMBMessage( pMac->hHdd, pMsg );
13201#if 0
13202 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
13203 if ( !HAL_STATUS_SUCCESS(status) ) break;
13204 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
13205 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13206 pMsg->reasonCode = 0;
13207 // bssid
13208 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13209 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13210 {
13211 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13212 }
13213 else
13214 {
13215 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13216 }
13217 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
13218 pMsg->transactionId = 0;
13219 pMsg->sessionId = (tANI_U8)sessionId;
13220 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13221 status = palSendMBMessage( pMac->hHdd, pMsg );
13222#endif
13223 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 return( status );
13225}
13226
Jeff Johnson295189b2012-06-20 16:38:30 -070013227eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13228 tCsrRoamModifyProfileFields *pModProfileFields,
13229 tANI_U32 *pRoamId, v_BOOL_t fForce)
13230{
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 eHalStatus status = eHAL_STATUS_FAILURE;
13232 tANI_U32 roamId = 0;
13233 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 if((csrIsConnStateConnected(pMac, sessionId)) &&
13235 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
13236 &pSession->connectedProfile.modifyProfileFields,
13237 sizeof(tCsrRoamModifyProfileFields)))) )
13238 {
13239 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13240 if(pRoamId)
13241 {
13242 *pRoamId = roamId;
13243 }
13244
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13246 eCsrSmeIssuedReassocToSameAP, roamId,
13247 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 return status;
13250}
Jeff Johnson295189b2012-06-20 16:38:30 -070013251static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13252{
13253 eHalStatus status = eHAL_STATUS_SUCCESS;
13254 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
13256 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13257 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13258 return (status);
13259}
Jeff Johnson295189b2012-06-20 16:38:30 -070013260eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13261{
13262 eHalStatus status = eHAL_STATUS_SUCCESS;
13263 tListElem *pEntry = NULL;
13264 tSmeCmd *pCommand = NULL;
13265 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 do
13267 {
13268 if(pMsg == NULL)
13269 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013270 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 status = eHAL_STATUS_FAILURE;
13272 break;
13273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13275 if(pEntry)
13276 {
13277 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13278 if(eSmeCommandAddStaSession == pCommand->command)
13279 {
13280 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013281 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 //Remove this command out of the active list
13285 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13286 {
13287 //Now put this command back on the avilable command list
13288 csrReleaseCommand(pMac, pCommand);
13289 }
13290 smeProcessPendingQueue( pMac );
13291 }
13292 else
13293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013294 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 -070013295 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 status = eHAL_STATUS_FAILURE;
13297 break;
13298 }
13299 }
13300 else
13301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013302 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 -070013303 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 status = eHAL_STATUS_FAILURE;
13305 break;
13306 }
13307 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013309}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013310eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13311 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013312{
13313 tSirSmeAddStaSelfReq *pMsg;
13314 tANI_U16 msgLen;
13315 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013317 msgLen = sizeof(tSirSmeAddStaSelfReq);
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13319 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13322 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 // self station address
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013324 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr,
13325 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13326
13327 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13328
13329 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pMsg->selfMacAddr[0],
13331 pMsg->selfMacAddr[1],
13332 pMsg->selfMacAddr[2],
13333 pMsg->selfMacAddr[3],
13334 pMsg->selfMacAddr[4],
13335 pMsg->selfMacAddr[5]);
13336 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 return( status );
13339}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013340eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13341 tANI_U32 sessionId,
13342 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013343{
13344 eHalStatus status = eHAL_STATUS_SUCCESS;
13345 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 pCommand = csrGetCommandBuffer(pMac);
13347 if(NULL == pCommand)
13348 {
13349 status = eHAL_STATUS_RESOURCES;
13350 }
13351 else
13352 {
13353 pCommand->command = eSmeCommandAddStaSession;
13354 pCommand->sessionId = (tANI_U8)sessionId;
13355 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013356 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13358 if( !HAL_STATUS_SUCCESS( status ) )
13359 {
13360 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013361 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 }
13363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 return (status);
13365}
Jeff Johnson295189b2012-06-20 16:38:30 -070013366eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13367{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013368 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013369}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013370eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13371 csrRoamCompleteCallback callback,
13372 void *pContext, tANI_U8 *pSelfMacAddr,
13373 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013374{
13375 eHalStatus status = eHAL_STATUS_SUCCESS;
13376 tANI_U32 i;
13377 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 *pbSessionId = CSR_SESSION_ID_INVALID;
13379 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13380 {
13381 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13382 {
13383 pSession = CSR_GET_SESSION( pMac, i );
13384 status = eHAL_STATUS_SUCCESS;
13385 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13386 pSession->sessionId = (tANI_U8)i;
13387 pSession->callback = callback;
13388 pSession->pContext = pContext;
13389 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13390 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13392 &pSession->roamingTimerInfo);
13393 if(!HAL_STATUS_SUCCESS(status))
13394 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013395 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 break;
13397 }
13398#ifdef FEATURE_WLAN_BTAMP_UT_RF
13399 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13400 &pSession->joinRetryTimerInfo);
13401 if(!HAL_STATUS_SUCCESS(status))
13402 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013403 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 break;
13405 }
13406#endif
13407 pSession->ibssJoinTimerInfo.pMac = pMac;
13408 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13410 &pSession->ibssJoinTimerInfo);
13411 if(!HAL_STATUS_SUCCESS(status))
13412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013413 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 break;
13415 }
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013416 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 break;
13418 }
13419 }
13420 if( CSR_ROAM_SESSION_MAX == i )
13421 {
13422 //No session is available
13423 status = eHAL_STATUS_RESOURCES;
13424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 return ( status );
13426}
Jeff Johnson295189b2012-06-20 16:38:30 -070013427eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13428{
13429 eHalStatus status = eHAL_STATUS_SUCCESS;
13430 tListElem *pEntry = NULL;
13431 tSmeCmd *pCommand = NULL;
13432 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 do
13434 {
13435 if(pMsg == NULL)
13436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013437 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 status = eHAL_STATUS_FAILURE;
13439 break;
13440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13442 if(pEntry)
13443 {
13444 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13445 if(eSmeCommandDelStaSession == pCommand->command)
13446 {
13447 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013449 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 //This session is done.
13451 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 if(pCommand->u.delStaSessionCmd.callback)
13453 {
13454
13455 status = sme_ReleaseGlobalLock( &pMac->sme );
13456 if ( HAL_STATUS_SUCCESS( status ) )
13457 {
13458 pCommand->u.delStaSessionCmd.callback(
13459 pCommand->u.delStaSessionCmd.pContext);
13460 status = sme_AcquireGlobalLock( &pMac->sme );
13461 if (! HAL_STATUS_SUCCESS( status ) )
13462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013463 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 return status;
13465 }
13466 }
13467 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013468 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 }
13470 }
13471
13472 //Remove this command out of the active list
13473 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13474 {
13475 //Now put this command back on the avilable command list
13476 csrReleaseCommand(pMac, pCommand);
13477 }
13478 smeProcessPendingQueue( pMac );
13479 }
13480 else
13481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013482 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 -070013483 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 status = eHAL_STATUS_FAILURE;
13485 break;
13486 }
13487 }
13488 else
13489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013490 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 -070013491 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 status = eHAL_STATUS_FAILURE;
13493 break;
13494 }
13495 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013497}
Jeff Johnson295189b2012-06-20 16:38:30 -070013498eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13499{
13500 tSirSmeDelStaSelfReq *pMsg;
13501 tANI_U16 msgLen;
13502 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13505 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13507 if ( !HAL_STATUS_SUCCESS(status) ) break;
13508
13509 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13511 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 // self station address
13513 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 return( status );
13517}
Jeff Johnson295189b2012-06-20 16:38:30 -070013518eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13519 tSirMacAddr sessionMacAddr,
13520 csrRoamSessionCloseCallback callback,
13521 void *pContext)
13522{
13523 eHalStatus status = eHAL_STATUS_SUCCESS;
13524 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 pCommand = csrGetCommandBuffer(pMac);
13526 if(NULL == pCommand)
13527 {
13528 status = eHAL_STATUS_RESOURCES;
13529 }
13530 else
13531 {
13532 pCommand->command = eSmeCommandDelStaSession;
13533 pCommand->sessionId = (tANI_U8)sessionId;
13534 pCommand->u.delStaSessionCmd.callback = callback;
13535 pCommand->u.delStaSessionCmd.pContext = pContext;
13536 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13538 if( !HAL_STATUS_SUCCESS( status ) )
13539 {
13540 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013541 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 }
13543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 return (status);
13545}
Jeff Johnson295189b2012-06-20 16:38:30 -070013546eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13547{
13548 return csrSendMBDelSelfStaReqMsg( pMac,
13549 pCommand->u.delStaSessionCmd.selfMacAddr );
13550}
Jeff Johnson295189b2012-06-20 16:38:30 -070013551static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13552{
13553 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13554 tListElem *pEntry, *pNext;
13555 tSmeCmd *pCommand;
13556 tDblLinkList localList;
13557
13558 vos_mem_zero(&localList, sizeof(tDblLinkList));
13559 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13560 {
13561 smsLog(pMac, LOGE, FL(" failed to open list"));
13562 return;
13563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 csrLLLock(pList);
13565 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13566 while(pEntry != NULL)
13567 {
13568 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13569 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13570 if(pCommand->sessionId == sessionId)
13571 {
13572 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13573 {
13574 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13575 }
13576 }
13577 pEntry = pNext;
13578 }
13579 csrLLUnlock(pList);
13580
13581 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13582 {
13583 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13584 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13585 }
13586 csrLLClose(&localList);
13587}
13588
Jeff Johnson295189b2012-06-20 16:38:30 -070013589void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13590{
13591 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13592 {
13593 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 csrRoamStop(pMac, sessionId);
13595 csrFreeConnectBssDesc(pMac, sessionId);
13596 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13597 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13598 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13599#ifdef FEATURE_WLAN_BTAMP_UT_RF
13600 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13601#endif
13602 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13603 purgeSmeSessionCmdList(pMac, sessionId);
13604 purgeCsrSessionCmdList(pMac, sessionId);
13605 csrInitSession(pMac, sessionId);
13606 }
13607}
13608
Jeff Johnson295189b2012-06-20 16:38:30 -070013609eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13610 tANI_BOOLEAN fSync,
13611 csrRoamSessionCloseCallback callback,
13612 void *pContext )
13613{
13614 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13616 {
13617 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13618 if(fSync)
13619 {
13620 csrCleanupSession(pMac, sessionId);
13621 }
13622 else
13623 {
13624 purgeSmeSessionCmdList(pMac, sessionId);
13625 purgeCsrSessionCmdList(pMac, sessionId);
13626 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13627 pSession->selfMacAddr, callback, pContext);
13628 }
13629 }
13630 else
13631 {
13632 status = eHAL_STATUS_INVALID_PARAMETER;
13633 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 return ( status );
13635}
13636
Jeff Johnson295189b2012-06-20 16:38:30 -070013637static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13638{
13639 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013640
13641 if(!pSession)
13642 {
13643 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13644 return;
13645 }
13646
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13648 pSession->sessionId = CSR_SESSION_ID_INVALID;
13649 pSession->callback = NULL;
13650 pSession->pContext = NULL;
13651 pSession->ibss_join_pending = FALSE;
13652 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13653 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13654 csrFreeRoamProfile( pMac, sessionId );
13655 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13656 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13657 csrFreeConnectBssDesc(pMac, sessionId);
13658 csrScanEnable(pMac);
13659 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13660 if(pSession->pWpaRsnReqIE)
13661 {
13662 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13663 pSession->pWpaRsnReqIE = NULL;
13664 }
13665 pSession->nWpaRsnReqIeLength = 0;
13666 if(pSession->pWpaRsnRspIE)
13667 {
13668 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13669 pSession->pWpaRsnRspIE = NULL;
13670 }
13671 pSession->nWpaRsnRspIeLength = 0;
13672#ifdef FEATURE_WLAN_WAPI
13673 if(pSession->pWapiReqIE)
13674 {
13675 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13676 pSession->pWapiReqIE = NULL;
13677 }
13678 pSession->nWapiReqIeLength = 0;
13679 if(pSession->pWapiRspIE)
13680 {
13681 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13682 pSession->pWapiRspIE = NULL;
13683 }
13684 pSession->nWapiRspIeLength = 0;
13685#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 if(pSession->pAddIEScan)
13687 {
13688 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13689 pSession->pAddIEScan = NULL;
13690 }
13691 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 if(pSession->pAddIEAssoc)
13693 {
13694 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13695 pSession->pAddIEAssoc = NULL;
13696}
13697 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013698}
13699
Jeff Johnson295189b2012-06-20 16:38:30 -070013700eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13701{
13702 eHalStatus status = eHAL_STATUS_FAILURE;
13703 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13705 {
13706 if( CSR_IS_SESSION_VALID( pMac, i ) )
13707 {
13708 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13709 {
13710 //Found it
13711 status = eHAL_STATUS_SUCCESS;
13712 *pSessionId = i;
13713 break;
13714 }
13715 }
13716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 return( status );
13718}
13719
Jeff Johnson295189b2012-06-20 16:38:30 -070013720//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13721//session because for IBSS, the bssid changes.
13722static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13723{
13724 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13725 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13727 {
13728 if( CSR_IS_SESSION_VALID( pMac, i ) )
13729 {
13730 pSession = CSR_GET_SESSION( pMac, i );
13731 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13732 {
13733 //Found it
13734 nRet = i;
13735 break;
13736 }
13737 }
13738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 return (nRet);
13740}
Jeff Johnson295189b2012-06-20 16:38:30 -070013741static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13742{
13743 /* Update the current BSS info in ho control block based on connected
13744 profile info from pmac global structure */
13745
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013746 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13748 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 /* Check for user misconfig of RSSI trigger threshold */
13750 pMac->roam.configParam.vccRssiThreshold =
13751 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13752 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13753 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 /* Check for user misconfig of UL MAC Loss trigger threshold */
13755 pMac->roam.configParam.vccUlMacLossThreshold =
13756 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13757 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013758#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13759 {
13760 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 /* Indicate the neighbor roal algorithm about the connect indication */
13762 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13763 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13764 }
13765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013766}
13767
Jeff Johnson295189b2012-06-20 16:38:30 -070013768static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13769{
13770 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013771
13772 if(!pSession)
13773 {
13774 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13775 return;
13776 }
13777
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 //Only to handle the case for Handover on infra link
13779 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13780 {
13781 return;
13782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13784 csrRoamDeregStatisticsReq(pMac);
13785 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13786#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13787 /* Indicate the neighbor roal algorithm about the disconnect indication */
13788 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13789#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013790
13791 //Remove this code once SLM_Sessionization is supported
13792 //BMPS_WORKAROUND_NOT_NEEDED
13793 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013794 csrIsInfraApStarted( pMac ) &&
13795 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013796 {
13797 pMac->roam.configParam.doBMPSWorkaround = 0;
13798 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013799}
13800
Jeff Johnson295189b2012-06-20 16:38:30 -070013801void csrRoamTlStatsTimerHandler(void *pv)
13802{
13803 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13804 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13806
Jeff Johnsone7245742012-09-05 17:12:55 -070013807 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13808
Jeff Johnson295189b2012-06-20 16:38:30 -070013809#if 0
13810 // TODO Persession .???
13811 //req TL for stats
13812 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013814 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 }
13816 else
13817 {
13818 //save in SME
13819 csrRoamSaveStatsFromTl(pMac, tlStats);
13820 }
13821#endif
13822 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13823 {
13824 if(pMac->roam.tlStatsReqInfo.periodicity)
13825 {
13826 //start timer
13827 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13828 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13829 if(!HAL_STATUS_SUCCESS(status))
13830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013831 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 return;
13833 }
13834 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13835 }
13836 }
13837}
Jeff Johnson295189b2012-06-20 16:38:30 -070013838void csrRoamPeStatsTimerHandler(void *pv)
13839{
13840 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13841 eHalStatus status;
13842 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13843 VOS_STATUS vosStatus;
13844 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 pPeStatsReqListEntry->timerRunning = FALSE;
13846 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13847 {
13848 // If we entered here, meaning the timer could not be successfully
13849 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13850
13851 /* Destroy the timer */
13852 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13853 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013855 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 }
13857
13858 // Free the entry
13859 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13860 pPeStatsReqListEntry = NULL;
13861 }
13862 else
13863 {
13864 if(!pPeStatsReqListEntry->rspPending)
13865 {
13866 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13867 pPeStatsReqListEntry->staId);
13868 if(!HAL_STATUS_SUCCESS(status))
13869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013870 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 }
13872 else
13873 {
13874 pPeStatsReqListEntry->rspPending = TRUE;
13875 }
13876 }
13877
13878 //send down a req
13879 if(pPeStatsReqListEntry->periodicity &&
13880 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13881 {
13882 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13883 if(ePMC_FULL_POWER == powerState)
13884 {
13885 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13886 {
13887 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13888 }
13889 }
13890 else
13891 {
13892 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13893 {
13894 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13895 }
13896 }
13897 //start timer
13898 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13899 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013901 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 return;
13903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 pPeStatsReqListEntry->timerRunning = TRUE;
13905
13906 }
13907
13908 }
13909}
Jeff Johnson295189b2012-06-20 16:38:30 -070013910void csrRoamStatsClientTimerHandler(void *pv)
13911{
13912 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13914 {
13915#if 0
13916 // TODO Stats fix for multisession
13917 //start the timer
13918 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13919
13920 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013922 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 }
13924#endif
13925 }
13926#if 0
13927 //send up the stats report
13928 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13929 pStaEntry->staId, pStaEntry->pContext);
13930#endif
13931}
13932
13933
13934
Jeff Johnson295189b2012-06-20 16:38:30 -070013935eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13936{
13937 tAniGetPEStatsReq *pMsg;
13938 eHalStatus status = eHAL_STATUS_SUCCESS;
13939 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13940 if ( !HAL_STATUS_SUCCESS(status) )
13941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013942 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 return status;
13944 }
13945 // need to initiate a stats request to PE
13946 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13947 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13948 pMsg->staId = staId;
13949 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013951 if(!HAL_STATUS_SUCCESS(status))
13952 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013953 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 return status;
13956}
Jeff Johnson295189b2012-06-20 16:38:30 -070013957void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13958{
13959 tAniGetPEStatsRsp *pSmeStatsRsp;
13960 eHalStatus status = eHAL_STATUS_FAILURE;
13961 tListElem *pEntry = NULL;
13962 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13963 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13964 tANI_U32 tempMask = 0;
13965 tANI_U8 counter = 0;
13966 tANI_U8 *pStats = NULL;
13967 tANI_U32 length = 0;
13968 v_PVOID_t pvosGCtx;
13969 v_S7_t rssi = 0;
13970 tANI_U32 *pRssi = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053013971 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13973 if(pSmeStatsRsp->rc)
13974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013975 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 goto post_update;
13977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 tempMask = pSmeStatsRsp->statsMask;
13979 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 /* subtract all statistics from this length, and after processing the entire
13981 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13982 * in this 'stats' message.
13983 */
13984 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 //new stats info from PE, fill up the stats strucutres in PMAC
13986 while(tempMask)
13987 {
13988 if(tempMask & 1)
13989 {
13990 switch(counter)
13991 {
13992 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013993 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13995 pStats, sizeof(tCsrSummaryStatsInfo));
13996 if(!HAL_STATUS_SUCCESS(status))
13997 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013998 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 }
14000 pStats += sizeof(tCsrSummaryStatsInfo);
14001 length -= sizeof(tCsrSummaryStatsInfo);
14002 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014004 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14006 pStats, sizeof(tCsrGlobalClassAStatsInfo));
14007 if(!HAL_STATUS_SUCCESS(status))
14008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014009 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 }
14011 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14012 length -= sizeof(tCsrGlobalClassAStatsInfo);
14013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014015 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14017 pStats, sizeof(tCsrGlobalClassBStatsInfo));
14018 if(!HAL_STATUS_SUCCESS(status))
14019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014020 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014021 }
14022 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14023 length -= sizeof(tCsrGlobalClassBStatsInfo);
14024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014026 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14028 pStats, sizeof(tCsrGlobalClassCStatsInfo));
14029 if(!HAL_STATUS_SUCCESS(status))
14030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014031 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 }
14033 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14034 length -= sizeof(tCsrGlobalClassCStatsInfo);
14035 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014037 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14039 {
14040 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14041 pStats, sizeof(tCsrPerStaStatsInfo));
14042 }
14043 else
14044 {
14045 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014046 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 VOS_ASSERT( 0 );
14048 }
14049 if(!HAL_STATUS_SUCCESS(status))
14050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014051 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 }
14053 pStats += sizeof(tCsrPerStaStatsInfo);
14054 length -= sizeof(tCsrPerStaStatsInfo);
14055 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014057 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014058 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 }
14060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 tempMask >>=1;
14062 counter++;
14063 }
14064 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14065 if (length != 0)
14066 {
14067 pRssi = (tANI_U32*)pStats;
14068 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014069 pStats += sizeof(tANI_U32);
14070 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 }
14072 else
14073 {
14074 /* If riva is not sending rssi, continue to use the hack */
14075 rssi = RSSI_HACK_BMPS;
14076 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014077
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014079
14080 if (length != 0)
14081 {
14082 linkCapacity = *(tANI_U32*)pStats;
14083 }
14084 else
14085 {
14086 linkCapacity = 0;
14087 }
14088
14089 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014090post_update:
14091 //make sure to update the pe stats req list
14092 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14093 if(pEntry)
14094 {
14095 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14096 pPeStaEntry->rspPending = FALSE;
14097
14098 }
14099 //check the one timer cases
14100 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14101 if(pEntry)
14102 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 if(pTempStaEntry->timerExpired)
14105 {
14106 //send up the stats report
14107 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14108 pTempStaEntry->staId, pTempStaEntry->pContext);
14109 //also remove from the client list
14110 csrRoamRemoveStatListEntry(pMac, pEntry);
14111 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 }
14113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014114}
Jeff Johnson295189b2012-06-20 16:38:30 -070014115tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14116{
14117 tListElem *pEntry = NULL;
14118 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 if(!pEntry)
14121 {
14122 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014123 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 return NULL;
14125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 while( pEntry )
14127 {
14128 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 if(pTempStaEntry->statsMask == statsMask)
14130 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014131 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 break;
14133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 return pEntry;
14137}
14138
Jeff Johnson295189b2012-06-20 16:38:30 -070014139tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14140 tANI_BOOLEAN update)
14141{
14142 tListElem *pEntry;
14143 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 if(!pEntry)
14146 {
14147 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014148 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014149 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 return NULL;
14151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 while( pEntry )
14153 {
14154 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14156 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014158 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 if(update)
14160 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014161 pTempStaEntry->periodicity = pStaEntry->periodicity;
14162 pTempStaEntry->callback = pStaEntry->callback;
14163 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 }
14165 break;
14166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 return pEntry;
14170}
Jeff Johnson295189b2012-06-20 16:38:30 -070014171tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14172{
14173 tListElem *pEntry;
14174 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 if(!pEntry)
14177 {
14178 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014179 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014180 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 return NULL;
14182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 while( pEntry )
14184 {
14185 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014188 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014189 break;
14190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 return pEntry;
14194}
Jeff Johnson295189b2012-06-20 16:38:30 -070014195eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14196 csrRoamLinkQualityIndCallback callback,
14197 void *pContext)
14198{
14199 pMac->roam.linkQualityIndInfo.callback = callback;
14200 pMac->roam.linkQualityIndInfo.context = pContext;
14201 if( NULL == callback )
14202 {
14203 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14204 }
14205 else
14206 {
14207 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014208 /* do we need to invoke the callback to notify client of initial value ?? */
14209 }
14210 return eHAL_STATUS_SUCCESS;
14211}
Jeff Johnson295189b2012-06-20 16:38:30 -070014212void csrRoamVccTrigger(tpAniSirGlobal pMac)
14213{
14214 eCsrRoamLinkQualityInd newVccLinkQuality;
14215 tANI_U32 ul_mac_loss = 0;
14216 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14218 /*-------------------------------------------------------------------------
14219 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 Check for a change in link quality and notify client if necessary
14221 -------------------------------------------------------------------------*/
14222 ul_mac_loss_trigger_threshold =
14223 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014225 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014227 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014229 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14231 }
14232 else
14233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014234 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14238 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014241 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014244 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 newVccLinkQuality );
14246
14247 /* we now invoke the callback once to notify client of initial value */
14248 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14249 pMac->roam.linkQualityIndInfo.context );
14250 //event: EVENT_WLAN_VCC
14251 }
14252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 pMac->roam.vccLinkQuality = newVccLinkQuality;
14254
Jeff Johnson295189b2012-06-20 16:38:30 -070014255}
Jeff Johnson295189b2012-06-20 16:38:30 -070014256VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14257 v_U8_t rssiNotification,
14258 void * context)
14259{
14260 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14261 eCsrRoamLinkQualityInd newVccLinkQuality;
14262 // TODO : Session info unavailable
14263 tANI_U32 sessionId = 0;
14264 VOS_STATUS status = VOS_STATUS_SUCCESS;
14265 /*-------------------------------------------------------------------------
14266 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014267 Check for a change in link quality and notify client if necessary
14268 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014269 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 pMac->roam.configParam.vccRssiThreshold);
14271 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14272 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014273 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 return VOS_STATUS_SUCCESS;
14275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014278 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014279 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14280 }
14281 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014283 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14285 }
14286 else
14287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014288 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 //Set to this so the code below won't do anything
14290 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 VOS_ASSERT(0);
14292 }
14293
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014296 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014299 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 /* we now invoke the callback once to notify client of initial value */
14302 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14303 pMac->roam.linkQualityIndInfo.context );
14304 //event: EVENT_WLAN_VCC
14305 }
14306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 return status;
14309}
Jeff Johnson295189b2012-06-20 16:38:30 -070014310tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14311 tDblLinkList *pStaList,
14312 tCsrStatsClientReqInfo *pStaEntry)
14313{
14314 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014316 //if same entity requested for same set of stats with different periodicity &
14317 // callback update it
14318 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14319 {
14320
14321 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
14322 if (!HAL_STATUS_SUCCESS(status))
14323 {
14324 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014325 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 return NULL;
14327 }
14328
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 pNewStaEntry->callback = pStaEntry->callback;
14330 pNewStaEntry->pContext = pStaEntry->pContext;
14331 pNewStaEntry->periodicity = pStaEntry->periodicity;
14332 pNewStaEntry->requesterId = pStaEntry->requesterId;
14333 pNewStaEntry->statsMask = pStaEntry->statsMask;
14334 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14335 pNewStaEntry->pMac = pStaEntry->pMac;
14336 pNewStaEntry->staId = pStaEntry->staId;
14337 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14338
14339 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14340 }
14341 return pNewStaEntry;
14342}
14343
Jeff Johnson295189b2012-06-20 16:38:30 -070014344tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14345 tDblLinkList *pStaList,
14346 tCsrPeStatsReqInfo *pStaEntry)
14347{
14348 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
14351 if (!HAL_STATUS_SUCCESS(status))
14352 {
14353 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014354 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 return NULL;
14356 }
14357
Jeff Johnson295189b2012-06-20 16:38:30 -070014358 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14359 pNewStaEntry->numClient = pStaEntry->numClient;
14360 pNewStaEntry->periodicity = pStaEntry->periodicity;
14361 pNewStaEntry->statsMask = pStaEntry->statsMask;
14362 pNewStaEntry->pMac = pStaEntry->pMac;
14363 pNewStaEntry->staId = pStaEntry->staId;
14364 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14365 pNewStaEntry->rspPending = pStaEntry->rspPending;
14366
14367 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 return pNewStaEntry;
14369}
Jeff Johnson295189b2012-06-20 16:38:30 -070014370eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14371 tCsrRssiCallback callback,
14372 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14373{
14374 eHalStatus status = eHAL_STATUS_SUCCESS;
14375 vos_msg_t msg;
14376 tANI_U32 sessionId;
14377
14378 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014379 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014380 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14381 if ( !HAL_STATUS_SUCCESS(status) )
14382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014383 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 return status;
14385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14387
14388 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14389 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14390 pMsg->sessionId = sessionId;
14391 pMsg->staId = staId;
14392 pMsg->rssiCallback = callback;
14393 pMsg->pDevContext = pContext;
14394 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014395 msg.type = eWNI_SME_GET_RSSI_REQ;
14396 msg.bodyptr = pMsg;
14397 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014400 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 palFreeMemory(pMac->hHdd, (void *)pMsg);
14402 status = eHAL_STATUS_FAILURE;
14403 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014404 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 return status;
14406}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014407
14408#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14409eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14410 tCsrRssiCallback callback,
14411 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14412{
14413 eHalStatus status = eHAL_STATUS_SUCCESS;
14414 tAniGetRssiReq *pMsg;
14415
14416 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14417 if ( !HAL_STATUS_SUCCESS(status) )
14418 {
14419 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14420 return status;
14421 }
14422 // need to initiate a stats request to PE
14423 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14424 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14425 pMsg->staId = staId;
14426 pMsg->rssiCallback = callback;
14427 pMsg->pDevContext = pContext;
14428 pMsg->pVosContext = pVosContext;
14429 status = palSendMBMessage(pMac->hHdd, pMsg );
14430 if(!HAL_STATUS_SUCCESS(status))
14431 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070014432 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
14433 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014434 status = eHAL_STATUS_FAILURE;
14435 }
14436 return status;
14437}
14438#endif
14439
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053014440/* ---------------------------------------------------------------------------
14441 \fn csrGetTLSTAState
14442 \helper function to get teh TL STA State whenever the function is called.
14443
14444 \param staId - The staID to be passed to the TL
14445 to get the relevant TL STA State
14446 \return the state as tANI_U16
14447 ---------------------------------------------------------------------------*/
14448tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
14449{
14450 WLANTL_STAStateType tlSTAState;
14451 tlSTAState = WLANTL_STA_INIT;
14452
14453 //request TL for STA State
14454 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
14455 {
14456 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
14457 }
14458
14459 return tlSTAState;
14460}
14461
Jeff Johnson295189b2012-06-20 16:38:30 -070014462eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14463 tANI_U32 statsMask,
14464 tCsrStatsCallback callback,
14465 tANI_U32 periodicity, tANI_BOOLEAN cache,
14466 tANI_U8 staId, void *pContext)
14467{
14468 tCsrStatsClientReqInfo staEntry;
14469 tCsrStatsClientReqInfo *pStaEntry = NULL;
14470 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14471 tListElem *pEntry = NULL;
14472 tANI_BOOLEAN found = FALSE;
14473 eHalStatus status = eHAL_STATUS_SUCCESS;
14474 tANI_BOOLEAN insertInClientList = FALSE;
14475 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014476 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014477
14478 if( csrIsAllSessionDisconnected(pMac) )
14479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014480 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 return eHAL_STATUS_FAILURE;
14482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 if((!statsMask) && (!callback))
14484 {
14485 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014486 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 return eHAL_STATUS_FAILURE;
14488 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014489 //for the search list method for deregister
14490 staEntry.requesterId = requesterId;
14491 staEntry.statsMask = statsMask;
14492 //requester wants to deregister or just an error
14493 if((statsMask) && (!callback))
14494 {
14495 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14496 if(!pEntry)
14497 {
14498 //msg
14499 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014500 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 return eHAL_STATUS_FAILURE;
14502 }
14503 else
14504 {
14505 //clean up & return
14506 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014507 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014509 pStaEntry->pPeStaEntry->numClient--;
14510 //check if we need to delete the entry from peStatsReqList too
14511 if(!pStaEntry->pPeStaEntry->numClient)
14512 {
14513 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014515 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014516
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 //check if we need to stop the tl stats timer too
14518 pMac->roam.tlStatsReqInfo.numClient--;
14519 if(!pMac->roam.tlStatsReqInfo.numClient)
14520 {
14521 if(pMac->roam.tlStatsReqInfo.timerRunning)
14522 {
14523 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14524 if(!HAL_STATUS_SUCCESS(status))
14525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014526 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 return eHAL_STATUS_FAILURE;
14528 }
14529 }
14530 pMac->roam.tlStatsReqInfo.periodicity = 0;
14531 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14532 }
14533 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014534 // Destroy the vos timer...
14535 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14536 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014538 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 csrRoamRemoveStatListEntry(pMac, pEntry);
14541 pStaEntry = NULL;
14542 return eHAL_STATUS_SUCCESS;
14543 }
14544 }
14545
14546 if(cache && !periodicity)
14547 {
14548 //return the cached stats
14549 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14550 }
14551 else
14552 {
14553 //add the request in the client req list
14554 staEntry.callback = callback;
14555 staEntry.pContext = pContext;
14556 staEntry.periodicity = periodicity;
14557 staEntry.pPeStaEntry = NULL;
14558 staEntry.staId = staId;
14559 staEntry.pMac = pMac;
14560 staEntry.timerExpired = FALSE;
14561
14562
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 //if periodic report requested with non cached result from PE/TL
14564 if(periodicity)
14565 {
14566
14567 //if looking for stats from PE
14568 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14569 {
14570
14571 //check if same request made already & waiting for rsp
14572 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14573 periodicity, &found, staId);
14574 if(!pPeStaEntry)
14575 {
14576 //bail out, maxed out on number of req for PE
14577 return eHAL_STATUS_FAILURE;
14578 }
14579 else
14580 {
14581 staEntry.pPeStaEntry = pPeStaEntry;
14582 }
14583
14584 }
14585 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14586 if(statsMask & (1 << eCsrGlobalClassDStats))
14587 {
14588 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014590 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 }
14592 else
14593 {
14594
14595 //update periodicity
14596 if(pMac->roam.tlStatsReqInfo.periodicity)
14597 {
14598 pMac->roam.tlStatsReqInfo.periodicity =
14599 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14600 }
14601 else
14602 {
14603 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14604 }
14605 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14606 {
14607 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14608 }
14609
14610 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14611 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014612 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14613 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014614 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014615 //req TL for class D stats
14616 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014618 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014619 }
14620 else
14621 {
14622 //save in SME
14623 csrRoamSaveStatsFromTl(pMac, pTlStats);
14624 }
14625 vos_mem_free(pTlStats);
14626 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 }
14628 else
14629 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014630 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014632
Jeff Johnson295189b2012-06-20 16:38:30 -070014633 if(pMac->roam.tlStatsReqInfo.periodicity)
14634 {
14635 //start timer
14636 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14637 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14638 if(!HAL_STATUS_SUCCESS(status))
14639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014640 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 return eHAL_STATUS_FAILURE;
14642 }
14643 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14644 }
14645 }
14646 }
14647 pMac->roam.tlStatsReqInfo.numClient++;
14648 }
14649
14650 insertInClientList = TRUE;
14651 }
14652 //if one time report requested with non cached result from PE/TL
14653 else if(!cache && !periodicity)
14654 {
14655 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14656 {
14657 //send down a req
14658 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14659 if(!HAL_STATUS_SUCCESS(status))
14660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014661 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014662 }
14663 //so that when the stats rsp comes back from PE we respond to upper layer
14664 //right away
14665 staEntry.timerExpired = TRUE;
14666 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014667 }
14668 if(statsMask & (1 << eCsrGlobalClassDStats))
14669 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014670 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14671 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014672 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014673 //req TL for class D stats
14674 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014676 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014677 }
14678 else
14679 {
14680 //save in SME
14681 csrRoamSaveStatsFromTl(pMac, pTlStats);
14682 }
14683 vos_mem_free(pTlStats);
14684 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 }
14686 else
14687 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014688 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014690
14691 }
14692 //if looking for stats from TL only
14693 if(!insertInClientList)
14694 {
14695 //return the stats
14696 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 if(insertInClientList)
14700 {
14701 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14702 if(!pStaEntry)
14703 {
14704 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014705 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 return eHAL_STATUS_FAILURE;
14707 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014708 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014709 //Init & start timer if needed
14710 if(periodicity)
14711 {
14712 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14713 csrRoamStatsClientTimerHandler, pStaEntry );
14714 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014716 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 return eHAL_STATUS_FAILURE;
14718 }
14719 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14720 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014722 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 return eHAL_STATUS_FAILURE;
14724 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014727 }
14728 return eHAL_STATUS_SUCCESS;
14729}
14730
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014731#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
14732
14733static tSirRetStatus
14734csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
14735 tANI_U8* pBD,
14736 tANI_U8 type,
14737 tANI_U8 subType,
14738 tSirMacAddr peerAddr,
14739 tSirMacAddr selfMacAddr)
14740{
14741 tSirRetStatus statusCode = eSIR_SUCCESS;
14742 tpSirMacMgmtHdr pMacHdr;
14743
14744 /* Prepare MAC management header */
14745 pMacHdr = (tpSirMacMgmtHdr) (pBD);
14746
14747 /* Prepare FC */
14748 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14749 pMacHdr->fc.type = type;
14750 pMacHdr->fc.subType = subType;
14751
14752 /* Prepare Address 1 */
14753 palCopyMemory( pMac->hHdd,
14754 (tANI_U8 *) pMacHdr->da,
14755 (tANI_U8 *) peerAddr,
14756 sizeof( tSirMacAddr ));
14757
14758 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
14759
14760 /* Prepare Address 3 */
14761 palCopyMemory( pMac->hHdd,
14762 (tANI_U8 *) pMacHdr->bssId,
14763 (tANI_U8 *) peerAddr,
14764 sizeof( tSirMacAddr ));
14765 return statusCode;
14766} /*** csrRoamScanOffloadPopulateMacHeader() ***/
14767
14768static tSirRetStatus
14769csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
14770 tANI_U8 nChannelNum,
14771 tANI_U32 dot11mode,
14772 tSirMacAddr selfMacAddr,
14773 tANI_U8 *pFrame,
14774 tANI_U16 *pusLen)
14775{
14776 tDot11fProbeRequest pr;
14777 tANI_U32 nStatus, nBytes, nPayload;
14778 tSirRetStatus nSirStatus;
14779 /*Bcast tx*/
14780 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
14781 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14782
14783
14784 palZeroMemory( pMac->hHdd, ( tANI_U8* )&pr, sizeof( pr ) );
14785
14786 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
14787
14788 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
14789 {
14790 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
14791 }
14792
14793
14794 if (IS_DOT11_MODE_HT(dot11mode))
14795 {
14796 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
14797 }
14798
14799
14800 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
14801 if ( DOT11F_FAILED( nStatus ) )
14802 {
14803 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14804 "Failed to calculate the packed size f"
14805 "or a Probe Request (0x%08x).\n", nStatus );
14806
14807
14808 nPayload = sizeof( tDot11fProbeRequest );
14809 }
14810 else if ( DOT11F_WARNED( nStatus ) )
14811 {
14812 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14813 "There were warnings while calculating"
14814 "the packed size for a Probe Request ("
14815 "0x%08x).\n", nStatus );
14816 }
14817
14818 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
14819
14820 /* Prepare outgoing frame*/
14821 palZeroMemory( pMac->hHdd, pFrame, nBytes );
14822
14823
14824 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
14825 SIR_MAC_MGMT_PROBE_REQ, bssId ,selfMacAddr);
14826
14827 if ( eSIR_SUCCESS != nSirStatus )
14828 {
14829 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14830 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
14831 nSirStatus );
14832 return nSirStatus;
14833 }
14834
14835
14836 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
14837 sizeof( tSirMacMgmtHdr ),
14838 nPayload, &nPayload );
14839 if ( DOT11F_FAILED( nStatus ) )
14840 {
14841 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14842 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
14843 return eSIR_FAILURE;
14844 }
14845 else if ( DOT11F_WARNED( nStatus ) )
14846 {
14847 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14848 "There were warnings while packing a Probe Request (0x%08x).\n" );
14849 }
14850
14851 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
14852 return eSIR_SUCCESS;
14853}
14854
14855eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
14856{
14857 vos_msg_t msg;
14858 tSirRoamOffloadScanReq *pRequestBuf;
14859 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
14860 tCsrRoamSession *pSession;
14861 tANI_U8 i,num_channels = 0, ucDot11Mode;
14862 tANI_U8 *ChannelList = NULL;
14863 tANI_U32 sessionId;
14864 eHalStatus status = eHAL_STATUS_SUCCESS;
14865 tpCsrChannelInfo currChannelListInfo;
14866 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
14867
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070014868 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014869 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070014870 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set \n");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070014871 return eHAL_STATUS_FAILURE;
14872 }
14873 status = csrRoamGetSessionIdFromBSSID(pMac,
14874 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
14875 &sessionId);
14876 /*The Dynamic Config Items Update may happen even if the state is in INIT.
14877 * It is important to ensure that the command is passed down to the FW only
14878 * if the Infra Station is in a connected state.A connected station could also be
14879 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
14880 * We also have to ensure that if there is a STOP command we always have to inform Riva,
14881 * irrespective of whichever state we are in.*/
14882 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
14883 (command != ROAM_SCAN_OFFLOAD_STOP))
14884 {
14885 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
14886 pMac->roam.neighborRoamInfo.neighborRoamState, command);
14887 return eHAL_STATUS_FAILURE;
14888 }
14889
14890 if ( !HAL_STATUS_SUCCESS( status ) )
14891 {
14892 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
14893 return eHAL_STATUS_FAILURE;
14894 }
14895 pSession = CSR_GET_SESSION( pMac, sessionId );
14896 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
14897 if (NULL == pRequestBuf)
14898 {
14899 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
14900 return eHAL_STATUS_FAILED_ALLOC;
14901 }
14902
14903 vos_mem_zero(pRequestBuf,sizeof(tSirRoamOffloadScanReq));
14904 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
14905 * host driver reloads, but Riva still up and running*/
14906 if(command == ROAM_SCAN_OFFLOAD_STOP)
14907 pRequestBuf->RoamScanOffloadEnabled = 0;
14908 else
14909 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
14910 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid, pNeighborRoamInfo->currAPbssid,
14911 sizeof(tCsrBssid));
14912 pRequestBuf->ConnectedNetwork.ssId.length =
14913 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
14914 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
14915 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
14916 pRequestBuf->ConnectedNetwork.ssId.length);
14917 pRequestBuf->ConnectedNetwork.authentication =
14918 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
14919 pRequestBuf->ConnectedNetwork.encryption =
14920 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
14921 pRequestBuf->ConnectedNetwork.mcencryption =
14922 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
14923 pRequestBuf->LookupThreshold =
14924 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
14925 pRequestBuf->RoamRssiDiff =
14926 pMac->roam.configParam.RoamRssiDiff;
14927 pRequestBuf->Command = command;
14928 pRequestBuf->StartScanReason = reason;
14929 pRequestBuf->NeighborScanTimerPeriod =
14930 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
14931 pRequestBuf->NeighborRoamScanRefreshPeriod =
14932 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
14933 pRequestBuf->NeighborScanChannelMinTime =
14934 pNeighborRoamInfo->cfgParams.minChannelScanTime;
14935 pRequestBuf->NeighborScanChannelMaxTime =
14936 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
14937 pRequestBuf->EmptyRefreshScanPeriod =
14938 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
14939#ifdef FEATURE_WLAN_CCX
14940 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
14941#endif
14942 if (
14943#ifdef FEATURE_WLAN_CCX
14944 ((pNeighborRoamInfo->isCCXAssoc) &&
14945 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
14946 eANI_BOOLEAN_FALSE)) ||
14947 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
14948#endif // CCX
14949 currChannelListInfo->numOfChannels == 0)
14950 {
14951
14952 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
14953 * Give Preference to INI Channels.*/
14954 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
14955 {
14956 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
14957 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
14958 {
14959 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14960 {
14961 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14962 }
14963 ChannelList++;
14964 }
14965 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14966 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
14967 }
14968 else{
14969 ChannelList = pMac->scan.occupiedChannels.channelList;
14970 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
14971 {
14972 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
14973 {
14974 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
14975 }
14976 ChannelList++;
14977 }
14978 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
14979 /* If the profile changes as to what it was earlier, inform the FW through
14980 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
14981 * for the earlier profile and try to learn them afresh.*/
14982 if (reason == REASON_FLUSH_CHANNEL_LIST)
14983 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
14984 else {
14985 if (csrNeighborRoamIsNewConnectedProfile(pMac))
14986 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
14987 else
14988 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
14989 }
14990 }
14991 }
14992#ifdef FEATURE_WLAN_CCX
14993 else
14994 {
14995 /* If CCX is enabled, and a neighbor Report is received,then
14996 * Ignore the INI Channels or the Occupied Channel List. Consider
14997 * the channels in the neighbor list sent by the CCX AP.*/
14998 if (currChannelListInfo->numOfChannels != 0)
14999 {
15000 ChannelList = currChannelListInfo->ChannelList;
15001 for (i=0;i<currChannelListInfo->numOfChannels;i++)
15002 {
15003 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15004 {
15005 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15006 }
15007 ChannelList++;
15008 }
15009 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15010 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15011 }
15012 }
15013#endif
15014 num_channels = 0;
15015 ChannelList = NULL;
15016
15017 /* Maintain the Valid Channels List*/
15018 if (0 == strncmp(pMac->scan.countryCodeCurrent, "KR", 2))
15019 {
15020 ChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
15021 for(i=0; i<pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels; i++)
15022 {
15023 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15024 {
15025 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15026 }
15027 ChannelList++;
15028 }
15029 pRequestBuf->ValidChannelCount = num_channels;
15030 } else {
15031 ChannelList = pMac->roam.validChannelList;
15032 for(i=0; i<pMac->roam.numValidChannels; i++)
15033 {
15034 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15035 {
15036 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15037 }
15038 ChannelList++;
15039 }
15040 pRequestBuf->ValidChannelCount = num_channels;
15041 }
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015042 pRequestBuf->MDID.mdiePresent =
15043 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15044 pRequestBuf->MDID.mobilityDomain =
15045 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015046 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15047
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015048 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015049
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015050 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15051 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15052 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15053 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15054 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15055
15056 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15057 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015058 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015059 msg.reserved = 0;
15060 msg.bodyptr = pRequestBuf;
15061 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15062 {
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015063 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 -070015064 vos_mem_free(pRequestBuf);
15065 return eHAL_STATUS_FAILURE;
15066 }
15067
15068 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15069 return status;
15070}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015071
15072eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15073{
15074 switch(reason)
15075 {
15076 case 0:
15077 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15078 break;
15079 case REASON_OS_REQUESTED_ROAMING_NOW:
15080 csrNeighborRoamProceedWithHandoffReq(pMac);
15081 break;
15082 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015083 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Rsp for Roam Scan Offload with reason %d", reason);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015084 }
15085 return eHAL_STATUS_SUCCESS;
15086}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015087#endif
15088
Jeff Johnson295189b2012-06-20 16:38:30 -070015089tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15090 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15091{
15092 tANI_BOOLEAN found = FALSE;
15093 eHalStatus status = eHAL_STATUS_SUCCESS;
15094 tCsrPeStatsReqInfo staEntry;
15095 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15096 tListElem *pStaEntry = NULL;
15097 VOS_STATUS vosStatus;
15098 tPmcPowerState powerState;
15099 *pFound = FALSE;
15100
15101 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15102 if(pStaEntry)
15103 {
15104 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15105 if(pTempStaEntry->periodicity)
15106 {
15107 pTempStaEntry->periodicity =
15108 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15109 }
15110 else
15111 {
15112 pTempStaEntry->periodicity = periodicity;
15113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 pTempStaEntry->numClient++;
15115 found = TRUE;
15116 }
15117 else
15118 {
15119 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
15120 staEntry.numClient = 1;
15121 staEntry.periodicity = periodicity;
15122 staEntry.pMac = pMac;
15123 staEntry.rspPending = FALSE;
15124 staEntry.staId = staId;
15125 staEntry.statsMask = statsMask;
15126 staEntry.timerRunning = FALSE;
15127 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15128 if(!pTempStaEntry)
15129 {
15130 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015131 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 return NULL;
15133 }
15134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15136 if(ePMC_FULL_POWER == powerState)
15137 {
15138 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15139 {
15140 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15141 }
15142 }
15143 else
15144 {
15145 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15146 {
15147 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15148 }
15149 }
15150 if(!pTempStaEntry->timerRunning)
15151 {
15152 //send down a req in case of one time req, for periodic ones wait for timer to expire
15153 if(!pTempStaEntry->rspPending &&
15154 !pTempStaEntry->periodicity)
15155 {
15156 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15157 if(!HAL_STATUS_SUCCESS(status))
15158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015159 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 }
15161 else
15162 {
15163 pTempStaEntry->rspPending = TRUE;
15164 }
15165 }
15166 if(pTempStaEntry->periodicity)
15167 {
15168 if(!found)
15169 {
15170
15171 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15172 csrRoamPeStatsTimerHandler, pTempStaEntry );
15173 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 return NULL;
15177 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 }
15179 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015180 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15182 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15183 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015184 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 return NULL;
15186 }
15187 pTempStaEntry->timerRunning = TRUE;
15188 }
15189 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015190 *pFound = found;
15191 return pTempStaEntry;
15192}
15193
Jeff Johnson295189b2012-06-20 16:38:30 -070015194/*
15195 pStaEntry is no longer invalid upon the return of this function.
15196*/
15197static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15198{
15199 if(pEntry)
15200 {
15201 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15202 {
15203 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015204 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 }
15206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015207
15208void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15209{
15210 tListElem *pEntry;
15211 tCsrPeStatsReqInfo *pTempStaEntry;
15212 VOS_STATUS vosStatus;
15213 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015214 if(!pEntry)
15215 {
15216 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015217 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 return;
15219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 while( pEntry )
15221 {
15222 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015223 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015225 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 if(pTempStaEntry->timerRunning)
15227 {
15228 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15229 /* If we are not able to stop the timer here, just remove
15230 * the entry from the linked list. Destroy the timer object
15231 * and free the memory in the timer CB
15232 */
15233 if( vosStatus == VOS_STATUS_SUCCESS )
15234 {
15235 /* the timer is successfully stopped */
15236 pTempStaEntry->timerRunning = FALSE;
15237
15238 /* Destroy the timer */
15239 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15240 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015242 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015243 }
15244 }
15245 else
15246 {
15247 // the timer could not be stopped. Hence destroy and free the
15248 // memory for the PE stat entry in the timer CB.
15249 pTempStaEntry->timerStopFailed = TRUE;
15250 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015252
15253 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15254 {
15255 // Only free the memory if we could stop the timer successfully
15256 if(!pTempStaEntry->timerStopFailed)
15257 {
15258 palFreeMemory(pMac->hHdd, pTempStaEntry);
15259 pTempStaEntry = NULL;
15260 }
15261 break;
15262 }
15263
15264 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15265 }
15266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 return;
15268}
15269
15270
Jeff Johnsone7245742012-09-05 17:12:55 -070015271void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015272{
15273
Jeff Johnsone7245742012-09-05 17:12:55 -070015274 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15275 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15276 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15277 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15278 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15279 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15280 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015282 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15283 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15284 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15285 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15286 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15287 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015289 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15290 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015291
15292}
15293
Jeff Johnson295189b2012-06-20 16:38:30 -070015294void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15295 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15296{
15297 tANI_U8 stats[500];
15298 tANI_U8 *pStats = NULL;
15299 tANI_U32 tempMask = 0;
15300 tANI_U8 counter = 0;
15301 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 if(!callback)
15303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015304 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 return;
15306 }
15307 if(!statsMask)
15308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015309 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015310 return;
15311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 while(tempMask)
15315 {
15316 if(tempMask & 1)
15317 {
15318 //new stats info from PE, fill up the stats strucutres in PMAC
15319 switch(counter)
15320 {
15321 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015322 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
15324 sizeof(tCsrSummaryStatsInfo));
15325 if(!HAL_STATUS_SUCCESS(status))
15326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015327 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 }
15329 pStats += sizeof(tCsrSummaryStatsInfo);
15330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015332 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015333 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
15334 sizeof(tCsrGlobalClassAStatsInfo));
15335 if(!HAL_STATUS_SUCCESS(status))
15336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015337 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 }
15339 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015341 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015342 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015343 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
15344 sizeof(tCsrGlobalClassBStatsInfo));
15345 if(!HAL_STATUS_SUCCESS(status))
15346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015347 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 }
15349 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015352 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015353 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
15354 sizeof(tCsrGlobalClassCStatsInfo));
15355 if(!HAL_STATUS_SUCCESS(status))
15356 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015357 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015358 }
15359 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015360 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015362 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015363 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
15364 sizeof(tCsrGlobalClassDStatsInfo));
15365 if(!HAL_STATUS_SUCCESS(status))
15366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015367 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 }
15369 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015372 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
15374 sizeof(tCsrPerStaStatsInfo));
15375 if(!HAL_STATUS_SUCCESS(status))
15376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015377 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 }
15379 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015381 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015382 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015384 }
15385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 tempMask >>=1;
15387 counter++;
15388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070015390}
15391
Jeff Johnson295189b2012-06-20 16:38:30 -070015392eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
15393{
15394 tListElem *pEntry = NULL;
15395 tListElem *pPrevEntry = NULL;
15396 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15397 eHalStatus status = eHAL_STATUS_SUCCESS;
15398 VOS_STATUS vosStatus;
15399 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 if(!pEntry)
15401 {
15402 //list empty
15403 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015404 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 return status;
15406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 while( pEntry )
15408 {
15409 if(pPrevEntry)
15410 {
15411 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15412 //send up the stats report
15413 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15414 pTempStaEntry->staId, pTempStaEntry->pContext);
15415 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
15419 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015420 pTempStaEntry->pPeStaEntry->numClient--;
15421 //check if we need to delete the entry from peStatsReqList too
15422 if(!pTempStaEntry->pPeStaEntry->numClient)
15423 {
15424 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
15425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015427 //check if we need to stop the tl stats timer too
15428 pMac->roam.tlStatsReqInfo.numClient--;
15429 if(!pMac->roam.tlStatsReqInfo.numClient)
15430 {
15431 if(pMac->roam.tlStatsReqInfo.timerRunning)
15432 {
15433 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15434 if(!HAL_STATUS_SUCCESS(status))
15435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015436 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 //we will continue
15438 }
15439 }
15440 pMac->roam.tlStatsReqInfo.periodicity = 0;
15441 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 if (pTempStaEntry->periodicity)
15444 {
15445 //While creating StaEntry in csrGetStatistics,
15446 //Initializing and starting timer only when periodicity is set.
15447 //So Stop and Destroy timer only when periodicity is set.
15448
Jeff Johnsone7245742012-09-05 17:12:55 -070015449 vos_timer_stop( &pTempStaEntry->timer );
15450 // Destroy the vos timer...
15451 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
15452 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015454 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015457
Jeff Johnson295189b2012-06-20 16:38:30 -070015458
15459 pPrevEntry = pEntry;
15460 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15461 }
15462 //the last one
15463 if(pPrevEntry)
15464 {
15465 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
15466 //send up the stats report
15467 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15468 pTempStaEntry->staId, pTempStaEntry->pContext);
15469 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
15470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 return status;
15472
15473}
15474
Jeff Johnson295189b2012-06-20 16:38:30 -070015475eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
15476 tRequestFullPowerReason *pReason,
15477 tANI_BOOLEAN *pfNeedPower )
15478{
15479 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15480 tRequestFullPowerReason reason = eSME_REASON_OTHER;
15481 tPmcState pmcState;
15482 eHalStatus status = eHAL_STATUS_SUCCESS;
15483 // TODO : Session info unavailable
15484 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 if( pfNeedPower )
15486 {
15487 *pfNeedPower = eANI_BOOLEAN_FALSE;
15488 }
15489 //We only handle CSR commands
15490 if( !(eSmeCsrCommandMask & pCommand->command) )
15491 {
15492 return eHAL_STATUS_SUCCESS;
15493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 //Check PMC state first
15495 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015496 switch( pmcState )
15497 {
15498 case REQUEST_IMPS:
15499 case IMPS:
15500 if( eSmeCommandScan == pCommand->command )
15501 {
15502 switch( pCommand->u.scanCmd.reason )
15503 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015504#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15505 case eCsrScanGetLfrResult:
15506#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015507 case eCsrScanGetResult:
15508 case eCsrScanBGScanAbort:
15509 case eCsrScanBGScanEnable:
15510 case eCsrScanGetScanChnInfo:
15511 //Internal process, no need for full power
15512 fNeedFullPower = eANI_BOOLEAN_FALSE;
15513 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 default:
15515 //Other scans are real scan, ask for power
15516 fNeedFullPower = eANI_BOOLEAN_TRUE;
15517 break;
15518 } //switch
15519 }
15520 else
15521 {
15522 //ask for power for roam and status change
15523 fNeedFullPower = eANI_BOOLEAN_TRUE;
15524 }
15525 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015526 case REQUEST_BMPS:
15527 case BMPS:
15528 case REQUEST_START_UAPSD:
15529 case UAPSD:
15530 //We treat WOWL same as BMPS
15531 case REQUEST_ENTER_WOWL:
15532 case WOWL:
15533 if( eSmeCommandRoam == pCommand->command )
15534 {
15535 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
15536 tCsrScanResult *pScanResult;
15537 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015538 switch ( pCommand->u.roamCmd.roamReason )
15539 {
15540 case eCsrForcedDisassoc:
15541 case eCsrForcedDisassocMICFailure:
15542 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15543 fNeedFullPower = eANI_BOOLEAN_TRUE;
15544 break;
15545 case eCsrSmeIssuedDisassocForHandoff:
15546 case eCsrForcedDeauth:
15547 case eCsrHddIssuedReassocToSameAP:
15548 case eCsrSmeIssuedReassocToSameAP:
15549 fNeedFullPower = eANI_BOOLEAN_TRUE;
15550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 case eCsrCapsChange:
15552 fNeedFullPower = eANI_BOOLEAN_TRUE;
15553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 default:
15555 //Check whether the profile is already connected. If so, no need for full power
15556 //Note: IBSS is ignored for now because we don't support powersave in IBSS
15557 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
15558 {
15559 //Only need to check the first one
15560 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
15561 if( pEntry )
15562 {
15563 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
15564#if 0
15565 // TODO : Session Specific info pConnectBssDesc
15566 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
15567 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
15568 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
15569 {
15570 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
15571 // with Authenticating first. To force this, stop the current association (Disassociate) and
15572 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
15573 // a new Association.
15574 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
15575 {
15576 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
15577 {
15578 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
15579 //No need for full power
15580 //Set the flag so the code later can avoid to do the above
15581 //check again.
15582 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
15583 break;
15584 }
15585 }
15586 }
15587#endif
15588 }
15589 }
15590 //If we are here, full power is needed
15591 fNeedFullPower = eANI_BOOLEAN_TRUE;
15592 break;
15593 }
15594 }
15595 else if( eSmeCommandWmStatusChange == pCommand->command )
15596 {
15597 //need full power for all
15598 fNeedFullPower = eANI_BOOLEAN_TRUE;
15599 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
15600 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015601#ifdef FEATURE_WLAN_TDLS
15602 else if( eSmeCommandTdlsAddPeer == pCommand->command )
15603 {
15604 //TDLS link is getting established. need full power
15605 fNeedFullPower = eANI_BOOLEAN_TRUE;
15606 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
15607 }
15608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015609 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015610 case REQUEST_STOP_UAPSD:
15611 case REQUEST_EXIT_WOWL:
15612 if( eSmeCommandRoam == pCommand->command )
15613 {
15614 fNeedFullPower = eANI_BOOLEAN_TRUE;
15615 switch ( pCommand->u.roamCmd.roamReason )
15616 {
15617 case eCsrForcedDisassoc:
15618 case eCsrForcedDisassocMICFailure:
15619 reason = eSME_LINK_DISCONNECTED_BY_HDD;
15620 break;
15621 default:
15622 break;
15623 }
15624 }
15625 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015626 case STOPPED:
15627 case REQUEST_STANDBY:
15628 case STANDBY:
15629 case LOW_POWER:
15630 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015631 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070015632 status = eHAL_STATUS_FAILURE;
15633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015634 case FULL_POWER:
15635 case REQUEST_FULL_POWER:
15636 default:
15637 //No need to ask for full power. This has to be FULL_POWER state
15638 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070015640 if( pReason )
15641 {
15642 *pReason = reason;
15643 }
15644 if( pfNeedPower )
15645 {
15646 *pfNeedPower = fNeedFullPower;
15647 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015648 return ( status );
15649}
15650
Jeff Johnson295189b2012-06-20 16:38:30 -070015651static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15652{
15653 eHalStatus status = eHAL_STATUS_SUCCESS;
15654 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
15655 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070015656 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070015657 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
15658 {
15659 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
15660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015661 return ( status );
15662}
15663
Jeff Johnson295189b2012-06-20 16:38:30 -070015664tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
15665{
15666 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070015667 if( pCmd )
15668 {
15669 pMac->roam.sPendingCommands++;
15670 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015671 return ( pCmd );
15672}
15673
Jeff Johnson295189b2012-06-20 16:38:30 -070015674void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
15675{
15676 if (pMac->roam.sPendingCommands > 0)
15677 {
15678 //All command allocated through csrGetCommandBuffer need to
15679 //decrement the pending count when releasing.
15680 pMac->roam.sPendingCommands--;
15681 smeReleaseCommand( pMac, pCommand );
15682 }
15683 else
15684 {
15685 smsLog(pMac, LOGE, FL( "no pending commands"));
15686 VOS_ASSERT(0);
15687 }
15688}
15689
Jeff Johnson295189b2012-06-20 16:38:30 -070015690//Return SUCCESS is the command is queued, failed
15691eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
15692{
15693 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015694 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
15695 {
15696 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
15697 pCommand->u.scanCmd.reason);
15698 return eHAL_STATUS_CSR_WRONG_STATE;
15699 }
15700
15701 //We can call request full power first before putting the command into pending Q
15702 //because we are holding SME lock at this point.
15703 status = csrRequestFullPower( pMac, pCommand );
15704 if( HAL_STATUS_SUCCESS( status ) )
15705 {
15706 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070015707 //make sure roamCmdPendingList is not empty first
15708 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
15709 if( fNoCmdPending )
15710 {
15711 smePushCommand( pMac, pCommand, fHighPriority );
15712 }
15713 else
15714 {
15715 //Other commands are waiting for PMC callback, queue the new command to the pending Q
15716 //no list lock is needed since SME lock is held
15717 if( !fHighPriority )
15718 {
15719 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15720 }
15721 else {
15722 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15723 }
15724 }
15725 }
15726 else if( eHAL_STATUS_PMC_PENDING == status )
15727 {
15728 //no list lock is needed since SME lock is held
15729 if( !fHighPriority )
15730 {
15731 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15732 }
15733 else {
15734 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
15735 }
15736 //Let caller know the command is queue
15737 status = eHAL_STATUS_SUCCESS;
15738 }
15739 else
15740 {
15741 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
15742 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015743 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070015744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015745 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015746}
Jeff Johnson295189b2012-06-20 16:38:30 -070015747eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
15748{
15749 eHalStatus status = eHAL_STATUS_SUCCESS;
15750 tSirUpdateAPWPSIEsReq *pMsg;
15751 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
15752
15753 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15754 if (NULL == pSession)
15755 {
15756 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15757 return eHAL_STATUS_FAILURE;
15758 }
15759
Jeff Johnson295189b2012-06-20 16:38:30 -070015760 do
15761 {
15762 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15763 if (!HAL_STATUS_SUCCESS(status)) break;
15764 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
15765 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
15766
15767 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070015768 VOS_ASSERT(pBuf);
15769
Jeff Johnson295189b2012-06-20 16:38:30 -070015770 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015771 // transactionId
15772 *pBuf = 0;
15773 *( pBuf + 1 ) = 0;
15774 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015775 // bssId
15776 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15777 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015778 //sessionId
15779 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015780 // APWPSIEs
15781 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15782 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015785 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015786 return ( status );
15787}
Jeff Johnson295189b2012-06-20 16:38:30 -070015788eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15789{
15790 eHalStatus status = eHAL_STATUS_SUCCESS;
15791 tSirUpdateAPWPARSNIEsReq *pMsg;
15792 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015793 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15794 if (NULL == pSession)
15795 {
15796 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15797 return eHAL_STATUS_FAILURE;
15798 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015799 do
15800 {
15801 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15802 if (!HAL_STATUS_SUCCESS(status)) break;
15803 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15804 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015805 pBuf = (tANI_U8 *)&pMsg->transactionId;
15806 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015807 // transactionId
15808 *pBuf = 0;
15809 *( pBuf + 1 ) = 0;
15810 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070015811 VOS_ASSERT(pBuf);
15812
Jeff Johnson295189b2012-06-20 16:38:30 -070015813 // bssId
15814 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15815 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 // sessionId
15817 *pBuf++ = (tANI_U8)sessionId;
15818
15819 // APWPARSNIEs
15820 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15821 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015822 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015823 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015825 return ( status );
15826}
Jeff Johnson295189b2012-06-20 16:38:30 -070015827
15828#ifdef WLAN_FEATURE_VOWIFI_11R
15829//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15830eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15831{
15832 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15833 tpSirFTPreAuthReq pftPreAuthReq;
15834 tANI_U16 auth_req_len = 0;
15835 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 auth_req_len = sizeof(tSirFTPreAuthReq);
15837 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15838 if (pftPreAuthReq == NULL)
15839 {
15840 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15841 return eHAL_STATUS_RESOURCES;
15842 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015843 // Save the SME Session ID here. We need it while processing the preauth response
15844 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015845 vos_mem_zero(pftPreAuthReq, auth_req_len);
15846
15847 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15848 sizeof(pBssDescription->length) + pBssDescription->length);
15849
15850 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15851
15852 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15853
Jeff Johnson295189b2012-06-20 16:38:30 -070015854 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015855 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15856
Jeff Johnson295189b2012-06-20 16:38:30 -070015857#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015858 if (csrRoamIs11rAssoc(pMac) &&
15859 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015860 {
15861 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15862 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15863 pMac->ft.ftSmeContext.auth_ft_ies_length);
15864 }
15865 else
15866#endif
15867 {
15868 pftPreAuthReq->ft_ies_length = 0;
15869 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015870 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15871 sizeof(pBssDescription->length) + pBssDescription->length);
15872 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15874}
Jeff Johnson295189b2012-06-20 16:38:30 -070015875/*--------------------------------------------------------------------------
15876 * This will receive and process the FT Pre Auth Rsp from the current
15877 * associated ap.
15878 *
15879 * This will invoke the hdd call back. This is so that hdd can now
15880 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15881 ------------------------------------------------------------------------*/
15882void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15883{
15884 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15885 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015886#ifdef FEATURE_WLAN_LFR
15887 tCsrRoamInfo roamInfo;
15888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015889
15890#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015891 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015892#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015893#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015894 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015895 if (status != eHAL_STATUS_SUCCESS) {
15896 /*
15897 * Bail out if pre-auth was not even processed.
15898 */
15899 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15900 return;
15901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015902#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015903 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15904 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15905 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015906 // Implies a success
15907 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015908 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15909 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070015910 /* No need to notify qos module if this is a non 11r roam*/
15911 if (csrRoamIs11rAssoc(pMac))
15912 {
15913 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15914 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015915 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15916 * actual transition from the current to handoff AP is triggered */
15917 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15918 60 * PAL_TIMER_TO_MS_UNIT,
15919 eANI_BOOLEAN_FALSE);
15920 if (eHAL_STATUS_SUCCESS != status)
15921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015922 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015923 return;
15924 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015925 // Save the received response
15926 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15927 if (csrRoamIs11rAssoc(pMac))
15928 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15929 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15930
15931 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015932#ifdef FEATURE_WLAN_LFR
15933 // If Legacy Fast Roaming is enabled, signal the supplicant
15934 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015935 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015936 {
15937 // Save the bssid from the received response
15938 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15939 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15940 }
15941
15942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015943
15944 // Done with it, init it.
15945 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15946}
15947#endif
15948#ifdef FEATURE_WLAN_BTAMP_UT_RF
15949void csrRoamJoinRetryTimerHandler(void *pv)
15950{
15951 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15952 tpAniSirGlobal pMac = pInfo->pMac;
15953 tANI_U32 sessionId = pInfo->sessionId;
15954 tCsrRoamSession *pSession;
15955
15956 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015958 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015959 pSession = CSR_GET_SESSION( pMac, sessionId );
15960 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15961 {
15962 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015964 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015965 }
15966 }
15967 }
15968}
Jeff Johnson295189b2012-06-20 16:38:30 -070015969eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15970{
15971 eHalStatus status = eHAL_STATUS_FAILURE;
15972 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15973
15974 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015976 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015977 pSession->maxRetryCount--;
15978 pSession->joinRetryTimerInfo.pMac = pMac;
15979 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15980 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15981 if(!HAL_STATUS_SUCCESS(status))
15982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015983 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015984 }
15985 }
15986 else
15987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015988 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015989 pSession->maxRetryCount);
15990 }
15991
15992 return (status);
15993}
Jeff Johnson295189b2012-06-20 16:38:30 -070015994eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15995{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015996 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15998 {
15999 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
16000 }
16001
16002 return eHAL_STATUS_SUCCESS;
16003}
16004#endif
16005
16006
16007/*
16008 pBuf points to the beginning of the message
16009 LIM packs disassoc rsp as below,
16010 messageType - 2 bytes
16011 messageLength - 2 bytes
16012 sessionId - 1 byte
16013 transactionId - 2 bytes (tANI_U16)
16014 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16015 peerMacAddr - 6 bytes
16016 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16017*/
16018static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16019{
16020 if(pBuf && pRsp)
16021 {
16022 pBuf += 4; //skip type and length
16023 pRsp->sessionId = *pBuf++;
16024 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16025 pBuf += 2;
16026 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16027 pBuf += 4;
16028 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16029 }
16030}
16031
Jeff Johnsond13512a2012-07-17 11:42:19 -070016032eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16033{
16034 static uNvTables nvTables;
16035 eHalStatus status = eHAL_STATUS_SUCCESS;
16036 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16037
16038 /* read the country code from NV and use it */
16039 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16040 {
16041 palCopyMemory( pMac->hHdd, pCountry,
16042 nvTables.defaultCountryTable.countryCode,
16043 WNI_CFG_COUNTRY_CODE_LEN );
16044 return status;
16045 }
16046 else
16047 {
16048 palCopyMemory( pMac->hHdd, pCountry,
16049 "XXX",
16050 WNI_CFG_COUNTRY_CODE_LEN );
16051 status = eHAL_STATUS_FAILURE;
16052 return status;
16053 }
16054}
16055
16056eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16057{
16058 palCopyMemory( pMac->hHdd, pCountry,
16059 pMac->scan.countryCode11d,
16060 WNI_CFG_COUNTRY_CODE_LEN );
16061 return eHAL_STATUS_SUCCESS;
16062}
schang86c22c42013-03-13 18:41:24 -070016063
16064eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16065{
16066 tSirSetTxPowerReq *pMsg = NULL;
16067 eHalStatus status = eHAL_STATUS_SUCCESS;
16068 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16069
16070 if (!pSession)
16071 {
16072 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16073 return eHAL_STATUS_FAILURE;
16074 }
16075
16076 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
16077 if (HAL_STATUS_SUCCESS(status))
16078 {
16079 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
16080 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16081 pMsg->length = sizeof(tSirSetTxPowerReq);
16082 pMsg->mwPower = mW;
16083 palCopyMemory( pMac->hHdd,
16084 (tSirMacAddr *)pMsg->bssId,
16085 &pSession->selfMacAddr,
16086 sizeof(tSirMacAddr) );
16087 status = palSendMBMessage(pMac->hHdd, pMsg);
16088 if (!HAL_STATUS_SUCCESS(status))
16089 {
16090 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016091 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016092 }
16093 }
16094 return status;
16095}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016096
16097/* Returns whether a session is in VOS_STA_MODE...or not */
16098tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16099{
16100 tCsrRoamSession *pSession = NULL;
16101 pSession = CSR_GET_SESSION ( pMac, sessionId );
16102 if(!pSession)
16103 {
16104 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16105 return eANI_BOOLEAN_FALSE;
16106 }
16107 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16108 {
16109 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16110 return eANI_BOOLEAN_FALSE;
16111 }
16112 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16113 {
16114 return eANI_BOOLEAN_FALSE;
16115 }
16116 /* There is a possibility that the above check may fail,because
16117 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16118 * when it is connected.So,we may sneak through the above check even
16119 * if we are not a STA mode INFRA station. So, if we sneak through
16120 * the above condition, we can use the following check if we are
16121 * really in STA Mode.*/
16122
16123 if ( NULL != pSession->pCurRoamProfile )
16124 {
16125 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16126 {
16127 return eANI_BOOLEAN_TRUE;
16128 } else {
16129 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16130 return eANI_BOOLEAN_FALSE;
16131 }
16132 }
16133
16134 return eANI_BOOLEAN_FALSE;
16135}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016136
16137#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16138eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16139 tCsrHandoffRequest *pHandoffInfo)
16140{
16141 eHalStatus status = eHAL_STATUS_SUCCESS;
16142 vos_msg_t msg;
16143
16144 tAniHandoffReq *pMsg;
16145 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniHandoffReq));
16146 if ( !HAL_STATUS_SUCCESS(status) )
16147 {
16148 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
16149 return status;
16150 }
16151 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16152 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16153 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16154 pMsg->channel = pHandoffInfo->channel;
16155 palCopyMemory(pMac->hHdd, pMsg->bssid,
16156 pHandoffInfo->bssid,
16157 6);
16158 msg.type = eWNI_SME_HANDOFF_REQ;
16159 msg.bodyptr = pMsg;
16160 msg.reserved = 0;
16161 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16162 {
16163 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
16164 palFreeMemory(pMac->hHdd, (void *)pMsg);
16165 status = eHAL_STATUS_FAILURE;
16166 }
16167 return status;
16168}
16169#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */